You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/10/03 05:58:08 UTC
svn commit: r452306 - in
/xerces/java/branches/stax-dev/src/org/apache/xerces/stax: ./ events/
Author: mrglavas
Date: Mon Oct 2 20:58:06 2006
New Revision: 452306
URL: http://svn.apache.org/viewvc?view=rev&rev=452306
Log:
JIRA Issue #1201:
http://issues.apache.org/jira/browse/XERCESJ-1201
An initial implementation of the StAX Event API.
Thanks to the generous contribution from Lucian Holland.
Added:
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java (with props)
Modified:
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.XMLEventAllocator;
+import javax.xml.stream.util.XMLEventConsumer;
+
+import org.apache.xerces.stax.events.AttributeImpl;
+import org.apache.xerces.stax.events.CharactersImpl;
+import org.apache.xerces.stax.events.CommentImpl;
+import org.apache.xerces.stax.events.DTDImpl;
+import org.apache.xerces.stax.events.EndDocumentImpl;
+import org.apache.xerces.stax.events.EndElementImpl;
+import org.apache.xerces.stax.events.EntityReferenceImpl;
+import org.apache.xerces.stax.events.NamespaceImpl;
+import org.apache.xerces.stax.events.ProcessingInstructionImpl;
+import org.apache.xerces.stax.events.StartDocumentImpl;
+import org.apache.xerces.stax.events.StartElementImpl;
+
+/**
+ * Default implementation of the event allocator interface.
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class DefaultEventAllocator implements XMLEventAllocator {
+
+ /**
+ * @see javax.xml.stream.util.XMLEventAllocator#newInstance()
+ */
+ public XMLEventAllocator newInstance() {
+ //This object is not stateful - we can just return the same instance each time.
+ return this;
+ }
+
+ /**
+ * @see javax.xml.stream.util.XMLEventAllocator#allocate(javax.xml.stream.XMLStreamReader)
+ */
+ public XMLEvent allocate(XMLStreamReader reader) throws XMLStreamException {
+ int eventType = reader.getEventType();
+ final Location location = reader.getLocation();
+ switch (eventType) {
+ case XMLStreamConstants.ATTRIBUTE:
+ //This can only happen for cases where just attributes are returned by
+ //a query. I'm assuming that in these cases the stream reader reports each attribute
+ //in turn at index 0.
+ return makeAttribute(0, reader);
+ case XMLStreamConstants.CDATA:
+ return new CharactersImpl(reader.getText(), false, true, false, location, null);
+ case XMLStreamConstants.CHARACTERS:
+ return new CharactersImpl(reader.getText(), false, false, false, location, null);
+ case XMLStreamConstants.COMMENT:
+ return new CommentImpl(reader.getText(), location);
+ case XMLStreamConstants.DTD:
+ return new DTDImpl(reader.getText(), location);
+ case XMLStreamConstants.END_DOCUMENT:
+ return new EndDocumentImpl(location);
+ case XMLStreamConstants.END_ELEMENT:
+ return new EndElementImpl(reader.getName(), location);
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ //TODO: Get the EntityDeclaration.
+ return new EntityReferenceImpl(null, location);
+ case XMLStreamConstants.NAMESPACE:
+ //This can only happen for cases where just namespaces are returned by
+ //a query. I'm assuming that in these cases the stream reader reports each namespace
+ //in turn at index 0.
+ final String namespacePrefix = reader.getNamespacePrefix(0);
+ return new NamespaceImpl(namespacePrefix, reader.getNamespaceURI(), location);
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ return new ProcessingInstructionImpl(reader.getPITarget(), reader.getPIData(), location);
+ case XMLStreamConstants.SPACE:
+ //TODO: Ignorable Whitespace
+ return new CharactersImpl(reader.getText(), true, false, false, location, null);
+ case XMLStreamConstants.START_DOCUMENT:
+ return new StartDocumentImpl(reader.getEncoding(), reader.getCharacterEncodingScheme() != null, reader.isStandalone(), reader.standaloneSet(), reader.getVersion(), location);
+ case XMLStreamConstants.START_ELEMENT:
+ return makeStartElement(reader);
+ default:
+ throw new IllegalStateException("Unknown eventType: '" + eventType + "'.");
+ }
+ }
+
+ /**
+ * @see javax.xml.stream.util.XMLEventAllocator#allocate(javax.xml.stream.XMLStreamReader, javax.xml.stream.util.XMLEventConsumer)
+ */
+ public void allocate(XMLStreamReader reader, XMLEventConsumer consumer)
+ throws XMLStreamException {
+ consumer.add(allocate(reader));
+ }
+
+ /**
+ * @return
+ */
+ private static StartElement makeStartElement(XMLStreamReader streamReader) {
+ if (!streamReader.isStartElement()) {
+ throw new IllegalStateException("makeStartElement must only be called when in the start element state.");
+ }
+
+ StartElementImpl startElement = new StartElementImpl(streamReader.getName(), streamReader.getNamespaceContext(), streamReader.getLocation(), null);
+ for(int i = 0; i < streamReader.getAttributeCount(); i++) {
+ startElement.addAttribute(makeAttribute(i, streamReader));
+ }
+ for(int i = 0; i < streamReader.getNamespaceCount(); i++) {
+ startElement.addNamespace(makeNamespace(i, streamReader));
+ }
+ return startElement;
+ }
+
+ /**
+ * @param i
+ * @return
+ */
+ private static Namespace makeNamespace(int i, XMLStreamReader streamReader) {
+ String prefix = streamReader.getNamespacePrefix(i);
+ String namespace = streamReader.getNamespaceURI(i);
+ return new NamespaceImpl(prefix, namespace, streamReader.getLocation());
+ }
+
+ /**
+ * @param i Index of attribute to make in the current list of attributes.
+ * @param streamReader TODO
+ * @return An attribute factoried from the detail of the attribute at index i
+ * given the current state of the reader.
+ */
+ private static Attribute makeAttribute(final int i, XMLStreamReader streamReader) {
+ String prefix = streamReader.getAttributePrefix(i);
+ final QName name = new QName(streamReader.getAttributeNamespace(i), streamReader.getAttributeLocalName(i), prefix == null ? "" : prefix);
+ return new AttributeImpl(name, streamReader.getAttributeValue(i), streamReader.getAttributeType(i), streamReader.isAttributeSpecified(i), streamReader.getLocation(), null);
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/DefaultEventAllocator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import java.util.NoSuchElementException;
+
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.XMLEventAllocator;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class XMLEventReaderImpl implements XMLEventReader {
+
+ private final XMLStreamReader fReader;
+
+ /**
+ * There is an asymmetry between XMLStreamReader and XMLEventReader.
+ * The event reader starts in a non-state, prior to the START_DOCUMENT, like
+ * a normal iterator. The stream reader starts already in the START_DOCUMENT
+ * state. So we need to treat the first event slightly differently (in effect
+ * like a peek)
+ */
+ private boolean fPreStart = true;
+
+ /**
+ * If a peek has been done, this event will
+ * be non-null, and subsequent peeks should
+ * return it
+ */
+ private XMLEvent fPeekedEvent = null;
+
+ /**
+ * If a peek has been done, this will be the
+ * event we were on before the peek. This is important
+ * for methods that are sensitive to "current" state, like
+ * getElementText
+ */
+ private XMLEvent fPrePeekEvent = null;
+
+ /**
+ * The event allocator to use to make events out of the stream.
+ */
+ private final XMLEventAllocator fAllocator;
+
+ /**
+ * Construct based on XMLStreamReader.
+ */
+ public XMLEventReaderImpl(final XMLEventAllocator allocator, final XMLStreamReader reader) {
+ fAllocator = allocator;
+ fReader = reader;
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#nextEvent()
+ */
+ public XMLEvent nextEvent() throws XMLStreamException {
+ populatePreStartEvent();
+ XMLEvent next = null;
+ if (fPeekedEvent != null) {
+ next = fPeekedEvent;
+ clearEventCache();
+ }
+ else {
+ fReader.next();
+ next = makeEvent();
+ }
+ return next;
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#hasNext()
+ */
+ public boolean hasNext() {
+ if (fPeekedEvent != null || fPreStart) {
+ return true;
+ }
+
+ try {
+ return fReader.hasNext();
+ }
+ catch (XMLStreamException e) {
+ //Assuming that the only meaningful thing
+ //to do here is to return false.
+ }
+ return false;
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#peek()
+ */
+ public XMLEvent peek() throws XMLStreamException {
+ populatePreStartEvent();
+ if (fPeekedEvent == null) {
+ try {
+ if(fReader.hasNext()){
+ fReader.next();
+ fPeekedEvent = makeEvent();
+ }
+ }
+ catch(NoSuchElementException e) {
+ //Just leave it as null, which is the desired behaviour
+ }
+
+ }
+ return fPeekedEvent;
+ }
+
+ /**
+ * @throws XMLStreamException
+ */
+ private void populatePreStartEvent() throws XMLStreamException {
+ if (fPreStart) {
+ fPeekedEvent = makeEvent();
+
+ //Not strictly meaningful, but simplifies code elsewhere.
+ fPrePeekEvent = fPeekedEvent;
+ fPreStart = false;
+ }
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#getElementText()
+ */
+ public String getElementText() throws XMLStreamException {
+ fPreStart = false;
+ if (fPeekedEvent == null) {
+ return fReader.getElementText();
+ }
+ else if (!fPrePeekEvent.isStartElement()) {
+ throw new XMLStreamException("getElementText called when not on a START_ELEMENT event", fPrePeekEvent.getLocation());
+ }
+ else if (!(fPeekedEvent.isCharacters() || fPeekedEvent.isProcessingInstruction() || fPeekedEvent instanceof Comment)) {
+ throw new XMLStreamException("Unexpected content encountered while trying to getElementText", fPeekedEvent.getLocation());
+ }
+ else {
+ StringBuffer buffer = new StringBuffer();
+ if (fPeekedEvent.isCharacters()) {
+ buffer.append(((Characters) fPeekedEvent).getData());
+ }
+ clearEventCache();
+ for (XMLEvent event = nextEvent(); !event.isEndElement(); event = nextEvent()){
+ if (event.isCharacters()) {
+ buffer.append(((Characters) fPeekedEvent).getData());
+ }
+ else if (!(event.isProcessingInstruction() || event.isProcessingInstruction() || event instanceof Comment)) {
+ throw new XMLStreamException("Unexpected content encountered while trying to getElementText", fPeekedEvent.getLocation());
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#nextTag()
+ */
+ public XMLEvent nextTag() throws XMLStreamException {
+ populatePreStartEvent();
+ if (fPeekedEvent != null) {
+ if (!(fPeekedEvent.isStartElement()
+ || fPeekedEvent.isEndElement()
+ || fPeekedEvent.isStartDocument()
+ || (fPeekedEvent.isCharacters() && ((Characters)fPeekedEvent).isWhiteSpace()))) {
+ throw new XMLStreamException("nextTag when next event was not an element event.", fReader.getLocation());
+ }
+ //nextTag moves to the next startElement or endElement; if we've already peeked
+ //one of these there's no need to advance to the nextTag now.
+ else if(!fPeekedEvent.isStartElement() && !fPeekedEvent.isEndElement()) {
+ fReader.nextTag();
+ }
+ clearEventCache();
+ }
+ else {
+ fReader.nextTag();
+ }
+ return makeEvent();
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#getProperty(java.lang.String)
+ */
+ public Object getProperty(String name) throws IllegalArgumentException {
+ return fReader.getProperty(name);
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventReader#close()
+ */
+ public void close() throws XMLStreamException {
+ fReader.close();
+ }
+
+ /**
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+
+ try {
+ return nextEvent();
+ }
+ catch (XMLStreamException ex) {
+ //Not sure what else to do in this case...
+ throw new IllegalStateException(ex.toString());
+ }
+
+ }
+
+ /**
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException("XMLEventReader does not support remove()");
+ }
+
+ /**
+ * @return A new event object for the current event in the stream.
+ */
+ private XMLEvent makeEvent() throws XMLStreamException {
+ return fAllocator.allocate(fReader);
+ }
+
+ /**
+ * Clears the cached next event used for peek();
+ */
+ private void clearEventCache() {
+ fPeekedEvent = null;
+ fPrePeekEvent = null;
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventReaderImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import java.io.Writer;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.Comment;
+import javax.xml.stream.events.DTD;
+import javax.xml.stream.events.EntityReference;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.ProcessingInstruction;
+import javax.xml.stream.events.StartDocument;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class XMLEventWriterImpl implements XMLEventWriter {
+
+ private final XMLStreamWriter fStreamWriter;
+ private final Writer fUnderlyingWriter;
+
+ public XMLEventWriterImpl(XMLStreamWriter streamWriter) {
+ this(streamWriter, null);
+ }
+
+
+
+ public XMLEventWriterImpl(XMLStreamWriter streamWriter, Writer underlyingWriter) {
+ fStreamWriter = streamWriter;
+ fUnderlyingWriter = underlyingWriter;
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#flush()
+ */
+ public void flush() throws XMLStreamException {
+ fStreamWriter.flush();
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#close()
+ */
+ public void close() throws XMLStreamException {
+ fStreamWriter.close();
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#add(javax.xml.stream.events.XMLEvent)
+ */
+ public void add(XMLEvent event) throws XMLStreamException {
+ switch(event.getEventType()) {
+ case XMLEvent.ATTRIBUTE:
+ writeAttribute((Attribute)event);
+ break;
+ case XMLEvent.SPACE:
+ case XMLEvent.CDATA:
+ case XMLEvent.CHARACTERS:
+ writeCharacters((Characters)event);
+ break;
+ case XMLEvent.COMMENT:
+ fStreamWriter.writeComment(((Comment)event).getText());
+ break;
+ case XMLEvent.DTD:
+ writeDTD((DTD)event);
+ break;
+ case XMLEvent.END_DOCUMENT:
+ fStreamWriter.writeEndDocument();
+ break;
+ case XMLEvent.END_ELEMENT:
+ fStreamWriter.writeEndElement();
+ break;
+ case XMLEvent.ENTITY_DECLARATION:
+ //TODO: Should this do anything?
+ break;
+ case XMLEvent.ENTITY_REFERENCE:
+ fStreamWriter.writeEntityRef(((EntityReference)event).getName());
+ break;
+ case XMLEvent.NAMESPACE:
+ Namespace namespace = (Namespace)event;
+ fStreamWriter.writeNamespace(namespace.getPrefix(), namespace.getNamespaceURI());
+ case XMLEvent.NOTATION_DECLARATION:
+ //TODO: Should this do anything?
+ break;
+ case XMLEvent.PROCESSING_INSTRUCTION:
+ writePI((ProcessingInstruction)event);
+ break;
+ case XMLEvent.START_DOCUMENT:
+ writeStartDoc((StartDocument)event);
+ break;
+ case XMLEvent.START_ELEMENT:
+ writeStartElement((StartElement)event);
+ break;
+ default:
+ if (fUnderlyingWriter != null) {
+ event.writeAsEncodedUnicode(fUnderlyingWriter);
+ }
+ break;
+
+ }
+
+ }
+
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#add(javax.xml.stream.XMLEventReader)
+ */
+ public void add(XMLEventReader reader) throws XMLStreamException {
+ while(reader.hasNext()) {
+ add(reader.nextEvent());
+ }
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#getPrefix(java.lang.String)
+ */
+ public String getPrefix(String uri) throws XMLStreamException {
+ return fStreamWriter.getPrefix(uri);
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#setPrefix(java.lang.String, java.lang.String)
+ */
+ public void setPrefix(String prefix, String uri) throws XMLStreamException {
+ fStreamWriter.setPrefix(prefix, uri);
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#setDefaultNamespace(java.lang.String)
+ */
+ public void setDefaultNamespace(String uri) throws XMLStreamException {
+ fStreamWriter.setDefaultNamespace(uri);
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#setNamespaceContext(javax.xml.namespace.NamespaceContext)
+ */
+ public void setNamespaceContext(NamespaceContext context)
+ throws XMLStreamException {
+ fStreamWriter.setNamespaceContext(context);
+ }
+
+ /**
+ * @see javax.xml.stream.XMLEventWriter#getNamespaceContext()
+ */
+ public NamespaceContext getNamespaceContext() {
+ return fStreamWriter.getNamespaceContext();
+ }
+
+ /**
+ * @param instruction
+ */
+ private void writePI(ProcessingInstruction pi) throws XMLStreamException {
+ if (pi.getData() != null) {
+ fStreamWriter.writeProcessingInstruction(pi.getTarget(), pi.getData());
+ }
+ else {
+ fStreamWriter.writeProcessingInstruction(pi.getTarget());
+ }
+ }
+
+
+
+ /**
+ * @param element
+ */
+ private void writeStartElement(StartElement element) throws XMLStreamException {
+ for (Iterator iter = element.getNamespaces(); iter.hasNext();) {
+ Namespace namespace = (Namespace) iter.next();
+ fStreamWriter.setPrefix(namespace.getPrefix(), namespace.getNamespaceURI());
+ }
+
+ String namespaceURI = element.getName().getNamespaceURI();
+ String prefix = element.getName().getPrefix();
+ if (prefix == null && namespaceURI != null) {
+ prefix = fStreamWriter.getPrefix(namespaceURI);
+ }
+
+ fStreamWriter.writeStartElement(prefix, element.getName().getLocalPart(), element.getName().getNamespaceURI());
+
+ for (Iterator iter = element.getNamespaces(); iter.hasNext();) {
+ Namespace namespace = (Namespace) iter.next();
+ fStreamWriter.writeNamespace(namespace.getPrefix(), namespace.getNamespaceURI());
+ }
+
+ for (Iterator iter = element.getAttributes(); iter.hasNext();) {
+ Attribute attr = (Attribute) iter.next();
+ writeAttribute(attr);
+ }
+ }
+
+
+
+ /**
+ * @param document
+ */
+ private void writeStartDoc(StartDocument document) throws XMLStreamException {
+ String version = document.getVersion();
+ String encoding = document.getCharacterEncodingScheme();
+ fStreamWriter.writeStartDocument(encoding, version);
+ }
+
+
+
+ /**
+ * @param dtd DTD event to write.
+ */
+ private void writeDTD(DTD dtd) throws XMLStreamException {
+ if(dtd.getDocumentTypeDeclaration() != null) {
+ fStreamWriter.writeDTD(dtd.getDocumentTypeDeclaration());
+ }
+ }
+
+
+
+ /**
+ * @param characters
+ */
+ private void writeCharacters(Characters characters) throws XMLStreamException {
+ if (characters.isCData()) {
+ fStreamWriter.writeCData(characters.getData());
+ }
+ else {
+ fStreamWriter.writeCharacters(characters.getData());
+ }
+ }
+
+
+
+ /**
+ * @param attribute
+ */
+ private void writeAttribute(Attribute attribute) throws XMLStreamException {
+ final String namespaceURI = attribute.getName().getNamespaceURI();
+ String prefix = attribute.getName().getPrefix();
+ if (prefix == null && namespaceURI != null && namespaceURI.length() > 0) {
+ prefix = fStreamWriter.getPrefix(namespaceURI);
+ }
+ if (prefix != null && prefix.length() > 0) {
+ fStreamWriter.writeAttribute(prefix, namespaceURI, attribute.getName().getLocalPart(), attribute.getValue());
+ }
+ else if (namespaceURI.length() > 0){
+ fStreamWriter.writeAttribute(namespaceURI, attribute.getName().getLocalPart(), attribute.getValue());
+ }
+ else {
+ fStreamWriter.writeAttribute(attribute.getName().getLocalPart(), attribute.getValue());
+ }
+ }
+
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLEventWriterImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java?view=diff&rev=452306&r1=452305&r2=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java (original)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java Mon Oct 2 20:58:06 2006
@@ -48,6 +48,8 @@
ConfigurationContext config = new ConfigurationContext();
+ DefaultEventAllocator fAllocator = new DefaultEventAllocator();
+
public XMLInputFactoryImpl() {}
public XMLStreamReader createXMLStreamReader(Reader reader)
@@ -100,40 +102,42 @@
}
public XMLEventReader createXMLEventReader(Reader reader)
- throws XMLStreamException {
- return null;
+ throws XMLStreamException {
+ return new XMLEventReaderImpl(createEventAllocator(), createXMLStreamReader(reader));
}
public XMLEventReader createXMLEventReader(String systemId, Reader reader)
- throws XMLStreamException {
- return null;
+ throws XMLStreamException {
+ return new XMLEventReaderImpl(createEventAllocator(), createXMLStreamReader(systemId, reader));
}
public XMLEventReader createXMLEventReader(XMLStreamReader reader)
- throws XMLStreamException {
- return null;
+ throws XMLStreamException {
+ return new XMLEventReaderImpl(createEventAllocator(), reader);
}
public XMLEventReader createXMLEventReader(Source source)
- throws XMLStreamException {
- return null;
+ throws XMLStreamException {
+ return new XMLEventReaderImpl(createEventAllocator(), createXMLStreamReader(source));
}
public XMLEventReader createXMLEventReader(InputStream stream)
- throws XMLStreamException {
- return null;
+ throws XMLStreamException {
+ return new XMLEventReaderImpl(createEventAllocator(), createXMLStreamReader(stream));
}
public XMLEventReader createXMLEventReader(InputStream stream,
String encoding) throws XMLStreamException {
- return null;
+ return new XMLEventReaderImpl(createEventAllocator(), createXMLStreamReader(stream, encoding));
}
public XMLEventReader createXMLEventReader(String systemId,
InputStream stream) throws XMLStreamException {
- return null;
+ return new XMLEventReaderImpl(createEventAllocator(), createXMLStreamReader(systemId, stream));
}
+
+
public XMLStreamReader createFilteredReader(XMLStreamReader reader,
StreamFilter filter) throws XMLStreamException {
return null;
@@ -215,5 +219,13 @@
public boolean isPropertySupported(String name) {
return config.isPropertySupported(name);
+ }
+
+ /**
+ * @return Either the user supplied event allocator, or a default one.
+ */
+ private XMLEventAllocator createEventAllocator() {
+ XMLEventAllocator userAlloc = config.getEventAllocator();
+ return userAlloc == null ? fAllocator.newInstance() : userAlloc.newInstance();
}
}
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.events.Attribute;
+
+/**
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class AttributeImpl extends XMLEventImpl implements Attribute {
+
+ private final boolean fIsSpecified;
+ private final QName fName;
+ private final String fValue;
+ private final String fDtdType;
+
+ /**
+ * Constructor.
+ */
+ public AttributeImpl(final QName name, final String value, final String dtdType, final boolean isSpecified, final Location location, final QName schemaType) {
+ this(ATTRIBUTE, name, value, dtdType, isSpecified, location, schemaType);
+ }
+
+ protected AttributeImpl(final int type, final QName name, final String value, final String dtdType, final boolean isSpecified, final Location location, final QName schemaType) {
+ super(type, location, schemaType);
+ fName = name;
+ fValue = value;
+ fDtdType = dtdType;
+ fIsSpecified = isSpecified;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Attribute#getName()
+ */
+ public QName getName() {
+ return fName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Attribute#getValue()
+ */
+ public String getValue() {
+ return fValue;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Attribute#getDTDType()
+ */
+ public String getDTDType() {
+ return fDtdType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Attribute#isSpecified()
+ */
+ public boolean isSpecified() {
+ return fIsSpecified;
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/AttributeImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.events.Characters;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class CharactersImpl extends XMLEventImpl implements Characters {
+
+ private final String fData;
+ private final boolean fIsWS;
+ private final boolean fIsCData;
+ private final boolean fIsIgnorableWS;
+
+ /**
+ * Standard constructor.
+ * @param eventType
+ * @param location
+ * @param schemaType
+ */
+ public CharactersImpl(final String data, final boolean isWS, final boolean isCData, final boolean isIgnorableWS, final Location location, final QName schemaType) {
+ super(CHARACTERS, location, schemaType);
+ fData = data;
+ fIsWS = isWS;
+ fIsCData = isCData;
+ fIsIgnorableWS = isIgnorableWS;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Characters#getData()
+ */
+ public String getData() {
+ return fData;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Characters#isWhiteSpace()
+ */
+ public boolean isWhiteSpace() {
+ return fIsWS;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Characters#isCData()
+ */
+ public boolean isCData() {
+ return fIsCData;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Characters#isIgnorableWhiteSpace()
+ */
+ public boolean isIgnorableWhiteSpace() {
+ return fIsIgnorableWS;
+ }
+
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CharactersImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.events.Comment;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class CommentImpl extends XMLEventImpl implements Comment {
+
+ /**
+ * The text of the comment. Will be the empty string if there's no
+ * body text in the comment.
+ */
+ private final String fText;
+
+ /**
+ * @param location
+ */
+ public CommentImpl(final String text, final Location location) {
+ super(COMMENT, location, null);
+ fText = text;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Comment#getText()
+ */
+ public String getText() {
+ return fText;
+ }
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/CommentImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import java.util.List;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.events.DTD;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class DTDImpl extends XMLEventImpl implements DTD {
+
+ private final String fDtd;
+
+ /**
+ * Constructor.
+ */
+ public DTDImpl(final String dtd, final Location location) {
+ super(XMLStreamConstants.DTD, location, null);
+ fDtd = dtd;
+ }
+
+ /**
+ * @see javax.xml.stream.events.DTD#getDocumentTypeDeclaration()
+ */
+ public String getDocumentTypeDeclaration() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.xml.stream.events.DTD#getProcessedDTD()
+ */
+ public Object getProcessedDTD() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.xml.stream.events.DTD#getNotations()
+ */
+ public List getNotations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.xml.stream.events.DTD#getEntities()
+ */
+ public List getEntities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/DTDImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.events.EndDocument;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class EndDocumentImpl extends XMLEventImpl implements EndDocument {
+
+ /**
+ * Constructor.
+ * @param location Location object for this event.
+ */
+ public EndDocumentImpl(Location location) {
+ super(XMLStreamConstants.END_DOCUMENT, location, null);
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndDocumentImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.events.EndElement;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class EndElementImpl extends XMLEventImpl implements EndElement {
+
+ /**
+ * The qualified name of the element that is being closed.
+ */
+ private final QName fName;
+
+ /**
+ * @param location The location object for this event.
+ */
+ public EndElementImpl(final QName name, final Location location) {
+ super(XMLStreamConstants.END_ELEMENT, location, null);
+ fName = name;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EndElement#getName()
+ */
+ public QName getName() {
+ return fName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EndElement#getNamespaces()
+ */
+ public Iterator getNamespaces() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EndElementImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.events.EntityDeclaration;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class EntityDeclarationImpl extends XMLEventImpl implements
+ EntityDeclaration {
+
+ private final String fPublicId;
+ private final String fSystemId;
+ private final String fName;
+ private final String fNotationName;
+
+ /**
+ * @param eventType
+ * @param location
+ * @param schemaType
+ */
+ public EntityDeclarationImpl(final String publicId, final String systemId, final String name, final String notationName, final Location location) {
+ super(ENTITY_DECLARATION, location, null);
+ fPublicId = publicId;
+ fSystemId = systemId;
+ fName = name;
+ fNotationName = notationName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityDeclaration#getPublicId()
+ */
+ public String getPublicId() {
+ return fPublicId;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityDeclaration#getSystemId()
+ */
+ public String getSystemId() {
+ return fSystemId;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityDeclaration#getName()
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityDeclaration#getNotationName()
+ */
+ public String getNotationName() {
+ return fNotationName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityDeclaration#getReplacementText()
+ */
+ public String getReplacementText() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityDeclaration#getBaseURI()
+ */
+ public String getBaseURI() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityDeclarationImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.events.EntityDeclaration;
+import javax.xml.stream.events.EntityReference;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class EntityReferenceImpl extends XMLEventImpl implements
+ EntityReference {
+
+ /**
+ * The entity declaration for this entity reference.
+ */
+ private final EntityDeclaration fDecl;
+
+ /**
+ * Constructor.
+ * @param location
+ */
+ public EntityReferenceImpl(final EntityDeclaration decl, final Location location) {
+ super(ENTITY_REFERENCE, location, null);
+ fDecl = decl;;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityReference#getDeclaration()
+ */
+ public EntityDeclaration getDeclaration() {
+ return fDecl;
+ }
+
+ /**
+ * @see javax.xml.stream.events.EntityReference#getName()
+ */
+ public String getName() {
+ //TODO: Is this actually correct? Not sure how an entity ref can have a different
+ //name to the entity decl, but needs checking just in case.
+ return fDecl.getName();
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/EntityReferenceImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.events.Namespace;
+
+import org.apache.xerces.xni.NamespaceContext;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class NamespaceImpl extends AttributeImpl implements Namespace {
+
+ private final String fPrefix;
+ private final String fNamespaceURI;
+
+ /**
+ * @param location
+ * @param schemaType
+ */
+ public NamespaceImpl(final String prefix, final String namespaceURI, final Location location) {
+ super(NAMESPACE, makeAttributeQName(prefix), namespaceURI, null, true, location, null);
+ fPrefix = (prefix == null ? "" : prefix);
+ fNamespaceURI = namespaceURI;
+ }
+
+ /**
+ * @param prefix The prefix for this namespace.
+ * @return A QName for the attribute that declares this namespace.
+ */
+ private static QName makeAttributeQName(String prefix) {
+ if (prefix == null) {
+ return new QName("", "xmlns", "");
+ }
+ return new QName(NamespaceContext.XMLNS_URI, prefix, "xmlns");
+ }
+
+ /**
+ * @see javax.xml.stream.events.Namespace#getPrefix()
+ */
+ public String getPrefix() {
+ return fPrefix;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Namespace#getNamespaceURI()
+ */
+ public String getNamespaceURI() {
+ return fNamespaceURI;
+ }
+
+ /**
+ * @see javax.xml.stream.events.Namespace#isDefaultNamespaceDeclaration()
+ */
+ public boolean isDefaultNamespaceDeclaration() {
+ return fPrefix == "";
+ }
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NamespaceImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.events.NotationDeclaration;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class NotationDeclarationImpl extends XMLEventImpl implements
+ NotationDeclaration {
+
+ private final String fSystemId;
+ private final String fPublicId;
+ private final String fName;
+
+ /**
+ * @param eventType
+ * @param location
+ * @param schemaType
+ */
+ public NotationDeclarationImpl(final String name, final String publicId, final String systemId, final Location location) {
+ super(NOTATION_DECLARATION, location, null);
+ fName = name;
+ fPublicId = publicId;
+ fSystemId = systemId;
+ }
+
+ /**
+ * @see javax.xml.stream.events.NotationDeclaration#getName()
+ */
+ public String getName() {
+ return fName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.NotationDeclaration#getPublicId()
+ */
+ public String getPublicId() {
+ return fPublicId;
+ }
+
+ /**
+ * @see javax.xml.stream.events.NotationDeclaration#getSystemId()
+ */
+ public String getSystemId() {
+ return fSystemId;
+ }
+
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/NotationDeclarationImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.ProcessingInstruction;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class ProcessingInstructionImpl extends XMLEventImpl implements
+ ProcessingInstruction {
+
+ private final String fTarget;
+ private final String fData;
+
+ /**
+ * @param location
+ */
+ public ProcessingInstructionImpl(final String target, final String data, final Location location) {
+ super(PROCESSING_INSTRUCTION, location, null);
+ fTarget = target;
+ fData = data;
+ }
+
+ /**
+ * @see javax.xml.stream.events.ProcessingInstruction#getTarget()
+ */
+ public String getTarget() {
+ return fTarget;
+ }
+
+ /**
+ * @see javax.xml.stream.events.ProcessingInstruction#getData()
+ */
+ public String getData() {
+ return fData;
+ }
+
+ /**
+ * @see org.apache.xerces.stax.events.XMLEventImpl#writeToStreamWriter(javax.xml.stream.XMLStreamWriter)
+ */
+ public void writeToStreamWriter(XMLStreamWriter writer) throws XMLStreamException {
+
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/ProcessingInstructionImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.events.StartDocument;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class StartDocumentImpl extends XMLEventImpl implements StartDocument {
+
+ private final String fCharEncoding;
+ private final boolean fEncodingSet;
+ private final String fVersion;
+ private final boolean fIsStandalone;
+ private final boolean fStandaloneSet;
+
+ /**
+ * @param location
+ */
+ public StartDocumentImpl(final String charEncoding, final boolean encodingSet, final boolean isStandalone, final boolean standaloneSet, final String version, final Location location) {
+ super(START_DOCUMENT, location, null);
+ fCharEncoding = charEncoding;
+ fEncodingSet = encodingSet;
+ fIsStandalone = isStandalone;
+ fStandaloneSet = standaloneSet;
+ fVersion = version;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartDocument#getSystemId()
+ */
+ public String getSystemId() {
+ return getLocation().getSystemId();
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartDocument#getCharacterEncodingScheme()
+ */
+ public String getCharacterEncodingScheme() {
+ return fCharEncoding;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartDocument#encodingSet()
+ */
+ public boolean encodingSet() {
+ return fEncodingSet;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartDocument#isStandalone()
+ */
+ public boolean isStandalone() {
+ return fIsStandalone;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartDocument#standaloneSet()
+ */
+ public boolean standaloneSet() {
+ return fStandaloneSet;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartDocument#getVersion()
+ */
+ public String getVersion() {
+ return fVersion;
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartDocumentImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public class StartElementImpl extends XMLEventImpl implements StartElement {
+
+ private final Map fAttributes = new TreeMap(new Comparator(){
+ public int compare(Object o1, Object o2) {
+ if(o1.equals(o2)) {
+ return 0;
+ }
+ QName name1 = (QName)o1;
+ QName name2 = (QName)o2;
+ return name1.toString().compareTo(name2.toString());
+ }});
+ private final List fNamespaces = new ArrayList();
+ private final QName fName;
+ private final NamespaceContext fNamespaceContext;
+
+ /**
+ * @param location
+ * @param schemaType
+ */
+ public StartElementImpl(final QName name, final NamespaceContext namespaceContext, final Location location, final QName schemaType) {
+ super(START_ELEMENT, location, schemaType);
+ fName = name;
+ fNamespaceContext = namespaceContext;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartElement#getName()
+ */
+ public QName getName() {
+ return fName;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartElement#getAttributes()
+ */
+ public Iterator getAttributes() {
+ return new NoRemoveIterator(fAttributes.values().iterator());
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartElement#getNamespaces()
+ */
+ public Iterator getNamespaces() {
+ return new NoRemoveIterator(fNamespaces.iterator());
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartElement#getAttributeByName(javax.xml.namespace.QName)
+ */
+ public Attribute getAttributeByName(final QName name) {
+ return (Attribute) fAttributes.get(name);
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartElement#getNamespaceContext()
+ */
+ public NamespaceContext getNamespaceContext() {
+ return fNamespaceContext;
+ }
+
+ /**
+ * @see javax.xml.stream.events.StartElement#getNamespaceURI(java.lang.String)
+ */
+ public String getNamespaceURI(final String prefix) {
+ return fNamespaceContext.getNamespaceURI(prefix);
+ }
+
+ public void addAttribute(final Attribute attribute) {
+ fAttributes.put(attribute.getName(), attribute);
+ }
+
+ public void addNamespace(final Namespace namespace) {
+ fNamespaces.add(namespace);
+ }
+
+
+ private final class NoRemoveIterator implements Iterator {
+
+ private final Iterator fWrapped;
+
+ public NoRemoveIterator(Iterator wrapped) {
+ fWrapped = wrapped;
+ }
+
+ /**
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return fWrapped.hasNext();
+ }
+
+ /**
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+ return fWrapped.next();
+ }
+
+ /**
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException("Attributes iterator is read-only.");
+ }
+
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/StartElementImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java?view=auto&rev=452306
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java Mon Oct 2 20:58:06 2006
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax.events;
+
+import java.io.Writer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+/**
+ *
+ * @author Lucian Holland
+ *
+ * @version $Id$
+ */
+public abstract class XMLEventImpl implements XMLEvent {
+
+ /**
+ * Constant representing the type of this event.
+ * {@see javax.xml.stream.XMLStreamConstants}
+ */
+ private int fEventType;
+
+ /**
+ * Location object for this event.
+ */
+ private Location fLocation;
+
+ /**
+ * The QName of the schema type for this element.
+ */
+ private QName fSchemaType;
+
+ /**
+ * Constructor.
+ */
+ public XMLEventImpl(final int eventType, final Location location, final QName schemaType) {
+ fEventType = eventType;
+ fLocation = location;
+ fSchemaType = schemaType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#getEventType()
+ */
+ public int getEventType() {
+ return fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#getLocation()
+ */
+ public Location getLocation() {
+ return fLocation;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isStartElement()
+ */
+ public boolean isStartElement() {
+ return XMLStreamConstants.START_ELEMENT == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isAttribute()
+ */
+ public boolean isAttribute() {
+ return XMLStreamConstants.ATTRIBUTE == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isNamespace()
+ */
+ public boolean isNamespace() {
+ return XMLStreamConstants.NAMESPACE == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isEndElement()
+ */
+ public boolean isEndElement() {
+ return XMLStreamConstants.END_ELEMENT == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isEntityReference()
+ */
+ public boolean isEntityReference() {
+ return XMLStreamConstants.ENTITY_REFERENCE == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isProcessingInstruction()
+ */
+ public boolean isProcessingInstruction() {
+ return XMLStreamConstants.PROCESSING_INSTRUCTION == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isCharacters()
+ */
+ public boolean isCharacters() {
+ return XMLStreamConstants.CHARACTERS == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isStartDocument()
+ */
+ public boolean isStartDocument() {
+ return XMLStreamConstants.START_DOCUMENT == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#isEndDocument()
+ */
+ public boolean isEndDocument() {
+ return XMLStreamConstants.END_DOCUMENT == fEventType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#asStartElement()
+ */
+ public StartElement asStartElement() {
+ return (StartElement) this;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#asEndElement()
+ */
+ public EndElement asEndElement() {
+ return (EndElement) this;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#asCharacters()
+ */
+ public Characters asCharacters() {
+ return (Characters) this;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#getSchemaType()
+ */
+ public QName getSchemaType() {
+ return fSchemaType;
+ }
+
+ /**
+ * @see javax.xml.stream.events.XMLEvent#writeAsEncodedUnicode(java.io.Writer)
+ */
+ public void writeAsEncodedUnicode(final Writer writer) throws XMLStreamException {
+ // TODO Auto-generated method stub
+ }
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/events/XMLEventImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org