FileDocCategorySizeDatePackage
GOMEntryImpl.javaAPI DocApache Lucene 2.1.018993Wed Feb 14 10:45:58 GMT 2007org.apache.lucene.gdata.gom.core

GOMEntryImpl

public class GOMEntryImpl extends AbstractGOMElement implements org.apache.lucene.gdata.gom.GOMEntry
The default implementation of {@link org.apache.lucene.gdata.gom.GOMEntry}
atomEntry =
element atom:entry {
atomCommonAttributes,
( atomAuthor*
& atomCategory*
& atomContent?
& atomContributor*
& atomId
& atomLink*
& atomPublished?
& atomRights?
& atomSource?
& atomSummary?
& atomTitle
& atomUpdated
& extensionElement*)
}
author
Simon Willnauer

Fields Summary
protected List
namespaces
protected List
extensions
private List
authors
private List
categories
private List
contributors
private org.apache.lucene.gdata.gom.GOMId
id
private List
links
private org.apache.lucene.gdata.gom.GOMPublished
published
private org.apache.lucene.gdata.gom.GOMRights
rights
private org.apache.lucene.gdata.gom.GOMSource
source
private org.apache.lucene.gdata.gom.GOMSummary
summary
private org.apache.lucene.gdata.gom.GOMTitle
title
private org.apache.lucene.gdata.gom.GOMUpdated
updated
private org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory
extensionFactory
private org.apache.lucene.gdata.gom.GOMContent
content
private final org.apache.lucene.gdata.gom.GOMNamespace
defaultNamespace
Constructors Summary
public GOMEntryImpl()


	 	 
	  
		super();
		this.localName = GOMEntry.LOCALNAME;
		this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);

	
Methods Summary
public voidaddAuthor(org.apache.lucene.gdata.gom.GOMAuthor aAuthor)

see
org.apache.lucene.gdata.gom.GOMEntry#addAuthor(org.apache.lucene.gdata.gom.GOMAuthor)

		if (aAuthor != null)
			this.authors.add(aAuthor);

	
public voidaddCategory(org.apache.lucene.gdata.gom.GOMCategory aCategory)

see
org.apache.lucene.gdata.gom.GOMEntry#addCategory(org.apache.lucene.gdata.gom.GOMCategory)

		if (aCategory != null)
			this.categories.add(aCategory);

	
public voidaddContributor(org.apache.lucene.gdata.gom.GOMContributor aContributor)

see
org.apache.lucene.gdata.gom.GOMEntry#addContributor(org.apache.lucene.gdata.gom.GOMContributor)

		if (aContributor != null)
			this.contributors.add(aContributor);

	
public voidaddLink(org.apache.lucene.gdata.gom.GOMLink aLink)

see
org.apache.lucene.gdata.gom.GOMEntry#addLink(org.apache.lucene.gdata.gom.GOMLink)

		if (aLink != null)
			this.links.add(aLink);

	
public voidaddNamespace(org.apache.lucene.gdata.gom.GOMNamespace aNamespace)

see
org.apache.lucene.gdata.gom.GOMEntry#addNamespace(org.apache.lucene.gdata.gom.GOMNamespace)

		if (aNamespace == null)
			return;
		// namespace overrides hash / equals
		if (this.namespaces.contains(aNamespace))
			return;
		if ("".equals(aNamespace.getNamespacePrefix())
				|| aNamespace.getNamespaceUri()
						.equals(GOMNamespace.ATOM_NS_URI))
			return;
		else
			this.namespaces.add(aNamespace);
	
public java.util.ListgetAuthors()

see
org.apache.lucene.gdata.gom.GOMEntry#getAuthors()

		return this.authors;
	
public java.util.ListgetCategories()

see
org.apache.lucene.gdata.gom.GOMEntry#getCategories()

		return this.categories;

	
public AtomParsergetChildParser(javax.xml.namespace.QName aName)

see
org.apache.lucene.gdata.gom.core.AbstractGOMElement#getChildParser(javax.xml.namespace.QName)

		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);
	
public org.apache.lucene.gdata.gom.GOMContentgetContent()

see
org.apache.lucene.gdata.gom.GOMEntry#getContent()

		return this.content;
	
public java.util.ListgetContributor()

see
org.apache.lucene.gdata.gom.GOMEntry#getContributor()

		return this.contributors;
	
public org.apache.lucene.gdata.gom.GOMNamespacegetDefaultNamespace()

see
org.apache.lucene.gdata.gom.GOMEntry#getDefaultNamespace()


		return this.defaultNamespace;
	
public java.util.ListgetExtensions()

see
org.apache.lucene.gdata.gom.GOMExtensible#getExtensions()

		return this.extensions;
	
public org.apache.lucene.gdata.gom.GOMIdgetId()

see
org.apache.lucene.gdata.gom.GOMEntry#getId()

		return this.id;
	
