com.tectonica.jonix.onix2.OtherText Maven / Gradle / Ivy
Show all versions of jonix-onix2 Show documentation
/*
* Copyright (C) 2012-2023 Zach Melamed
*
* Latest version available online at https://github.com/zach-m/jonix
* Contact me at [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tectonica.jonix.onix2;
import com.tectonica.jonix.common.JPU;
import com.tectonica.jonix.common.OnixComposite.OnixDataCompositeWithKey;
import com.tectonica.jonix.common.codelist.Languages;
import com.tectonica.jonix.common.codelist.OtherTextTypes;
import com.tectonica.jonix.common.codelist.RecordSourceTypes;
import com.tectonica.jonix.common.codelist.TextCaseFlags;
import com.tectonica.jonix.common.codelist.TextFormats;
import com.tectonica.jonix.common.codelist.TransliterationSchemes;
import com.tectonica.jonix.common.struct.JonixOtherText;
import java.io.Serializable;
import java.util.function.Consumer;
/*
* NOTE: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT MANUALLY
*/
/**
* Other text composite
*
* An optional and repeatable group of data elements which together identify and either include, or provide pointers to,
* text related to the product.
*
*
*
* Reference name
* <OtherText>
*
*
* Short tag
* <othertext>
*
*
*
* This tag may be included in the following composites:
*
* - <{@link Product}>
* - <{@link ContentItem}>
* - <{@link SubSeriesRecord}>
* - <{@link MainSeriesRecord}>
*
*
* Possible placements within ONIX message:
*
* - {@link Product} ⯈ {@link OtherText}
* - {@link Product} ⯈ {@link ContentItem} ⯈ {@link OtherText}
* - {@link SubSeriesRecord} ⯈ {@link OtherText}
* - {@link MainSeriesRecord} ⯈ {@link OtherText}
*
*/
public class OtherText implements OnixDataCompositeWithKey, Serializable {
private static final long serialVersionUID = 1L;
public static final String refname = "OtherText";
public static final String shortname = "othertext";
/////////////////////////////////////////////////////////////////////////////////
// ATTRIBUTES
/////////////////////////////////////////////////////////////////////////////////
public TextFormats textformat;
public TextCaseFlags textcase;
public Languages language;
public TransliterationSchemes transliteration;
/**
* (type: DateOrDateTime)
*/
public String datestamp;
public RecordSourceTypes sourcetype;
public String sourcename;
/////////////////////////////////////////////////////////////////////////////////
// CONSTRUCTION
/////////////////////////////////////////////////////////////////////////////////
private boolean initialized;
private final boolean exists;
private final org.w3c.dom.Element element;
public static final OtherText EMPTY = new OtherText();
public OtherText() {
exists = false;
element = null;
initialized = true; // so that no further processing will be done on this intentionally-empty object
}
public OtherText(org.w3c.dom.Element element) {
exists = true;
initialized = false;
this.element = element;
textformat = TextFormats.byCode(JPU.getAttribute(element, "textformat"));
textcase = TextCaseFlags.byCode(JPU.getAttribute(element, "textcase"));
language = Languages.byCode(JPU.getAttribute(element, "language"));
transliteration = TransliterationSchemes.byCode(JPU.getAttribute(element, "transliteration"));
datestamp = JPU.getAttribute(element, "datestamp");
sourcetype = RecordSourceTypes.byCode(JPU.getAttribute(element, "sourcetype"));
sourcename = JPU.getAttribute(element, "sourcename");
}
@Override
public void _initialize() {
if (initialized) {
return;
}
initialized = true;
JPU.forElementsOf(element, e -> {
final String name = e.getNodeName();
switch (name) {
case TextTypeCode.refname:
case TextTypeCode.shortname:
textTypeCode = new TextTypeCode(e);
break;
case TextLinkType.refname:
case TextLinkType.shortname:
textLinkType = new TextLinkType(e);
break;
case TextLink.refname:
case TextLink.shortname:
textLink = new TextLink(e);
break;
case TextFormat.refname:
case TextFormat.shortname:
textFormat = new TextFormat(e);
break;
case Text.refname:
case Text.shortname:
text = new Text(e);
break;
case TextAuthor.refname:
case TextAuthor.shortname:
textAuthor = new TextAuthor(e);
break;
case TextSourceCorporate.refname:
case TextSourceCorporate.shortname:
textSourceCorporate = new TextSourceCorporate(e);
break;
case TextSourceTitle.refname:
case TextSourceTitle.shortname:
textSourceTitle = new TextSourceTitle(e);
break;
case TextPublicationDate.refname:
case TextPublicationDate.shortname:
textPublicationDate = new TextPublicationDate(e);
break;
case StartDate.refname:
case StartDate.shortname:
startDate = new StartDate(e);
break;
case EndDate.refname:
case EndDate.shortname:
endDate = new EndDate(e);
break;
default:
break;
}
});
}
/**
* @return whether this tag (<OtherText> or <othertext>) is explicitly provided in the ONIX XML
*/
@Override
public boolean exists() {
return exists;
}
public void ifExists(Consumer action) {
if (exists) {
action.accept(this);
}
}
@Override
public org.w3c.dom.Element getXmlElement() {
return element;
}
/////////////////////////////////////////////////////////////////////////////////
// MEMBERS
/////////////////////////////////////////////////////////////////////////////////
private TextTypeCode textTypeCode = TextTypeCode.EMPTY;
/**
*
* An ONIX code which identifies the type of text which is sent in the <Text> element, or referenced in the
* <TextLink> element. Mandatory in each occurrence of the <OtherText> composite, and non-repeating.
*
* Jonix-Comment: this field is required
*/
public TextTypeCode textTypeCode() {
_initialize();
return textTypeCode;
}
private TextLinkType textLinkType = TextLinkType.EMPTY;
/**
*
* An ONIX code which identifies the type of link which is given in the <TextLink> element.
*
* Jonix-Comment: this field is required
*/
public TextLinkType textLinkType() {
_initialize();
return textLinkType;
}
private TextLink textLink = TextLink.EMPTY;
/**
*
* A link to the text item specified in the <TextTypeCode> element, using the link type specified in
* <TextLinkType>.
*
* Jonix-Comment: this field is required
*/
public TextLink textLink() {
_initialize();
return textLink;
}
private TextFormat textFormat = TextFormat.EMPTY;
/**
*
* An ONIX code which identifies the format of text which is sent in the <Text> element, or referenced in the
* <TextLink> element. Optional and non-repeating. It is now possible to use a “textformat” attribute
* in the <Text> element for this purpose, and this is the recommended practise when the text is sent in the
* ONIX record. The <TextFormat> element may still be used when the text is held outside the ONIX record, and
* referenced by the <TextLink> element.
*
* Jonix-Comment: this field is optional
*/
public TextFormat textFormat() {
_initialize();
return textFormat;
}
private Text text = Text.EMPTY;
/**
*
* The text specified in the <TextTypeCode> element, if it is suitable to be sent in full as part of the ONIX
* record. Either the <Text> element or both of the <TextLinkType> and <TextLink> elements must be
* present in any occurrence of the <OtherText> composite. Non-repeating.
*
*
* The <Text> element may carry any of the following ONIX attributes: textformat, language,
* transliteration, textcase.
*
* Jonix-Comment: this field is optional
*/
public Text text() {
_initialize();
return text;
}
private TextAuthor textAuthor = TextAuthor.EMPTY;
/**
*
* The name of the author of text sent in the <Text> element, or referenced in the <TextLink> element,
* eg if it is a review or promotional quote.
*
* Jonix-Comment: this field is optional
*/
public TextAuthor textAuthor() {
_initialize();
return textAuthor;
}
private TextSourceCorporate textSourceCorporate = TextSourceCorporate.EMPTY;
/**
*
* The name of a company or corporate body responsible for the text sent in the <Text> element, or referenced
* in the <TextLink> element, eg if it is part of a Reading Group Guide. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public TextSourceCorporate textSourceCorporate() {
_initialize();
return textSourceCorporate;
}
private TextSourceTitle textSourceTitle = TextSourceTitle.EMPTY;
/**
*
* The title of a publication from which the text sent in the <Text> element, or referenced in the
* <TextLink> element, was taken, eg if it is a review quote. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public TextSourceTitle textSourceTitle() {
_initialize();
return textSourceTitle;
}
private TextPublicationDate textPublicationDate = TextPublicationDate.EMPTY;
/**
*
* The date on which text sent in the <Text> element, or referenced in the <TextLink> element, was
* published. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public TextPublicationDate textPublicationDate() {
_initialize();
return textPublicationDate;
}
private StartDate startDate = StartDate.EMPTY;
/**
*
* The date from which text sent in the <Text> element, or referenced in the <TextLink> element, is
* intended to be used, eg for date-limited promotions. Optional and non-repeating, but either both or
* neither of <StartDate> and <EndDate> must be present.
*
* Jonix-Comment: this field is optional
*/
public StartDate startDate() {
_initialize();
return startDate;
}
private EndDate endDate = EndDate.EMPTY;
/**
*
* The date until which text sent in the <Text> element, or referenced in the <TextLink> element, is
* intended to be used, eg for date-limited promotions. Optional and non-repeating, but either both or
* neither of <StartDate> and <EndDate> must be present.
*
* Jonix-Comment: this field is optional
*/
public EndDate endDate() {
_initialize();
return endDate;
}
@Override
public JonixOtherText asStruct() {
_initialize();
JonixOtherText struct = new JonixOtherText();
struct.textTypeCode = textTypeCode.value;
struct.textFormat = textFormat.value;
struct.text = text.value;
struct.textLinkType = textLinkType.value;
struct.textLink = textLink.value;
struct.textAuthor = textAuthor.value;
struct.textSourceCorporate = textSourceCorporate.value;
struct.textSourceTitle = textSourceTitle.value;
struct.textPublicationDate = textPublicationDate.value;
struct.startDate = startDate.value;
struct.endDate = endDate.value;
return struct;
}
@Override
public OtherTextTypes structKey() {
return textTypeCode().value;
}
}