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

GOMBuilder

public class GOMBuilder extends Object
author
Simon Willnauer

Fields Summary
private final XMLStreamReader
streamReader
private final GOMFactory
factory
private final Stack
parserStack
Constructors Summary
public GOMBuilder(XMLStreamReader arg0)

param
arg0

		if (arg0 == null)
			throw new IllegalArgumentException(
					"XMLStreamReader instance must not be null");
		this.streamReader = arg0;
		this.factory = GOMFactory.createInstance();
		this.parserStack = new Stack<AtomParser>();
	
Methods Summary
public org.apache.lucene.gdata.gom.GOMDocumentbuildGOMEntry()

		GOMDocument<GOMEntry> document = new GOMDocumentImpl<GOMEntry>();
		GOMEntry element = startEntryDocument(document);
		document.setRootElement(element);
		parse(this.streamReader);

		return document;

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

		GOMDocument<GOMFeed> document = new GOMDocumentImpl<GOMFeed>();
		GOMFeed element = startFeedDocument(document);
		document.setRootElement(element);
		parse(this.streamReader);

		return document;
	
private intnext()

		return this.streamReader.next();

	
private voidparse(javax.xml.stream.XMLStreamReader aReader)


		int next = 0;

		while ((next = next()) != XMLStreamConstants.END_DOCUMENT) {

			if (next == XMLStreamConstants.START_ELEMENT) {
				AtomParser childParser = this.parserStack.peek()
						.getChildParser(this.streamReader.getName());
				processAttributes(childParser);
				this.parserStack.push(childParser);
			} else if (next == XMLStreamConstants.END_ELEMENT) {
				this.parserStack.pop().processEndElement();
			} else if (next == XMLStreamConstants.CHARACTERS) {
				this.parserStack.peek().processElementValue(
						this.streamReader.getText());
			} else if (next == XMLStreamConstants.CDATA) {
				System.out.println("CDdata");
			}
			// System.out.println(next);
		}

	
private voidprocessAttributes(AtomParser childParser)

param
childParser

		int attributeCount = this.streamReader.getAttributeCount();
		for (int i = 0; i < attributeCount; i++) {
			childParser.processAttribute(this.streamReader.getAttributeName(i),
					this.streamReader.getAttributeValue(i));
		}
	
private org.apache.lucene.gdata.gom.GOMEntrystartEntryDocument(org.apache.lucene.gdata.gom.GOMDocument aDocument)

		aDocument.setVersion(this.streamReader.getVersion());
		aDocument.setCharacterEncoding(this.streamReader
				.getCharacterEncodingScheme());
		GOMEntry entry = this.factory.createEntry();
		if (next() != XMLStreamConstants.START_ELEMENT)
			throw new GDataParseException("Expected start of feed element");
		processAttributes(entry);
		this.parserStack.push(entry);
		int count = this.streamReader.getNamespaceCount();
		for (int i = 0; i < count; i++) {
			GOMNamespace namespace = new GOMNamespace(this.streamReader
					.getNamespaceURI(i), this.streamReader
					.getNamespacePrefix(i));
			entry.addNamespace(namespace);
		}
		return entry;
	
private org.apache.lucene.gdata.gom.GOMFeedstartFeedDocument(org.apache.lucene.gdata.gom.GOMDocument aDocument)

		aDocument.setVersion(this.streamReader.getVersion());
		aDocument.setCharacterEncoding(this.streamReader
				.getCharacterEncodingScheme());
		GOMFeed feed = this.factory.createFeed();
		if (next() != XMLStreamConstants.START_ELEMENT)
			throw new GDataParseException("Expected start of feed element");
		processAttributes(feed);
		this.parserStack.push(feed);
		int count = this.streamReader.getNamespaceCount();
		for (int i = 0; i < count; i++) {

			GOMNamespace namespace = new GOMNamespace(this.streamReader
					.getNamespaceURI(i), this.streamReader
					.getNamespacePrefix(i));
			System.out.println(namespace);
			feed.addNamespace(namespace);
		}
		return feed;