public java.util.ListgetLinks()

see
org.apache.lucene.gdata.gom.GOMEntry#getLinks()

		return this.links;
	
public java.util.ListgetNamespaces()

see
org.apache.lucene.gdata.gom.GOMEntry#getNamespaces()

		return this.namespaces;
	
public org.apache.lucene.gdata.gom.GOMPublishedgetPublished()

see
org.apache.lucene.gdata.gom.GOMEntry#getPublished()

		return this.published;
	
public org.apache.lucene.gdata.gom.GOMRightsgetRights()

see
org.apache.lucene.gdata.gom.GOMEntry#getRights()

		return this.rights;
	
public org.apache.lucene.gdata.gom.GOMSourcegetSource()

see
org.apache.lucene.gdata.gom.GOMEntry#getSource()

		return this.source;
	
public org.apache.lucene.gdata.gom.GOMSummarygetSummary()

see
org.apache.lucene.gdata.gom.GOMEntry#getSummary()

		return this.summary;
	
public org.apache.lucene.gdata.gom.GOMTitlegetTitle()

see
org.apache.lucene.gdata.gom.GOMEntry#getTitle()

		return this.title;
	
public org.apache.lucene.gdata.gom.GOMUpdatedgetUpdated()

see
org.apache.lucene.gdata.gom.GOMEntry#getUpdated()

		return this.updated;
	
public voidprocessEndElement()

see
org.apache.lucene.gdata.gom.core.AbstractGOMElement#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");
		}
	
public voidsetContent(org.apache.lucene.gdata.gom.GOMContent aContent)

see
org.apache.lucene.gdata.gom.GOMEntry#setContent(org.apache.lucene.gdata.gom.GOMContent)

		this.content = aContent;

	
public voidsetExtensionFactory(org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory aFactory)

see
org.apache.lucene.gdata.gom.GOMExtensible#setExtensionFactory(org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory)

		if (extensionFactory != null) {
			List<GOMNamespace> namespaces2 = extensionFactory.getNamespaces();
			if (namespaces2 != null)
				for (GOMNamespace namespace : namespaces2) {
					this.addNamespace(namespace);
				}

		}
		this.extensionFactory = aFactory;
	
public voidsetId(org.apache.lucene.gdata.gom.GOMId aId)

see
org.apache.lucene.gdata.gom.GOMEntry#setId(org.apache.lucene.gdata.gom.GOMId)

		this.id = aId;
	
public voidsetPublished(org.apache.lucene.gdata.gom.GOMPublished aPublished)

see
org.apache.lucene.gdata.gom.GOMEntry#setPublished(org.apache.lucene.gdata.gom.GOMPublished)

		this.published = aPublished;
	
public voidsetRights(org.apache.lucene.gdata.gom.GOMRights aRights)

see
org.apache.lucene.gdata.gom.GOMEntry#setRights(org.apache.lucene.gdata.gom.GOMRights)

		this.rights = aRights;
	
public voidsetSource(org.apache.lucene.gdata.gom.GOMSource aSource)

see
org.apache.lucene.gdata.gom.GOMEntry#setSource(org.apache.lucene.gdata.gom.GOMSource)

		this.source = aSource;
	
public voidsetSummary(org.apache.lucene.gdata.gom.GOMSummary aSummary)

see
org.apache.lucene.gdata.gom.GOMEntry#setSummary(org.apache.lucene.gdata.gom.GOMSummary)

		this.summary = aSummary;
	
public voidsetTitle(org.apache.lucene.gdata.gom.GOMTitle aTitle)

see
org.apache.lucene.gdata.gom.GOMEntry#setTitle(org.apache.lucene.gdata.gom.GOMTitle)

		this.title = aTitle;

	
public voidsetUpdated(org.apache.lucene.gdata.gom.GOMUpdated aUpdated)

see
org.apache.lucene.gdata.gom.GOMEntry#setUpdated(org.apache.lucene.gdata.gom.GOMUpdated)

		this.updated = aUpdated;
	
public voidwriteAtomOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter aStreamWriter)

see
org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)

		aStreamWriter
				.writeStartElement(this.qname, getXmlNamespaceAttributes());
		if (this.defaultNamespace != null)
			aStreamWriter.writeDefaultNamespace(this.defaultNamespace);
		for (GOMNamespace namespace : this.namespaces) {
			aStreamWriter.writeNamespace(namespace);
		}
		if (this.id != null)
			this.id.writeAtomOutput(aStreamWriter);
		if (this.published != null)
			this.published.writeAtomOutput(aStreamWriter);
		if (this.updated != null)
			this.updated.writeAtomOutput(aStreamWriter);
		for (GOMCategory category : this.categories) {
			category.writeAtomOutput(aStreamWriter);
		}
		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();

	
public voidwriteRssOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter aStreamWriter)

see
org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)

		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();