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

GOMFeedImpl

public class GOMFeedImpl extends GOMSourceImpl implements org.apache.lucene.gdata.gom.GOMFeed
atom:feed { atomCommonAttributes, (atomAuthor* & atomCategory* & atomContributor* & atomGenerator? & atomIcon? & atomId & atomLink* & atomLogo? & atomRights? & atomSubtitle? & atomTitle & atomUpdated & extensionElement*), atomEntry* }
author
Simon Willnauer

Fields Summary
static final int
DEFAULT_START_INDEX
static final int
DEFAULT_ITEMS_PER_PAGE
private static final org.apache.lucene.gdata.gom.GOMAttribute
RSS_VERSION_ATTRIBUTE
protected List
entries
protected List
extensions
protected List
namespaces
private SimpleGOMElementImpl
startIndexElement
private SimpleGOMElementImpl
itemsPerPageElement
private org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory
extensionFactory
private org.apache.lucene.gdata.gom.GOMNamespace
defaultNamespace
Constructors Summary
GOMFeedImpl()


	 
		this.localName = GOMFeed.LOCALNAME;
		this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
		startIndexElement = new SimpleGOMElementImpl(
				SimpleGOMElementImpl.ELEMENT_OS_START_INDEX,
				GOMNamespace.OPENSEARCH_NAMESPACE);
		itemsPerPageElement = new SimpleGOMElementImpl(
				SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE,
				GOMNamespace.OPENSEARCH_NAMESPACE);
		itemsPerPageElement.setTextValue(Integer
				.toString(DEFAULT_ITEMS_PER_PAGE));
		startIndexElement.setTextValue(Integer.toString(DEFAULT_START_INDEX));
	
Methods Summary
public voidaddEntry(org.apache.lucene.gdata.gom.GOMEntry aEntry)

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

		if (aEntry != null)
			this.entries.add(aEntry);

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

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

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

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

see
org.apache.lucene.gdata.gom.GOMFeed#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 AtomParsergetChildParser(javax.xml.namespace.QName aName)

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

		if (aName.getNamespaceURI().equals(GOMNamespace.OPENSEARCH_NS_URI)) {
			if (aName.getLocalPart().equals(
					SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE)) {

				this.itemsPerPageElement = new SimpleGOMElementImpl(
						SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE,
						GOMNamespace.OPENSEARCH_NAMESPACE);
				this.itemsPerPageElement
						.setValidator(new PositiveIntegerValidator(
								SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE));
				return this.itemsPerPageElement;
			}
			if (aName.getLocalPart().equals(
					SimpleGOMElementImpl.ELEMENT_OS_START_INDEX)) {
				this.startIndexElement = new SimpleGOMElementImpl(
						SimpleGOMElementImpl.ELEMENT_OS_START_INDEX,
						GOMNamespace.OPENSEARCH_NAMESPACE);
				this.startIndexElement
						.setValidator(new PositiveIntegerValidator(
								SimpleGOMElementImpl.ELEMENT_OS_START_INDEX));
				return this.startIndexElement;
			}

		}
		if (aName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)
				&& aName.getLocalPart().equals(GOMEntry.LOCALNAME)) {
			GOMEntry entry = new GOMEntryImpl();
			this.entries.add(entry);
			return entry;

		}
		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.GOMNamespacegetDefaultNamespace()

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

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

see
org.apache.lucene.gdata.gom.GOMFeed#getEntries()

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

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

		return this.extensions;
	
public intgetItemsPerPage()

see
org.apache.lucene.gdata.gom.GOMFeed#getItemsPerPage()

		return Integer.parseInt(this.itemsPerPageElement.getTextValue());
	
public java.util.ListgetNamespaces()

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

		return this.namespaces;
	
public intgetStartIndex()

see
org.apache.lucene.gdata.gom.GOMFeed#getStartIndex()

		return Integer.parseInt(this.startIndexElement.getTextValue());
	
public voidsetExtensionFactory(org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory aFactory)

