📄 mpeg7instancemetadata.java
字号:
/*
* This file is part of Caliph & Emir.
*
* Caliph & Emir is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Caliph & Emir is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Caliph & Emir; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Copyright statement:
* --------------------
* (c) 2005 by Werner Klieber (werner@klieber.info)
* http://caliph-emir.sourceforge.net
*/
package at.wklieber.mpeg7;
import at.wklieber.tools.XmlTools;
import org.jdom.Document;
import org.jdom.Element;
import java.util.Date;
import java.util.List;
/**
* User: wklieber
* Date: 06.10.2004
* Time: 22:22:56
* This class wrapps setter and getter methods to access the mpeg7 instance metadata.
* This are Dublin core metadata like title or author and some further mpeg7 metadata
* like Generationtool, ...
* This class is used to extend the Mpeg7Template class.
* either use myMpeg7Instance.getInstanMetadata or give this instance in the constructor.
* This class contains mpeg7-description data and mpeg7-Content description (media)
* If the underlying is null, the values are stored in member variables. This can be
* used to exchange mpeg7 data without invoking xml. Eg. by a non mpeg7 loader (eg. GoogleLoader)
* to tranport its data to the mpeg7FormatNormalizer
*/
public class Mpeg7InstanceMetadata {
Mpeg7Template mpeg7;
// these member varialbes are use to get fast access to the data and to use
// this class when no xml dom document is available (mpeg7=null)
private String descriptionMediaId;
private String descriptionVersion;
private Date descriptionLastUpdate;
//private String descriptionTitle;
private String descriptionSummary;
private String descriptionCreatorRole;
private String descriptionCreatorAgentFamilyName;
private String descriptionCreatorAgentGivenName;
private Date descriptionCreationTime;
private String contentCreationLocation;
private String descriptionTool;
private String contentType;
private String contentTitle;
private Date contentMediaCreationDate;
private long contentFileSize;
private String contentMediaUri;
private String contentMediaSummary;
private String contentGenre;
private static final String OFFSET = "Mpeg7/";
public Mpeg7InstanceMetadata(Mpeg7Template mpeg7) {
setMpeg7(mpeg7);
}
/**
* Title of the content. This comes from the creation-part of the Mpeg7 description
*
* @return
*/
public String getContentTitle() {
String xPath = OFFSET + "Description/MultimediaContent/*/CreationInformation/Creation/Title";
//System.out.println(mpeg7.toString());
contentTitle = readXmlValue(xPath, contentTitle);
if (contentTitle == null) {
contentTitle = "";
}
return contentTitle;
}
/**
* Title of the content. This comes from the creation-part of the Mpeg7 description
* ContentType is e.g. "Video", "Image", "Text", "Audio"
*/
public void setContentTitle(String contentTitle, String contentType) {
this.contentTitle = contentTitle;
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/CreationInformation/Creation/Title";
writeXmlValue(xPath, this.contentTitle);
}
/**
* get a keyframe from results from the mmdb. For each Timepoint in a temporal description
* a keyframe exists in the database. Ths method retrieves the first timpepoint
* Timepoints are also in "Description/Summarization"
* ContentType is "Video".
*/
public String getContentFirstKeyframe() {
String xPath = OFFSET + "Description/MultimediaContent/Video/TemporalDecomposition/VideoSegment/MediaTime/MediaTimePoint";
String returnValue = readXmlValue(xPath, "");
return returnValue;
}
/**
* content file size in byte
*
* @return
*/
public long getContentFileSize() {
String xPath = OFFSET + "Description/MultimediaContent/*/MediaInformation/MediaProfile/MediaFormat/FileSize";
String sizeString = readXmlValue(xPath, "");
if (sizeString.length() > 0) {
contentFileSize = Long.parseLong(sizeString);
} else {
contentFileSize = 0;
}
return contentFileSize;
}
/**
* content file size in byte
*
* @param contentFileSize
*/
public void setContentFileSize(long contentFileSize, String contentType) {
this.contentFileSize = contentFileSize;
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/MediaInformation/MediaProfile/MediaFormat/FileSize";
writeXmlValue(xPath, Long.toString(this.contentFileSize));
}
/**
* e.g. Documentary
*
* @return
*/
public String getContentGenre() {
String xPath = OFFSET + "Description/MultimediaContent/*/CreationInformation/Classification/Genre/Name";
//System.out.println(mpeg7.toString());
contentGenre = readXmlValue(xPath, contentGenre);
if (contentGenre == null) {
contentGenre = "";
}
return contentTitle;
}
/**
* e.g. Documentary
*
* @param contentGenre
*/
public void setContentGenre(String contentGenre, String contentType) {
this.contentGenre = contentGenre;
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/CreationInformation/Classification/Genre/Name";
writeXmlValue(xPath, this.contentGenre);
}
/**
* creation date of the content file
*
* @return
*/
public Date getContentMediaCreationDate() {
String xPath = OFFSET + "Description/MultimediaContent/*/CreationInformation/Creation/CreationCoordinates/CreationDate/TimePoint";
//System.out.println(mpeg7.toString());
String dateString = readXmlValue(xPath, "");
if (dateString.length() > 0) {
contentMediaCreationDate = Mpeg7ConversionTools.getReference().timePointToDate(dateString);
} else {
contentMediaCreationDate = null;
}
return contentMediaCreationDate;
}
/**
* creation date of the content file
*
* @param contentMediaCreationDate
*/
public void setContentMediaCreationDate(Date contentMediaCreationDate, String contentType) {
this.contentMediaCreationDate = contentMediaCreationDate;
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/CreationInformation/Creation/CreationCoordinates/CreationDate/TimePoint";
writeXmlValue(xPath, Mpeg7ConversionTools.getReference().dateTotimePoint(this.contentMediaCreationDate));
}
/**
* e.g. video, image, ...
* This is stored in mpeg7 as mediaFormat and seems to be the same as contentType.
* To avoid confusion, here contentType and mediaFormat is the same.
* Here we use just the name contentType.
* The data can read either from the mediaFormat tag, which is not always present or from the contenType tag, that
* is the parent of the mediaInformation. Since this is always available, we used this. (But maybe this is
* not according to the MPEG7 intentions???)
*
* @return contentType can be used withn the set-Functions. if the xml file contains
* no contentType, the contentType of the last setContentType() call is returned or
* "Text" if this value is null or empty.
*/
public String getContentType() {
String returnValue = "Text";
//String xPath = OFFSET + "Description/MultimediaContent/*/MediaInformation/MediaProfile/MediaFormat/Content";
String xPath = OFFSET + "Description/MultimediaContent/*";
//System.out.println(mpeg7.toString());
if (contentType != null && contentType.length() > 0) {
returnValue = contentType;
}
String result = readXmlValue(xPath, returnValue, true);
assert(result != null);
/*if (contentType == null) {
contentType = "";
}*/
//System.err.println("RETURN: \"" + result + "\", default: \"" + returnValue + "\", contentType: \"" + contentType + "\"");
contentType = result;
returnValue = result;
return returnValue;
}
/**
* e.g. video, image, ...
*
* @param contentMediaformat can be used a contentType
*/
public void setContentMediaformat(String contentMediaformat, String contentType) {
this.contentType = contentMediaformat;
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/MediaInformation/MediaProfile/MediaFormat/Content";
writeXmlValue(xPath, this.contentType);
}
/**
* Summary about the content of the media file
*
* @return
*/
public String getContentMediaSummary() {
String xPath = OFFSET + "Description/MultimediaContent/*/TextAnnotation/FreeTextAnnotation";
//System.out.println(mpeg7.toString());
contentMediaSummary = readXmlValue(xPath, contentMediaSummary);
if (contentMediaSummary == null) {
contentMediaSummary = "";
}
return contentMediaSummary;
}
/**
* Summary about the content of the media file
*
* @param contentMediaSummary
*/
public void setContentMediaSummary(String contentMediaSummary, String contentType) {
this.contentMediaSummary = contentMediaSummary;
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/TextAnnotation/FreeTextAnnotation";
writeXmlValue(xPath, this.contentMediaSummary);
}
public String getContentMediaUri() {
String xPath = OFFSET + "Description/MultimediaContent/*/MediaInformation/MediaProfile/MediaInstance/MediaLocator/MediaUri";
//System.out.println(mpeg7.toString());
contentMediaUri = readXmlValue(xPath, contentMediaUri);
if (contentMediaUri == null) {
contentMediaUri = "";
}
return contentMediaUri;
}
public void setContentMediaUri(String contentMediaUri, String contentType) {
this.contentMediaUri = contentMediaUri;
// change this path also in XmlMpeg7Result
String xPath = OFFSET + "Description/MultimediaContent/" + contentType + "/MediaInformation/MediaProfile/MediaInstance/MediaLocator/MediaUri";
writeXmlValue(xPath, this.contentMediaUri);
}
/**
* where the description has been created
*
* @return
*/
public String getContentCreationLocation() {
String xPath = OFFSET + "Description/MultimediaContent/*/MediaInformation/CreationInformation/Creation/CreationCoordinates/CreationLocation/Name";
//System.out.println(mpeg7.toString());
contentCreationLocation = readXmlValue(xPath, contentCreationLocation);
if (contentCreationLocation == null) {
contentCreationLocation = "";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -