diff options
author | Chris Burdess <dog@bluezoo.org> | 2006-03-03 12:30:59 +0000 |
---|---|---|
committer | Chris Burdess <dog@bluezoo.org> | 2006-03-03 12:30:59 +0000 |
commit | 85b35b1bda7ca489cbe770303289ed28c2a49363 (patch) | |
tree | 6ad41665c318feeebd7793a292b9f53d3bf3c52d | |
parent | 6ecf858745c60dcbf2b5ffac9da4e07ec15862d4 (diff) | |
download | classpath-85b35b1bda7ca489cbe770303289ed28c2a49363.tar.gz |
2006-03-03 Chris Burdess <dog@gnu.org>
Fixes PR 26503
* gnu/xml/stream/EntityReferenceImpl.java,
gnu/xml/stream/FilteredEventReader.java,
gnu/xml/stream/SAXParser.java,
gnu/xml/stream/XIncludeFilter.java,
gnu/xml/stream/XMLEventAllocatorImpl.java,
gnu/xml/stream/XMLEventFactoryImpl.java,
gnu/xml/stream/XMLEventImpl.java,
gnu/xml/stream/XMLEventReaderImpl.java,
gnu/xml/stream/XMLEventWriterImpl.java,
gnu/xml/stream/XMLInputFactoryImpl.java,
gnu/xml/stream/XMLOutputFactoryImpl.java,
gnu/xml/stream/XMLParser.java,
javax/xml/stream/EventFilter.java,
javax/xml/stream/Location.java,
javax/xml/stream/StreamFilter.java,
javax/xml/stream/XMLEventFactory.java,
javax/xml/stream/XMLEventReader.java,
javax/xml/stream/XMLEventWriter.java,
javax/xml/stream/XMLInputFactory.java,
javax/xml/stream/XMLOutputFactory.java,
javax/xml/stream/XMLReporter.java,
javax/xml/stream/XMLResolver.java,
javax/xml/stream/XMLStreamConstants.java,
javax/xml/stream/XMLStreamReader.java,
javax/xml/stream/events/EntityDeclaration.java,
javax/xml/stream/events/EntityReference.java,
javax/xml/stream/events/XMLEvent.java,
javax/xml/stream/util/EventReaderDelegate.java,
javax/xml/stream/util/ReaderDelegate.java: Updated to final version of
StAX API as specified in JWSDP 2.0.
* gnu/xml/stream/EndEntityImpl.java,
gnu/xml/stream/LocationImpl.java,
gnu/xml/stream/StartEntityImpl.java,
gnu/xml/stream/XMLStreamReaderImpl.java,
javax/xml/stream/XMLFilter.java,
javax/xml/stream/XMLIterator.java,
javax/xml/stream/events/EndEntity.java,
javax/xml/stream/events/StartEntity.java: Removed legacy files.
38 files changed, 340 insertions, 1791 deletions
@@ -1,3 +1,45 @@ +2006-03-03 Chris Burdess <dog@gnu.org> + + Fixes PR 26503 + * gnu/xml/stream/EntityReferenceImpl.java, + gnu/xml/stream/FilteredEventReader.java, + gnu/xml/stream/SAXParser.java, + gnu/xml/stream/XIncludeFilter.java, + gnu/xml/stream/XMLEventAllocatorImpl.java, + gnu/xml/stream/XMLEventFactoryImpl.java, + gnu/xml/stream/XMLEventImpl.java, + gnu/xml/stream/XMLEventReaderImpl.java, + gnu/xml/stream/XMLEventWriterImpl.java, + gnu/xml/stream/XMLInputFactoryImpl.java, + gnu/xml/stream/XMLOutputFactoryImpl.java, + gnu/xml/stream/XMLParser.java, + javax/xml/stream/EventFilter.java, + javax/xml/stream/Location.java, + javax/xml/stream/StreamFilter.java, + javax/xml/stream/XMLEventFactory.java, + javax/xml/stream/XMLEventReader.java, + javax/xml/stream/XMLEventWriter.java, + javax/xml/stream/XMLInputFactory.java, + javax/xml/stream/XMLOutputFactory.java, + javax/xml/stream/XMLReporter.java, + javax/xml/stream/XMLResolver.java, + javax/xml/stream/XMLStreamConstants.java, + javax/xml/stream/XMLStreamReader.java, + javax/xml/stream/events/EntityDeclaration.java, + javax/xml/stream/events/EntityReference.java, + javax/xml/stream/events/XMLEvent.java, + javax/xml/stream/util/EventReaderDelegate.java, + javax/xml/stream/util/ReaderDelegate.java: Updated to final version of + StAX API as specified in JWSDP 2.0. + * gnu/xml/stream/EndEntityImpl.java, + gnu/xml/stream/LocationImpl.java, + gnu/xml/stream/StartEntityImpl.java, + gnu/xml/stream/XMLStreamReaderImpl.java, + javax/xml/stream/XMLFilter.java, + javax/xml/stream/XMLIterator.java, + javax/xml/stream/events/EndEntity.java, + javax/xml/stream/events/StartEntity.java: Removed legacy files. + 2006-03-03 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/CellEditor.java: API doc updates, diff --git a/gnu/xml/stream/EndEntityImpl.java b/gnu/xml/stream/EndEntityImpl.java deleted file mode 100644 index fd36ee267..000000000 --- a/gnu/xml/stream/EndEntityImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* EndEntityImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.stream; - -import java.io.IOException; -import java.io.Writer; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.EndEntity; - -/** - * An end-entity event. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class EndEntityImpl - extends XMLEventImpl - implements EndEntity -{ - - protected final String name; - - protected EndEntityImpl(Location location, String name) - { - super(location); - this.name = name; - } - - public int getEventType() - { - return END_ENTITY; - } - - public String getName() - { - return name; - } - - public void writeAsEncodedUnicode(Writer writer) - throws XMLStreamException - { - } - -} - diff --git a/gnu/xml/stream/EntityReferenceImpl.java b/gnu/xml/stream/EntityReferenceImpl.java index 4b40bfa52..38e1f00b1 100644 --- a/gnu/xml/stream/EntityReferenceImpl.java +++ b/gnu/xml/stream/EntityReferenceImpl.java @@ -1,5 +1,5 @@ /* EntityReferenceImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,7 +41,7 @@ import java.io.IOException; import java.io.Writer; import javax.xml.stream.Location; import javax.xml.stream.XMLStreamException; -//import javax.xml.stream.events.EntityDeclaration; +import javax.xml.stream.events.EntityDeclaration; import javax.xml.stream.events.EntityReference; /** @@ -54,26 +54,16 @@ public class EntityReferenceImpl implements EntityReference { - //protected final EntityDeclaration decl; + protected final EntityDeclaration decl; protected final String name; - protected final String baseUri; - protected final String publicId; - protected final String systemId; - protected final String replacementText; protected EntityReferenceImpl(Location location, - //EntityDeclaration decl, - String name, - String baseUri, String publicId, - String systemId, String replacementText) + EntityDeclaration decl, + String name) { super(location); - //this.decl = decl; + this.decl = decl; this.name = name; - this.baseUri = baseUri; - this.publicId = publicId; - this.systemId = systemId; - this.replacementText = replacementText; } public int getEventType() @@ -81,36 +71,16 @@ public class EntityReferenceImpl return ENTITY_REFERENCE; } - /*public EntityDeclaration getDeclaration() + public EntityDeclaration getDeclaration() { return decl; - }*/ + } public String getName() { return name; } - public String getBaseUri() - { - return baseUri; - } - - public String getPublicId() - { - return publicId; - } - - public String getSystemId() - { - return systemId; - } - - public String getReplacementText() - { - return replacementText; - } - public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException { diff --git a/gnu/xml/stream/FilteredEventReader.java b/gnu/xml/stream/FilteredEventReader.java index 3bf0f2518..fd6fe8b07 100644 --- a/gnu/xml/stream/FilteredEventReader.java +++ b/gnu/xml/stream/FilteredEventReader.java @@ -1,5 +1,5 @@ /* FilteredEventReader.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,24 +56,37 @@ class FilteredEventReader } public boolean hasNext() - throws XMLStreamException { // XXX ??? return super.hasNext(); } - public XMLEvent next() + public XMLEvent nextEvent() throws XMLStreamException { XMLEvent ret; do { - ret = super.next(); + ret = super.nextEvent(); } while (!filter.accept(ret)); return ret; } + public Object next() + { + try + { + return nextEvent(); + } + catch (XMLStreamException e) + { + RuntimeException e2 = new RuntimeException(); + e2.initCause(e); + throw e2; + } + } + public XMLEvent peek() throws XMLStreamException { diff --git a/gnu/xml/stream/LocationImpl.java b/gnu/xml/stream/LocationImpl.java deleted file mode 100644 index 1900aeb45..000000000 --- a/gnu/xml/stream/LocationImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* LocationImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.stream; - -import javax.xml.stream.Location; - -/** - * Information about the location of an XML event within the underlying - * stream. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class LocationImpl - implements Location -{ - - protected final int offset; - - protected final int col; - - protected final int line; - - protected final String systemId; - - protected LocationImpl(int offset, int col, int line, String systemId) - { - this.offset = offset; - this.col = col; - this.line = line; - this.systemId = systemId; - } - - public int getLineNumber() - { - return line; - } - - public int getColumnNumber() - { - return col; - } - - public int getCharacterOffset() - { - return offset; - } - - public String getLocationURI() - { - return systemId; - } - -} - diff --git a/gnu/xml/stream/SAXParser.java b/gnu/xml/stream/SAXParser.java index ee20851f9..9dd0921ba 100644 --- a/gnu/xml/stream/SAXParser.java +++ b/gnu/xml/stream/SAXParser.java @@ -92,8 +92,7 @@ import org.xml.sax.ext.Locator2; */ public class SAXParser extends javax.xml.parsers.SAXParser - implements XMLReader, Attributes2, Locator2, XMLReporter, - XMLParser.XMLResolver2 + implements XMLReader, Attributes2, Locator2, XMLReporter, XMLResolver { ContentHandler contentHandler; @@ -323,6 +322,7 @@ public class SAXParser supportDTD, baseAware, stringInterning, + true, this, this); else @@ -338,6 +338,7 @@ public class SAXParser supportDTD, baseAware, stringInterning, + true, this, this); } @@ -357,6 +358,7 @@ public class SAXParser supportDTD, baseAware, stringInterning, + true, this, this); } @@ -486,14 +488,14 @@ public class SAXParser contentHandler.processingInstruction(target, data); } break; - case XMLStreamConstants.START_ENTITY: + case XMLParser.START_ENTITY: if (lexicalHandler != null) { String name = reader.getText(); lexicalHandler.startEntity(name); } break; - case XMLStreamConstants.END_ENTITY: + case XMLParser.END_ENTITY: if (lexicalHandler != null) { String name = reader.getText(); @@ -688,7 +690,7 @@ public class SAXParser int ac = reader.getAttributeCount(); for (int i = 0; i < ac; i++) { - QName aname = reader.getAttributeQName(i); + QName aname = reader.getAttributeName(i); if ("space".equals(aname.getLocalPart()) && XMLConstants.XML_NS_URI.equals(aname.getNamespaceURI())) { @@ -729,7 +731,7 @@ public class SAXParser int len = reader.getAttributeCount(); for (int i = 0; i < len; i++) { - QName q = reader.getAttributeQName(i); + QName q = reader.getAttributeName(i); String localName = q.getLocalPart(); String prefix = q.getPrefix(); String qn = ("".equals(prefix)) ? localName : prefix + ":" + localName; @@ -744,7 +746,7 @@ public class SAXParser int len = reader.getAttributeCount(); for (int i = 0; i < len; i++) { - QName q = reader.getAttributeQName(i); + QName q = reader.getAttributeName(i); String ln = q.getLocalPart(); String u = q.getNamespaceURI(); if (u == null && uri != null) @@ -764,12 +766,12 @@ public class SAXParser public String getLocalName(int index) { - return reader.getAttributeName(index); + return reader.getAttributeLocalName(index); } public String getQName(int index) { - QName q = reader.getAttributeQName(index); + QName q = reader.getAttributeName(index); String localName = q.getLocalPart(); String prefix = q.getPrefix(); return ("".equals(prefix)) ? localName : prefix + ":" + localName; @@ -867,13 +869,14 @@ public class SAXParser public String getPublicId() { - return null; + Location l = reader.getLocation(); + return l.getPublicId(); } public String getSystemId() { Location l = reader.getLocation(); - return l.getLocationURI(); + return l.getSystemId(); } public String getEncoding() @@ -888,13 +891,8 @@ public class SAXParser // -- XMLResolver -- - public InputStream resolve(String uri) - throws XMLStreamException - { - return resolve(null, uri); - } - - public InputStream resolve(String publicId, String systemId) + public Object resolveEntity(String publicId, String systemId, + String baseURI, String namespace) throws XMLStreamException { if (entityResolver != null) diff --git a/gnu/xml/stream/StartEntityImpl.java b/gnu/xml/stream/StartEntityImpl.java deleted file mode 100644 index 6e4ca257a..000000000 --- a/gnu/xml/stream/StartEntityImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* StartEntityImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.stream; - -import java.io.IOException; -import java.io.Writer; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.StartEntity; - -/** - * A start-entity event. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class StartEntityImpl - extends XMLEventImpl - implements StartEntity -{ - - protected final String name; - - protected StartEntityImpl(Location location, String name) - { - super(location); - this.name = name; - } - - public int getEventType() - { - return START_ENTITY; - } - - public String getName() - { - return name; - } - - public void writeAsEncodedUnicode(Writer writer) - throws XMLStreamException - { - } - -} - diff --git a/gnu/xml/stream/XIncludeFilter.java b/gnu/xml/stream/XIncludeFilter.java index 6d12bb3b2..7e707820d 100644 --- a/gnu/xml/stream/XIncludeFilter.java +++ b/gnu/xml/stream/XIncludeFilter.java @@ -148,7 +148,7 @@ class XIncludeFilter return super.getAttributeCount(); } - public String getAttributeName(int index) + public String getAttributeLocalName(int index) { if (current != null) { @@ -158,7 +158,7 @@ class XIncludeFilter Node attr = attrs.item(index); return attr.getLocalName(); } - return super.getAttributeName(index); + return super.getAttributeLocalName(index); } public String getAttributeNamespace(int index) @@ -187,7 +187,7 @@ class XIncludeFilter return super.getAttributePrefix(index); } - public QName getAttributeQName(int index) + public QName getAttributeName(int index) { if (current != null) { @@ -200,7 +200,7 @@ class XIncludeFilter String prefix = attr.getPrefix(); return new QName(uri, localName, prefix); } - return super.getAttributeQName(index); + return super.getAttributeName(index); } public String getAttributeType(int index) diff --git a/gnu/xml/stream/XMLEventAllocatorImpl.java b/gnu/xml/stream/XMLEventAllocatorImpl.java index 4b21b6c71..666bffabe 100644 --- a/gnu/xml/stream/XMLEventAllocatorImpl.java +++ b/gnu/xml/stream/XMLEventAllocatorImpl.java @@ -1,5 +1,5 @@ /* XMLEventAllocatorImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -116,10 +116,9 @@ public class XMLEventAllocatorImpl namespaces); case XMLStreamConstants.ENTITY_REFERENCE: String name = reader.getLocalName(); - //EntityDeclaration decl = - // (EntityDeclaration) entityDeclarations.get(name); - //return new EntityReferenceImpl(location, decl, name); - return new EntityReferenceImpl(location, name, null, null, null, null); + EntityDeclaration decl = + (EntityDeclaration) entityDeclarations.get(name); + return new EntityReferenceImpl(location, decl, name); case XMLStreamConstants.PROCESSING_INSTRUCTION: return new ProcessingInstructionImpl(location, reader.getPITarget(), @@ -132,7 +131,7 @@ public class XMLEventAllocatorImpl return new CharactersImpl(location, text, whitespace, false, ignorableWhitespace); case XMLStreamConstants.START_DOCUMENT: - String systemId = location.getLocationURI(); + String systemId = location.getSystemId(); String encoding = reader.getCharacterEncodingScheme(); boolean encodingDeclared = encoding != null; if (encoding == null) @@ -164,7 +163,7 @@ public class XMLEventAllocatorImpl List attributes = new LinkedList(); for (int i = 0; i < len; i++) attributes.add(new AttributeImpl(location, - reader.getAttributeQName(i), + reader.getAttributeName(i), reader.getAttributeValue(i), QName.valueOf(reader.getAttributeType(i)), reader.isAttributeSpecified(i))); diff --git a/gnu/xml/stream/XMLEventFactoryImpl.java b/gnu/xml/stream/XMLEventFactoryImpl.java index a839b182c..e1d7d6ab8 100644 --- a/gnu/xml/stream/XMLEventFactoryImpl.java +++ b/gnu/xml/stream/XMLEventFactoryImpl.java @@ -1,5 +1,5 @@ /* XMLEventFactoryImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -233,12 +233,9 @@ public class XMLEventFactoryImpl } public EntityReference createEntityReference(String name, - //EntityDeclaration declaration) - String replacementText) + EntityDeclaration declaration) { - //return new EntityReferenceImpl(location, declaration, name); - return new EntityReferenceImpl(location, name, null, null, null, - replacementText); + return new EntityReferenceImpl(location, declaration, name); } public Comment createComment(String text) diff --git a/gnu/xml/stream/XMLEventImpl.java b/gnu/xml/stream/XMLEventImpl.java index a8b522f88..9f57d89d8 100644 --- a/gnu/xml/stream/XMLEventImpl.java +++ b/gnu/xml/stream/XMLEventImpl.java @@ -1,5 +1,5 @@ /* XMLEventImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -116,16 +116,6 @@ public abstract class XMLEventImpl return getEventType() == END_DOCUMENT; } - public boolean isStartEntity() - { - return getEventType() == START_ENTITY; - } - - public boolean isEndEntity() - { - return getEventType() == END_ENTITY; - } - public StartElement asStartElement() { return (StartElement) this; diff --git a/gnu/xml/stream/XMLEventReaderImpl.java b/gnu/xml/stream/XMLEventReaderImpl.java index 70481d7c4..bb64b1e3f 100644 --- a/gnu/xml/stream/XMLEventReaderImpl.java +++ b/gnu/xml/stream/XMLEventReaderImpl.java @@ -67,7 +67,7 @@ public class XMLEventReaderImpl this.systemId = systemId; } - public XMLEvent next() + public XMLEvent nextEvent() throws XMLStreamException { XMLEvent ret = peek(); @@ -75,10 +75,32 @@ public class XMLEventReaderImpl return ret; } + public Object next() + { + try + { + return nextEvent(); + } + catch (XMLStreamException e) + { + RuntimeException e2 = new RuntimeException(); + e2.initCause(e); + throw e2; + } + } + public boolean hasNext() - throws XMLStreamException { - return peekEvent != null || reader.hasNext(); + if (peekEvent != null) + return true; + try + { + return reader.hasNext(); + } + catch (XMLStreamException e) + { + return false; + } } public XMLEvent peek() @@ -121,5 +143,16 @@ public class XMLEventReaderImpl return reader.getProperty(name); } + public void close() + throws XMLStreamException + { + reader.close(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + } diff --git a/gnu/xml/stream/XMLEventWriterImpl.java b/gnu/xml/stream/XMLEventWriterImpl.java index 45024158d..72b7adce2 100644 --- a/gnu/xml/stream/XMLEventWriterImpl.java +++ b/gnu/xml/stream/XMLEventWriterImpl.java @@ -155,7 +155,7 @@ public class XMLEventWriterImpl throws XMLStreamException { while (reader.hasNext()) - add(reader.next()); + add(reader.nextEvent()); } public String getPrefix(String uri) diff --git a/gnu/xml/stream/XMLInputFactoryImpl.java b/gnu/xml/stream/XMLInputFactoryImpl.java index 164774d82..5f72e361e 100644 --- a/gnu/xml/stream/XMLInputFactoryImpl.java +++ b/gnu/xml/stream/XMLInputFactoryImpl.java @@ -1,5 +1,5 @@ /* XMLInputFactoryImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -89,14 +89,15 @@ public class XMLInputFactoryImpl public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { - /* - return new XMLStreamReaderImpl(reader, null, null, - resolver, reporter, - validating, namespaceAware, - coalescing, replacingEntityReferences, - externalEntities, supportDTD); - */ - XMLParser ret = new XMLParser(reader, null, + return createXMLStreamReader(null, reader); + } + + public XMLStreamReader createXMLStreamReader(Source source) + throws XMLStreamException + { + String systemId = source.getSystemId(); + InputStream in = getInputStream(source); + XMLParser ret = new XMLParser(in, systemId, validating, namespaceAware, coalescing, @@ -105,24 +106,30 @@ public class XMLInputFactoryImpl supportDTD, baseAware, stringInterning, + false, reporter, resolver); if (xIncludeAware) - return new XIncludeFilter(ret, null, namespaceAware, validating, + return new XIncludeFilter(ret, systemId, namespaceAware, validating, replacingEntityReferences); return ret; } - public XMLStreamReader createXMLStreamReader(Source source) + public XMLStreamReader createXMLStreamReader(InputStream in) + throws XMLStreamException + { + return createXMLStreamReader(null, in); + } + + public XMLStreamReader createXMLStreamReader(InputStream in, String encoding) + throws XMLStreamException + { + return createXMLStreamReader(in); + } + + public XMLStreamReader createXMLStreamReader(String systemId, InputStream in) throws XMLStreamException { - String systemId = source.getSystemId(); - InputStream in = getInputStream(source); - /*return new XMLStreamReaderImpl(in, null, systemId, - resolver, reporter, - validating, namespaceAware, - coalescing, replacingEntityReferences, - externalEntities, supportDTD);*/ XMLParser ret = new XMLParser(in, systemId, validating, namespaceAware, @@ -132,23 +139,19 @@ public class XMLInputFactoryImpl supportDTD, baseAware, stringInterning, + false, reporter, resolver); if (xIncludeAware) - return new XIncludeFilter(ret, systemId, namespaceAware, validating, + return new XIncludeFilter(ret, null, namespaceAware, validating, replacingEntityReferences); return ret; } - - public XMLStreamReader createXMLStreamReader(InputStream in) + + public XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException { - /*return new XMLStreamReaderImpl(in, null, null, - resolver, reporter, - validating, namespaceAware, - coalescing, replacingEntityReferences, - externalEntities, supportDTD);*/ - XMLParser ret = new XMLParser(in, null, + XMLParser ret = new XMLParser(reader, systemId, validating, namespaceAware, coalescing, @@ -157,6 +160,7 @@ public class XMLInputFactoryImpl supportDTD, baseAware, stringInterning, + false, reporter, resolver); if (xIncludeAware) @@ -164,12 +168,6 @@ public class XMLInputFactoryImpl replacingEntityReferences); return ret; } - - public XMLStreamReader createXMLStreamReader(InputStream in, String encoding) - throws XMLStreamException - { - return createXMLStreamReader(in); - } public XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException @@ -178,6 +176,13 @@ public class XMLInputFactoryImpl return new XMLEventReaderImpl(sr, allocator, null); } + public XMLEventReader createXMLEventReader(String systemId, Reader reader) + throws XMLStreamException + { + XMLStreamReader sr = createXMLStreamReader(systemId, reader); + return new XMLEventReaderImpl(sr, allocator, null); + } + public XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException { @@ -205,6 +210,13 @@ public class XMLInputFactoryImpl return new XMLEventReaderImpl(sr, allocator, null); } + public XMLEventReader createXMLEventReader(String systemId, InputStream in) + throws XMLStreamException + { + XMLStreamReader sr = createXMLStreamReader(systemId, in); + return new XMLEventReaderImpl(sr, allocator, null); + } + public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException diff --git a/gnu/xml/stream/XMLOutputFactoryImpl.java b/gnu/xml/stream/XMLOutputFactoryImpl.java index 05b6d6c0f..c8c651fb1 100644 --- a/gnu/xml/stream/XMLOutputFactoryImpl.java +++ b/gnu/xml/stream/XMLOutputFactoryImpl.java @@ -42,6 +42,8 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.io.UnsupportedEncodingException; +import javax.xml.transform.Result; +import javax.xml.transform.stream.StreamResult; import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; @@ -94,6 +96,22 @@ public class XMLOutputFactoryImpl } } + public XMLStreamWriter createXMLStreamWriter(Result result) + throws XMLStreamException + { + if (result instanceof StreamResult) + { + StreamResult sr = (StreamResult) result; + OutputStream out = sr.getOutputStream(); + if (out != null) + return createXMLStreamWriter(out); + Writer writer = sr.getWriter(); + if (writer != null) + return createXMLStreamWriter(writer); + } + throw new UnsupportedOperationException(); + } + public XMLEventWriter createXMLEventWriter(OutputStream stream) throws XMLStreamException { @@ -116,10 +134,26 @@ public class XMLOutputFactoryImpl return new XMLEventWriterImpl(writer); } + public XMLEventWriter createXMLEventWriter(Result result) + throws XMLStreamException + { + if (result instanceof StreamResult) + { + StreamResult sr = (StreamResult) result; + OutputStream out = sr.getOutputStream(); + if (out != null) + return createXMLEventWriter(out); + Writer writer = sr.getWriter(); + if (writer != null) + return createXMLEventWriter(writer); + } + throw new UnsupportedOperationException(); + } + public void setProperty(String name, Object value) throws IllegalArgumentException { - if (IS_PREFIX_DEFAULTING.equals(name)) + if (IS_REPAIRING_NAMESPACES.equals(name)) prefixDefaulting = ((Boolean) value).booleanValue(); else throw new IllegalArgumentException(name); @@ -128,14 +162,14 @@ public class XMLOutputFactoryImpl public Object getProperty(String name) throws IllegalArgumentException { - if (IS_PREFIX_DEFAULTING.equals(name)) + if (IS_REPAIRING_NAMESPACES.equals(name)) return new Boolean(prefixDefaulting); throw new IllegalArgumentException(name); } public boolean isPropertySupported(String name) { - if (IS_PREFIX_DEFAULTING.equals(name)) + if (IS_REPAIRING_NAMESPACES.equals(name)) return true; return false; } diff --git a/gnu/xml/stream/XMLParser.java b/gnu/xml/stream/XMLParser.java index 147fff720..9bb483426 100644 --- a/gnu/xml/stream/XMLParser.java +++ b/gnu/xml/stream/XMLParser.java @@ -137,6 +137,10 @@ public class XMLParser final static int ATTRIBUTE_DEFAULT_REQUIRED = 33; final static int ATTRIBUTE_DEFAULT_FIXED = 34; + // -- additional event types -- + final static int START_ENTITY = 50; + final static int END_ENTITY = 51; + /** * The current input. */ @@ -318,6 +322,12 @@ public class XMLParser private final boolean baseAware; /** + * Whether to report extended event types (START_ENTITY and END_ENTITY) + * in addition to the standard event types. Used by the SAX parser. + */ + private final boolean extendedEventTypes; + + /** * The reporter to receive parsing warnings. */ final XMLReporter reporter; @@ -389,6 +399,7 @@ public class XMLParser boolean supportDTD, boolean baseAware, boolean stringInterning, + boolean extendedEventTypes, XMLReporter reporter, XMLResolver resolver) { @@ -400,6 +411,7 @@ public class XMLParser this.supportDTD = supportDTD; this.baseAware = baseAware; this.stringInterning = stringInterning; + this.extendedEventTypes = extendedEventTypes; this.reporter = reporter; this.resolver = resolver; if (validating) @@ -446,6 +458,7 @@ public class XMLParser boolean supportDTD, boolean baseAware, boolean stringInterning, + boolean extendedEventTypes, XMLReporter reporter, XMLResolver resolver) { @@ -457,6 +470,7 @@ public class XMLParser this.supportDTD = supportDTD; this.baseAware = baseAware; this.stringInterning = stringInterning; + this.extendedEventTypes = extendedEventTypes; this.reporter = reporter; this.resolver = resolver; if (validating) @@ -561,7 +575,7 @@ public class XMLParser return attrs.size(); } - public String getAttributeName(int index) + public String getAttributeLocalName(int index) { Attribute a = (Attribute) attrs.get(index); return a.localName; @@ -579,7 +593,7 @@ public class XMLParser return a.prefix; } - public QName getAttributeQName(int index) + public QName getAttributeName(int index) { Attribute a = (Attribute) attrs.get(index); String namespaceURI = getNamespaceURI(a.prefix); @@ -995,16 +1009,16 @@ public class XMLParser String entityName = (String) startEntityStack.removeFirst(); buf.setLength(0); buf.append(entityName); - event = XMLStreamConstants.START_ENTITY; - return event; + event = START_ENTITY; + return extendedEventTypes ? event : next(); } else if (!endEntityStack.isEmpty()) { String entityName = (String) endEntityStack.removeFirst(); buf.setLength(0); buf.append(entityName); - event = XMLStreamConstants.END_ENTITY; - return event; + event = END_ENTITY; + return extendedEventTypes ? event : next(); } try { @@ -1499,10 +1513,10 @@ public class XMLParser InputStream in = null; if (resolver != null) { - if (resolver instanceof XMLResolver2) - in = ((XMLResolver2) resolver).resolve(ids.publicId, url); - else - in = resolver.resolve(url); + Object obj = resolver.resolveEntity(ids.publicId, url, getXMLBase(), + null); + if (obj instanceof InputStream) + in = (InputStream) obj; } if (in == null) in = resolve(url); @@ -4249,6 +4263,7 @@ public class XMLParser true, // supportDTD true, // baseAware true, // stringInterning + true, // extendedEventTypes null, null); XMLStreamReader reader = p; @@ -4280,7 +4295,7 @@ public class XMLParser "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) - System.out.println("\tattribute "+reader.getAttributeQName(i)+ + System.out.println("\tattribute "+reader.getAttributeName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: @@ -4308,10 +4323,10 @@ public class XMLParser System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; - case XMLStreamConstants.START_ENTITY: + case START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; - case XMLStreamConstants.END_ENTITY: + case END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: @@ -4324,7 +4339,7 @@ public class XMLParser Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ - " of "+l.getLocationURI()); + " of "+l.getSystemId()); throw e; } } @@ -4933,19 +4948,6 @@ public class XMLParser } /** - * Compatibility interface that can be used to resolve based on a public - * ID, not just an URL. - */ - interface XMLResolver2 - extends XMLResolver - { - - InputStream resolve(String publicId, String systemId) - throws XMLStreamException; - - } - - /** * An XML input source. */ static class Input @@ -5013,7 +5015,12 @@ public class XMLParser return line; } - public String getLocationURI() + public String getPublicId() + { + return publicId; + } + + public String getSystemId() { return systemId; } diff --git a/gnu/xml/stream/XMLStreamReaderImpl.java b/gnu/xml/stream/XMLStreamReaderImpl.java deleted file mode 100644 index 568d800ae..000000000 --- a/gnu/xml/stream/XMLStreamReaderImpl.java +++ /dev/null @@ -1,1037 +0,0 @@ -/* XMLStreamReaderImpl.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package gnu.xml.stream; - -import java.io.InputStream; -import java.io.IOException; -import java.io.Reader; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.stream.Location; -import javax.xml.stream.XMLResolver; -import javax.xml.stream.XMLReporter; -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.Characters; -import javax.xml.stream.events.Comment; -import javax.xml.stream.events.DTD; -import javax.xml.stream.events.EndDocument; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.EndEntity; -import javax.xml.stream.events.EntityDeclaration; -import javax.xml.stream.events.EntityReference; -import javax.xml.stream.events.Namespace; -import javax.xml.stream.events.NotationDeclaration; -import javax.xml.stream.events.ProcessingInstruction; -import javax.xml.stream.events.StartDocument; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.StartEntity; -import javax.xml.stream.events.XMLEvent; - -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.DTDHandler; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.XMLReader; -import org.xml.sax.ext.Attributes2; -import org.xml.sax.ext.DeclHandler; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.ext.Locator2; -import org.xml.sax.helpers.NamespaceSupport; - -/** - * An XML parser. - * - * This implementation uses SAX to create a series of events in memory, - * and then iterates over this series. This has the advantage of being simple - * and unifying the existing XML parsing code. However, it is quite - * memory-inefficient and obviously won't cope with streams of arbitrary - * length. - * - * A future task could be to write a real, progressive/incremental - * implementation of this class. In that case we should consider making that - * the default XML parser implementation and using a SAX wrapper to it to - * provide the GNU SAX implementation. - * - * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> - */ -public class XMLStreamReaderImpl - implements XMLStreamReader, NamespaceContext -{ - - private LinkedList events; - private XMLEvent currentEvent; - private int eventType; - private NamespaceSupport namespaces; - - protected String publicId; - protected String systemId; - - protected XMLResolver resolver; - protected XMLReporter reporter; - protected boolean validating; - protected boolean namespaceAware; - protected boolean coalescing; - protected boolean replacingEntityReferences; - protected boolean externalEntities; - protected boolean supportDTD; - - protected XMLStreamReaderImpl(InputStream in, - String publicId, - String systemId, - XMLResolver resolver, - XMLReporter reporter, - boolean validating, - boolean namespaceAware, - boolean coalescing, - boolean replacingEntityReferences, - boolean externalEntities, - boolean supportDTD) - throws XMLStreamException - { - //this.in = in; - this.publicId = publicId; - this.systemId = systemId; - this.resolver = resolver; - this.reporter = reporter; - this.validating = validating; - this.namespaceAware = namespaceAware; - this.coalescing = coalescing; - this.replacingEntityReferences = replacingEntityReferences; - this.externalEntities = externalEntities; - this.supportDTD = supportDTD; - namespaces = new NamespaceSupport(); - events = new LinkedList(); - - // Configure the SAX parser and perform the parse - try - { - SAXParserFactory f = SAXParserFactory.newInstance(); - f.setNamespaceAware(namespaceAware); - f.setValidating(validating); - SAXParser p = f.newSAXParser(); - XMLReader r = p.getXMLReader(); - CallbackHandler ch = this.new CallbackHandler(r); - r.setFeature("http://xml.org/sax/features/external-general-entities", - externalEntities); - r.setFeature("http://xml.org/sax/features/namespaces", - namespaceAware); - r.setContentHandler(ch); - r.setDTDHandler(ch); - r.setEntityResolver(ch); - r.setErrorHandler(ch); - r.setProperty("http://xml.org/sax/properties/lexical-handler", - ch); - InputSource source = new InputSource(in); - source.setSystemId(systemId); - r.parse(source); - } - catch (SAXException e) - { - events.add(e); - } - catch (IOException e) - { - events.add(e); - } - catch (ParserConfigurationException e) - { - XMLStreamException e2 = new XMLStreamException(e); - e2.initCause(e); - throw e2; - } - } - - protected XMLStreamReaderImpl(Reader reader, - String publicId, - String systemId, - XMLResolver resolver, - XMLReporter reporter, - boolean validating, - boolean namespaceAware, - boolean coalescing, - boolean replacingEntityReferences, - boolean externalEntities, - boolean supportDTD) - throws XMLStreamException - { - //this.reader = reader; - this.publicId = publicId; - this.systemId = systemId; - this.resolver = resolver; - this.reporter = reporter; - this.validating = validating; - this.namespaceAware = namespaceAware; - this.coalescing = coalescing; - this.replacingEntityReferences = replacingEntityReferences; - this.externalEntities = externalEntities; - this.supportDTD = supportDTD; - namespaces = new NamespaceSupport(); - events = new LinkedList(); - - // Configure the SAX parser and perform the parse - try - { - SAXParserFactory f = SAXParserFactory.newInstance(); - f.setNamespaceAware(namespaceAware); - f.setValidating(validating); - SAXParser p = f.newSAXParser(); - XMLReader r = p.getXMLReader(); - CallbackHandler ch = this.new CallbackHandler(r); - r.setFeature("http://xml.org/sax/features/external-general-entities", - externalEntities); - r.setFeature("http://xml.org/sax/features/namespaces", - namespaceAware); - r.setContentHandler(ch); - r.setDTDHandler(ch); - r.setEntityResolver(ch); - r.setErrorHandler(ch); - r.setProperty("http://xml.org/sax/properties/lexical-handler", - ch); - InputSource source = new InputSource(reader); - source.setSystemId(systemId); - r.parse(source); - } - catch (SAXException e) - { - events.add(e); - } - catch (IOException e) - { - events.add(e); - } - catch (ParserConfigurationException e) - { - XMLStreamException e2 = new XMLStreamException(e); - e2.initCause(e); - throw e2; - } - } - - public Object getProperty(String name) - throws IllegalArgumentException - { - throw new IllegalArgumentException(name); - } - - public int next() - throws XMLStreamException - { - if (events.isEmpty()) - throw new XMLStreamException("EOF"); - Object event = events.removeFirst(); - if (event instanceof Exception) - { - Exception e = (Exception) event; - XMLStreamException e2 = new XMLStreamException(e); - e2.initCause(e); - throw e2; - } - currentEvent = (XMLEvent) event; - eventType = currentEvent.getEventType(); - return eventType; - } - - public void require(int type, String namespaceURI, String localName) - throws XMLStreamException - { - // TODO - throw new UnsupportedOperationException(); - } - - public String getElementText() - throws XMLStreamException - { - // TODO - throw new UnsupportedOperationException(); - } - - public int nextTag() - throws XMLStreamException - { - int ret; - do - { - ret = next(); - } - while (ret != XMLStreamConstants.START_ELEMENT && - ret != XMLStreamConstants.END_ELEMENT); - return ret; - } - - public boolean hasNext() - throws XMLStreamException - { - return !events.isEmpty(); - } - - public void close() - throws XMLStreamException - { - } - - public String getNamespaceURI(String prefix) - { - return namespaces.getURI(prefix); - } - - public String getPrefix(String namespaceURI) - { - return namespaces.getPrefix(namespaceURI); - } - - public Iterator getPrefixes(String namespaceURI) - { - LinkedList acc = new LinkedList(); - for (Enumeration e = namespaces.getPrefixes(namespaceURI); - e.hasMoreElements(); ) - acc.add(e.nextElement()); - return acc.iterator(); - } - - public boolean isStartElement() - { - return eventType == START_ELEMENT; - } - - public boolean isEndElement() - { - return eventType == END_ELEMENT; - } - - public boolean isCharacters() - { - return eventType == CHARACTERS || eventType == CDATA; - } - - public boolean isWhiteSpace() - { - return eventType == SPACE; - } - - public String getAttributeValue(String namespaceURI, String localName) - { - StartElement se = (StartElement) currentEvent; - for (Iterator i = se.getAttributes(); i.hasNext(); ) - { - Attribute attr = (Attribute) i.next(); - QName name = attr.getName(); - if (namespaceURI != null && - !namespaceURI.equals(name.getNamespaceURI())) - continue; - if (!localName.equals(name.getLocalPart())) - continue; - return attr.getValue(); - } - return null; - } - - public int getAttributeCount() - { - StartElement se = (StartElement) currentEvent; - int count = 0; - for (Iterator i = se.getAttributes(); i.hasNext(); ) - { - i.next(); - count++; - } - return count; - } - - public QName getAttributeQName(int index) - { - StartElement se = (StartElement) currentEvent; - int count = 0; - for (Iterator i = se.getAttributes(); i.hasNext(); ) - { - Attribute attr = (Attribute) i.next(); - if (index == count) - return attr.getName(); - count++; - } - return null; - } - - public String getAttributeNamespace(int index) - { - QName name = getAttributeQName(index); - return (name == null) ? null : name.getNamespaceURI(); - } - - public String getAttributeName(int index) - { - QName name = getAttributeQName(index); - return (name == null) ? null : name.getLocalPart(); - } - - public String getAttributePrefix(int index) - { - QName name = getAttributeQName(index); - return (name == null) ? null : name.getPrefix(); - } - - public String getAttributeType(int index) - { - StartElement se = (StartElement) currentEvent; - int count = 0; - for (Iterator i = se.getAttributes(); i.hasNext(); ) - { - Attribute attr = (Attribute) i.next(); - if (index == count) - { - QName type = attr.getDTDType(); - return (type == null) ? "CDATA" : type.toString(); - } - count++; - } - return null; - } - - public String getAttributeValue(int index) - { - StartElement se = (StartElement) currentEvent; - int count = 0; - for (Iterator i = se.getAttributes(); i.hasNext(); ) - { - Attribute attr = (Attribute) i.next(); - if (index == count) - return attr.getValue(); - count++; - } - return null; - } - - public boolean isAttributeSpecified(int index) - { - StartElement se = (StartElement) currentEvent; - int count = 0; - for (Iterator i = se.getAttributes(); i.hasNext(); ) - { - Attribute attr = (Attribute) i.next(); - if (index == count) - return attr.isSpecified(); - count++; - } - return false; - } - - public int getNamespaceCount() - { - Iterator i = null; - switch (eventType) - { - case XMLStreamConstants.START_ELEMENT: - i = ((StartElement) currentEvent).getNamespaces(); - break; - case XMLStreamConstants.END_ELEMENT: - i = ((EndElement) currentEvent).getNamespaces(); - break; - default: - throw new IllegalStateException(); - } - int count = 0; - while (i.hasNext()) - { - i.next(); - count++; - } - return count; - } - - public String getNamespacePrefix(int index) - { - Iterator i = null; - switch (eventType) - { - case XMLStreamConstants.START_ELEMENT: - i = ((StartElement) currentEvent).getNamespaces(); - break; - case XMLStreamConstants.END_ELEMENT: - i = ((EndElement) currentEvent).getNamespaces(); - break; - default: - throw new IllegalStateException(); - } - int count = 0; - while (i.hasNext()) - { - Namespace ns = (Namespace) i.next(); - if (index == count) - return ns.getPrefix(); - count++; - } - return null; - } - - public String getNamespaceURI(int index) - { - Iterator i = null; - switch (eventType) - { - case XMLStreamConstants.START_ELEMENT: - i = ((StartElement) currentEvent).getNamespaces(); - break; - case XMLStreamConstants.END_ELEMENT: - i = ((EndElement) currentEvent).getNamespaces(); - break; - default: - throw new IllegalStateException(); - } - int count = 0; - while (i.hasNext()) - { - Namespace ns = (Namespace) i.next(); - if (index == count) - return ns.getNamespaceURI(); - count++; - } - return null; - } - - public NamespaceContext getNamespaceContext() - { - return this; - } - - public int getEventType() - { - return eventType; - } - - public String getText() - { - switch (eventType) - { - case XMLStreamConstants.CHARACTERS: - case XMLStreamConstants.CDATA: - case XMLStreamConstants.SPACE: - return ((Characters) currentEvent).getData(); - case XMLStreamConstants.COMMENT: - return ((Comment) currentEvent).getText(); - case XMLStreamConstants.ENTITY_REFERENCE: - return ((EntityReference) currentEvent).getReplacementText(); - case XMLStreamConstants.DTD: - return ((DTD) currentEvent).getDocumentTypeDeclaration(); - } - return null; - } - - public char[] getTextCharacters() - { - String text = getText(); - return (text == null) ? null : text.toCharArray(); - } - - public int getTextCharacters(int sourceStart, char[] target, - int targetStart, int length) - throws XMLStreamException - { - char[] source = getTextCharacters(); - int len = Math.min(source.length, length); - System.arraycopy(source, sourceStart, target, targetStart, len); - return len; - } - - public int getTextStart() - { - return 0; - } - - public int getTextLength() - { - String text = getText(); - return (text == null) ? 0 : text.length(); - } - - public String getEncoding() - { - // XXX SAX doesn't provide this - return null; - } - - public boolean hasText() - { - return eventType == CHARACTERS || eventType == DTD || - eventType == SPACE || eventType == ENTITY_REFERENCE || - eventType == COMMENT || eventType == DTD; - } - - public Location getLocation() - { - return currentEvent.getLocation(); - } - - public QName getName() - { - switch (eventType) - { - case XMLStreamConstants.START_ELEMENT: - return ((StartElement) currentEvent).getName(); - case XMLStreamConstants.END_ELEMENT: - return ((EndElement) currentEvent).getName(); - case XMLStreamConstants.ATTRIBUTE: - return ((Attribute) currentEvent).getName(); - } - return null; - } - - public String getLocalName() - { - QName name = getName(); - return (name == null) ? null : name.getLocalPart(); - } - - public boolean hasName() - { - return getName() != null; - } - - public String getNamespaceURI() - { - QName name = getName(); - return (name == null) ? null : name.getNamespaceURI(); - } - - public String getPrefix() - { - QName name = getName(); - return (name == null) ? null : name.getPrefix(); - } - - public String getVersion() - { - StartDocument sd = (StartDocument) currentEvent; - return sd.getVersion(); - } - - public boolean isStandalone() - { - StartDocument sd = (StartDocument) currentEvent; - return sd.isStandalone(); - } - - public boolean standaloneSet() - { - StartDocument sd = (StartDocument) currentEvent; - return sd.standaloneSet(); - } - - public String getCharacterEncodingScheme() - { - StartDocument sd = (StartDocument) currentEvent; - return sd.getCharacterEncodingScheme(); - } - - public String getPITarget() - { - ProcessingInstruction pi = (ProcessingInstruction) currentEvent; - return pi.getTarget(); - } - - public String getPIData() - { - ProcessingInstruction pi = (ProcessingInstruction) currentEvent; - return pi.getData(); - } - - /** - * This class is used to construct the event series from SAX callbacks. - */ - class CallbackHandler - implements ContentHandler, DTDHandler, LexicalHandler, - DeclHandler, EntityResolver, ErrorHandler - { - - XMLReader reader; - Locator locator; - Location location; - private boolean inCDATA; - private LinkedList namespaces = new LinkedList(); - private LinkedList notations; - private LinkedList entities; - - CallbackHandler(XMLReader reader) - { - this.reader = reader; - } - - public void setDocumentLocator(Locator locator) - { - this.locator = locator; - location = new LocationImpl(-1, - locator.getColumnNumber(), - locator.getLineNumber(), - locator.getSystemId()); - } - - public void startDocument() - throws SAXException - { - String version = (locator instanceof Locator2) ? - ((Locator2) locator).getXMLVersion() : null; - String encoding = (locator instanceof Locator2) ? - ((Locator2) locator).getEncoding() : null; - boolean standalone = - reader.getFeature("http://xml.org/sax/features/is-standalone"); - boolean standaloneDeclared = standalone; - boolean encodingDeclared = (encoding != null); - events.add(new StartDocumentImpl(location, - location.getLocationURI(), - encoding, - version, - standalone, - standaloneDeclared, - encodingDeclared)); - } - - public void endDocument() - throws SAXException - { - events.add(new EndDocumentImpl(location)); - } - - public void startPrefixMapping(String prefix, String uri) - throws SAXException - { - namespaces.add(new NamespaceImpl(location, prefix, uri)); - } - - public void endPrefixMapping(String prefix) - throws SAXException - { - } - - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) - throws SAXException - { - LinkedList ns = namespaces; - namespaces = new LinkedList(); - int ci = qName.indexOf(':'); - String prefix = null; - localName = qName; - if (ci != -1) - { - prefix = qName.substring(0, ci); - localName = qName.substring(ci + 1); - } - QName name = new QName(namespaceURI, localName, prefix); - LinkedList attrs = new LinkedList(); - StartElementImpl se = new StartElementImpl(location, name, - attrs, ns, null); - events.add(se); - // Add namespaces - //for (Iterator i = ns.iterator(); i.hasNext(); ) - // events.add(i.next()); - // Add attributes - int len = atts.getLength(); - for (int i = 0; i < len; i++) - { - String attURI = atts.getURI(i); - String attQName = atts.getQName(i); - String value = atts.getValue(i); - QName type = QName.valueOf(atts.getType(i)); - boolean specified = (atts instanceof Attributes2) && - ((Attributes2) atts).isSpecified(i); - ci = attQName.indexOf(':'); - String attPrefix = null; - String attLocalName = attQName; - if (ci != -1) - { - attPrefix = attQName.substring(0, ci); - attLocalName = attQName.substring(ci + 1); - } - if ("xmlns".equals(attPrefix) || "xmlns".equals(attQName)) - continue; - QName attrName = new QName(attURI, attLocalName, attPrefix); - AttributeImpl attr = new AttributeImpl(location, attrName, - value, type, specified); - attrs.add(attr); - //events.add(attr); - } - } - - public void endElement(String namespaceURI, String localName, - String qName) - throws SAXException - { - int ci = qName.indexOf(':'); - String prefix = null; - localName = qName; - if (ci != -1) - { - prefix = qName.substring(0, ci); - localName = qName.substring(ci + 1); - } - QName name = new QName(namespaceURI, localName, prefix); - events.add(new EndElementImpl(location, name, new LinkedList())); - // TODO namespaces out of scope - } - - public void characters(char[] ch, int start, int length) - throws SAXException - { - boolean whitespace = isWhitespace(ch, start, length); - events.add(new CharactersImpl(location, new String(ch, start, length), - whitespace, inCDATA, false)); - } - - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException - { - boolean whitespace = isWhitespace(ch, start, length); - events.add(new CharactersImpl(location, new String(ch, start, length), - whitespace, inCDATA, true)); - } - - boolean isWhitespace(char[] ch, int start, int len) - { - int end = start + len; - for (int i = start; i < end; i++) - { - char c = ch[i]; - if (c != ' ' && c != '\t' && c != '\n' && c != '\r') - return false; - } - return true; - } - - public void processingInstruction(String target, String data) - throws SAXException - { - events.add(new ProcessingInstructionImpl(location, target, data)); - } - - public void skippedEntity(String name) - throws SAXException - { - } - - public void startDTD(String name, String publicId, String systemId) - throws SAXException - { - notations = new LinkedList(); - entities = new LinkedList(); - events.add(new DTDImpl(location, null, null, notations, entities)); - } - - public void endDTD() - throws SAXException - { - } - - public void startEntity(String name) - throws SAXException - { - events.add(new StartEntityImpl(location, name)); - } - - public void endEntity(String name) - throws SAXException - { - events.add(new EndEntityImpl(location, name)); - } - - public void startCDATA() - throws SAXException - { - inCDATA = true; - } - - public void endCDATA() - throws SAXException - { - inCDATA = false; - } - - public void comment(char[] ch, int start, int length) - throws SAXException - { - events.add(new CommentImpl(location, new String(ch, start, length))); - } - - public void notationDecl(String name, String publicId, String systemId) - throws SAXException - { - Object n = new NotationDeclarationImpl(location, name, publicId, - systemId); - notations.add(n); - //events.add(n); - } - - public void unparsedEntityDecl(String name, String publicId, - String systemId, String notationName) - throws SAXException - { - Object e = new EntityDeclarationImpl(location, publicId, systemId, - name, notationName, - null, null); - entities.add(e); - //events.add(e); - } - - public void elementDecl(String name, String model) - throws SAXException - { - } - - public void attributeDecl(String eName, String aName, String type, - String valueDefault, String value) - throws SAXException - { - } - - public void internalEntityDecl(String name, String value) - throws SAXException - { - Object e = new EntityDeclarationImpl(location, null, null, - name, null, value, null); - entities.add(e); - //events.add(e); - } - - public void externalEntityDecl(String name, String publicId, - String systemId) - throws SAXException - { - Object e = new EntityDeclarationImpl(location, publicId, systemId, - name, null, null, null); - entities.add(e); - //events.add(e); - } - - public void warning(SAXParseException e) - throws SAXException - { - if (reporter != null) - { - try - { - reporter.report(e.getMessage(), "warning", e, location); - } - catch (XMLStreamException e2) - { - SAXException e3 = new SAXException(e2.getMessage()); - e3.initCause(e2); - throw e3; - } - } - } - - public void error(SAXParseException e) - throws SAXException - { - if (reporter != null) - { - try - { - reporter.report(e.getMessage(), "error", e, location); - } - catch (XMLStreamException e2) - { - SAXException e3 = new SAXException(e2.getMessage()); - e3.initCause(e2); - throw e3; - } - } - } - - public void fatalError(SAXParseException e) - throws SAXException - { - if (reporter != null) - { - try - { - reporter.report(e.getMessage(), "fatal-error", e, location); - } - catch (XMLStreamException e2) - { - SAXException e3 = new SAXException(e2.getMessage()); - e3.initCause(e2); - throw e3; - } - } - } - - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException - { - if (resolver != null) - { - try - { - InputStream in = resolver.resolve(systemId); - if (in != null) - { - InputSource ret = new InputSource(in); - ret.setPublicId(publicId); - ret.setSystemId(systemId); - return ret; - } - } - catch (XMLStreamException e) - { - SAXException e2 = new SAXException(e.getMessage()); - e2.initCause(e); - throw e2; - } - } - return null; - } - - } - -} - diff --git a/javax/xml/stream/EventFilter.java b/javax/xml/stream/EventFilter.java index 288c7411d..6d0cb6552 100644 --- a/javax/xml/stream/EventFilter.java +++ b/javax/xml/stream/EventFilter.java @@ -1,5 +1,5 @@ /* EventFilter.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,7 +43,6 @@ import javax.xml.stream.events.XMLEvent; * Simple filter interface for XML events. */ public interface EventFilter - extends XMLFilter { /** diff --git a/javax/xml/stream/Location.java b/javax/xml/stream/Location.java index d043ba254..8f9f807e0 100644 --- a/javax/xml/stream/Location.java +++ b/javax/xml/stream/Location.java @@ -63,9 +63,14 @@ public interface Location int getCharacterOffset(); /** + * Returns the public identifier for this location, if any. + */ + String getPublicId(); + + /** * Returns the system identifier for the underlying source. */ - String getLocationURI(); + String getSystemId(); } diff --git a/javax/xml/stream/StreamFilter.java b/javax/xml/stream/StreamFilter.java index 77fbfc7f5..376bd940a 100644 --- a/javax/xml/stream/StreamFilter.java +++ b/javax/xml/stream/StreamFilter.java @@ -1,5 +1,5 @@ /* StreamFilter.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,7 +41,6 @@ package javax.xml.stream; * Simple filter interface for XMLStreamReaders. */ public interface StreamFilter - extends XMLFilter { /** diff --git a/javax/xml/stream/XMLEventFactory.java b/javax/xml/stream/XMLEventFactory.java index 456414d61..ee47af2a9 100644 --- a/javax/xml/stream/XMLEventFactory.java +++ b/javax/xml/stream/XMLEventFactory.java @@ -1,5 +1,5 @@ /* XMLEventFactory.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -320,10 +320,8 @@ public abstract class XMLEventFactory /** * Create an entity reference event. */ - //public abstract EntityReference createEntityReference(String name, - // EntityDeclaration declaration); public abstract EntityReference createEntityReference(String name, - String replacementText); + EntityDeclaration declaration); /** * Create a comment event. diff --git a/javax/xml/stream/XMLEventReader.java b/javax/xml/stream/XMLEventReader.java index 5d4c17000..35ad5696e 100644 --- a/javax/xml/stream/XMLEventReader.java +++ b/javax/xml/stream/XMLEventReader.java @@ -1,5 +1,5 @@ /* XMLEventReader.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,10 +44,21 @@ import javax.xml.stream.events.XMLEvent; * An XML parser. */ public interface XMLEventReader - extends XMLIterator + extends Iterator { /** + * Returns the next XML event. + */ + XMLEvent nextEvent() + throws XMLStreamException; + + /** + * Indicates whether there are more XML events to be read. + */ + boolean hasNext(); + + /** * Looks at the next XML event without advancing the cursor in the stream. * Returns <code>null</code> if there are no more events to read. */ @@ -80,5 +91,12 @@ public interface XMLEventReader Object getProperty(String name) throws IllegalArgumentException; + /** + * Free any resources associated with this parser. + * This method will not close the underlying input source. + */ + void close() + throws XMLStreamException; + } diff --git a/javax/xml/stream/XMLEventWriter.java b/javax/xml/stream/XMLEventWriter.java index 60b18f977..fe85f236e 100644 --- a/javax/xml/stream/XMLEventWriter.java +++ b/javax/xml/stream/XMLEventWriter.java @@ -1,5 +1,5 @@ /* XMLEventWriter.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/javax/xml/stream/XMLFilter.java b/javax/xml/stream/XMLFilter.java deleted file mode 100644 index 7e7698df1..000000000 --- a/javax/xml/stream/XMLFilter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* XMLFilter.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package javax.xml.stream; - -/** - * Marker interface for stream and event filters. - */ -public interface XMLFilter -{ -} - diff --git a/javax/xml/stream/XMLInputFactory.java b/javax/xml/stream/XMLInputFactory.java index 4c904a62f..4dfd1203a 100644 --- a/javax/xml/stream/XMLInputFactory.java +++ b/javax/xml/stream/XMLInputFactory.java @@ -1,5 +1,5 @@ /* XMLInputFactory.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -324,17 +324,17 @@ public abstract class XMLInputFactory /** * Creates a new stream reader. - * + */ public abstract XMLStreamReader createXMLStreamReader(String systemId, InputStream stream) - throws XMLStreamException;*/ + throws XMLStreamException; /** * Creates a new stream reader. - * + */ public abstract XMLStreamReader createXMLStreamReader(String systemId, Reader reader) - throws XMLStreamException;*/ + throws XMLStreamException; /** * Creates a new event reader. @@ -344,10 +344,10 @@ public abstract class XMLInputFactory /** * Creates a new event reader. - * + */ public abstract XMLEventReader createXMLEventReader(String systemId, Reader reader) - throws XMLStreamException;*/ + throws XMLStreamException; /** * Creates a new event reader. @@ -376,10 +376,10 @@ public abstract class XMLInputFactory /** * Creates a new event reader. - * + */ public abstract XMLEventReader createXMLEventReader(String systemId, InputStream stream) - throws XMLStreamException;*/ + throws XMLStreamException; /** * Create a new filtered reader. @@ -444,15 +444,5 @@ public abstract class XMLInputFactory */ public abstract XMLEventAllocator getEventAllocator(); - /** - * Sets whether text will be coalesced. - */ - public abstract void setCoalescing(boolean coalescing); - - /** - * Indicates whether text will be coalesced. - */ - public abstract boolean isCoalescing(); - } diff --git a/javax/xml/stream/XMLIterator.java b/javax/xml/stream/XMLIterator.java deleted file mode 100644 index e12bffafd..000000000 --- a/javax/xml/stream/XMLIterator.java +++ /dev/null @@ -1,61 +0,0 @@ -/* XMLIterator.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package javax.xml.stream; - -import javax.xml.stream.events.XMLEvent; - -/** - * Simple iterator for XML events. - */ -public interface XMLIterator -{ - - /** - * Returns the next XML event. - */ - XMLEvent next() - throws XMLStreamException; - - /** - * Indicates whether there are more XML events to be read. - */ - boolean hasNext() - throws XMLStreamException; - -} - diff --git a/javax/xml/stream/XMLOutputFactory.java b/javax/xml/stream/XMLOutputFactory.java index cf31f02a5..e4c9dd40d 100644 --- a/javax/xml/stream/XMLOutputFactory.java +++ b/javax/xml/stream/XMLOutputFactory.java @@ -1,5 +1,5 @@ /* XMLOutputFactory.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,7 +46,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import java.util.Properties; -//import javax.xml.transform.Result; +import javax.xml.transform.Result; /** * Factory for obtaining XML stream and event writers for various kinds of @@ -77,8 +77,8 @@ public abstract class XMLOutputFactory * If true, the writer will create a namespace declaration for any * attribute that doesn't have a namespace declaration in scope. */ - public static final java.lang.String IS_PREFIX_DEFAULTING = - "javax.xml.stream.isPrefixDefaulting"; + public static final java.lang.String IS_REPAIRING_NAMESPACES = + "javax.xml.stream.isRepairingNamespaces"; protected XMLOutputFactory() { @@ -219,16 +219,16 @@ public abstract class XMLOutputFactory * @exception UnsupportedOperationException if this method is not * supported */ - //public abstract XMLStreamWriter createXMLStreamWriter(Result result) - // throws XMLStreamException; + public abstract XMLStreamWriter createXMLStreamWriter(Result result) + throws XMLStreamException; /** * Creates a new event writer. * @exception UnsupportedOperationException if this method is not * supported */ - //public abstract XMLEventWriter createXMLEventWriter(Result result) - // throws XMLStreamException; + public abstract XMLEventWriter createXMLEventWriter(Result result) + throws XMLStreamException; /** * Creates a new event writer. @@ -264,23 +264,9 @@ public abstract class XMLOutputFactory throws IllegalArgumentException; /** - * Indicates whether writers created by this factory will perform prefix - * defaulting. - * @see #IS_PREFIX_DEFAULTING - */ - public abstract boolean isPrefixDefaulting(); - - /** * Indicates whether the specified property is supported. */ public abstract boolean isPropertySupported(String name); - /** - * Sets whether writers created by this factory will perform prefix - * defaulting. - * @see #IS_PREFIX_DEFAULTING - */ - public abstract void setPrefixDefaulting(boolean value); - } diff --git a/javax/xml/stream/XMLReporter.java b/javax/xml/stream/XMLReporter.java index bdf0b8acc..d54565681 100644 --- a/javax/xml/stream/XMLReporter.java +++ b/javax/xml/stream/XMLReporter.java @@ -1,5 +1,5 @@ /* XMLReporter.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. diff --git a/javax/xml/stream/XMLResolver.java b/javax/xml/stream/XMLResolver.java index 148afc6f1..2dabaeea4 100644 --- a/javax/xml/stream/XMLResolver.java +++ b/javax/xml/stream/XMLResolver.java @@ -1,5 +1,5 @@ /* XMLResolver.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,8 +37,6 @@ exception statement from your version. */ package javax.xml.stream; -import java.io.InputStream; - /** * Interface used to resolve XML external entities during parsing. */ @@ -59,28 +57,10 @@ public interface XMLResolver * @param systemID the system ID of the external entity * @param baseURI the absolute base URI of the referring entity * @param namespace the namespace of the external entity - * + */ Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) - throws XMLStreamException;*/ - - /** - * Retrieves a resource from the specified URI. - */ - XMLEventReader resolveAsXMLEventReader(String uri) throws XMLStreamException; - /** - * Retrieves a resource from the specified URI. - */ - XMLStreamReader resolveAsXMLStreamReader(String uri) - throws XMLStreamException; - - /** - * Retrieves a resource from the specified URI. - */ - InputStream resolve(String uri) - throws XMLStreamException; - } diff --git a/javax/xml/stream/XMLStreamConstants.java b/javax/xml/stream/XMLStreamConstants.java index 1f0d2ef33..e41627dd6 100644 --- a/javax/xml/stream/XMLStreamConstants.java +++ b/javax/xml/stream/XMLStreamConstants.java @@ -1,5 +1,5 @@ /* XMLStreamConstants.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -109,24 +109,14 @@ public interface XMLStreamConstants static final int NAMESPACE = 13; /** - * A start-entity event. - */ - static final int START_ENTITY = 14; - - /** - * An end-entity event. - */ - static final int END_ENTITY = 15; - - /** * A notation declaration event. */ - static final int NOTATION_DECLARATION = 16; + static final int NOTATION_DECLARATION = 14; /** * An entity declaration event. */ - static final int ENTITY_DECLARATION = 17; + static final int ENTITY_DECLARATION = 15; } diff --git a/javax/xml/stream/XMLStreamReader.java b/javax/xml/stream/XMLStreamReader.java index e598fabb6..f8648b1ad 100644 --- a/javax/xml/stream/XMLStreamReader.java +++ b/javax/xml/stream/XMLStreamReader.java @@ -1,5 +1,5 @@ /* XMLStreamReader.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -136,7 +136,7 @@ public interface XMLStreamReader /** * Returns the QName of the attribute at the given index. */ - QName getAttributeQName(int index); + QName getAttributeName(int index); /** * Returns the namespace URI of the attribute at the given index. @@ -146,7 +146,7 @@ public interface XMLStreamReader /** * Returns the local-name of the attribute at the given index. */ - String getAttributeName(int index); + String getAttributeLocalName(int index); /** * Returns the namespace prefix of the attribute at the given index. diff --git a/javax/xml/stream/events/EndEntity.java b/javax/xml/stream/events/EndEntity.java deleted file mode 100644 index b5c32d716..000000000 --- a/javax/xml/stream/events/EndEntity.java +++ /dev/null @@ -1,53 +0,0 @@ -/* EndEntity.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package javax.xml.stream.events; - -/** - * An end-entity event. - */ -public interface EndEntity - extends XMLEvent -{ - - /** - * Returns the entity name. - */ - String getName(); - -} - diff --git a/javax/xml/stream/events/EntityDeclaration.java b/javax/xml/stream/events/EntityDeclaration.java index a319f098c..a0120ddb0 100644 --- a/javax/xml/stream/events/EntityDeclaration.java +++ b/javax/xml/stream/events/EntityDeclaration.java @@ -1,5 +1,5 @@ /* EntityDeclaration.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -67,12 +67,12 @@ public interface EntityDeclaration /** * Returns the replacement text for the entity. */ - //String getReplacementText(); + String getReplacementText(); /** * Returns the base URI for the entity. */ - //String getBaseURI(); + String getBaseURI(); } diff --git a/javax/xml/stream/events/EntityReference.java b/javax/xml/stream/events/EntityReference.java index 72447096b..460433c16 100644 --- a/javax/xml/stream/events/EntityReference.java +++ b/javax/xml/stream/events/EntityReference.java @@ -1,5 +1,5 @@ /* EntityReference.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,34 +45,14 @@ public interface EntityReference { /** - * Returns the base URI for the entity. - */ - String getBaseUri(); - - /** - * Returns the public identifier for the entity. - */ - String getPublicId(); - - /** - * Returns the system identifierfor the entity. - */ - String getSystemId(); - - /** * Returns the declaration of this reference. */ - //EntityDeclaration getDeclaration(); + EntityDeclaration getDeclaration(); /** * Returns the entity name. */ String getName(); - /** - * Returns the replacement text for the entity. - */ - String getReplacementText(); - } diff --git a/javax/xml/stream/events/StartEntity.java b/javax/xml/stream/events/StartEntity.java deleted file mode 100644 index d41e0db7a..000000000 --- a/javax/xml/stream/events/StartEntity.java +++ /dev/null @@ -1,53 +0,0 @@ -/* StartEntity.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package javax.xml.stream.events; - -/** - * An start-entity event. - */ -public interface StartEntity - extends XMLEvent -{ - - /** - * Returns the entity name. - */ - String getName(); - -} - diff --git a/javax/xml/stream/events/XMLEvent.java b/javax/xml/stream/events/XMLEvent.java index 54e9516f6..7c427da87 100644 --- a/javax/xml/stream/events/XMLEvent.java +++ b/javax/xml/stream/events/XMLEvent.java @@ -1,5 +1,5 @@ /* XMLEvent.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -106,16 +106,6 @@ public interface XMLEvent boolean isEndDocument(); /** - * Indicates whether this event is a start-entity event. - */ - boolean isStartEntity(); - - /** - * Indicates whether this event is an end-entity event. - */ - boolean isEndEntity(); - - /** * Returns this event as a start-element event. */ StartElement asStartElement(); diff --git a/javax/xml/stream/util/EventReaderDelegate.java b/javax/xml/stream/util/EventReaderDelegate.java index f6d1585b7..be943e465 100644 --- a/javax/xml/stream/util/EventReaderDelegate.java +++ b/javax/xml/stream/util/EventReaderDelegate.java @@ -1,5 +1,5 @@ /* EventReaderDelegate.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -82,16 +82,22 @@ public class EventReaderDelegate return parent; } - public XMLEvent next() + public XMLEvent nextEvent() throws XMLStreamException { if (parent != null) + return parent.nextEvent(); + throw new NoSuchElementException(); + } + + public Object next() + { + if (parent != null) return parent.next(); throw new NoSuchElementException(); } public boolean hasNext() - throws XMLStreamException { if (parent != null) return parent.hasNext(); @@ -130,5 +136,17 @@ public class EventReaderDelegate throw new IllegalArgumentException(name); } + public void close() + throws XMLStreamException + { + if (parent != null) + parent.close(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + } diff --git a/javax/xml/stream/util/ReaderDelegate.java b/javax/xml/stream/util/ReaderDelegate.java index ef7017563..d502866fb 100644 --- a/javax/xml/stream/util/ReaderDelegate.java +++ b/javax/xml/stream/util/ReaderDelegate.java @@ -1,5 +1,5 @@ /* ReaderDelegate.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -186,10 +186,10 @@ public class ReaderDelegate return 0; } - public QName getAttributeQName(int index) + public QName getAttributeName(int index) { if (parent != null) - return parent.getAttributeQName(index); + return parent.getAttributeName(index); return null; } @@ -207,10 +207,10 @@ public class ReaderDelegate return null; } - public String getAttributeName(int index) + public String getAttributeLocalName(int index) { if (parent != null) - return parent.getAttributeName(index); + return parent.getAttributeLocalName(index); return null; } |