see
org.apache.lucene.gdata.gom.GOMFeed#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 voidsetItemsPerPage(int aInt)

see
org.apache.lucene.gdata.gom.GOMFeed#setItemsPerPage(int)

		if (aInt < 0)
			return;
		this.itemsPerPageElement.textValue = Integer.toString(aInt);
	
public voidsetStartIndex(int aIndex)

see
org.apache.lucene.gdata.gom.GOMFeed#setStartIndex(int)

		if (aIndex < 1)
			return;
		this.startIndexElement.textValue = Integer.toString(aIndex);
	
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);
		if (this.defaultNamespace != null)
			aStreamWriter.writeDefaultNamespace(this.defaultNamespace);
		for (GOMNamespace namespace : this.namespaces) {
			aStreamWriter.writeNamespace(namespace);
		}
		List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
		for (GOMAttribute attribute : xmlNamespaceAttributes) {
			aStreamWriter.writeAttribute(attribute);
		}
		writeInnerAtomOutput(aStreamWriter);
		if (this.itemsPerPageElement != null)
			this.itemsPerPageElement.writeAtomOutput(aStreamWriter);
		if (this.startIndexElement != null)
			this.startIndexElement.writeAtomOutput(aStreamWriter);
		for (GOMExtension extension : this.extensions) {
			extension.writeAtomOutput(aStreamWriter);
		}
		for (GOMEntry entry : this.entries) {
			entry.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(LOCALNAME_RSS, this.extensionAttributes);
		List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
		for (GOMAttribute attribute : xmlNamespaceAttributes) {
			aStreamWriter.writeAttribute(attribute);
		}
		if (this.defaultNamespace != null)
			aStreamWriter.writeNamespace(this.defaultNamespace);
		for (GOMNamespace namespace : this.namespaces) {
			aStreamWriter.writeNamespace(namespace);
		}
		aStreamWriter.writeAttribute(RSS_VERSION_ATTRIBUTE);

		aStreamWriter.writeStartElement(RSS_CHANNEL_ELEMENT_NAME);

		if (this.id != null)
			this.id.writeRssOutput(aStreamWriter);
		if (this.title != null)
			this.title.writeRssOutput(aStreamWriter);
		if (this.subtitle != null)
			this.subtitle.writeRssOutput(aStreamWriter);
		if (this.rights != null)
			this.rights.writeRssOutput(aStreamWriter);
		for (GOMAuthor authors : this.authors) {
			authors.writeRssOutput(aStreamWriter, "managingEditor");
		}
		for (GOMCategory category : this.categories) {
			category.writeRssOutput(aStreamWriter);
		}
		for (GOMLink link : this.links) {
			link.writeRssOutput(aStreamWriter);
		}
		if (this.updated != null) {
			// udated.getDate can not be null
			aStreamWriter.writeSimpleXMLElement("lastBuildDate", GOMUtils
					.buildRfc822Date(this.updated.getDate().getTime()), null);
		}

		if (this.logo != null || this.icon != null) {
			aStreamWriter.writeStartElement("image");
			if (this.logo != null)
				this.logo.writeRssOutput(aStreamWriter);
			else
				this.icon.writeRssOutput(aStreamWriter);
			aStreamWriter.writeEndElement();

		}

		if (this.generator != null)
			this.generator.writeRssOutput(aStreamWriter);
		if (this.itemsPerPageElement != null)
			this.itemsPerPageElement.writeRssOutput(aStreamWriter);
		if (this.startIndexElement != null)
			this.startIndexElement.writeRssOutput(aStreamWriter);
		for (GOMExtension extension : this.extensions) {
			extension.writeRssOutput(aStreamWriter);
		}
		for (GOMExtension extension : this.extensions) {
			extension.writeRssOutput(aStreamWriter);
		}
		for (GOMEntry entry : this.entries) {
			entry.writeRssOutput(aStreamWriter);
		}
		// channel
		aStreamWriter.writeEndElement();
		// rss
		aStreamWriter.writeEndElement();