FileDocCategorySizeDatePackage
GOMStaxWriter.javaAPI DocApache Lucene 2.1.09602Wed Feb 14 10:46:00 GMT 2007org.apache.lucene.gdata.gom.writer

GOMStaxWriter

public class GOMStaxWriter extends Object implements GOMOutputWriter
author
Simon Willnauer

Fields Summary
private static final String
STAX_OUTPUTFACTORY_KEY
private final Set
namespaceSet
private final XMLStreamWriter
writer
Constructors Summary
public GOMStaxWriter(OutputStream aOutputStream, String encoding)

param
aOutputStream
param
encoding
throws
UnsupportedEncodingException
throws
XMLStreamException
throws
FactoryConfigurationError

	 
		/*
		 * set the system property to make sure the factory will be found
		 */
		String property = System.getProperty(STAX_OUTPUTFACTORY_KEY);
		if (property == null)
			System.setProperty(STAX_OUTPUTFACTORY_KEY, STAX_OUTPUTFACTORY_KEY);
	
		this(new OutputStreamWriter(aOutputStream, encoding));
	
public GOMStaxWriter(OutputStream aOutputStream)
Class constructor

param
aOutputStream - a output stream to write the xml stream to.
throws
XMLStreamException - if a write exception occurs
throws
FactoryConfigurationError - if XMLOutputFactory throws an exception

		this(new OutputStreamWriter(aOutputStream));
	
public GOMStaxWriter(Writer aWriter)
Class constructor

param
aWriter - a writer to write the xml stream to.
throws
XMLStreamException - if a write exception occurs
throws
FactoryConfigurationError - if XMLOutputFactory throws an exception

		if (aWriter == null)
			throw new IllegalArgumentException("Given writer must not be null");

		this.writer = XMLOutputFactory.newInstance(STAX_OUTPUTFACTORY_KEY,
				GOMStaxWriter.class.getClassLoader()).createXMLStreamWriter(
				aWriter);

	
Methods Summary
public voidclose()

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#close()

		this.writer.close();
	
public voidflush()

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#flush()

		this.writer.flush();
	
public voidwriteAttribute(org.apache.lucene.gdata.gom.GOMAttribute attribute)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeAttribute(org.apache.lucene.gdata.gom.GOMAttribute)

		if (attribute.hasDefaultNamespace())
			this.writer.writeAttribute(attribute.getLocalName(), attribute
					.getTextValue());
		else
			this.writer.writeAttribute(attribute.getQname().getPrefix(),
					attribute.getQname().getNamespaceURI(), attribute
							.getLocalName(), attribute.getTextValue());
	
public voidwriteContent(java.lang.String aContent)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeContent(java.lang.String)

		if (aContent != null) {
			char[] cs = aContent.toCharArray();
			this.writer.writeCharacters(cs, 0, cs.length);
		}
	
public voidwriteContentUnescaped(java.lang.String aContent)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeContentUnescaped(java.lang.String)

		if (aContent != null)
			this.writer.writeCharacters(aContent);
	
public voidwriteDefaultNamespace(java.lang.String aNsUri)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeDefaultNamespace(java.lang.String)

		this.writer.writeDefaultNamespace(aNsUri);

	
public voidwriteDefaultNamespace(org.apache.lucene.gdata.gom.GOMNamespace aNameSpace)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeDefaultNamespace(org.apache.lucene.gdata.gom.GOMNamespace)

		if (aNameSpace != null)
			writeDefaultNamespace(aNameSpace.getNamespaceUri());
	
public voidwriteEndDocument()

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeEndDocument()

		this.writer.writeEndDocument();
	
public voidwriteEndElement()

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeEndElement()

		this.writer.writeEndElement();
	
public voidwriteNamespace(org.apache.lucene.gdata.gom.GOMNamespace aNameSpace)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeNamespace(org.apache.lucene.gdata.gom.GOMNamespace)

		if (aNameSpace == null)
			return;
		if (this.namespaceSet.contains(aNameSpace))
			return;
		this.namespaceSet.add(aNameSpace);
		this.writer.writeNamespace(aNameSpace.getNamespacePrefix(), aNameSpace
				.getNamespaceUri());
	
public voidwriteSimpleXMLElement(javax.xml.namespace.QName aName, java.util.List aList, java.lang.String aValue)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeSimpleXMLElement(javax.xml.namespace.QName, java.util.List, java.lang.String)

		writeStartElement(aName, aList);
		writeContent(aValue);
		this.writer.writeEndElement();
	
public voidwriteSimpleXMLElement(javax.xml.namespace.QName aName, java.lang.String aValue, org.apache.lucene.gdata.gom.GOMAttribute aAttribute)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeSimpleXMLElement(javax.xml.namespace.QName, java.lang.String, org.apache.lucene.gdata.gom.GOMAttribute)

		List<GOMAttribute> list = null;
		if (aAttribute != null) {
			list = new ArrayList<GOMAttribute>(1);
			list.add(aAttribute);
		}
		writeSimpleXMLElement(aName, list, aValue);
	
public voidwriteSimpleXMLElement(java.lang.String aName, java.lang.String aValue, org.apache.lucene.gdata.gom.GOMAttribute aAttribute)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeSimpleXMLElement(java.lang.String, java.lang.String, org.apache.lucene.gdata.gom.GOMAttribute)

		List<GOMAttribute> list = null;
		if (aAttribute != null) {
			list = new ArrayList<GOMAttribute>(1);
			list.add(aAttribute);
		}
		writeSimpleXMLElement(aName, list, aValue);
	
public voidwriteSimpleXMLElement(java.lang.String aName, java.util.List aList, java.lang.String aValue)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeSimpleXMLElement(java.lang.String, java.util.List, java.lang.String)

		writeStartElement(aName, aList);
		writeContent(aValue);
		this.writer.writeEndElement();
	
public voidwriteStartDocument(java.lang.String aString, java.lang.String aString2)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeStartDocument(java.lang.String, java.lang.String)

		this.writer.writeStartDocument(aString, aString2);
	
public voidwriteStartElement(java.lang.String aName, org.apache.lucene.gdata.gom.GOMAttribute aAttribute)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeStartElement(java.lang.String, org.apache.lucene.gdata.gom.GOMAttribute)

		this.writer.writeStartElement(aName);
		writeAttribute(aAttribute);
	
public voidwriteStartElement(java.lang.String aName)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeStartElement(java.lang.String)

		this.writer.writeStartElement(aName);
	
public voidwriteStartElement(javax.xml.namespace.QName aName, java.util.List aList)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeStartElement(javax.xml.namespace.QName, java.util.List)

		this.writer.writeStartElement(aName.getPrefix(), aName.getLocalPart(),
				aName.getNamespaceURI());
		if (aList != null)
			for (GOMAttribute attribute : aList) {
				writeAttribute(attribute);
			}
	
public voidwriteStartElement(java.lang.String aName, java.util.List aList)

see
org.apache.lucene.gdata.gom.writer.GOMOutputWriter#writeStartElement(java.lang.String, java.util.List)

		this.writer.writeStartElement(aName);
		if (aList != null)
			for (GOMAttribute attribute : aList) {
				writeAttribute(attribute);
			}