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

GOMContentImpl

public class GOMContentImpl extends GOMTextContructImpl implements org.apache.lucene.gdata.gom.GOMContent
author
Simon Willnauer

Fields Summary
private String
src
private String
type
private org.apache.lucene.gdata.gom.AtomMediaType
mediaType
Constructors Summary
public GOMContentImpl()

		this.localName = GOMContent.LOCALNAME;
		this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
		this.rssLocalName = GOMContent.LOCAL_NAME_RSS;
	
Methods Summary
public org.apache.lucene.gdata.gom.AtomMediaTypegetAtomMediaType()

see
org.apache.lucene.gdata.gom.GOMContent#getAtomMediaType()

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

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

		if (aName == null)
			throw new GDataParseException("QName must not be null");
		if (this.mediaType == AtomMediaType.XML) {
			if (this.blobParser != null)
				throw new GDataParseException(String.format(
						DUPLICATE_ELEMENT, aName.getLocalPart()));
			this.blobParser = new XMLBlobContentParser();
			return this.blobParser.getChildParser(aName);
		}
		return super.getChildParser(aName);
	
public java.lang.StringgetSrc()

see
org.apache.lucene.gdata.gom.GOMContent#getSrc()

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

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

		if (aQName == null)
			throw new GDataParseException("QName must not be null");
		if (aValue == null)
			throw new GDataParseException("Value must not be null");
		if ("src".equals(aQName.getLocalPart())) {
			if (this.src != null)
				throw new GDataParseException(String.format(
						DUPLICATE_ATTRIBUTE, "src"));
			this.src = aValue;
			return;
		}
		if ("type".equals(aQName.getLocalPart())) {
			if (this.contentType != null || this.mediaType != null)
				throw new GDataParseException(String.format(
						DUPLICATE_ATTRIBUTE, "type"));
			if (AtomParserUtils.isAtomMediaType(aValue)) {
				this.type = aValue;
				this.mediaType = AtomParserUtils.getAtomMediaType(aValue);
				return;
			}

		}
		super.processAttribute(aQName, aValue);

	
public voidprocessElementValue(java.lang.String aValue)

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

		if (this.src != null)
			throw new GDataParseException(String.format(
					AtomParser.UNEXPECTED_ELEMENT_VALUE, this.localName
							+ " with attribute src set "));
		super.processElementValue(aValue);
	
public voidprocessEndElement()

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

		if (this.src != null)
			try {
				AtomParserUtils.getAbsolutAtomURI(this.xmlBase, this.src);
			} catch (URISyntaxException e) {
				throw new GDataParseException(String.format(INVALID_ATTRIBUTE,
						"src", "absolute uri"), e);
			}

		if (this.mediaType == null)
			super.processEndElement();
		else if (this.blobParser != null) {
			this.textValue = this.blobParser.toString();
			this.blobParser.close();
			this.blobParser = null;
		}

	
public voidsetAtomMediaType(org.apache.lucene.gdata.gom.AtomMediaType aMediaType)

see
org.apache.lucene.gdata.gom.GOMContent#setAtomMediaType(org.apache.lucene.gdata.gom.AtomMediaType)


		this.mediaType = aMediaType;

	
public voidsetSrc(java.lang.String aSrc)

see
org.apache.lucene.gdata.gom.GOMContent#setSrc(java.lang.String)

		this.src = aSrc;

	
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 (this.mediaType != null) {
			List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
			xmlNamespaceAttributes.add(GOMUtils.buildDefaultNamespaceAttribute(
					this.type, "type"));
			aStreamWriter.writeStartElement(this.localName,
					xmlNamespaceAttributes);
			if (this.src == null)
				aStreamWriter.writeContentUnescaped(this.textValue);
			else
				aStreamWriter.writeAttribute(GOMUtils
						.buildDefaultNamespaceAttribute(this.src, "src"));
			aStreamWriter.writeEndElement();

		} else {
			super.writeAtomOutput(aStreamWriter);
		}

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

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

		if (this.mediaType != null) {
			// if content is atomOutOfLineContent (has not textValue) ->
			// generate a <link> element.
			if (src != null) {
				aStreamWriter.writeSimpleXMLElement("link", null, this.src);
			} else if (this.mediaType == AtomMediaType.TEXT) {
				aStreamWriter.writeSimpleXMLElement("description", null,
						this.textValue);
			} else {
				// RSS doesn't support non-text content --> write atom type
				this.writeAtomOutput(aStreamWriter);
			}
		} else {
			super.writeRssOutput(aStreamWriter);
		}