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

GOMSourceImpl

public class GOMSourceImpl extends AbstractGOMElement implements org.apache.lucene.gdata.gom.GOMSource
author
Simon Willnauer

Fields Summary
protected List
authors
protected List
categories
protected List
links
protected List
contributors
protected org.apache.lucene.gdata.gom.GOMGenerator
generator
protected org.apache.lucene.gdata.gom.GOMId
id
protected org.apache.lucene.gdata.gom.GOMLogo
logo
protected org.apache.lucene.gdata.gom.GOMRights
rights
protected org.apache.lucene.gdata.gom.GOMSubtitle
subtitle
protected org.apache.lucene.gdata.gom.GOMTitle
title
protected org.apache.lucene.gdata.gom.GOMUpdated
updated
protected org.apache.lucene.gdata.gom.GOMIcon
icon
Constructors Summary
GOMSourceImpl()


	 
		this.localName = 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.GOMSource#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.GOMSource#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.GOMSource#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.GOMSource#addLink(org.apache.lucene.gdata.gom.GOMLink)

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

	
public java.util.ListgetAuthors()

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

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

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

		return this.categories;
	
public AtomParsergetChildParser(javax.xml.namespace.QName aName)

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

		if (aName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)) {
			if (aName.getLocalPart().equals(GOMId.LOCALNAME)) {
				// atom:feed / atom:source 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:feed / atom:source 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(GOMSubtitle.LOCALNAME)) {
				GOMSubtitleImpl impl = new GOMSubtitleImpl();
				/*
				 * atom:feed elements MUST NOT contain more than one
				 * atom:subtitle element.
				 */
				if (this.subtitle != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ELEMENT,
							GOMSubtitle.LOCALNAME));
				this.subtitle = impl;
				return this.subtitle;
			}
			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(GOMLogo.LOCALNAME)) {
				if (this.logo != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ELEMENT, GOMLogo.LOCALNAME));

				this.logo = new GOMLogoImpl();
				return this.logo;

			}
			if (aName.getLocalPart().equals(GOMIcon.LOCALNAME)) {
				if (this.icon != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ELEMENT, GOMIcon.LOCALNAME));

				this.icon = new GOMIconImpl();
				return this.icon;

			}
			if (aName.getLocalPart().equals(GOMGenerator.LOCALNAME)) {
				if (this.generator != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ELEMENT,
							GOMGenerator.LOCALNAME));

				this.generator = new GOMGeneratorImpl();
				return this.generator;

			}
			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;

			}

		}
		throw new GDataParseException(String.format(
				AtomParser.URECOGNIZED_ELEMENT_CHILD, this.localName, aName
						.getLocalPart()));

	
public java.util.ListgetContributor()

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

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

see
org.apache.lucene.gdata.gom.GOMSource#getGenerator()

		return this.generator;
	
public org.apache.lucene.gdata.gom.GOMIcongetIcon()

return
the icon

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

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

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

return
the links

		return this.links;
	
public java.lang.StringgetLocalName()

see
org.apache.lucene.gdata.gom.core.AbstractGOMElement#getLocalName()

		return this.localName;
	
public org.apache.lucene.gdata.gom.GOMLogogetLogo()

return
the logo

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

return
the rights

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

return
the subtitle

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

return
the title

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

return
the updated

		return this.updated;
	
public voidprocessElementValue(java.lang.String aValue)

see
org.apache.lucene.gdata.gom.core.AtomParser#processElementValue(java.lang.String)

		throw new GDataParseException(String.format(
				AtomParser.UNEXPECTED_ELEMENT_VALUE, this.localName));
	
public voidprocessEndElement()

see
org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()

		/*
		 * atom:feed 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:feed 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:feed 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:feed elements MUST contain one or more atom:author elements,
		 * unless all of the
		 */
		if (this.authors.size() < 1)
			throw new GDataParseException(String.format(
					MISSING_ELEMENT_CHILD, this.localName,
					GOMAuthor.LOCALNAME));

		/*
		 * atom:feed 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:feed 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 (link != link2)
						if (AtomParserUtils.compareAlternateLinks(link, link2))
							throw new GDataParseException(
									String
											.format(DUPLICATE_ELEMENT,
													"link with rel=\"alternate\" and same href and type attributes"));

				}
			}
		}

	
public voidsetGenerator(org.apache.lucene.gdata.gom.GOMGenerator aGenerator)

see
org.apache.lucene.gdata.gom.GOMSource#setGenerator(org.apache.lucene.gdata.gom.GOMGenerator)

		this.generator = aGenerator;

	
public voidsetIcon(org.apache.lucene.gdata.gom.GOMIcon aIcon)

see
org.apache.lucene.gdata.gom.GOMSource#setIcon(org.apache.lucene.gdata.gom.GOMIcon)

		this.icon = aIcon;

	
public voidsetId(org.apache.lucene.gdata.gom.GOMId aId)

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

		this.id = aId;

	
public voidsetLogo(org.apache.lucene.gdata.gom.GOMLogo aLogo)

param
aLogo the logo to set

		this.logo = aLogo;
	
public voidsetRights(org.apache.lucene.gdata.gom.GOMRights aRights)

param
aRights the rights to set

		rights = aRights;
	
public voidsetSubtitle(org.apache.lucene.gdata.gom.GOMSubtitle aSubtitle)

param
aSubtitle the subtitle to set

		this.subtitle = aSubtitle;
	
public voidsetTitle(org.apache.lucene.gdata.gom.GOMTitle aTitle)

param
aTitle the title to set

		this.title = aTitle;
	
public voidsetUpdated(org.apache.lucene.gdata.gom.GOMUpdated aUpdated)

param
aUpdated the updated to set

		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.localName,
				this.extensionAttributes);
		List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
		for (GOMAttribute attribute : xmlNamespaceAttributes) {
			aStreamWriter.writeAttribute(attribute);
		}
		writeInnerAtomOutput(aStreamWriter);
		aStreamWriter.writeEndElement();

	
protected voidwriteInnerAtomOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter aStreamWriter)

param
aStreamWriter
throws
XMLStreamException

		if (this.id != null)
			this.id.writeAtomOutput(aStreamWriter);
		if (this.title != null)
			this.title.writeAtomOutput(aStreamWriter);
		if (this.subtitle != null)
			this.subtitle.writeAtomOutput(aStreamWriter);
		for (GOMAuthor authors : this.authors) {
			authors.writeAtomOutput(aStreamWriter);
		}
		for (GOMCategory category : this.categories) {
			category.writeAtomOutput(aStreamWriter);
		}
		for (GOMContributor contributor : this.contributors) {
			contributor.writeAtomOutput(aStreamWriter);
		}
		for (GOMLink link : this.links) {
			link.writeAtomOutput(aStreamWriter);
		}
		if (this.rights != null)
			this.rights.writeAtomOutput(aStreamWriter);
		if (this.updated != null)
			this.updated.writeAtomOutput(aStreamWriter);
		if (this.logo != null)
			this.logo.writeAtomOutput(aStreamWriter);
		if (this.icon != null)
			this.icon.writeAtomOutput(aStreamWriter);
		if (this.generator != null)
			this.generator.writeAtomOutput(aStreamWriter);
	
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)

		// no rss output