⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gomentryimpl.java

📁 lucene2.2.0版本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if (this.title != null)			this.title.writeAtomOutput(aStreamWriter);		if (this.summary != null)			this.summary.writeAtomOutput(aStreamWriter);		if (this.content != null)			this.content.writeAtomOutput(aStreamWriter);		for (GOMLink link : this.links) {			link.writeAtomOutput(aStreamWriter);		}		for (GOMAuthor autor : this.authors) {			autor.writeAtomOutput(aStreamWriter);		}		for (GOMContributor contributor : this.contributors) {			contributor.writeAtomOutput(aStreamWriter);		}		if (this.rights != null) {			this.rights.writeAtomOutput(aStreamWriter);		}		if (this.source != null) {			this.source.writeAtomOutput(aStreamWriter);		}		for (GOMExtension extension : this.extensions) {			extension.writeAtomOutput(aStreamWriter);		}		aStreamWriter.writeEndElement();	}	/**	 * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)	 */	public void writeRssOutput(GOMOutputWriter aStreamWriter)			throws XMLStreamException {		aStreamWriter.writeStartElement(GOMEntry.LOCALNAME_RSS,				getXmlNamespaceAttributes());		if (this.defaultNamespace != null)			aStreamWriter.writeNamespace(this.defaultNamespace);		for (GOMNamespace namespace : this.namespaces) {			aStreamWriter.writeNamespace(namespace);		}		if (this.id != null)			this.id.writeRssOutput(aStreamWriter, GOMId.LOCALNAME_RSS);		String xmlLang = null;		if (this.content != null) {			xmlLang = this.content.getXmlLang();		}		if (xmlLang == null && this.summary != null) {			xmlLang = this.summary.getXmlLang();		}		if (xmlLang == null && this.title != null) {			xmlLang = this.title.getXmlLang();		}		if (xmlLang != null) {			aStreamWriter.writeSimpleXMLElement("language", xmlLang, null);		}		if (this.published != null) {			this.published.writeRssOutput(aStreamWriter);		}		if (this.updated != null)			this.updated.writeRssOutput(aStreamWriter);		for (GOMCategory category : this.categories) {			category.writeRssOutput(aStreamWriter);		}		if (this.title != null)			this.title.writeRssOutput(aStreamWriter);		if (this.summary != null)			this.summary.writeRssOutput(aStreamWriter);		if (this.content != null)			this.content.writeRssOutput(aStreamWriter);		for (GOMLink link : this.links) {			link.writeRssOutput(aStreamWriter);		}		for (GOMAuthor author : this.authors) {			author.writeRssOutput(aStreamWriter);		}		for (GOMContributor contributors : this.contributors) {			contributors.writeRssOutput(aStreamWriter);		}		for (GOMExtension extension : this.extensions) {			extension.writeRssOutput(aStreamWriter);		}		aStreamWriter.writeEndElement();	}	/**	 * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#getChildParser(javax.xml.namespace.QName)	 */	@Override	public AtomParser getChildParser(QName aName) {		if (aName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)) {			if (aName.getLocalPart().equals(GOMId.LOCALNAME)) {				// atom:feed elements MUST contain exactly one atom:id element.				if (this.id != null)					throw new GDataParseException(String.format(							AtomParser.DUPLICATE_ELEMENT, GOMId.LOCALNAME));				this.id = new GOMIdImpl();				return this.id;			}			if (aName.getLocalPart().equals(GOMTitle.LOCALNAME)) {				// atom:entry elements MUST contain exactly one atom:title				// element.				if (this.title != null)					throw new GDataParseException(String.format(							AtomParser.DUPLICATE_ELEMENT, GOMTitle.LOCALNAME));				this.title = new GOMTitleImpl();				return this.title;			}			if (aName.getLocalPart().equals(GOMAuthor.LOCALNAME)) {				GOMAuthor author = new GOMAuthorImpl();				this.authors.add(author);				return author;			}			if (aName.getLocalPart().equals(GOMCategory.LOCALNAME)) {				GOMCategory category = new GOMCategoryImpl();				this.categories.add(category);				return category;			}			if (aName.getLocalPart().equals(GOMContributor.LOCALNAME)) {				GOMContributorImpl impl = new GOMContributorImpl();				this.contributors.add(impl);				return impl;			}			if (aName.getLocalPart().equals(GOMLink.LOCALNAME)) {				GOMLinkImpl impl = new GOMLinkImpl();				this.links.add(impl);				return impl;			}			if (aName.getLocalPart().equals(GOMUpdated.LOCALNAME)) {				if (this.updated != null)					throw new GDataParseException(String.format(							AtomParser.DUPLICATE_ELEMENT,							GOMUpdated.LOCALNAME));				GOMUpdated updatedImpl = new GOMUpdatedImpl();				this.updated = updatedImpl;				return this.updated;			}			if (aName.getLocalPart().equals(GOMRights.LOCALNAME)) {				if (this.rights != null)					throw new GDataParseException(String							.format(AtomParser.DUPLICATE_ELEMENT,									GOMRights.LOCALNAME));				this.rights = new GOMRightsImpl();				return this.rights;			}			if (aName.getLocalPart().equals(GOMSource.LOCALNAME)) {				if (this.source != null)					throw new GDataParseException(String							.format(AtomParser.DUPLICATE_ELEMENT,									GOMSource.LOCALNAME));				this.source = new GOMSourceImpl();				return this.source;			}			if (aName.getLocalPart().equals(GOMSummary.LOCALNAME)) {				if (this.summary != null)					throw new GDataParseException(String.format(							AtomParser.DUPLICATE_ELEMENT,							GOMSummary.LOCALNAME));				this.summary = new GOMSummaryImpl();				return this.summary;			}			if (aName.getLocalPart().equals(GOMPublished.LOCALNAME)) {				if (this.published != null)					throw new GDataParseException(String.format(							AtomParser.DUPLICATE_ELEMENT,							GOMPublished.LOCALNAME));				this.published = new GOMPublishedImpl();				return this.published;			}			if (aName.getLocalPart().endsWith(GOMContent.LOCALNAME)) {				if (this.content != null)					throw new GDataParseException(String.format(							AtomParser.DUPLICATE_ELEMENT,							GOMContent.LOCALNAME));				this.content = new GOMContentImpl();				return this.content;			}		}		if (this.extensionFactory != null) {			GOMExtension extension = this.extensionFactory					.canHandleExtensionElement(aName);			if (extension != null) {				this.extensions.add(extension);				return extension;			}		}		return super.getChildParser(aName);	}	/**	 * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processEndElement()	 */	@Override	public void processEndElement() {		/*		 * atom:entry elements MUST contain an atom:summary element in either of		 * the following cases:		 * 		 * the atom:entry contains an atom:content that has a "src" attribute		 * (and is thus empty). the atom:entry contains content that is encoded		 * in Base64; i.e., the "type" attribute of atom:content is a MIME media		 * type [MIMEREG], but is not an XML media type [RFC3023], does not		 * begin with "text/", and does not end with "/xml" or "+xml".		 * 		 * 		 */		if (this.summary == null && this.content != null) {			if (this.content.getAtomMediaType() == AtomMediaType.BINARY					|| "".equals(this.content.getSrc())) {				throw new GDataParseException(String.format(						MISSING_ELEMENT_CHILD, this.localName,						GOMSummary.LOCALNAME));			}		}		/*		 * atom:entry elements MUST contain exactly one atom:id element.		 */		if (this.id == null)			throw new GDataParseException(String.format(					MISSING_ELEMENT_CHILD, this.localName, GOMId.LOCALNAME));		/*		 * atom:entry elements MUST contain exactly one atom:title element.		 */		if (this.title == null)			throw new GDataParseException(String					.format(MISSING_ELEMENT_CHILD, this.localName,							GOMTitle.LOCALNAME));		/*		 * atom:entry elements MUST contain exactly one atom:updated element.		 */		if (this.updated == null)			throw new GDataParseException(String.format(					MISSING_ELEMENT_CHILD, this.localName,					GOMUpdated.LOCALNAME));		/*		 * atom:entry elements MUST NOT contain more than one atom:link element		 * with a rel attribute value of "alternate" that has the same		 * combination of type and hreflang attribute values.		 */		List<GOMLink> alternateLinks = new LinkedList<GOMLink>();		for (GOMLink link : this.links) {			/*			 * atom:link elements MAY have a "rel" attribute that indicates the			 * link relation type. If the "rel" attribute is not present, the			 * link element MUST be interpreted as if the link relation type is			 * "alternate".			 */			if (link.getRel() == null					|| link.getRel().equalsIgnoreCase("alternate"))				alternateLinks.add(link);		}		/*		 * atom:entry elements MUST NOT contain more than one atom:link element		 * with a rel attribute value of "alternate" that has the same		 * combination of type and hreflang attribute values.		 */		if (alternateLinks.size() > 1) {			for (GOMLink link : alternateLinks) {				for (GOMLink link2 : alternateLinks) {					if (AtomParserUtils.compareAlternateLinks(link, link2))						throw new GDataParseException(								String										.format(DUPLICATE_ELEMENT,												"link with rel=\"alternate\" and same href and type attributes"));				}			}		} else if (this.content == null && alternateLinks.size() == 0) {			throw new GDataParseException(					"Element Entry must contain a element link with attribute alternate if no content element is set");		}	}	/**	 * @see org.apache.lucene.gdata.gom.GOMExtensible#getExtensions()	 */	public List<GOMExtension> getExtensions() {		return this.extensions;	}	/**	 * @see org.apache.lucene.gdata.gom.GOMExtensible#setExtensionFactory(org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory)	 */	public void setExtensionFactory(GOMExtensionFactory aFactory) {		if (extensionFactory != null) {			List<GOMNamespace> namespaces2 = extensionFactory.getNamespaces();			if (namespaces2 != null)				for (GOMNamespace namespace : namespaces2) {					this.addNamespace(namespace);				}		}		this.extensionFactory = aFactory;	}	/**	 * @see org.apache.lucene.gdata.gom.GOMEntry#getContent()	 */	public GOMContent getContent() {		return this.content;	}	/**	 * @see org.apache.lucene.gdata.gom.GOMEntry#setContent(org.apache.lucene.gdata.gom.GOMContent)	 */	public void setContent(GOMContent aContent) {		this.content = aContent;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -