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

GOMCategoryImpl

public class GOMCategoryImpl extends AbstractGOMElement implements org.apache.lucene.gdata.gom.GOMCategory
author
Simon Willnauer

Fields Summary
private static final String
DOMAIN
protected String
term
protected String
label
protected String
scheme
Constructors Summary
public GOMCategoryImpl()


	 	 
	  
		super();
		this.localName = LOCALNAME;
		this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
	
Methods Summary
public java.lang.StringgetLabel()

see
org.apache.lucene.gdata.gom.GOMCategory#getLabel()

		return this.label;
	
public java.lang.StringgetScheme()

see
org.apache.lucene.gdata.gom.GOMCategory#getScheme()

		return this.scheme;
	
public java.lang.StringgetTerm()

see
org.apache.lucene.gdata.gom.GOMCategory#getTerm()

		return this.term;
	
public voidprocessAttribute(javax.xml.namespace.QName aQName, java.lang.String aValue)

see
org.apache.lucene.gdata.gom.core.AbstractGOMElement#processAttribute(javax.xml.namespace.QName, java.lang.String)

		if (aQName == null)
			throw new GDataParseException("QName must not be null");
		if (aQName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)
				|| aQName.getNamespaceURI().equals("")) {
			String localPart = aQName.getLocalPart();
			if (localPart.equals(TERM_ATTRIBUTE)) {
				if (this.term != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ATTRIBUTE, TERM_ATTRIBUTE));
				this.term = aValue;
			} else if (localPart.equals(LABLE_ATTRIBUTE)) {
				if (this.label != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ATTRIBUTE, LABLE_ATTRIBUTE));
				this.label = aValue;
			} else if (localPart.equals(SCHEME_ATTRIBUTE)) {
				if (this.scheme != null)
					throw new GDataParseException(String.format(
							AtomParser.DUPLICATE_ATTRIBUTE, SCHEME_ATTRIBUTE));
				this.scheme = aValue;
			} else {
				super.processAttribute(aQName, aValue);
			}

		} else {
			super.processAttribute(aQName, aValue);
		}

	
public voidprocessEndElement()

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

		/*
		 * ATOM defines "undefinedContent" for this. GData defines this as no
		 * content containing element
		 */
		if (this.term == null)
			throw new GDataParseException(String.format(
					AtomParser.MISSING_ELEMENT_ATTRIBUTE, this.localName,
					TERM_ATTRIBUTE));
		if (this.scheme != null) {
			try {
				AtomParserUtils.getAbsolutAtomURI(this.xmlBase, this.scheme);
			} catch (URISyntaxException e) {
				throw new GDataParseException(String.format(
						AtomParser.INVALID_ATTRIBUTE, this.localName
								+ " attribute " + GOMCategory.SCHEME_ATTRIBUTE,
						"absolute uri"), e);
			}
		}
	
public voidsetLabel(java.lang.String aLabel)

see
org.apache.lucene.gdata.gom.GOMCategory#setLabel(java.lang.String)

		this.label = aLabel;

	
public voidsetScheme(java.lang.String aScheme)

see
org.apache.lucene.gdata.gom.GOMCategory#setScheme(java.lang.String)

		this.scheme = aScheme;
	
public voidsetTerm(java.lang.String aTerm)

see
org.apache.lucene.gdata.gom.GOMCategory#setTerm(java.lang.String)


		this.term = aTerm;

	
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)

		if (aStreamWriter == null)
			throw new NullPointerException("StreamWriter is null");
		List<GOMAttribute> list = new LinkedList<GOMAttribute>();
		/*
		 * term attribute is requiered for a category. attribute term { text },
		 */
		list.add(GOMUtils.buildDefaultNamespaceAttribute(this.term,
				TERM_ATTRIBUTE));
		if (this.scheme != null)
			list.add(GOMUtils.buildDefaultNamespaceAttribute(this.scheme,
					SCHEME_ATTRIBUTE));
		if (this.label != null)
			list.add(GOMUtils.buildDefaultNamespaceAttribute(this.label,
					LABLE_ATTRIBUTE));

		if (this.xmlLang != null)
			list.add(GOMUtils
					.buildXMLNamespaceAttribute(this.xmlLang, XML_LANG));
		aStreamWriter.writeSimpleXMLElement(this.localName, list, null);

	
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)

		if (aStreamWriter == null)
			throw new NullPointerException("StreamWriter is null");
		List<GOMAttribute> list = getXmlNamespaceAttributes();
		/*
		 * build this domain attr. even if scheme is null or empty
		 */
		list.add(GOMUtils.buildDefaultNamespaceAttribute(this.scheme, DOMAIN));

		aStreamWriter.writeSimpleXMLElement(this.localName, list, this.term);