diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/javax/xml/stream | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libjava/classpath/javax/xml/stream')
33 files changed, 4103 insertions, 0 deletions
diff --git a/libjava/classpath/javax/xml/stream/EventFilter.java b/libjava/classpath/javax/xml/stream/EventFilter.java new file mode 100644 index 000000000..eed54f8a9 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/EventFilter.java @@ -0,0 +1,53 @@ +/* EventFilter.java -- + Copyright (C) 2005,2006 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 filter interface for XML events. + */ +public interface EventFilter +{ + + /** + * Indicates whether this filter can accept the specified event. + */ + boolean accept(XMLEvent event); + +} diff --git a/libjava/classpath/javax/xml/stream/FactoryConfigurationError.java b/libjava/classpath/javax/xml/stream/FactoryConfigurationError.java new file mode 100644 index 000000000..104b160cd --- /dev/null +++ b/libjava/classpath/javax/xml/stream/FactoryConfigurationError.java @@ -0,0 +1,85 @@ +/* FactoryConfigurationError.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; + +/** + * Error indicating that a factory could not be configured. + */ +public class FactoryConfigurationError + extends Error +{ + + private final Exception exception; + + public FactoryConfigurationError() + { + this((String) null, (Exception) null); + } + + public FactoryConfigurationError(Exception e) + { + this(e, null); + } + + public FactoryConfigurationError(Exception e, String msg) + { + super(msg); + exception = e; + } + + public FactoryConfigurationError(String msg, Exception e) + { + this(e, msg); + } + + public FactoryConfigurationError(String msg) + { + this(null, msg); + } + + public Exception getException() + { + return exception; + } + + public String getMessage() + { + return super.getMessage(); + } + +} diff --git a/libjava/classpath/javax/xml/stream/Location.java b/libjava/classpath/javax/xml/stream/Location.java new file mode 100644 index 000000000..6e3483a5c --- /dev/null +++ b/libjava/classpath/javax/xml/stream/Location.java @@ -0,0 +1,75 @@ +/* Location.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; + +/** + * Information about the location of an XML event within the underlying + * stream. + */ +public interface Location +{ + + /** + * Returns the line number at which the current event ends, + * or -1 if this is not available. + */ + int getLineNumber(); + + /** + * Returns the column number at which the current event ends, + * or -1 if this is not available. + */ + int getColumnNumber(); + + /** + * Returns the offset from the start of the source, in bytes or characters + * depending on the nature of the source, or -1 if this is not available. + */ + int getCharacterOffset(); + + /** + * Returns the public identifier for this location, if any. + */ + String getPublicId(); + + /** + * Returns the system identifier for the underlying source. + */ + String getSystemId(); + +} diff --git a/libjava/classpath/javax/xml/stream/StreamFilter.java b/libjava/classpath/javax/xml/stream/StreamFilter.java new file mode 100644 index 000000000..a0ff2c8f3 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/StreamFilter.java @@ -0,0 +1,52 @@ +/* StreamFilter.java -- + Copyright (C) 2005,2006 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; + +/** + * Simple filter interface for XMLStreamReaders. + */ +public interface StreamFilter +{ + + /** + * Indicates whether the current state of the specified reader in part of + * this stream. + */ + boolean accept(XMLStreamReader reader); + +} diff --git a/libjava/classpath/javax/xml/stream/XMLEventFactory.java b/libjava/classpath/javax/xml/stream/XMLEventFactory.java new file mode 100644 index 000000000..fc2d493d5 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLEventFactory.java @@ -0,0 +1,352 @@ +/* XMLEventFactory.java -- + Copyright (C) 2005,2006,2009 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 java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.IOException; +import java.util.Iterator; +import java.util.Properties; +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +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.EntityDeclaration; +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; + +/** + * Factory for XML events. + */ +public abstract class XMLEventFactory +{ + + protected XMLEventFactory() + { + } + + /** + * Create a new factory instance. + * @see #newInstance(String,ClassLoader) + */ + public static XMLEventFactory newInstance() + throws FactoryConfigurationError + { + return newInstance(null, null); + } + + /** + * Create a new factory instance. + * The implementation class to load is the first found in the following + * locations: + * <ol> + * <li>the <code>javax.xml.stream.XMLEventFactory</code> system + * property</li> + * <li>the above named property value in the + * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li> + * <li>the class name specified in the + * <code>META-INF/services/javax.xml.stream.XMLEventFactory</code> + * system resource</li> + * <li>the default factory class</li> + * </ol> + * @param factoryId name of the factory to find, same as a property name + * @param classLoader the class loader to use + * @return the factory implementation + * @exception FactoryConfigurationError if an instance of this factory + * cannot be loaded + */ + public static XMLEventFactory newInstance(String factoryId, + ClassLoader classLoader) + throws FactoryConfigurationError + { + ClassLoader loader = classLoader; + if (loader == null) + { + loader = Thread.currentThread().getContextClassLoader(); + } + if (loader == null) + { + loader = XMLEventFactory.class.getClassLoader(); + } + String className = null; + int count = 0; + do + { + className = getFactoryClassName(loader, count++); + if (className != null) + { + try + { + Class<?> t = (loader != null) ? loader.loadClass(className) : + Class.forName(className); + return (XMLEventFactory) t.newInstance(); + } + catch (ClassNotFoundException e) + { + className = null; + } + catch (Exception e) + { + throw new FactoryConfigurationError(e, + "error instantiating class " + className); + } + } + } + while (className == null && count < 3); + return new gnu.xml.stream.XMLEventFactoryImpl(); + } + + private static String getFactoryClassName(ClassLoader loader, int attempt) + { + final String propertyName = "javax.xml.stream.XMLEventFactory"; + switch (attempt) + { + case 0: + return System.getProperty(propertyName); + case 1: + try + { + File file = new File(System.getProperty("java.home")); + file = new File(file, "lib"); + file = new File(file, "stax.properties"); + InputStream in = new FileInputStream(file); + Properties props = new Properties(); + props.load(in); + in.close(); + return props.getProperty(propertyName); + } + catch (IOException e) + { + return null; + } + case 2: + try + { + String serviceKey = "/META-INF/services/" + propertyName; + InputStream in = (loader != null) ? + loader.getResourceAsStream(serviceKey) : + XMLEventFactory.class.getResourceAsStream(serviceKey); + if (in != null) + { + BufferedReader r = + new BufferedReader(new InputStreamReader(in)); + String ret = r.readLine(); + r.close(); + return ret; + } + } + catch (IOException e) + { + } + return null; + default: + return null; + } + } + + /** + * Sets the location for each event created by this factory. + */ + public abstract void setLocation(Location location); + + /** + * Create an attribute event. + */ + public abstract Attribute createAttribute(String prefix, String namespaceURI, + String localName, String value); + + /** + * Create an attribute event. + */ + public abstract Attribute createAttribute(String localName, String value); + + /** + * Create an attribute event. + */ + public abstract Attribute createAttribute(QName name, String value); + + /** + * Create a namespace declaration event. + */ + public abstract Namespace createNamespace(String namespaceURI); + + /** + * Create a namespace declaration event. + */ + public abstract Namespace createNamespace(String prefix, String namespaceUri); + + /** + * Create a start-element event. + */ + @SuppressWarnings("unchecked") + public abstract StartElement createStartElement(QName name, + Iterator attributes, + Iterator namespaces); + + /** + * Create a start-element event. + */ + public abstract StartElement createStartElement(String prefix, + String namespaceUri, + String localName); + + /** + * Create a start-element event. + */ + @SuppressWarnings("unchecked") + public abstract StartElement createStartElement(String prefix, + String namespaceUri, + String localName, + Iterator attributes, + Iterator namespaces); + + /** + * Create a start-element event. + */ + @SuppressWarnings("unchecked") + public abstract StartElement createStartElement(String prefix, + String namespaceUri, + String localName, + Iterator attributes, + Iterator namespaces, + NamespaceContext context); + + /** + * Create an end-element event. + */ + @SuppressWarnings("unchecked") + public abstract EndElement createEndElement(QName name, + Iterator namespaces); + + /** + * Create an end-element event. + */ + public abstract EndElement createEndElement(String prefix, + String namespaceUri, + String localName); + + /** + * Create an end-element event. + */ + @SuppressWarnings("unchecked") + public abstract EndElement createEndElement(String prefix, + String namespaceUri, + String localName, + Iterator namespaces); + + /** + * Create a text event. + */ + public abstract Characters createCharacters(String content); + + /** + * Create a text event of type CDATA section. + */ + public abstract Characters createCData(String content); + + /** + * Create a text event of type whitespace. + */ + public abstract Characters createSpace(String content); + + /** + * Create a text event of type ignorable whitespace. + */ + public abstract Characters createIgnorableSpace(String content); + + /** + * Create a start-document event. + */ + public abstract StartDocument createStartDocument(); + + /** + * Create a start-document event. + */ + public abstract StartDocument createStartDocument(String encoding, + String version, + boolean standalone); + + /** + * Create a start-document event. + */ + public abstract StartDocument createStartDocument(String encoding, + String version); + + /** + * Create a start-document event. + */ + public abstract StartDocument createStartDocument(String encoding); + + /** + * Create an end-document event. + */ + public abstract EndDocument createEndDocument(); + + /** + * Create an entity reference event. + */ + public abstract EntityReference createEntityReference(String name, + EntityDeclaration declaration); + + /** + * Create a comment event. + */ + public abstract Comment createComment(String text); + + /** + * Create a processing instruction event. + */ + public abstract ProcessingInstruction createProcessingInstruction(String target, + String data); + + /** + * Create a DOCTYPE declaration event. + */ + public abstract DTD createDTD(String dtd); + +} diff --git a/libjava/classpath/javax/xml/stream/XMLEventReader.java b/libjava/classpath/javax/xml/stream/XMLEventReader.java new file mode 100644 index 000000000..d5c76b6b1 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLEventReader.java @@ -0,0 +1,102 @@ +/* XMLEventReader.java -- + Copyright (C) 2005,2006 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 java.util.Iterator; +import javax.xml.stream.events.XMLEvent; + +/** + * An XML parser. + */ +@SuppressWarnings("unchecked") +public interface XMLEventReader + 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. + */ + XMLEvent peek() + throws XMLStreamException; + + /** + * Reads the text context of an element. + * When invoked, the current event must be START_ELEMENT. + * On completion, the current event will be END_ELEMENT. + */ + String getElementText() + throws XMLStreamException; + + /** + * Returns the next element event. + * This method skips insignificant space until a START_ELEMENT or + * END_ELEMENT event is found. + * @exception XMLStreamException if an event that was not an insignificant + * space event was encountered + */ + XMLEvent nextTag() + throws XMLStreamException; + + /** + * Returns the implementation-specific feature or property of the given + * name. + * @exception IllegalArgumentException if the property is not supported + */ + 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/libjava/classpath/javax/xml/stream/XMLEventWriter.java b/libjava/classpath/javax/xml/stream/XMLEventWriter.java new file mode 100644 index 000000000..5eb18760a --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLEventWriter.java @@ -0,0 +1,108 @@ +/* XMLEventWriter.java -- + Copyright (C) 2005,2006 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.namespace.NamespaceContext; +import javax.xml.stream.events.XMLEvent; +import javax.xml.stream.util.XMLEventConsumer; + +/** + * Interface for writing XML documents from a series of events. + */ +public interface XMLEventWriter + extends XMLEventConsumer +{ + + /** + * Ensures that any cached events are written to the underlying output + * sink. + */ + void flush() + throws XMLStreamException; + + /** + * Frees any resources used by this writer. + */ + void close() + throws XMLStreamException; + + /** + * Adds the specified event to this writer. + */ + void add(XMLEvent event) + throws XMLStreamException; + + /** + * Adds the specified XML stream to this writer. + * The implementation will call <code>next</code> on the given argument + * while <code>hasNext</code> returns true. + */ + void add(XMLEventReader reader) + throws XMLStreamException; + + /** + * Returns the namespace prefix the specified URI is currently associated + * with. + */ + String getPrefix(String uri) + throws XMLStreamException; + + /** + * Associates the given namespace prefix and URI. + */ + void setPrefix(String prefix, String uri) + throws XMLStreamException; + + /** + * Sets the current default namespace URI. + */ + void setDefaultNamespace(String uri) + throws XMLStreamException; + + /** + * Sets the namespace context for managing namespace prefixes and URIs. + */ + void setNamespaceContext(NamespaceContext context) + throws XMLStreamException; + + /** + * Returns the namespace context. + */ + NamespaceContext getNamespaceContext(); + +} diff --git a/libjava/classpath/javax/xml/stream/XMLInputFactory.java b/libjava/classpath/javax/xml/stream/XMLInputFactory.java new file mode 100644 index 000000000..39ba8e3b4 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLInputFactory.java @@ -0,0 +1,451 @@ +/* XMLInputFactory.java -- + Copyright (C) 2005,2006,2009 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 java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.Reader; +import java.util.Properties; +import javax.xml.stream.util.XMLEventAllocator; +import javax.xml.transform.Source; + +/** + * Factory for creating stream and event readers from various kinds of input + * source. + * <h3>Parameters</h3> + * <table> + * <tr> + * <th>Name</th> + * <th>Description</th> + * <th>Type</th> + * <th>Default</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>javax.xml.stream.isValidating</td> + * <td>Controls DTD validation</td> + * <td>Boolean</td> + * <td>Boolean.FALSE</td> + * <td>no</td> + * </tr> + * <tr> + * <td>javax.xml.stream.isNamespaceAware</td> + * <td>Controls namespace processing for XML 1.0</td> + * <td>Boolean</td> + * <td>Boolean.TRUE</td> + * <td>true is required, false is optional</td> + * </tr> + * <tr> + * <td>javax.xml.stream.isCoalescing</td> + * <td>Controls coalescing (normalization of adjacent character data)</td> + * <td>Boolean</td> + * <td>Boolean.FALSE</td> + * <td>yes</td> + * </tr> + * <tr> + * <td>javax.xml.stream.isReplacingEntityReferences</td> + * <td>Controls replacement of entity references with their replacement + * text</td> + * <td>Boolean</td> + * <td>Boolean.TRUE</td> + * <td>yes</td> + * </tr> + * <tr> + * <td>javax.xml.stream.isSupportingExternalEntities</td> + * <td>Controls whether to resolve external entities</td> + * <td>Boolean</td> + * <td>not specified</td> + * <td>yes</td> + * </tr> + * <tr> + * <td>javax.xml.stream.supportDTD</td> + * <td>Controls whether to support DTDs</td> + * <td>Boolean</td> + * <td>Boolean.TRUE</td> + * <td>yes</td> + * </tr> + * <tr> + * <td>javax.xml.stream.reporter</td> + * <td></td> + * <td>javax.xml.stream.XMLReporter</td> + * <td></td> + * <td>yes</td> + * </tr> + * <tr> + * <td>javax.xml.stream.resolver</td> + * <td></td> + * <td>javax.xml.stream.XMLResolver</td> + * <td></td> + * <td>yes</td> + * </tr> + * <tr> + * <td>javax.xml.stream.allocator</td> + * <td></td> + * <td>javax.xml.stream.util.XMLEventAllocator</td> + * <td></td> + * <td>yes</td> + * </tr> + * </table> + */ +public abstract class XMLInputFactory +{ + + /** + * Property used to control namespace support. + */ + public static final String IS_NAMESPACE_AWARE = + "javax.xml.stream.isNamespaceAware"; + + /** + * Property used to control DTD validation. + */ + public static final String IS_VALIDATING = "javax.xml.stream.isValidating"; + + /** + * Property used to control whether to coalesce adjacent text events. + */ + public static final String IS_COALESCING = "javax.xml.stream.isCoalescing"; + + /** + * Property used to control whether to replace entity references with + * their replacement text. + */ + public static final String IS_REPLACING_ENTITY_REFERENCES = + "javax.xml.stream.isReplacingEntityReferences"; + + /** + * Property used to control whether to resolve external entities. + */ + public static final String IS_SUPPORTING_EXTERNAL_ENTITIES = + "javax.xml.stream.isSupportingExternalEntities"; + + /** + * Property used to indicate whether to support DTDs. + */ + public static final String SUPPORT_DTD = "javax.xml.stream.supportDTD"; + + /** + * Property used to control the error reporter implementation. + */ + public static final String REPORTER = "javax.xml.stream.reporter"; + + /** + * Property used to control the entity resolver implementation. + */ + public static final String RESOLVER = "javax.xml.stream.resolver"; + + /** + * Property used to control the event allocator implementation. + */ + public static final String ALLOCATOR = "javax.xml.stream.allocator"; + + protected XMLInputFactory() + { + } + + /** + * Creates a new factory instance. + * @see #newInstance(String,ClassLoader) + */ + public static XMLInputFactory newInstance() + throws FactoryConfigurationError + { + return newInstance(null, null); + } + + /** + * Creates a new factory instance. + * The implementation class to load is the first found in the following + * locations: + * <ol> + * <li>the <code>javax.xml.stream.XMLInputFactory</code> system + * property</li> + * <li>the above named property value in the + * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li> + * <li>the class name specified in the + * <code>META-INF/services/javax.xml.stream.XMLInputFactory</code> + * system resource</li> + * <li>the default factory class</li> + * </ol> + * @param factoryId name of the factory, same as a property name + * @param classLoader the class loader to use + * @return the factory implementation + * @exception FactoryConfigurationError if an instance of this factory + * cannot be loaded + */ + public static XMLInputFactory newInstance(String factoryId, + ClassLoader classLoader) + throws FactoryConfigurationError + { + ClassLoader loader = classLoader; + if (loader == null) + { + loader = Thread.currentThread().getContextClassLoader(); + } + if (loader == null) + { + loader = XMLInputFactory.class.getClassLoader(); + } + String className = null; + int count = 0; + do + { + className = getFactoryClassName(loader, count++); + if (className != null) + { + try + { + Class<?> t = (loader != null) ? loader.loadClass(className) : + Class.forName(className); + return (XMLInputFactory) t.newInstance(); + } + catch (ClassNotFoundException e) + { + className = null; + } + catch (Exception e) + { + throw new FactoryConfigurationError(e, + "error instantiating class " + className); + } + } + } + while (className == null && count < 3); + return new gnu.xml.stream.XMLInputFactoryImpl(); + } + + private static String getFactoryClassName(ClassLoader loader, int attempt) + { + final String propertyName = "javax.xml.stream.XMLInputFactory"; + switch (attempt) + { + case 0: + return System.getProperty(propertyName); + case 1: + try + { + File file = new File(System.getProperty("java.home")); + file = new File(file, "lib"); + file = new File(file, "stax.properties"); + InputStream in = new FileInputStream(file); + Properties props = new Properties(); + props.load(in); + in.close(); + return props.getProperty(propertyName); + } + catch (IOException e) + { + return null; + } + case 2: + try + { + String serviceKey = "/META-INF/services/" + propertyName; + InputStream in = (loader != null) ? + loader.getResourceAsStream(serviceKey) : + XMLInputFactory.class.getResourceAsStream(serviceKey); + if (in != null) + { + BufferedReader r = + new BufferedReader(new InputStreamReader(in)); + String ret = r.readLine(); + r.close(); + return ret; + } + } + catch (IOException e) + { + } + return null; + default: + return null; + } + } + + /** + * Creates a new stream reader. + */ + public abstract XMLStreamReader createXMLStreamReader(Reader reader) + throws XMLStreamException; + + /** + * Creates a new stream reader. + */ + public abstract XMLStreamReader createXMLStreamReader(Source source) + throws XMLStreamException; + + /** + * Creates a new stream reader. + */ + public abstract XMLStreamReader createXMLStreamReader(InputStream stream) + throws XMLStreamException; + + /** + * Creates a new stream reader. + */ + public abstract XMLStreamReader createXMLStreamReader(InputStream stream, + String encoding) + throws XMLStreamException; + + /** + * Creates a new stream reader. + */ + public abstract XMLStreamReader createXMLStreamReader(String systemId, + InputStream stream) + throws XMLStreamException; + + /** + * Creates a new stream reader. + */ + public abstract XMLStreamReader createXMLStreamReader(String systemId, + Reader reader) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(Reader reader) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(String systemId, + Reader reader) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(Source source) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(InputStream stream) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(InputStream stream, + String encoding) + throws XMLStreamException; + + /** + * Creates a new event reader. + */ + public abstract XMLEventReader createXMLEventReader(String systemId, + InputStream stream) + throws XMLStreamException; + + /** + * Create a new filtered reader. + */ + public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader, + StreamFilter filter) + throws XMLStreamException; + + /** + * Create a new filtered reader. + */ + public abstract XMLEventReader createFilteredReader(XMLEventReader reader, + EventFilter filter) + throws XMLStreamException; + + /** + * Returns the entity resolver. + */ + public abstract XMLResolver getXMLResolver(); + + /** + * Sets the entity resolver. + */ + public abstract void setXMLResolver(XMLResolver resolver); + + /** + * Returns the error reporter. + */ + public abstract XMLReporter getXMLReporter(); + + /** + * Sets the error reporter. + */ + public abstract void setXMLReporter(XMLReporter reporter); + + /** + * Sets the implementation-specific property of the given name. + * @exception IllegalArgumentException if the property is not supported + */ + public abstract void setProperty(String name, Object value) + throws IllegalArgumentException; + + /** + * Returns the implementation-specific property of the given name. + * @exception IllegalArgumentException if the property is not supported + */ + public abstract Object getProperty(String name) + throws IllegalArgumentException; + + /** + * Indicates whether the specified property is supported. + */ + public abstract boolean isPropertySupported(String name); + + /** + * Sets the event allocator. + */ + public abstract void setEventAllocator(XMLEventAllocator allocator); + + /** + * Returns the event allocator. + */ + public abstract XMLEventAllocator getEventAllocator(); + +} diff --git a/libjava/classpath/javax/xml/stream/XMLOutputFactory.java b/libjava/classpath/javax/xml/stream/XMLOutputFactory.java new file mode 100644 index 000000000..a8579aa31 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLOutputFactory.java @@ -0,0 +1,279 @@ +/* XMLOutputFactory.java -- + Copyright (C) 2005,2006,2009 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 java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; +import java.util.Properties; +import javax.xml.transform.Result; + +/** + * Factory for obtaining XML stream and event writers for various kinds of + * output sink. + * <h3>Configuration</h3> + * <table> + * <tr> + * <th>Name</th> + * <th>Description</th> + * <th>Type</th> + * <th>Default</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>javax.xml.stream.isRepairingNamespaces</td> + * <td>default namespace prefixes</td> + * <td>Boolean</td> + * <td>Boolean.FALSE</td> + * <td>yes</td> + * </tr> + * </table> + */ +public abstract class XMLOutputFactory +{ + + /** + * Property used to control whether to default namespace prefixes. + * 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_REPAIRING_NAMESPACES = + "javax.xml.stream.isRepairingNamespaces"; + + protected XMLOutputFactory() + { + } + + /** + * Creates a new <b>output</b> factory. + * @see #newInstance(String,ClassLoader) + */ + public static XMLOutputFactory newInstance() + throws FactoryConfigurationError + { + return newInstance(null, null); + } + + /** + * Creates a new <b>output</b> factory. + * The implementation class to load is the first found in the following + * locations: + * <ol> + * <li>the <code>javax.xml.stream.XMLOutputFactory</code> system + * property</li> + * <li>the above named property value in the + * <code><i>$JAVA_HOME</i>/lib/stax.properties</code> file</li> + * <li>the class name specified in the + * <code>META-INF/services/javax.xml.stream.XMLOutputFactory</code> + * system resource</li> + * <li>the default factory class</li> + * </ol> + * @param factoryId the name of the factory, same as the property + * @param classLoader the class loader to use + * @return a new factory instance + * @exception FactoryConfigurationError if an instance of this factory + * could not be loaded + */ + public static XMLOutputFactory newInstance(String factoryId, + ClassLoader classLoader) + throws FactoryConfigurationError + { + if (classLoader == null) + { + classLoader = Thread.currentThread().getContextClassLoader(); + } + if (classLoader == null) + { + classLoader = XMLOutputFactory.class.getClassLoader(); + } + String className = null; + int count = 0; + do + { + className = getFactoryClassName(classLoader, count++); + if (className != null) + { + try + { + Class<?> t = (classLoader != null) ? + classLoader.loadClass(className) : + Class.forName(className); + return (XMLOutputFactory) t.newInstance(); + } + catch (ClassNotFoundException e) + { + className = null; + } + catch (Exception e) + { + throw new FactoryConfigurationError(e, + "error instantiating class " + className); + } + } + } + while (className == null && count < 3); + return new gnu.xml.stream.XMLOutputFactoryImpl(); + } + + private static String getFactoryClassName(ClassLoader loader, int attempt) + { + final String propertyName = "javax.xml.stream.XMLOutputFactory"; + switch (attempt) + { + case 0: + return System.getProperty(propertyName); + case 1: + try + { + File file = new File(System.getProperty("java.home")); + file = new File(file, "lib"); + file = new File(file, "stax.properties"); + InputStream in = new FileInputStream(file); + Properties props = new Properties(); + props.load(in); + in.close(); + return props.getProperty(propertyName); + } + catch (IOException e) + { + return null; + } + case 2: + try + { + String serviceKey = "/META-INF/services/" + propertyName; + InputStream in = (loader != null) ? + loader.getResourceAsStream(serviceKey) : + XMLOutputFactory.class.getResourceAsStream(serviceKey); + if (in != null) + { + BufferedReader r = + new BufferedReader(new InputStreamReader(in)); + String ret = r.readLine(); + r.close(); + return ret; + } + } + catch (IOException e) + { + } + return null; + default: + return null; + } + } + + /** + * Creates a new stream writer. + */ + public abstract XMLStreamWriter createXMLStreamWriter(Writer stream) + throws XMLStreamException; + + /** + * Creates a new stream writer. + */ + public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream) + throws XMLStreamException; + + /** + * Creates a new stream writer. + */ + public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream, + String encoding) + throws XMLStreamException; + + /** + * Creates a new stream writer. + * @exception UnsupportedOperationException if this method is not + * supported + */ + 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; + + /** + * Creates a new event writer. + */ + public abstract XMLEventWriter createXMLEventWriter(OutputStream stream) + throws XMLStreamException; + + /** + * Creates a new event writer. + */ + public abstract XMLEventWriter createXMLEventWriter(OutputStream stream, + String encoding) + throws XMLStreamException; + + /** + * Creates a new event writer. + */ + public abstract XMLEventWriter createXMLEventWriter(Writer stream) + throws XMLStreamException; + + /** + * Sets the implementation-specific property of the given name. + * @exception IllegalArgumentException if the property is not supported + */ + public abstract void setProperty(String name, Object value) + throws IllegalArgumentException; + + /** + * Returns the implementation-specific property of the given name. + * @exception IllegalArgumentException if the property is not supported + */ + public abstract Object getProperty(String name) + throws IllegalArgumentException; + + /** + * Indicates whether the specified property is supported. + */ + public abstract boolean isPropertySupported(String name); + +} diff --git a/libjava/classpath/javax/xml/stream/XMLReporter.java b/libjava/classpath/javax/xml/stream/XMLReporter.java new file mode 100644 index 000000000..389437542 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLReporter.java @@ -0,0 +1,57 @@ +/* XMLReporter.java -- + Copyright (C) 2005,2006 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; + +/** + * Interface used to report non-fatal errors during parsing. + */ +public interface XMLReporter +{ + + /** + * Reports an error. + * @param message the error message + * @param errorType an implementation-specific error type + * @param relatedInformation additional information, if any + * @param location the error location, if available + */ + void report(String message, String errorType, + Object relatedInformation, Location location) + throws XMLStreamException; + +} diff --git a/libjava/classpath/javax/xml/stream/XMLResolver.java b/libjava/classpath/javax/xml/stream/XMLResolver.java new file mode 100644 index 000000000..e537bb74c --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLResolver.java @@ -0,0 +1,65 @@ +/* XMLResolver.java -- + Copyright (C) 2005,2006 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; + +/** + * Interface used to resolve XML external entities during parsing. + */ +public interface XMLResolver +{ + + /** + * Returns an input source from which the specified external entity can be + * read. The following return types are possible: + * <ol> + * <li><code>java.io.InputStream</code></li> + * <li><code>javax.xml.stream.XMLStreamReader</code></li> + * <li><code>java.xml.stream.XMLEventReader</code></li> + * </ol> + * If <code>null</code> is returned, the processor will attempt to resolve + * the entity itself. + * @param publicID the public ID of the external entity + * @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; + +} diff --git a/libjava/classpath/javax/xml/stream/XMLStreamConstants.java b/libjava/classpath/javax/xml/stream/XMLStreamConstants.java new file mode 100644 index 000000000..60541344e --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLStreamConstants.java @@ -0,0 +1,121 @@ +/* XMLStreamConstants.java -- + Copyright (C) 2005,2006 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; + +/** + * STaX constants. + */ +public interface XMLStreamConstants +{ + + /** + * A start element event. + */ + static final int START_ELEMENT = 1; + + /** + * An end element event. + */ + static final int END_ELEMENT = 2; + + /** + * A processing instruction event. + */ + static final int PROCESSING_INSTRUCTION = 3; + + /** + * A text event. + */ + static final int CHARACTERS = 4; + + /** + * A comment event. + */ + static final int COMMENT = 5; + + /** + * An ignorable whitespace event. + */ + static final int SPACE = 6; + + /** + * A start document event. + */ + static final int START_DOCUMENT = 7; + + /** + * An end document event. + */ + static final int END_DOCUMENT = 8; + + /** + * An entity reference event. + */ + static final int ENTITY_REFERENCE = 9; + + /** + * An attribute event. + */ + static final int ATTRIBUTE = 10; + + /** + * A DOCTYPE declaration event. + */ + static final int DTD = 11; + + /** + * A CDATA section event. + */ + static final int CDATA = 12; + + /** + * A namespace event. + */ + static final int NAMESPACE = 13; + + /** + * A notation declaration event. + */ + static final int NOTATION_DECLARATION = 14; + + /** + * An entity declaration event. + */ + static final int ENTITY_DECLARATION = 15; + +} diff --git a/libjava/classpath/javax/xml/stream/XMLStreamException.java b/libjava/classpath/javax/xml/stream/XMLStreamException.java new file mode 100644 index 000000000..929afbb75 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLStreamException.java @@ -0,0 +1,98 @@ +/* XMLStreamException.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; + +/** + * Exception indicating an XML stream processing error. + */ +public class XMLStreamException + extends Exception +{ + + protected Location location; + protected Throwable nested; + + public XMLStreamException() + { + this(null, null, null); + } + + public XMLStreamException(String msg) + { + this(msg, null, null); + } + + public XMLStreamException(Throwable th) + { + this(null, null, th); + } + + public XMLStreamException(String msg, Throwable th) + { + this(msg, null, th); + } + + public XMLStreamException(String msg, Location location, Throwable th) + { + super(msg); + this.location = location; + nested = th; + } + + public XMLStreamException(String msg, Location location) + { + this(msg, location, null); + } + + /** + * Returns the nested exception. + */ + public Throwable getNestedException() + { + return nested; + } + + /** + * Returns the location of the exception. + */ + public Location getLocation() + { + return location; + } + +} diff --git a/libjava/classpath/javax/xml/stream/XMLStreamReader.java b/libjava/classpath/javax/xml/stream/XMLStreamReader.java new file mode 100644 index 000000000..10bc4a5a5 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLStreamReader.java @@ -0,0 +1,300 @@ +/* XMLStreamReader.java -- + Copyright (C) 2005,2006 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.namespace.NamespaceContext; +import javax.xml.namespace.QName; + +/** + * Interface implemented by an XML parser. + */ +public interface XMLStreamReader + extends XMLStreamConstants +{ + + /** + * Returns the implementation-specific feature or property of the given + * name. + */ + Object getProperty(String name) + throws IllegalArgumentException; + + /** + * Returns the next parsing event. + */ + int next() + throws XMLStreamException; + + /** + * Tests whether the current event is of the given type and namespace. + * @exception XMLStreamException if the test fails + */ + void require(int type, String namespaceURI, String localName) + throws XMLStreamException; + + /** + * Returns the text content of a text-only element. + * When invoked, the current event must be START_ELEMENT. + * On completion, the current event will be END_ELEMENT. + */ + String getElementText() + throws XMLStreamException; + + /** + * Skips any ignorable whitespace, comments, and processing instructions + * until a START_ELEMENT or END_ELEMENT event is encountered. + * @exception XMLStreamException if an event of any other type is + * encountered + */ + int nextTag() + throws XMLStreamException; + + /** + * Indicates whether there are any remaining events to be read. + */ + boolean hasNext() + throws XMLStreamException; + + /** + * Frees any resources used by this parser. + * This method will not close the underlying input source. + */ + void close() + throws XMLStreamException; + + /** + * Returns the namespace URI for the given prefix. + */ + String getNamespaceURI(String prefix); + + /** + * Indicates whether the current event is START_ELEMENT. + */ + boolean isStartElement(); + + /** + * Indicates whether the current event is END_ELEMENT. + */ + boolean isEndElement(); + + /** + * Indicates whether the current event is character data. + */ + boolean isCharacters(); + + /** + * Indicates whether the current event is ignorable whitespace. + */ + boolean isWhiteSpace(); + + /** + * Returns the normalized attribute value for the given attribute. + */ + String getAttributeValue(String namespaceURI, String localName); + + /** + * Returns the number of attributes on this element. + * This method can only be invoked on a START_ELEMENT event. + */ + int getAttributeCount(); + + /** + * Returns the QName of the attribute at the given index. + */ + QName getAttributeName(int index); + + /** + * Returns the namespace URI of the attribute at the given index. + */ + String getAttributeNamespace(int index); + + /** + * Returns the local-name of the attribute at the given index. + */ + String getAttributeLocalName(int index); + + /** + * Returns the namespace prefix of the attribute at the given index. + */ + String getAttributePrefix(int index); + + /** + * Returns the type of the attribute at the specified index. + */ + String getAttributeType(int index); + + /** + * Returns the normalized value of the attribute at the given index. + */ + String getAttributeValue(int index); + + /** + * Indicates whether the attribute at the given index was specified in the + * underlying XML source or created by default. + */ + boolean isAttributeSpecified(int index); + + /** + * Returns the number of namespaces declared on this event. + * This method is only valid on a START_ELEMENT, END_ELEMENT, or NAMESPACE + * event. + */ + int getNamespaceCount(); + + /** + * Returns the prefix of the namespace at the given index, or null if this + * is the default namespace declaration. + */ + String getNamespacePrefix(int index); + + /** + * Returns the URI of the namespace at the given index. + */ + String getNamespaceURI(int index); + + /** + * Returns the namespace context for the current position. + */ + NamespaceContext getNamespaceContext(); + + /** + * Returns the type of the current event. + */ + int getEventType(); + + /** + * Returns the string value of the current event. + */ + String getText(); + + /** + * Returns the string value of the current event as a character array. + */ + char[] getTextCharacters(); + + /** + * Copies the string value of the current event into the specified + * character array. + */ + int getTextCharacters(int sourceStart, char[] target, + int targetStart, int length) + throws XMLStreamException; + + /** + * Returns the offset of the first character in the text character array. + */ + int getTextStart(); + + /** + * Returns the length of the characters in the text character array. + */ + int getTextLength(); + + /** + * Returns the input encoding. + */ + String getEncoding(); + + /** + * Indicates whether the current event has text. + */ + boolean hasText(); + + /** + * Returns the current location of the parser cursor in the underlying + * input source. + */ + Location getLocation(); + + /** + * Returns the QName of the current element. + * This method is only valid on a START_ELEMENT or END_ELEMENT event. + */ + QName getName(); + + /** + * Returns the local-name of the current element. + */ + String getLocalName(); + + /** + * Indicates whether the current event has a name. + */ + boolean hasName(); + + /** + * Returns the namespace URI of the current element. + */ + String getNamespaceURI(); + + /** + * Returns the namespace prefix of the current element. + */ + String getPrefix(); + + /** + * Returns the XML version declared in the XML declaration. + */ + String getVersion(); + + /** + * Returns the standalone flag declared in the XML declaration. + */ + boolean isStandalone(); + + /** + * Indicates whether the standalone flag was set in the document. + */ + boolean standaloneSet(); + + /** + * Returns the encoding declared in the XML declaration. + */ + String getCharacterEncodingScheme(); + + /** + * Returns the target of the current processing instruction event. + */ + String getPITarget(); + + /** + * Returns the data of the current processing instruction event. + */ + String getPIData(); + +} diff --git a/libjava/classpath/javax/xml/stream/XMLStreamWriter.java b/libjava/classpath/javax/xml/stream/XMLStreamWriter.java new file mode 100644 index 000000000..d7d739660 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/XMLStreamWriter.java @@ -0,0 +1,243 @@ +/* XMLStreamWriter.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.namespace.NamespaceContext; + +/** + * Interface for writing XML to a stream. + */ +public interface XMLStreamWriter +{ + + /** + * Write the start of a tag. + */ + void writeStartElement(String localName) + throws XMLStreamException; + + /** + * Write the start of a tag. + */ + void writeStartElement(String namespaceURI, String localName) + throws XMLStreamException; + + /** + * Write the start of a tag. + */ + void writeStartElement(String prefix, String localName, String namespaceURI) + throws XMLStreamException; + + /** + * Write an empty tag. + */ + void writeEmptyElement(String namespaceURI, String localName) + throws XMLStreamException; + + /** + * Write an empty tag. + */ + void writeEmptyElement(String prefix, String localName, String namespaceURI) + throws XMLStreamException; + + /** + * Write an empty tag. + */ + void writeEmptyElement(String localName) + throws XMLStreamException; + + /** + * Closes the currently open tag. + */ + void writeEndElement() + throws XMLStreamException; + + /** + * Closes any currently open tags. + */ + void writeEndDocument() + throws XMLStreamException; + + /** + * Frees any resources used by this writer. + * This will not close the underlying output sink. + */ + void close() + throws XMLStreamException; + + /** + * Flushes any cached information to the underlying output sink. + */ + void flush() + throws XMLStreamException; + + /** + * Write an attribute. + */ + void writeAttribute(String localName, String value) + throws XMLStreamException; + + /** + * Write an attribute. + */ + void writeAttribute(String prefix, String namespaceURI, + String localName, String value) + throws XMLStreamException; + + /** + * Write an attribute. + */ + void writeAttribute(String namespaceURI, String localName, String value) + throws XMLStreamException; + + /** + * Write a namespace declaration. + */ + void writeNamespace(String prefix, String namespaceURI) + throws XMLStreamException; + + /** + * Write a default namespace declaration. + */ + void writeDefaultNamespace(String namespaceURI) + throws XMLStreamException; + + /** + * Write a comment. + */ + void writeComment(String data) + throws XMLStreamException; + + /** + * Write a processing instruction. + */ + void writeProcessingInstruction(String target) + throws XMLStreamException; + + /** + * Write a processing instruction. + */ + void writeProcessingInstruction(String target, String data) + throws XMLStreamException; + + /** + * Write a CDATA section. + */ + void writeCData(String data) + throws XMLStreamException; + + /** + * Write a DOCTYPE declaration. + */ + void writeDTD(String dtd) + throws XMLStreamException; + + /** + * Write an entity reference. + */ + void writeEntityRef(String name) + throws XMLStreamException; + + /** + * Write an XML declaration. + */ + void writeStartDocument() + throws XMLStreamException; + + /** + * Write an XML declaration with the specified XML version. + */ + void writeStartDocument(String version) + throws XMLStreamException; + + /** + * Write an XML declaration with the specifed XML version and encoding. + */ + void writeStartDocument(String encoding, String version) + throws XMLStreamException; + + /** + * Write the specified text. + */ + void writeCharacters(String text) + throws XMLStreamException; + + /** + * Write the specified text. + */ + void writeCharacters(char[] text, int start, int len) + throws XMLStreamException; + + /** + * Returns the prefix associated with the given namespace URI. + */ + String getPrefix(String uri) + throws XMLStreamException; + + /** + * Sets the prefix for the given namespace URI. + */ + void setPrefix(String prefix, String uri) + throws XMLStreamException; + + /** + * Sets the URI for the default namespace. + */ + void setDefaultNamespace(String uri) + throws XMLStreamException; + + /** + * Sets the namespace context for namespace resolution. + */ + void setNamespaceContext(NamespaceContext context) + throws XMLStreamException; + + /** + * Returns the current namespace context. + */ + NamespaceContext getNamespaceContext(); + + /** + * Returns the implementation-specific feature or property of the given + * name. + * @exception IllegalArgumentException if the property is not supported + */ + Object getProperty(String name) + throws IllegalArgumentException; + +} diff --git a/libjava/classpath/javax/xml/stream/events/Attribute.java b/libjava/classpath/javax/xml/stream/events/Attribute.java new file mode 100644 index 000000000..1824a9c02 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/Attribute.java @@ -0,0 +1,70 @@ +/* Attribute.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; + +import javax.xml.namespace.QName; + +/** + * An attribute event. + */ +public interface Attribute + extends XMLEvent +{ + + /** + * Returns the name of this attribute. + */ + QName getName(); + + /** + * Returns the normalized value of this attribute. + */ + String getValue(); + + /** + * Returns the type of this attribute. + */ + String getDTDType(); + + /** + * Indicates whether this attribute was specified in the input source, or + * just defaulted by the DTD. + */ + boolean isSpecified(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/Characters.java b/libjava/classpath/javax/xml/stream/events/Characters.java new file mode 100644 index 000000000..d82009247 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/Characters.java @@ -0,0 +1,67 @@ +/* Characters.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; + +/** + * A character data (text) event. + */ +public interface Characters + extends XMLEvent +{ + + /** + * Returns the character data assocated with this event. + */ + String getData(); + + /** + * Indicates whether this text is all whitespace. + */ + boolean isWhiteSpace(); + + /** + * Indicates whether this is a CDATA section. + */ + boolean isCData(); + + /** + * Indicates whether this text is all ignorable whitespace. + */ + boolean isIgnorableWhiteSpace(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/Comment.java b/libjava/classpath/javax/xml/stream/events/Comment.java new file mode 100644 index 000000000..4419e58f2 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/Comment.java @@ -0,0 +1,52 @@ +/* Comment.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; + +/** + * A comment event. + */ +public interface Comment + extends XMLEvent +{ + + /** + * Returns the comment text. + */ + String getText(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/DTD.java b/libjava/classpath/javax/xml/stream/events/DTD.java new file mode 100644 index 000000000..b1a906919 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/DTD.java @@ -0,0 +1,72 @@ +/* DTD.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; + +import java.util.List; + +/** + * A DOCTYPE declaration event. + */ +public interface DTD + extends XMLEvent +{ + + /** + * Returns the body of the DTD, including the internal DTD subset. + */ + String getDocumentTypeDeclaration(); + + /** + * Returns an implementation-specific representation of the DTD, or null + * if no such representation is available. + */ + Object getProcessedDTD(); + + /** + * Returns the notations declared in the DTD. + */ + @SuppressWarnings("unchecked") + List getNotations(); + + /** + * Returns the entities declared in the DTD. + */ + @SuppressWarnings("unchecked") + List getEntities(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/EndDocument.java b/libjava/classpath/javax/xml/stream/events/EndDocument.java new file mode 100644 index 000000000..fd7e3fa4f --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/EndDocument.java @@ -0,0 +1,46 @@ +/* EndDocument.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-document event. + */ +public interface EndDocument + extends XMLEvent +{ +} diff --git a/libjava/classpath/javax/xml/stream/events/EndElement.java b/libjava/classpath/javax/xml/stream/events/EndElement.java new file mode 100644 index 000000000..a6b5c3fa2 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/EndElement.java @@ -0,0 +1,61 @@ +/* EndElement.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; + +import java.util.Iterator; +import javax.xml.namespace.QName; + +/** + * An end-element event. + */ +public interface EndElement + extends XMLEvent +{ + + /** + * Returns the element name. + */ + QName getName(); + + /** + * Returns the namespaces that have gone out of scope. + */ + @SuppressWarnings("unchecked") + Iterator getNamespaces(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/EntityDeclaration.java b/libjava/classpath/javax/xml/stream/events/EntityDeclaration.java new file mode 100644 index 000000000..61fa177f9 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/EntityDeclaration.java @@ -0,0 +1,77 @@ +/* EntityDeclaration.java -- + Copyright (C) 2005,2006 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 entity declaration event. + */ +public interface EntityDeclaration + extends XMLEvent +{ + + /** + * Returns the public identifier of the entity. + */ + String getPublicId(); + + /** + * Returns the system identifier of the entity. + */ + String getSystemId(); + + /** + * Returns the name of the entity. + */ + String getName(); + + /** + * Returns the name of the associated notation. + */ + String getNotationName(); + + /** + * Returns the replacement text for the entity. + */ + String getReplacementText(); + + /** + * Returns the base URI for the entity. + */ + String getBaseURI(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/EntityReference.java b/libjava/classpath/javax/xml/stream/events/EntityReference.java new file mode 100644 index 000000000..27bcb040f --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/EntityReference.java @@ -0,0 +1,57 @@ +/* EntityReference.java -- + Copyright (C) 2005,2006 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 entity reference event. + */ +public interface EntityReference + extends XMLEvent +{ + + /** + * Returns the declaration of this reference. + */ + EntityDeclaration getDeclaration(); + + /** + * Returns the entity name. + */ + String getName(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/Namespace.java b/libjava/classpath/javax/xml/stream/events/Namespace.java new file mode 100644 index 000000000..05de86c96 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/Namespace.java @@ -0,0 +1,62 @@ +/* Namespace.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; + +/** + * A namespace declaration event. + */ +public interface Namespace + extends Attribute +{ + + /** + * Returns the namespace prefix, if any. + */ + String getPrefix(); + + /** + * Returns the namespace URI. + */ + String getNamespaceURI(); + + /** + * Indicates whether this event declares the default namespace. + */ + boolean isDefaultNamespaceDeclaration(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/NotationDeclaration.java b/libjava/classpath/javax/xml/stream/events/NotationDeclaration.java new file mode 100644 index 000000000..708beb5f5 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/NotationDeclaration.java @@ -0,0 +1,62 @@ +/* NotationDeclaration.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; + +/** + * A notation declaration event. + */ +public interface NotationDeclaration + extends XMLEvent +{ + + /** + * Returns the name of the notation. + */ + String getName(); + + /** + * Returns the public identifier of the notation. + */ + String getPublicId(); + + /** + * Returns the system identifier of the notation. + */ + String getSystemId(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java b/libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java new file mode 100644 index 000000000..340202300 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/ProcessingInstruction.java @@ -0,0 +1,57 @@ +/* ProcessingInstruction.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; + +/** + * A processing instruction event. + */ +public interface ProcessingInstruction + extends XMLEvent +{ + + /** + * Returns the processing instruction target. + */ + String getTarget(); + + /** + * Returns the processing instruction data. + */ + String getData(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/StartDocument.java b/libjava/classpath/javax/xml/stream/events/StartDocument.java new file mode 100644 index 000000000..7a5434624 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/StartDocument.java @@ -0,0 +1,79 @@ +/* StartDocument.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; + +/** + * A start-document event. + */ +public interface StartDocument + extends XMLEvent +{ + + /** + * Returns the system identifier of the document entity. + */ + String getSystemId(); + + /** + * Returns the character encoding of the document. + */ + String getCharacterEncodingScheme(); + + /** + * Indicates whether the character encoding was set in the XML + * declaration. + */ + boolean encodingSet(); + + /** + * Indicates whether the document is standalone. + */ + boolean isStandalone(); + + /** + * Indicates whether the standalone parameter was set in the XML + * declaration. + */ + boolean standaloneSet(); + + /** + * Returns the XML version of the document. + */ + String getVersion(); + +} diff --git a/libjava/classpath/javax/xml/stream/events/StartElement.java b/libjava/classpath/javax/xml/stream/events/StartElement.java new file mode 100644 index 000000000..359b57eef --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/StartElement.java @@ -0,0 +1,83 @@ +/* StartElement.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; + +import java.util.Iterator; +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; + +/** + * A start-element event. + */ +public interface StartElement + extends XMLEvent +{ + + /** + * Returns the element name. + */ + QName getName(); + + /** + * Returns the attributes declared on this element. + */ + @SuppressWarnings("unchecked") + Iterator getAttributes(); + + /** + * Returns the namespaces declared on this element. + */ + @SuppressWarnings("unchecked") + Iterator getNamespaces(); + + /** + * Returns an attribute by name. + */ + Attribute getAttributeByName(QName name); + + /** + * Returns a read-only namespace context associated with this event. + */ + NamespaceContext getNamespaceContext(); + + /** + * Returns the namespace URI associated with the given prefix. + */ + String getNamespaceURI(String prefix); + +} diff --git a/libjava/classpath/javax/xml/stream/events/XMLEvent.java b/libjava/classpath/javax/xml/stream/events/XMLEvent.java new file mode 100644 index 000000000..90f354667 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/events/XMLEvent.java @@ -0,0 +1,135 @@ +/* XMLEvent.java -- + Copyright (C) 2005,2006 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; + +import java.io.Writer; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; + +/** + * An XML stream event. + */ +public interface XMLEvent + extends XMLStreamConstants +{ + + /** + * Returns the type of this event. + */ + int getEventType(); + + /** + * Returns the location of this event. + */ + Location getLocation(); + + /** + * Indicates whether this event is a start-element event. + */ + boolean isStartElement(); + + /** + * Indicates whether this event is an attribute event. + */ + boolean isAttribute(); + + /** + * Indicates whether this event is a namespace declaration event. + */ + boolean isNamespace(); + + /** + * Indicates whether this event is an end-element event. + */ + boolean isEndElement(); + + /** + * Indicates whether this event is an entity reference event. + */ + boolean isEntityReference(); + + /** + * Indicates whether this event is a processing instruction event. + */ + boolean isProcessingInstruction(); + + /** + * Indicates whether this event is a text event. + */ + boolean isCharacters(); + + /** + * Indicates whether this event is a start-document event. + */ + boolean isStartDocument(); + + /** + * Indicates whether this event is an end-document event. + */ + boolean isEndDocument(); + + /** + * Returns this event as a start-element event. + */ + StartElement asStartElement(); + + /** + * Returns this event as an end-element event. + */ + EndElement asEndElement(); + + /** + * Returns this event as a text event. + */ + Characters asCharacters(); + + /** + * Returns schema-related type information about this event, or null if + * not available. + */ + QName getSchemaType(); + + /** + * Writes this event to the specified writer. + */ + void writeAsEncodedUnicode(Writer writer) + throws XMLStreamException; + +} diff --git a/libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java b/libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java new file mode 100644 index 000000000..2c04c09de --- /dev/null +++ b/libjava/classpath/javax/xml/stream/util/EventReaderDelegate.java @@ -0,0 +1,151 @@ +/* EventReaderDelegate.java -- + Copyright (C) 2005,2006 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.util; + +import java.util.NoSuchElementException; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.events.XMLEvent; + +/** + * Base class for event reader filters. + */ +public class EventReaderDelegate + implements XMLEventReader +{ + + private XMLEventReader parent; + + /** + * Constructs an empty filter with no parent set. + */ + public EventReaderDelegate() + { + } + + /** + * Constructs an empty filter with the given parent. + */ + public EventReaderDelegate(XMLEventReader reader) + { + parent = reader; + } + + /** + * Sets the parent. + */ + public void setParent(XMLEventReader reader) + { + parent = reader; + } + + /** + * Returns the parent. + */ + public XMLEventReader getParent() + { + return parent; + } + + 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() + { + if (parent != null) + return parent.hasNext(); + return false; + } + + public XMLEvent peek() + throws XMLStreamException + { + if (parent != null) + return parent.peek(); + return null; + } + + public String getElementText() + throws XMLStreamException + { + if (parent != null) + return parent.getElementText(); + throw new XMLStreamException(); + } + + public XMLEvent nextTag() + throws XMLStreamException + { + if (parent != null) + return parent.nextTag(); + throw new XMLStreamException(); + } + + public Object getProperty(String name) + throws IllegalArgumentException + { + if (parent != null) + return parent.getProperty(name); + throw new IllegalArgumentException(name); + } + + public void close() + throws XMLStreamException + { + if (parent != null) + parent.close(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + +} diff --git a/libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java b/libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java new file mode 100644 index 000000000..75a7ca597 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/util/StreamReaderDelegate.java @@ -0,0 +1,408 @@ +/* StreamReaderDelegate.java -- + Copyright (C) 2005,2006,2009 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.util; + +import javax.xml.namespace.NamespaceContext; +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; + +/** + * Base class for XML stream reader filters. + */ +public class StreamReaderDelegate + implements XMLStreamReader, XMLStreamConstants +{ + + private XMLStreamReader parent; + + /** + * Constructs an empty filter with no parent set. + */ + public StreamReaderDelegate() + { + } + + /** + * Constructs an empty filter with the specfied parent. + */ + public StreamReaderDelegate(XMLStreamReader reader) + { + parent = reader; + } + + /** + * Sets the parent. + */ + public void setParent(XMLStreamReader reader) + { + parent = reader; + } + + /** + * Returns the parent. + */ + public XMLStreamReader getParent() + { + return parent; + } + + public int next() + throws XMLStreamException + { + if (parent != null) + return parent.next(); + throw new XMLStreamException(); + } + + public int nextTag() + throws XMLStreamException + { + if (parent != null) + return parent.nextTag(); + throw new XMLStreamException(); + } + + public String getElementText() + throws XMLStreamException + { + if (parent != null) + return parent.getElementText(); + throw new XMLStreamException(); + } + + public void require(int type, String namespaceURI, String localName) + throws XMLStreamException + { + if (parent != null) + parent.require(type, namespaceURI, localName); + } + + public boolean hasNext() + throws XMLStreamException + { + if (parent != null) + return parent.hasNext(); + return false; + } + + public void close() + throws XMLStreamException + { + if (parent != null) + parent.close(); + } + + public String getNamespaceURI(String prefix) + { + if (parent != null) + return parent.getNamespaceURI(prefix); + return null; + } + + public NamespaceContext getNamespaceContext() + { + if (parent != null) + return parent.getNamespaceContext(); + return null; + } + + public boolean isStartElement() + { + if (parent != null) + return parent.isStartElement(); + return false; + } + + public boolean isEndElement() + { + if (parent != null) + return parent.isEndElement(); + return false; + } + + public boolean isCharacters() + { + if (parent != null) + return parent.isCharacters(); + return false; + } + + public boolean isWhiteSpace() + { + if (parent != null) + return parent.isWhiteSpace(); + return false; + } + + public String getAttributeValue(String namespaceUri, String localName) + { + if (parent != null) + return parent.getAttributeValue(namespaceUri, localName); + return null; + } + + public int getAttributeCount() + { + if (parent != null) + return parent.getAttributeCount(); + return 0; + } + + public QName getAttributeName(int index) + { + if (parent != null) + return parent.getAttributeName(index); + return null; + } + + public String getAttributePrefix(int index) + { + if (parent != null) + return parent.getAttributePrefix(index); + return null; + } + + public String getAttributeNamespace(int index) + { + if (parent != null) + return parent.getAttributeNamespace(index); + return null; + } + + public String getAttributeLocalName(int index) + { + if (parent != null) + return parent.getAttributeLocalName(index); + return null; + } + + public String getAttributeType(int index) + { + if (parent != null) + return parent.getAttributeType(index); + return null; + } + + public String getAttributeValue(int index) + { + if (parent != null) + return parent.getAttributeValue(index); + return null; + } + + public boolean isAttributeSpecified(int index) + { + if (parent != null) + return parent.isAttributeSpecified(index); + return false; + } + + public int getNamespaceCount() + { + if (parent != null) + return parent.getNamespaceCount(); + return 0; + } + + public String getNamespacePrefix(int index) + { + if (parent != null) + return parent.getNamespacePrefix(index); + return null; + } + + public String getNamespaceURI(int index) + { + if (parent != null) + return parent.getNamespaceURI(index); + return null; + } + + public int getEventType() + { + if (parent != null) + return parent.getEventType(); + return 0; + } + + public String getText() + { + if (parent != null) + return parent.getText(); + return null; + } + + public int getTextCharacters(int sourceStart, char[] target, + int targetStart, int length) + throws XMLStreamException + { + if (parent != null) + return parent.getTextCharacters(sourceStart, target, targetStart, length); + return 0; + } + + public char[] getTextCharacters() + { + if (parent != null) + return parent.getTextCharacters(); + return null; + } + + public int getTextStart() + { + if (parent != null) + return parent.getTextStart(); + return 0; + } + + public int getTextLength() + { + if (parent != null) + return parent.getTextLength(); + return 0; + } + + public String getEncoding() + { + if (parent != null) + return parent.getEncoding(); + return null; + } + + public boolean hasText() + { + if (parent != null) + return parent.hasText(); + return false; + } + + public Location getLocation() + { + if (parent != null) + return parent.getLocation(); + return null; + } + + public QName getName() + { + if (parent != null) + return parent.getName(); + return null; + } + + public String getLocalName() + { + if (parent != null) + return parent.getLocalName(); + return null; + } + + public boolean hasName() + { + if (parent != null) + return parent.hasName(); + return false; + } + + public String getNamespaceURI() + { + if (parent != null) + return parent.getNamespaceURI(); + return null; + } + + public String getPrefix() + { + if (parent != null) + return parent.getPrefix(); + return null; + } + + public String getVersion() + { + if (parent != null) + return parent.getVersion(); + return null; + } + + public boolean isStandalone() + { + if (parent != null) + return parent.isStandalone(); + return false; + } + + public boolean standaloneSet() + { + if (parent != null) + return parent.standaloneSet(); + return false; + } + + public String getCharacterEncodingScheme() + { + if (parent != null) + return parent.getCharacterEncodingScheme(); + return null; + } + + public String getPITarget() + { + if (parent != null) + return parent.getPITarget(); + return null; + } + + public String getPIData() + { + if (parent != null) + return parent.getPIData(); + return null; + } + + public Object getProperty(String name) + { + if (parent != null) + return parent.getProperty(name); + throw new IllegalArgumentException(); + } + +} diff --git a/libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java b/libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java new file mode 100644 index 000000000..b8a7ddab8 --- /dev/null +++ b/libjava/classpath/javax/xml/stream/util/XMLEventAllocator.java @@ -0,0 +1,68 @@ +/* XMLEventAllocator.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.util; + +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; + +/** + * Interface for allocating events according to a stream reader. + */ +public interface XMLEventAllocator +{ + + /** + * Creates a new allocator. + */ + XMLEventAllocator newInstance(); + + /** + * Allocates an event based on the current state of the stream reader. + */ + XMLEvent allocate(XMLStreamReader reader) + throws XMLStreamException; + + /** + * Allocates one or more events based on the current state of the stream + * reader and adds those events to the specified consumer. + */ + void allocate(XMLStreamReader reader, XMLEventConsumer consumer) + throws XMLStreamException; + +} diff --git a/libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java b/libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java new file mode 100644 index 000000000..3a825f9de --- /dev/null +++ b/libjava/classpath/javax/xml/stream/util/XMLEventConsumer.java @@ -0,0 +1,55 @@ +/* XMLEventConsumer.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.util; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; + +/** + * Interface for consuming XML events. + */ +public interface XMLEventConsumer +{ + + /** + * Consumes an event. + */ + void add(XMLEvent event) + throws XMLStreamException; + +} |