com.tectonica.jonix.onix2.MediaFile 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.ImageAudioVideoFileTypes;
import com.tectonica.jonix.common.codelist.Languages;
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.JonixMediaFile;
import java.io.Serializable;
import java.util.function.Consumer;
/*
* NOTE: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT MANUALLY
*/
/**
* Image/audio/video file link composite
*
* A repeatable group of data elements which together identify and provide pointers to, an image, audio or video file
* related to the product.
*
*
*
* Reference name
* <MediaFile>
*
*
* Short tag
* <mediafile>
*
*
*
* This tag may be included in the following composites:
*
* - <{@link Product}>
* - <{@link ContentItem}>
* - <{@link Reissue}>
*
*
* Possible placements within ONIX message:
*
* - {@link Product} ⯈ {@link MediaFile}
* - {@link Product} ⯈ {@link ContentItem} ⯈ {@link MediaFile}
* - {@link Product} ⯈ {@link SupplyDetail} ⯈ {@link Reissue} ⯈ {@link MediaFile}
*
*/
public class MediaFile implements OnixDataCompositeWithKey, Serializable {
private static final long serialVersionUID = 1L;
public static final String refname = "MediaFile";
public static final String shortname = "mediafile";
/////////////////////////////////////////////////////////////////////////////////
// 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 MediaFile EMPTY = new MediaFile();
public MediaFile() {
exists = false;
element = null;
initialized = true; // so that no further processing will be done on this intentionally-empty object
}
public MediaFile(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 MediaFileTypeCode.refname:
case MediaFileTypeCode.shortname:
mediaFileTypeCode = new MediaFileTypeCode(e);
break;
case MediaFileLinkTypeCode.refname:
case MediaFileLinkTypeCode.shortname:
mediaFileLinkTypeCode = new MediaFileLinkTypeCode(e);
break;
case MediaFileLink.refname:
case MediaFileLink.shortname:
mediaFileLink = new MediaFileLink(e);
break;
case DownloadCaption.refname:
case DownloadCaption.shortname:
downloadCaption = new DownloadCaption(e);
break;
case MediaFileFormatCode.refname:
case MediaFileFormatCode.shortname:
mediaFileFormatCode = new MediaFileFormatCode(e);
break;
case ImageResolution.refname:
case ImageResolution.shortname:
imageResolution = new ImageResolution(e);
break;
case TextWithDownload.refname:
case TextWithDownload.shortname:
textWithDownload = new TextWithDownload(e);
break;
case DownloadCredit.refname:
case DownloadCredit.shortname:
downloadCredit = new DownloadCredit(e);
break;
case DownloadCopyrightNotice.refname:
case DownloadCopyrightNotice.shortname:
downloadCopyrightNotice = new DownloadCopyrightNotice(e);
break;
case DownloadTerms.refname:
case DownloadTerms.shortname:
downloadTerms = new DownloadTerms(e);
break;
case MediaFileDate.refname:
case MediaFileDate.shortname:
mediaFileDate = new MediaFileDate(e);
break;
default:
break;
}
});
}
/**
* @return whether this tag (<MediaFile> or <mediafile>) 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 MediaFileTypeCode mediaFileTypeCode = MediaFileTypeCode.EMPTY;
/**
*
* An ONIX code which identifies the type of image/audio/video file which is linked by the <MediaFileLink>
* element. Mandatory in each occurrence of the <MediaFile> composite, and non-repeating.
*
* Jonix-Comment: this field is required
*/
public MediaFileTypeCode mediaFileTypeCode() {
_initialize();
return mediaFileTypeCode;
}
private MediaFileLinkTypeCode mediaFileLinkTypeCode = MediaFileLinkTypeCode.EMPTY;
/**
*
* An ONIX code which identifies the type of link which is given in the <MediaFileLink> element, for example a
* URL, DOI, filename etc. Mandatory in each occurrence of the <MediaFile> composite, and
* non-repeating.
*
* Jonix-Comment: this field is required
*/
public MediaFileLinkTypeCode mediaFileLinkTypeCode() {
_initialize();
return mediaFileLinkTypeCode;
}
private MediaFileLink mediaFileLink = MediaFileLink.EMPTY;
/**
*
* A link to the image/audio/video file specified by the <MediaFileTypeCode>, using the link type specified by
* the <MediaFileLinkTypeCode>. Mandatory in each occurrence of the <MediaFile> composite, and
* non-repeating.
*
* Jonix-Comment: this field is required
*/
public MediaFileLink mediaFileLink() {
_initialize();
return mediaFileLink;
}
private DownloadCaption downloadCaption = DownloadCaption.EMPTY;
/**
*
* Text of a caption associated with a download file, and intended to be displayed whenever the file content is
* used. Optional and non-repeating. The <DownloadCaption> element may be sent together with either or both of
* fields <DownloadCredit>, or <DownloadCopyrightNotice>.
*
* Jonix-Comment: this field is required
*/
public DownloadCaption downloadCaption() {
_initialize();
return downloadCaption;
}
private MediaFileFormatCode mediaFileFormatCode = MediaFileFormatCode.EMPTY;
/**
*
* An ONIX code which identifies the format of the image/audio/video file which is linked by the
* <MediaFileLink> element. For image files, JPEG, GIF and TIF are supported. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public MediaFileFormatCode mediaFileFormatCode() {
_initialize();
return mediaFileFormatCode;
}
private ImageResolution imageResolution = ImageResolution.EMPTY;
/**
*
* The resolution of an image file which is linked by the <MediaFileLink> element, expressed as dots or pixels
* per inch. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public ImageResolution imageResolution() {
_initialize();
return imageResolution;
}
private TextWithDownload textWithDownload = TextWithDownload.EMPTY;
/**
*
* Unstructured text associated with a file which is available for download, and intended to be displayed whenever
* the file content is used. Optional and non-repeating. Text may include credits, copyright notice, etc.
* If this field is sent, the individual elements <DownloadCaption>, <DownloadCredit>, and
* <DownloadCopyrightNotice> must not be sent, and vice versa.
*
* Jonix-Comment: this field is optional
*/
public TextWithDownload textWithDownload() {
_initialize();
return textWithDownload;
}
private DownloadCredit downloadCredit = DownloadCredit.EMPTY;
/**
*
* Text of a personal or corporate credit associated with a download file, and intended to be displayed whenever the
* file content is used. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public DownloadCredit downloadCredit() {
_initialize();
return downloadCredit;
}
private DownloadCopyrightNotice downloadCopyrightNotice = DownloadCopyrightNotice.EMPTY;
/**
*
* Text of a copyright notice associated with a download file, and intended to be displayed whenever the file
* content is used. Optional and non-repeating.
*
* Jonix-Comment: this field is optional
*/
public DownloadCopyrightNotice downloadCopyrightNotice() {
_initialize();
return downloadCopyrightNotice;
}
private DownloadTerms downloadTerms = DownloadTerms.EMPTY;
/**
*
* Text of any terms and conditions associated with a download file. Optional and non-repeating. This field may be
* sent alone, or with the <TextWithDownload> element, or with any combination of the <DownloadCaption>,
* <DownloadCredit>, and <DownloadCopyrightNotice> elements.
*
* Jonix-Comment: this field is optional
*/
public DownloadTerms downloadTerms() {
_initialize();
return downloadTerms;
}
private MediaFileDate mediaFileDate = MediaFileDate.EMPTY;
/**
*
* The date when the image referenced by the <MediaFileLink> element was last changed. Optional and
* non-repeating. This element is intended to allow the receiver of an updated ONIX record to determine whether it
* is necessary to download a new copy of the file.
*
* Jonix-Comment: this field is optional
*/
public MediaFileDate mediaFileDate() {
_initialize();
return mediaFileDate;
}
@Override
public JonixMediaFile asStruct() {
_initialize();
JonixMediaFile struct = new JonixMediaFile();
struct.mediaFileTypeCode = mediaFileTypeCode.value;
struct.mediaFileFormatCode = mediaFileFormatCode.value;
struct.imageResolution = imageResolution.value;
struct.mediaFileLinkTypeCode = mediaFileLinkTypeCode.value;
struct.mediaFileLink = mediaFileLink.value;
struct.textWithDownload = textWithDownload.value;
struct.downloadCaption = downloadCaption.value;
struct.downloadCredit = downloadCredit.value;
struct.downloadCopyrightNotice = downloadCopyrightNotice.value;
struct.downloadTerms = downloadTerms.value;
struct.mediaFileDate = mediaFileDate.value;
return struct;
}
@Override
public ImageAudioVideoFileTypes structKey() {
return mediaFileTypeCode().value;
}
}