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

GOMTextContructImpl

public abstract class GOMTextContructImpl extends AbstractGOMElement implements org.apache.lucene.gdata.gom.GOMTextConstruct
author
Simon Willnauer

Fields Summary
protected org.apache.lucene.gdata.gom.ContentType
contentType
protected String
rssLocalName
protected transient XMLBlobContentParser
blobParser
protected transient StringBuilder
htmlBuilder
Constructors Summary
Methods Summary
public AtomParsergetChildParser(javax.xml.namespace.QName aName)

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

		if (aName == null)
			throw new GDataParseException("QName must not be null");
		if (this.contentType == ContentType.XHTML
				&& aName.getLocalPart().equals("div")) {
			if (this.blobParser != null)
				throw new GDataParseException(String.format(
						DUPLICATE_ELEMENT, "div"));
			this.blobParser = new XMLBlobContentParser();
			return this.blobParser.getChildParser(aName);
		}

		return super.getChildParser(aName);

	
public org.apache.lucene.gdata.gom.ContentTypegetContentType()

return
the contentType


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

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

		if (aQName == null)
			throw new GDataParseException("QName must not be null");
		if ("type".equals(aQName.getLocalPart()) && aValue != null) {
			if (this.contentType != null)
				throw new GDataParseException(String.format(
						DUPLICATE_ATTRIBUTE, "type"));
			this.contentType = ContentType.valueOf(aValue.toUpperCase());
			if (this.contentType == ContentType.HTML)
				this.htmlBuilder = new StringBuilder();
		}
		super.processAttribute(aQName, aValue);

	
public voidprocessElementValue(java.lang.String aValue)

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

		if (this.htmlBuilder != null)
			this.htmlBuilder.append(aValue);
		else {
			this.textValue = aValue;
		}
	
public voidprocessEndElement()

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

		if (this.contentType == null)
			throw new GDataParseException(String.format(
					MISSING_ELEMENT_ATTRIBUTE, this.qname, "type"));
		switch (this.contentType) {
		case XHTML:
			if (this.blobParser != null) {
				this.textValue = this.blobParser.toString();
				this.blobParser.close();
				this.blobParser = null;
			}

			break;
		case HTML:
			if (this.htmlBuilder != null) {
				this.textValue = this.htmlBuilder.toString();
				this.htmlBuilder = null;
			}

		default:
			break;
		}

	
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)

		List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
		xmlNamespaceAttributes.add(GOMUtils
				.getAttributeByContentTypeDefaultNs(this.contentType));
		if (this.contentType == ContentType.XHTML) {
			/*
			 * if the content is xhtml write it unescaped
			 */
			aStreamWriter.writeStartElement(this.localName,
					xmlNamespaceAttributes);
			aStreamWriter.writeContentUnescaped(this.textValue);
			aStreamWriter.writeEndElement();

		} else {
			// html and text will be escaped by stax writer
			aStreamWriter.writeSimpleXMLElement(this.localName,
					xmlNamespaceAttributes, this.textValue);
		}

	
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)

		/*
		 * RSS does not support markup as child elements StaX Writer will encode
		 * all containing markup into valid xml entities
		 */
		aStreamWriter.writeSimpleXMLElement(this.rssLocalName,
				getXmlNamespaceAttributes(), this.textValue);