
org.maxwe.epub.parser.meta.xml.Metadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parser Show documentation
Show all versions of parser Show documentation
Parse EPub Metadata and HTML
The newest version!
package org.maxwe.epub.parser.meta.xml;
import org.maxwe.epub.parser.EPubParserUtils;
import org.maxwe.epub.parser.constant.XmlLabelName;
import org.maxwe.epub.parser.core.AXmlLabelParser;
import org.xmlpull.v1.XmlPullParser;
import java.util.LinkedList;
/**
* Created by dingpengwei on 12/16/14.
*/
public class Metadata extends AXmlLabelParser {
/**
* 图书的唯一标记
*/
private LinkedList dcIdentifier;
/**
* 即图书的名称
*/
private LinkedList dcTitle;
/**
* 语言
*/
private LinkedList dcLanguage;
/**
* 图书作者
*/
private LinkedList dcCreator;
/**
* 出版社
*/
private LinkedList dcPublisher;
private LinkedList dcDate;
private LinkedList metas;
public Metadata(XmlPullParser xmlPullParser) throws Exception {
super(xmlPullParser);
int eventType = xmlPullParser.next();
while (eventType != XmlPullParser.END_DOCUMENT) {
String nodeName = xmlPullParser.getName();
switch (eventType) {
//开始节点
case XmlPullParser.START_TAG:
if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.DC_IDENTIFIER.toString(), nodeName)) {
//dc:identifier的开始节点
if (this.dcIdentifier == null) {
this.dcIdentifier = new LinkedList();
}
this.dcIdentifier.add(new Identifier(xmlPullParser));
System.out.println();
} else if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.DC_TITLE.toString(), nodeName)) {
//dc:title的开始节点
if (this.dcTitle == null) {
this.dcTitle = new LinkedList();
}
this.dcTitle.add(new Title(xmlPullParser));
} else if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.DC_LANGUAGE.toString(), nodeName)) {
//dc:language的开始节点
if (this.dcLanguage == null) {
this.dcLanguage = new LinkedList();
}
this.dcLanguage.add(new Language(xmlPullParser));
} else if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.DC_CREATOR.toString(), nodeName)) {
if (this.dcCreator == null) {
this.dcCreator = new LinkedList();
}
this.dcCreator.add(new Creator(xmlPullParser));
} else if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.DC_PUBLISHER.toString(), nodeName)) {
if (this.dcPublisher == null) {
this.dcPublisher = new LinkedList();
}
this.dcPublisher.add(new Publisher(xmlPullParser));
} else if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.DC_DATE.toString(), nodeName)) {
if (this.dcDate == null) {
this.dcDate = new LinkedList();
}
this.dcDate.add(new Date(xmlPullParser));
} else if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.META.toString(), nodeName)) {
if (this.metas == null) {
this.metas = new LinkedList();
}
this.metas.add(new Meta(xmlPullParser));
}
//结束节点
case XmlPullParser.END_TAG:
if (EPubParserUtils.xmlLabelEquals(false,XmlLabelName.METADATA.toString(), nodeName)) {
eventType = XmlPullParser.END_DOCUMENT;
}
break;
default:
break;
}
if (eventType != XmlPullParser.END_DOCUMENT) {
eventType = xmlPullParser.next();
}
}
}
public LinkedList getDcIdentifier() {
return dcIdentifier;
}
public LinkedList getDcTitle() {
return dcTitle;
}
public LinkedList getDcLanguage() {
return dcLanguage;
}
public LinkedList getDcCreator() {
return dcCreator;
}
public LinkedList getDcPublisher() {
return dcPublisher;
}
public LinkedList getDcDate() {
return dcDate;
}
public LinkedList getMetas() {
return metas;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy