summaryrefslogtreecommitdiffstats
path: root/xml/src/main/java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:55 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:55 -0800
commitdd828f42a5c83b4270d4fbf6fce2da1878f1e84a (patch)
treefdd4b68fa1020f2b6426034c94823419a7236200 /xml/src/main/java
parentfdb2704414a9ed92394ada0d1395e4db86889465 (diff)
downloadlibcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.zip
libcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.tar.gz
libcore-dd828f42a5c83b4270d4fbf6fce2da1878f1e84a.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'xml/src/main/java')
-rw-r--r--xml/src/main/java/javax/xml/package.html8
-rw-r--r--xml/src/main/java/javax/xml/parsers/DocumentBuilder.java129
-rw-r--r--xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java200
-rw-r--r--xml/src/main/java/javax/xml/parsers/FactoryConfigurationError.java74
-rw-r--r--xml/src/main/java/javax/xml/parsers/ParserConfigurationException.java15
-rw-r--r--xml/src/main/java/javax/xml/parsers/SAXParser.java215
-rw-r--r--xml/src/main/java/javax/xml/parsers/SAXParserFactory.java145
-rw-r--r--xml/src/main/java/javax/xml/parsers/package.html1
-rw-r--r--xml/src/main/java/org/kxml2/io/KXmlParser.java12
-rw-r--r--xml/src/main/java/org/kxml2/kdom/Element.java37
-rw-r--r--xml/src/main/java/org/kxml2/kdom/Node.java12
-rw-r--r--xml/src/main/java/org/kxml2/wap/WbxmlParser.java121
-rw-r--r--xml/src/main/java/org/kxml2/wap/WbxmlSerializer.java166
13 files changed, 734 insertions, 401 deletions
diff --git a/xml/src/main/java/javax/xml/package.html b/xml/src/main/java/javax/xml/package.html
new file mode 100644
index 0000000..5a4621d
--- /dev/null
+++ b/xml/src/main/java/javax/xml/package.html
@@ -0,0 +1,8 @@
+<html>
+ <body>
+ <p>
+ Provides a utility class with useful XML constants.
+ </p>
+ @since Android 1.0
+ </body>
+</html> \ No newline at end of file
diff --git a/xml/src/main/java/javax/xml/parsers/DocumentBuilder.java b/xml/src/main/java/javax/xml/parsers/DocumentBuilder.java
index ad35256..6fd6550 100644
--- a/xml/src/main/java/javax/xml/parsers/DocumentBuilder.java
+++ b/xml/src/main/java/javax/xml/parsers/DocumentBuilder.java
@@ -31,81 +31,104 @@ import java.io.InputStream;
/**
* Defines a bridge from XML sources (files, stream etc.) to DOM trees. Can be
- * used for easily obtaining a Document for the input. The class itself is
- * abstract. The class DocumentBuilderFactory is able to provide instances (of
- * concrete subclasses known to the system).
+ * used for easily obtaining a {@link org.w3c.dom.Document} for the input. The
+ * class itself is abstract. The class {@link DocumentBuilderFactory} is able to
+ * provide instances (of concrete subclasses known to the system).
+ *
+ * @since Android 1.0
*/
public abstract class DocumentBuilder {
/**
* Do-nothing constructor. Prevents instantiation. To be overridden by
* concrete subclasses.
+ *
+ * @since Android 1.0
*/
protected DocumentBuilder() {
// Does nothing.
}
/**
- * Queries the DOM implementation this DocumentBuilder is working on.
+ * Queries the DOM implementation this {@code DocumentBuilder} is working
+ * on.
+ *
+ * @return the DOM implementation
*
- * @return The DOM implementation
+ * @since Android 1.0
*/
public abstract DOMImplementation getDOMImplementation();
+// TODO No XSchema support in Android 1.0. Maybe later.
+// /**
+// * Queries the XML schema used by the DocumentBuilder.
+// *
+// * @return The XML schema
+// *
+// * @throws UnsupportedOperationException when the underlying implementation
+// * doesn't support XML schemas.
+// */
+// public javax.xml.validation.Schema getSchema() throws
+// UnsupportedOperationException {
+// throw new UnsupportedOperationException();
+// }
+
/**
- * Queries the XML schema used by the DocumentBuilder.
+ * Queries whether the {@code DocumentBuilder} has namespace support
+ * enabled.
*
- * @return The XML schema
- *
- * @throws UnsupportedOperationException when the underlying implementation
- * doesn't support XML schemas.
- */
- // TODO Do we want the validation package in?
- // public javax.xml.validation.Schema getSchema() throws
- // UnsupportedOperationException {
- // throw new UnsupportedOperationException();
- // }
- /**
- * Queries whether the DocumentBuilder has namespaces enabled.
+ * @return {@code true} if namespaces are turned on, {@code false}
+ * otherwise.
*
- * @return true if namespaces are turned on, false otherwise.
+ * @since Android 1.0
*/
public abstract boolean isNamespaceAware();
/**
- * Queries whether the DocumentBuilder has validating enabled.
+ * Queries whether the {@code DocumentBuilder} has validation support
+ * enabled.
+ *
+ * @return {@code true} if validation is turned on, {@code false} otherwise.
*
- * @return true if validating is turned on, false otherwise.
+ * @since Android 1.0
*/
public abstract boolean isValidating();
/**
- * Queries whether the DocumentBuilder has XInclude support enabled.
+ * Queries whether the {@code DocumentBuilder} has XInclude support enabled.
*
- * @return true if XInclude support is turned on, false otherwise.
+ * @return {@code true} if XInclude support is turned on, {@code false}
+ * otherwise.
*
- * @throws UnsupportedOperationException when the underlying imlementation
+ * @throws UnsupportedOperationException if the underlying implementation
* doesn't support XInclude.
+ *
+ * @since Android 1.0
*/
public boolean isXIncludeAware() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
/**
- * Creates a new document, serving as the starting point for a DOM tree.
+ * Creates a new, empty document, serving as the starting point for a DOM
+ * tree.
+ *
+ * @return the document.
*
- * @return The document.
+ * @since Android 1.0
*/
public abstract Document newDocument();
/**
* Parses a given XML file and builds a DOM tree from it.
*
- * @param file The file to be parsed.
- * @return The document element that represents the root of the DOM tree.
+ * @param file the file to be parsed.
+ * @return the document element that represents the root of the DOM tree.
*
* @throws SAXException if the XML parsing fails.
* @throws IOException if an input/output error occurs.
+ *
+ * @since Android 1.0
*/
public Document parse(File file) throws SAXException, IOException {
if (file == null) {
@@ -118,11 +141,13 @@ public abstract class DocumentBuilder {
/**
* Parses a given XML input stream and builds a DOM tree from it.
*
- * @param stream The stream to be parsed.
- * @return The document element that represents the root of the DOM tree.
+ * @param stream the stream to be parsed.
+ * @return the document element that represents the root of the DOM tree.
*
* @throws SAXException if the XML parsing fails.
* @throws IOException if an input/output error occurs.
+ *
+ * @since Android 1.0
*/
public Document parse(InputStream stream) throws SAXException, IOException {
if (stream == null) {
@@ -135,12 +160,14 @@ public abstract class DocumentBuilder {
/**
* Parses a given XML input stream and builds a DOM tree from it.
*
- * @param stream The stream to be parsed.
- * @param systemId The base for resolving relative URIs.
- * @return The document element that represents the root of the DOM tree.
+ * @param stream the stream to be parsed.
+ * @param systemId the base for resolving relative URIs.
+ * @return the document element that represents the root of the DOM tree.
*
* @throws SAXException if the XML parsing fails.
* @throws IOException if an input/output error occurs.
+ *
+ * @since Android 1.0
*/
public org.w3c.dom.Document parse(InputStream stream, String systemId)
throws SAXException, IOException {
@@ -157,11 +184,13 @@ public abstract class DocumentBuilder {
* Parses an XML input stream from a given URI and builds a DOM tree from
* it.
*
- * @param uri The URI to fetch the XML stream from.
- * @return The document element that represents the root of the DOM tree.
+ * @param uri the URI to fetch the XML stream from.
+ * @return the document element that represents the root of the DOM tree.
*
* @throws SAXException if the XML parsing fails.
* @throws IOException if an input/output error occurs.
+ *
+ * @since Android 1.0
*/
public org.w3c.dom.Document parse(String uri) throws SAXException,
IOException {
@@ -175,11 +204,13 @@ public abstract class DocumentBuilder {
/**
* Parses an XML input source and builds a DOM tree from it.
*
- * @param source The input source to parse.
- * @return The document element that represents the root of the DOM tree.
+ * @param source the input source to parse.
+ * @return the document element that represents the root of the DOM tree.
*
* @throws SAXException if the XML parsing fails.
* @throws IOException if an input/output error occurs.
+ *
+ * @since Android 1.0
*/
public abstract org.w3c.dom.Document parse(InputSource source)
throws SAXException, IOException;
@@ -187,26 +218,34 @@ public abstract class DocumentBuilder {
/**
* Resets the DocumentBuilder to the same state is was in after its
* creation.
+ *
+ * @since Android 1.0
*/
public void reset() {
// Do nothing.
}
/**
- * Sets the EntityResolver used for resolving entities encountered during
- * the parse process. Passing null results in the DocumentBuilder's own
- * EntityResolver being used.
+ * Sets the {@link EntityResolver} used for resolving entities encountered
+ * during the parse process. Passing {@code null} results in the
+ * {@code DocumentBuilder}'s own {@code EntityResolver} being used.
*
- * @param resolver The EntityResolver to use, or null for the built-in one.
+ * @param resolver the {@code EntityResolver} to use, or null for the
+ * built-in one.
+ *
+ * @since Android 1.0
*/
public abstract void setEntityResolver(EntityResolver resolver);
/**
- * Sets the ErrorHandler used for dealing with errors encountered during the
- * parse process. Passing null results in the DocumentBuilder's own
- * ErrorHandler being used.
+ * Sets the {@link ErrorHandler} used for dealing with errors encountered
+ * during the parse process. Passing {@code null} results in the
+ * {@code DocumentBuilder}'s own {@code ErrorHandler} being used.
+ *
+ * @param handler the {@code ErrorHandler} to use, or {@code null} for the
+ * built-in one.
*
- * @param handler The ErrorHandler to use, or null for the built-in one.
+ * @since Android 1.0
*/
public abstract void setErrorHandler(ErrorHandler handler);
diff --git a/xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java b/xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
index 5e8d8cd..4e186c1 100644
--- a/xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
+++ b/xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
@@ -19,12 +19,15 @@ package javax.xml.parsers;
import org.apache.harmony.xml.parsers.DocumentBuilderFactoryImpl;
/**
- * Provides a factory for DocumentBuilder instances. The class first needs to be
- * instantiated using the newInstance() method. The instance can be configured
- * as desired. A call to newDocumentBuilder () then provides a DocumentBuilder
+ * Provides a factory for {@link DocumentBuilder} instances. The class first
+ * needs to be instantiated using the {@link #newInstance()} method. The
+ * instance can be configured as desired. A call to
+ * {@link #newDocumentBuilder()} then provides a {@code DocumentBuilder}
* instance matching this configuration (if possible).
+ *
+ * @since Android 1.0
*/
-public abstract class DocumentBuilderFactory extends java.lang.Object {
+public abstract class DocumentBuilderFactory extends Object {
private boolean coalesce;
@@ -40,6 +43,8 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
/**
* Do-nothing constructor. To be overridden by concrete document builders.
+ *
+ * @since Android 1.0
*/
protected DocumentBuilderFactory() {
// Does nothing.
@@ -48,11 +53,13 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
/**
* Queries an attribute from the underlying implementation.
*
- * @param name The name of the attribute.
- * @return The value of the attribute.
+ * @param name the name of the attribute.
+ * @return the value of the attribute.
*
- * @throws java.lang.IllegalArgumentException if the argument is unknown to
- * the underlying implementation.
+ * @throws IllegalArgumentException if the argument is unknown to the
+ * underlying implementation.
+ *
+ * @since Android 1.0
*/
public abstract Object getAttribute(String name)
throws IllegalArgumentException;
@@ -61,7 +68,7 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries a feature from the underlying implementation.
*
* @param name The name of the feature. The default Android implementation
- * of DocumentBuilder supports only the following three
+ * of {@link DocumentBuilder} supports only the following three
* features:
*
* <dl>
@@ -85,32 +92,37 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* namespace prefixes can be enabled, but not both at the same
* time.
*
- * @return The status of the feature.
+ * @return the status of the feature.
*
- * @throws java.lang.IllegalArgumentException if the feature is unknown to
+ * @throws IllegalArgumentException if the feature is unknown to
* the underlying implementation.
- * @throws javax.xml.parsers.ParserConfigurationException if the feature is
+ * @throws ParserConfigurationException if the feature is
* known, but not supported.
+ *
+ * @since Android 1.0
*/
public abstract boolean getFeature(String name)
- throws javax.xml.parsers.ParserConfigurationException;
+ throws ParserConfigurationException;
- /**
- * Queries the desired XML Schema object.
- *
- * @return The XML Schema object, if it has been set by a call to setSchema,
- * or null otherwise.
- */
- // TODO Do we want the validation package in?
- // public javax.xml.validation.Schema getSchema() {
- // return schema;
- // }
+// TODO No XSchema support in Android 1.0. Maybe later.
+// /**
+// * Queries the desired XML Schema object.
+// *
+// * @return The XML Schema object, if it has been set by a call to setSchema,
+// * or null otherwise.
+// */
+// public javax.xml.validation.Schema getSchema() {
+// return schema;
+// }
/**
* Queries whether the factory is configured to deliver parsers that convert
- * CDATA nodes to text nodes and melt them with neighbouring nodes.
+ * CDATA nodes to text nodes and melt them with neighboring nodes. This is
+ * called "coalescing".
+ *
+ * @return {@code true} if coalescing is desired, {@code false} otherwise.
*
- * @return true if coalescing is desired, false otherwise.
+ * @since Android 1.0
*/
public boolean isCoalescing() {
return coalesce;
@@ -120,7 +132,10 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries whether the factory is configured to deliver parsers that expand
* entity references.
*
- * @return true if entity expansion is desired, false otherwise.
+ * @return {@code true} if entity expansion is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isExpandEntityReferences() {
return expandEntityReferences;
@@ -130,7 +145,10 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries whether the factory is configured to deliver parsers that ignore
* comments.
*
- * @return true if comment ignorance is desired, false otherwise.
+ * @return {@code true} if comment ignorance is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isIgnoringComments() {
return ignoreComments;
@@ -140,7 +158,10 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries whether the factory is configured to deliver parsers that ignore
* whitespace in elements.
*
- * @return true if whitespace ignorance is desired, false otherwise.
+ * @return {@code true} if whitespace ignorance is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isIgnoringElementContentWhitespace() {
return ignoreElementContentWhitespace;
@@ -150,7 +171,10 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries whether the factory is configured to deliver parsers that are
* namespace-aware.
*
- * @return true if namespace-awareness is desired, false otherwise.
+ * @return {@code true} if namespace-awareness is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isNamespaceAware() {
return namespaceAware;
@@ -160,7 +184,9 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries whether the factory is configured to deliver parsers that are
* validating.
*
- * @return true if validating is desired, false otherwise.
+ * @return {@code true} if validating is desired, {@code false} otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isValidating() {
return validate;
@@ -170,31 +196,44 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Queries whether the factory is configured to deliver parsers that are
* XInclude-aware.
*
- * @return true if XInclude-awareness is desired, false otherwise.
+ * @return {@code true} if XInclude-awareness is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isXIncludeAware() {
throw new UnsupportedOperationException();
}
/**
- * Creates a new DocumentBuilder that matches the current configuration.
+ * Creates a new {@link DocumentBuilder} that matches the current
+ * configuration of the factory.
+ *
+ * @return the DocumentBuilder.
+ * @throws ParserConfigurationException if no matching
+ * {@code DocumentBuilder} could be found.
*
- * @return The DocumentBuilder.
- * @throws javax.xml.parsers.ParserConfigurationException if no matching
- * DocumentBuilder could be found.
+ * @since Android 1.0
*/
- public abstract javax.xml.parsers.DocumentBuilder newDocumentBuilder()
- throws javax.xml.parsers.ParserConfigurationException;
+ public abstract DocumentBuilder newDocumentBuilder()
+ throws ParserConfigurationException;
/**
* Creates a new DocumentBuilderFactory that can be configured and then be
- * used for creating DocumentBuilder objects.
+ * used for creating DocumentBuilder objects. The method first checks the
+ * value of the {@code DocumentBuilderFactory} property.
+ * If this is non-{@code null}, it is assumed to be the name of a class
+ * that serves as the factory. The class is instantiated, and the instance
+ * is returned. If the property value is {@code null}, the system's default
+ * factory implementation is returned.
*
- * @return The DocumentBuilderFactory.
- * @throws FactoryConfigurationError If no DocumentBuilderFactory can be
- * created.
+ * @return the DocumentBuilderFactory.
+ * @throws FactoryConfigurationError if no {@code DocumentBuilderFactory}
+ * can be created.
+ *
+ * @since Android 1.0
*/
- public static javax.xml.parsers.DocumentBuilderFactory newInstance()
+ public static DocumentBuilderFactory newInstance()
throws FactoryConfigurationError {
// TODO Properties file and META-INF case missing here. See spec.
String factory = System
@@ -221,20 +260,25 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
/**
* Sets an attribute in the underlying implementation.
*
- * @param name The name of the attribute.
- * @param value The value of the attribute.
+ * @param name the name of the attribute.
+ * @param value the value of the attribute.
*
- * @throws java.lang.IllegalArgumentException if the argument is unknown to
- * the underlying implementation.
+ * @throws IllegalArgumentException if the argument is unknown to the
+ * underlying implementation.
+ *
+ * @since Android 1.0
*/
public abstract void setAttribute(String name, Object value)
throws IllegalArgumentException;
/**
* Determines whether the factory is configured to deliver parsers that
- * convert CDATA nodes to text nodes and melt them with neighbouring nodes.
+ * convert CDATA nodes to text nodes and melt them with neighboring nodes.
+ * This is called "coalescing".
+ *
+ * @param value turns coalescing on or off.
*
- * @param value Turns coalescing on or off.
+ * @since Android 1.0
*/
public void setCoalescing(boolean value) {
coalesce = value;
@@ -244,7 +288,9 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Determines whether the factory is configured to deliver parsers that
* expands entity references.
*
- * @param value Turns entity reference expansion on or off.
+ * @param value turns entity reference expansion on or off.
+ *
+ * @since Android 1.0
*/
public void setExpandEntityReferences(boolean value) {
expandEntityReferences = value;
@@ -253,33 +299,35 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
/**
* Sets a feature in the underlying implementation.
*
- * @param name The name of the feature. The default Android implementation
- * of DocumentBuilder supports only the following three
+ * @param name the name of the feature. The default Android implementation
+ * of {@link DocumentBuilder} supports only the following three
* features:
*
* <dl>
* <dt>{@code http://xml.org/sax/features/namespaces}</dt>
- * <dd>Queries the state of namespace-awareness.</dd>
- *
+ * <dd>Sets the state of namespace-awareness.</dd>
+ *
* <dt>
* {@code http://xml.org/sax/features/namespace-prefixes}
* </dt>
- * <dd>Queries the state of namespace prefix processing</dd>
+ * <dd>Sets the state of namespace prefix processing</dd>
*
* <dt>{@code http://xml.org/sax/features/validation}</dt>
- * <dd>Queries the state of validation.</dd>
+ * <dd>Sets the state of validation.</dd>
* </dl>
*
- * Note that despite the ability to query the validation
+ * Note that despite the ability to set the validation
* feature, there is currently no validating parser available.
* Also note that currently either namespaces or
* namespace prefixes can be enabled, but not both at the same
* time.
*
- * @param value The value of the feature.
+ * @param value the value of the feature.
*
* @throws ParserConfigurationException if the feature is unknown to the
* underlying implementation.
+ *
+ * @since Android 1.0
*/
public abstract void setFeature(String name, boolean value)
throws ParserConfigurationException;
@@ -288,7 +336,9 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Determines whether the factory is configured to deliver parsers that
* ignore comments.
*
- * @param value Turns comment ignorance on or off.
+ * @param value turns comment ignorance on or off.
+ *
+ * @since Android 1.0
*/
public void setIgnoringComments(boolean value) {
ignoreComments = value;
@@ -298,7 +348,9 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Determines whether the factory is configured to deliver parsers that
* ignores element whitespace.
*
- * @param value Turns element whitespace ignorance on or off.
+ * @param value turns element whitespace ignorance on or off.
+ *
+ * @since Android 1.0
*/
public void setIgnoringElementContentWhitespace(boolean value) {
ignoreElementContentWhitespace = value;
@@ -308,27 +360,31 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Determines whether the factory is configured to deliver parsers that are
* namespace-aware.
*
- * @param value Turns namespace-awareness on or off.
+ * @param value turns namespace-awareness on or off.
+ *
+ * @since Android 1.0
*/
public void setNamespaceAware(boolean value) {
namespaceAware = value;
}
- /**
- * Sets the desired XML Schema object.
- *
- * @param schema The XML Schema object.
- */
- // TODO Do we want the validation package in?
- // public void setSchema(Schema schema) {
- // this.schema = schema;
- // }
+// TODO No XSchema support in Android 1.0. Maybe later.
+// /**
+// * Sets the desired XML Schema object.
+// *
+// * @param schema The XML Schema object.
+// */
+// public void setSchema(Schema schema) {
+// this.schema = schema;
+// }
/**
* Determines whether the factory is configured to deliver parsers that are
* validating.
*
- * @param value Turns validation on or off.
+ * @param value turns validation on or off.
+ *
+ * @since Android 1.0
*/
public void setValidating(boolean value) {
validate = value;
@@ -338,7 +394,9 @@ public abstract class DocumentBuilderFactory extends java.lang.Object {
* Determines whether the factory is configured to deliver parsers that are
* XInclude-aware.
*
- * @param value Turns XInclude-awareness on or off.
+ * @param value turns XInclude-awareness on or off.
+ *
+ * @since Android 1.0
*/
public void setXIncludeAware(boolean value) {
throw new UnsupportedOperationException();
diff --git a/xml/src/main/java/javax/xml/parsers/FactoryConfigurationError.java b/xml/src/main/java/javax/xml/parsers/FactoryConfigurationError.java
index 56023e1..f5e0c03 100644
--- a/xml/src/main/java/javax/xml/parsers/FactoryConfigurationError.java
+++ b/xml/src/main/java/javax/xml/parsers/FactoryConfigurationError.java
@@ -17,36 +17,42 @@
package javax.xml.parsers;
/**
- * Represents an error that occured during the configuration of parser factory.
+ * Represents an error that occurred during the configuration of parser factory.
+ *
+ * @since Android 1.0
*/
public class FactoryConfigurationError extends Error {
/**
* The nested exception that caused this exception. Note that the nested
- * exception will be stored in a special attribute, and can be queried
- * using the getException() method. It does not use the facility the
- * Exception class provides for storing nested exceptions, since the XML
- * API predates that facility.
+ * exception will be stored in a special attribute, and can be queried using
+ * the {@link #getException()} method. It does not use the facility the
+ * {@link Exception} class provides for storing nested exceptions, since the
+ * XML API predates that facility.
*/
private Exception cause;
/**
- * Creates a new FactoryConfigurationError with no error message an no
- * cause.
+ * Creates a new {@code FactoryConfigurationError} with no error message and
+ * no cause.
+ *
+ * @since Android 1.0
*/
public FactoryConfigurationError() {
super();
}
/**
- * Creates a new FactoryConfigurationError with no error message and a given
- * cause.
+ * Creates a new {@code FactoryConfigurationError} with no error message and
+ * a given cause.
+ *
+ * @param cause the cause of the error. Note that the nested exception will
+ * be stored in a special attribute, and can be queried using the
+ * {@link #getException()} method. It does not use the facility the
+ * Exception class provides for storing nested exceptions, since the
+ * XML API predates that facility.
*
- * @param cause The cause of the error. Note that the nested
- * exception will be stored in a special attribute, and can be
- * queried using the getException() method. It does not use the
- * facility the Exception class provides for storing nested
- * exceptions, since the XML API predates that facility.
+ * @since Android 1.0
*/
public FactoryConfigurationError(Exception cause) {
super();
@@ -54,15 +60,17 @@ public class FactoryConfigurationError extends Error {
}
/**
- * Creates a new FactoryConfigurationError with a given error message and
- * cause.
+ * Creates a new {@code FactoryConfigurationError} with a given error
+ * message and cause.
*
- * @param cause The cause of the error. Note that the nested
- * exception will be stored in a special attribute, and can be
- * queried using the getException() method. It does not use the
- * facility the Exception class provides for storing nested
- * exceptions, since the XML API predates that facility.
+ * @param cause the cause of the error. Note that the nested exception will
+ * be stored in a special attribute, and can be queried using the
+ * {@link #getException()} method. It does not use the facility the
+ * {@link Exception} class provides for storing nested exceptions,
+ * since the XML API predates that facility.
* @param message The error message.
+ *
+ * @since Android 1.0
*/
public FactoryConfigurationError(Exception cause, String message) {
super(message);
@@ -70,10 +78,12 @@ public class FactoryConfigurationError extends Error {
}
/**
- * Creates a new FactoryConfigurationError with a given error message and no
- * cause.
+ * Creates a new {@code FactoryConfigurationError} with a given error
+ * message and no cause.
*
- * @param message The error message.
+ * @param message the error message.
+ *
+ * @since Android 1.0
*/
public FactoryConfigurationError(String message) {
super(message);
@@ -82,21 +92,27 @@ public class FactoryConfigurationError extends Error {
/**
* Returns the cause of the error, in case there is one.
*
- * @return The exception that caused the error, or null if none is set.
+ * @return the exception that caused the error, or {@code null} if none is
+ * set.
+ *
+ * @since Android 1.0
*/
- public java.lang.Exception getException() {
+ public Exception getException() {
return cause;
}
/**
* Returns the message of the error, in case there is one.
*
- * @return The message. If an explicit error message has been assigned to
+ * @return the message. If an explicit error message has been assigned to
* the exception, this one is returned. If not, and there is an
* underlying exception (the cause), then the result of invoking
- * toString() for that is returned. Otherwise, null is returned.
+ * {@link #toString()} on that object is returned. Otherwise, {@code
+ * null} is returned.
+ *
+ * @since Android 1.0
*/
- public java.lang.String getMessage() {
+ public String getMessage() {
String message = super.getMessage();
if (message != null) {
diff --git a/xml/src/main/java/javax/xml/parsers/ParserConfigurationException.java b/xml/src/main/java/javax/xml/parsers/ParserConfigurationException.java
index 2028d2c..49875d6 100644
--- a/xml/src/main/java/javax/xml/parsers/ParserConfigurationException.java
+++ b/xml/src/main/java/javax/xml/parsers/ParserConfigurationException.java
@@ -17,21 +17,28 @@
package javax.xml.parsers;
/**
- * Represents an exception that occured during the configuration of parser.
+ * Represents an exception that occurred during the configuration of parser.
+ *
+ * @since Android 1.0
*/
public class ParserConfigurationException extends Exception {
/**
- * Creates a new ParserConfigurationException with no error message.
+ * Creates a new {@code ParserConfigurationException} with no error message.
+ *
+ * @since Android 1.0
*/
public ParserConfigurationException() {
super();
}
/**
- * Creates a new ParserConfigurationException with a given error message.
+ * Creates a new {@code ParserConfigurationException} with a given error
+ * message.
+ *
+ * @param msg the error message.
*
- * @param msg The error message.
+ * @since Android 1.0
*/
public ParserConfigurationException(String msg) {
super(msg);
diff --git a/xml/src/main/java/javax/xml/parsers/SAXParser.java b/xml/src/main/java/javax/xml/parsers/SAXParser.java
index bbee754..73cc0eb 100644
--- a/xml/src/main/java/javax/xml/parsers/SAXParser.java
+++ b/xml/src/main/java/javax/xml/parsers/SAXParser.java
@@ -25,89 +25,110 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
+import java.io.BufferedInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
- * Provides a wrapper around a SAX XMLReader. This abstract class only defines
- * the interface, whereas the SAXParserFactory class is used to obtain instances
- * of concrete subclasses.
+ * Provides a wrapper around a SAX {@link XMLReader}. This abstract
+ * class only defines the interface, whereas the {@link SAXParserFactory} class
+ * is used to obtain instances of concrete subclasses.
+ *
+ * @since Android 1.0
*/
public abstract class SAXParser extends java.lang.Object {
/**
* Do-nothing constructor. Prevents instantiation. To be overridden by
* concrete subclasses.
+ *
+ * @since Android 1.0
*/
protected SAXParser() {
// Does nothing.
}
/**
- * Queries the underlying SAX Parser object.
+ * Queries the underlying SAX {@link Parser} object.
+ *
+ * @return the SAX {@code Parser}.
*
- * @return The SAX Parser.
+ * @throws SAXException if a problem occurs.
*
- * @throws org.xml.sax.SAXException if a problem occurs.
+ * @since Android 1.0
*/
- public abstract org.xml.sax.Parser getParser()
- throws org.xml.sax.SAXException;
+ public abstract Parser getParser()
+ throws SAXException;
/**
- * Queries a property of the underlying SAX XMLReader.
+ * Queries a property of the underlying SAX {@link XMLReader}.
+ *
+ * @param name the name of the property.
+ * @return the value of the property.
*
- * @param name The name of the property.
- * @return The value of the property.
+ * @throws SAXNotRecognizedException if the property is not known to the
+ * underlying SAX {@code XMLReader}.
+ * @throws SAXNotSupportedException if the property is known, but not
+ * supported by the underlying SAX {@code XMLReader}.
*
- * @throws SAXNotRecognizedException If the property is not known to the
- * underlying SAX XMLReader.
- * @throws SAXNotSupportedException If the property is known, but not
- * supported by the underlying SAX XMLReader.
+ * @since Android 1.0
*/
public abstract Object getProperty(String name)
throws SAXNotRecognizedException, SAXNotSupportedException;
- /**
- * Queries the XML Schema used by the underlying XMLReader.
- *
- * @return The XML Schema.
- */
- // TODO Do we want the validation package in?
- // public Schema getSchema() {
- // return schema;
- // }
+// TODO No XSchema support in Android 1.0. Maybe later.
+// /**
+// * Queries the XML Schema used by the underlying XMLReader.
+// *
+// * @return The XML Schema.
+// */
+// public Schema getSchema() {
+// return schema;
+// }
/**
* Queries the underlying SAX XMLReader object.
*
- * @return The SAX XMLREader.
+ * @return the SAX XMLREader.
*
- * @throws org.xml.sax.SAXException if a problem occurs.
+ * @throws SAXException if a problem occurs.
+ *
+ * @since Android 1.0
*/
public abstract XMLReader getXMLReader() throws SAXException;
/**
- * Reflects whether this SAXParser is namespace-aware.
+ * Reflects whether this {@code SAXParser} is namespace-aware.
+ *
+ * @return {@code true} if the {@code SAXParser} is namespace-aware, or
+ * {@code false} otherwise.
*
- * @return true if the SAXParser is namespace-aware, or false otherwise.
+ * @since Android 1.0
*/
public abstract boolean isNamespaceAware();
/**
- * Reflects whether this SAXParser is validating.
+ * Reflects whether this {@code SAXParser} is validating.
+ *
+ * @return {@code true} if the {@code SAXParser} is validating, or {@code
+ * false} otherwise.
*
- * @return true if the SAXParser is validating, or false otherwise.
+ * @since Android 1.0
*/
public abstract boolean isValidating();
/**
- * Reflects whether this SAXParser is XInclude-aware.
+ * Reflects whether this {@code SAXParser} is XInclude-aware.
*
- * @return true if the SAXParser is XInclude-aware, or false otherwise.
+ * @return {@code true} if the {@code SAXParser} is XInclude-aware, or
+ * {@code false} otherwise.
*
* @throws UnsupportedOperationException if the underlying implementation
* doesn't know about XInclude at all (backwards compatibility).
+ *
+ * @since Android 1.0
*/
public boolean isXIncludeAware() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
@@ -116,11 +137,13 @@ public abstract class SAXParser extends java.lang.Object {
/**
* Parses the given XML file using the given SAX event handler.
*
- * @param file The file.
- * @param handler The SAX handler.
+ * @param file the file containing the XML document.
+ * @param handler the SAX handler.
+ *
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(File file, HandlerBase handler) throws SAXException,
IOException {
@@ -137,11 +160,13 @@ public abstract class SAXParser extends java.lang.Object {
/**
* Parses the given XML file using the given SAX event handler.
*
- * @param file The file.
- * @param handler The SAX handler.
+ * @param file the file containing the XML document.
+ * @param handler the SAX handler.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
+ *
+ * @since Android 1.0
*/
public void parse(File file, DefaultHandler handler) throws SAXException,
IOException {
@@ -158,11 +183,13 @@ public abstract class SAXParser extends java.lang.Object {
/**
* Parses the given XML InputStream using the given SAX event handler.
*
- * @param stream The InputStream.
- * @param handler The SAX handler.
+ * @param stream the InputStream containing the XML document.
+ * @param handler the SAX handler.
+ *
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(InputStream stream, HandlerBase handler)
throws SAXException, IOException {
@@ -176,12 +203,14 @@ public abstract class SAXParser extends java.lang.Object {
* Parses the given XML InputStream using the given SAX event handler and
* system ID.
*
- * @param stream The InputStream.
- * @param handler The SAX handler.
- * @param systemId The system ID.
+ * @param stream the InputStream containing the XML document.
+ * @param handler the SAX handler.
+ * @param systemId the system ID.
+ *
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(InputStream stream, HandlerBase handler, String systemId)
throws SAXException, IOException {
@@ -198,11 +227,13 @@ public abstract class SAXParser extends java.lang.Object {
/**
* Parses the given XML InputStream using the given SAX event handler.
*
- * @param stream The InputStream.
- * @param handler The SAX handler.
+ * @param stream the InputStream containing the XML document.
+ * @param handler the SAX handler.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
+ *
+ * @since Android 1.0
*/
public void parse(InputStream stream, DefaultHandler handler)
throws SAXException, IOException {
@@ -213,12 +244,14 @@ public abstract class SAXParser extends java.lang.Object {
* Parses the given XML InputStream using the given SAX event handler and
* system ID.
*
- * @param stream The InputStream.
- * @param handler The SAX handler.
- * @param systemId The system ID.
+ * @param stream the InputStream containing the XML document.
+ * @param handler the SAX handler.
+ * @param systemId the system ID.
+ *
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(InputStream stream, DefaultHandler handler,
String systemId) throws SAXException, IOException {
@@ -235,11 +268,13 @@ public abstract class SAXParser extends java.lang.Object {
/**
* Parses the contents of the given URI using the given SAX event handler.
*
- * @param uri The URI.
- * @param handler The SAX handler.
+ * @param uri the URI pointing to the XML document.
+ * @param handler the SAX handler.
+ *
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(String uri, HandlerBase handler) throws SAXException,
IOException {
@@ -252,11 +287,13 @@ public abstract class SAXParser extends java.lang.Object {
/**
* Parses the contents of the given URI using the given SAX event handler.
*
- * @param uri The URI.
- * @param handler The SAX handler.
+ * @param uri the URI pointing to the XML document.
+ * @param handler the SAX handler.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
+ *
+ * @since Android 1.0
*/
public void parse(String uri, DefaultHandler handler) throws SAXException,
IOException {
@@ -267,13 +304,16 @@ public abstract class SAXParser extends java.lang.Object {
}
/**
- * Parses the given SAX InputSource using the given SAX event handler.
+ * Parses the given SAX {@link InputSource} using the given SAX event
+ * handler.
+ *
+ * @param source the SAX {@code InputSource} containing the XML document.
+ * @param handler the SAX handler.
*
- * @param source The SAX InputSource.
- * @param handler The SAX handler.
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(InputSource source, HandlerBase handler)
throws SAXException, IOException {
@@ -293,13 +333,16 @@ public abstract class SAXParser extends java.lang.Object {
}
/**
- * Parses the given SAX InputSource using the given SAX event handler.
+ * Parses the given SAX {@link InputSource} using the given SAX event
+ * handler.
+ *
+ * @param source the SAX {@code InputSource} containing the XML document.
+ * @param handler the SAX handler.
*
- * @param source The SAX HandlerBase.
- * @param handler The SAX handler.
+ * @throws SAXException if a problem occurs during SAX parsing.
+ * @throws IOException if a general IO problem occurs.
*
- * @throws SAXException If a problem occurs during SAX parsing.
- * @throws IOException If a general IO problem occurs.
+ * @since Android 1.0
*/
public void parse(InputSource source, DefaultHandler handler)
throws SAXException, IOException {
@@ -319,23 +362,27 @@ public abstract class SAXParser extends java.lang.Object {
}
/**
- * Resets the DocumentBuilder to the same state is was in after its
+ * Resets the {@code SAXParser} to the same state is was in after its
* creation.
+ *
+ * @since Android 1.0
*/
public void reset() {
// Do nothing.
}
/**
- * Sets a property of the underlying SAX XMLReader.
+ * Sets a property of the underlying SAX {@link XMLReader}.
+ *
+ * @param name the name of the property.
+ * @param value the value of the property.
*
- * @param name The name of the property.
- * @param value The value of the property.
+ * @throws SAXNotRecognizedException if the property is not known to the
+ * underlying SAX {@code XMLReader}.
+ * @throws SAXNotSupportedException if the property is known, but not
+ * supported by the underlying SAX {@code XMLReader}.
*
- * @throws SAXNotRecognizedException If the property is not known to the
- * underlying SAX XMLReader.
- * @throws SAXNotSupportedException If the property is known, but not
- * supported by the underlying SAX XMLReader.
+ * @since Android 1.0
*/
public abstract void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException;
diff --git a/xml/src/main/java/javax/xml/parsers/SAXParserFactory.java b/xml/src/main/java/javax/xml/parsers/SAXParserFactory.java
index 435b89c..ebf0531 100644
--- a/xml/src/main/java/javax/xml/parsers/SAXParserFactory.java
+++ b/xml/src/main/java/javax/xml/parsers/SAXParserFactory.java
@@ -23,10 +23,12 @@ import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXException;
/**
- * Provides a factory for SAXParser instances. The class first needs to be
- * instantiated using the newInstance() method. The instance can be
- * configured as desired. A call to newSAXParser() then provides a SAXParser
- * instance matching this configuration.
+ * Provides a factory for {@link SAXParser} instances. The class first needs to
+ * be instantiated using the {@link #newInstance()} method. The instance can be
+ * configured as desired. A call to its {@link #newSAXParser()} then provides a
+ * {@code SAXParser} instance matching this configuration, if possible.
+ *
+ * @since Android 1.0
*/
public abstract class SAXParserFactory {
@@ -39,6 +41,8 @@ public abstract class SAXParserFactory {
/**
* Do-nothing constructor. Prevents instantiation. To be overridden by
* concrete subclasses.
+ *
+ * @since Android 1.0
*/
protected SAXParserFactory() {
// Does nothing.
@@ -48,7 +52,8 @@ public abstract class SAXParserFactory {
* Queries a feature from the underlying implementation.
*
* @param name The name of the feature. The default Android implementation
- * of SAXParser supports only the following three features:
+ * of {@link SAXParser} supports only the following three
+ * features:
*
* <dl>
* <dt>{@code http://xml.org/sax/features/namespaces}</dt>
@@ -69,35 +74,40 @@ public abstract class SAXParserFactory {
* namespace prefixes can be enabled, but not both at the same
* time.
*
- * @return The status of the feature.
+ * @return the status of the feature.
*
- * @throws ParserConfigurationException if no SAXParser matching the given
- * criteria is available.
- * @throws SAXNotRecognizedException If the given feature is not known to
+ * @throws ParserConfigurationException if no {@code SAXParser} matching the
+ * given criteria is available.
+ * @throws SAXNotRecognizedException if the given feature is not known to
* the underlying implementation.
- * @throws SAXNotSupportedException If the given features is known, but not
+ * @throws SAXNotSupportedException if the given features is known, but not
* supported by the underlying implementation.
+ *
+ * @since Android 1.0
*/
public abstract boolean getFeature(String name)
throws ParserConfigurationException, SAXNotRecognizedException,
SAXNotSupportedException;
- /**
- * Queries the desired XML Schema object.
- *
- * @return The XML Schema object, if it has been set by a call to setSchema,
- * or null otherwise.
- */
- // TODO Do we want the validation package in?
- // public javax.xml.validation.Schema getSchema() {
- // return schema;
- // }
+// TODO No XSchema support in Android 1.0. Maybe later.
+// /**
+// * Queries the desired XML Schema object.
+// *
+// * @return The XML Schema object, if it has been set by a call to setSchema,
+// * or null otherwise.
+// */
+// public javax.xml.validation.Schema getSchema() {
+// return schema;
+// }
/**
* Queries whether the factory is configured to deliver parsers that are
* namespace-aware.
*
- * @return true if namespace-awareness is desired, false otherwise.
+ * @return {@code true} if namespace-awareness is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isNamespaceAware() {
return namespaceAware;
@@ -107,7 +117,9 @@ public abstract class SAXParserFactory {
* Queries whether the factory is configured to deliver parsers that are
* validating.
*
- * @return true if validating is desired, false otherwise.
+ * @return {@code true} if validating is desired, {@code false} otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isValidating() {
return validating;
@@ -117,19 +129,30 @@ public abstract class SAXParserFactory {
* Queries whether the factory is configured to deliver parsers that are
* XInclude-aware.
*
- * @return true if XInclude-awareness is desired, false otherwise.
+ * @return {@code true} if XInclude-awareness is desired, {@code false}
+ * otherwise.
+ *
+ * @since Android 1.0
*/
public boolean isXIncludeAware() {
throw new UnsupportedOperationException();
}
/**
- * Creates a new SAXParserFactory that can be configured and then be used
- * for creating SAXPArser objects.
+ * Creates a new {@code SAXParserFactory} that can be configured and then be
+ * used for creating {@link SAXParser} objects. The method first checks the
+ * value of the {@code SAXParserFactory} property. If this
+ * is non-{@code null}, it is assumed to be the name of a class that serves
+ * as the factory. The class is instantiated, and the instance is returned.
+ * If the property value is {@code null}, the system's default factory
+ * implementation is returned.
*
- * @return The SAXParserFactory.
+ * @return the {@code SAXParserFactory}.
*
- * @throws FactoryConfigurationError If no SAXParserFactory can be created.
+ * @throws FactoryConfigurationError if no {@code SAXParserFactory} can be
+ * created.
+ *
+ * @since Android 1.0
*/
public static SAXParserFactory newInstance()
throws FactoryConfigurationError {
@@ -154,13 +177,17 @@ public abstract class SAXParserFactory {
}
/**
- * Creates a new SAXParser that matches the current configuration.
+ * Creates a new {@link SAXParser} that matches the current configuration of
+ * the factory.
+ *
+ * @return the {@code SAXParser}.
*
- * @return The SAXParser.
+ * @throws ParserConfigurationException if no matching {@code SAXParser}
+ * could be found.
+ * @throws SAXException if creating the {@code SAXParser} failed due to some
+ * other reason.
*
- * @throws ParserConfigurationException if no matching SAXParser could be
- * found.
- * @throws SAXException If a problem occurs during SAX parsing.
+ * @since Android 1.0
*/
public abstract SAXParser newSAXParser()
throws ParserConfigurationException, SAXException;
@@ -168,20 +195,21 @@ public abstract class SAXParserFactory {
/**
* Sets a feature in the underlying implementation.
*
- * @param name The name of the feature. The default Android implementation
- * of SAXParser supports only the following three features:
+ * @param name the name of the feature. The default Android implementation
+ * of {@link SAXParser} supports only the following three
+ * features:
*
* <dl>
* <dt>{@code http://xml.org/sax/features/namespaces}</dt>
- * <dd>Queries the state of namespace-awareness.</dd>
+ * <dd>Sets the state of namespace-awareness.</dd>
*
* <dt>
* {@code http://xml.org/sax/features/namespace-prefixes}
* </dt>
- * <dd>Queries the state of namespace prefix processing</dd>
+ * <dd>Sets the state of namespace prefix processing</dd>
*
* <dt>{@code http://xml.org/sax/features/validation}</dt>
- * <dd>Queries the state of validation.</dd>
+ * <dd>Sets the state of validation.</dd>
* </dl>
*
* Note that despite the ability to query the validation
@@ -190,14 +218,16 @@ public abstract class SAXParserFactory {
* namespace prefixes can be enabled, but not both at the same
* time.
*
- * @param value The status of the feature.
+ * @param value the status of the feature.
*
- * @throws ParserConfigurationException if no SAXParser matching the given
- * criteria is available.
- * @throws SAXNotRecognizedException If the given feature is not known to
+ * @throws ParserConfigurationException if no {@code SAXParser} matching
+ * the given criteria is available.
+ * @throws SAXNotRecognizedException if the given feature is not known to
* the underlying implementation.
- * @throws SAXNotSupportedException If the given features is known, but not
+ * @throws SAXNotSupportedException if the given features is known, but not
* supported by the underlying implementation.
+ *
+ * @since Android 1.0
*/
public abstract void setFeature(String name, boolean value)
throws ParserConfigurationException, SAXNotRecognizedException,
@@ -207,26 +237,31 @@ public abstract class SAXParserFactory {
* Determines whether the factory is configured to deliver parsers that are
* namespace-aware.
*
- * @param value Turns namespace-awareness on or off.
+ * @param value turns namespace-awareness on or off.
+ *
+ * @since Android 1.0
*/
public void setNamespaceAware(boolean value) {
namespaceAware = value;
}
- /**
- * Sets the desired XML Schema object.
- *
- * @param schema The XML Schema object.
- */
- // TODO Do we want the validation package in?
- // public void setSchema(Schema schema) {
- // this.schema = schema;
- // }
+// TODO No XSchema support in Android 1.0. Maybe later.
+// /**
+// * Sets the desired XML Schema object.
+// *
+// * @param schema The XML Schema object.
+// */
+// public void setSchema(Schema schema) {
+// this.schema = schema;
+// }
+
/**
* Determines whether the factory is configured to deliver parsers that are
* validating.
*
- * @param value Turns validation on or off.
+ * @param value turns validation on or off.
+ *
+ * @since Android 1.0
*/
public void setValidating(boolean value) {
validating = value;
@@ -236,7 +271,9 @@ public abstract class SAXParserFactory {
* Determines whether the factory is configured to deliver parsers that are
* XInclude-aware.
*
- * @param value Turns XInclude-awareness on or off.
+ * @param value turns XInclude-awareness on or off.
+ *
+ * @since Android 1.0
*/
public void setXIncludeAware(boolean value) {
throw new UnsupportedOperationException();
diff --git a/xml/src/main/java/javax/xml/parsers/package.html b/xml/src/main/java/javax/xml/parsers/package.html
index 1522e5a..7e0921d 100644
--- a/xml/src/main/java/javax/xml/parsers/package.html
+++ b/xml/src/main/java/javax/xml/parsers/package.html
@@ -19,5 +19,6 @@
various DOM classes might differ from other implementations and (b)
requesting a validating parser will always fail.
</p>
+ @since Android 1.0
</body>
</html> \ No newline at end of file
diff --git a/xml/src/main/java/org/kxml2/io/KXmlParser.java b/xml/src/main/java/org/kxml2/io/KXmlParser.java
index 8125745..0727bc7 100644
--- a/xml/src/main/java/org/kxml2/io/KXmlParser.java
+++ b/xml/src/main/java/org/kxml2/io/KXmlParser.java
@@ -45,7 +45,7 @@ public class KXmlParser implements XmlPullParser {
private boolean processNsp;
private boolean relaxed;
- private HashMap entityMap;
+ private Hashtable entityMap;
private int depth;
private String[] elementStack = new String[16];
private String[] nspStack = new String[8];
@@ -95,10 +95,12 @@ public class KXmlParser implements XmlPullParser {
private boolean token;
public KXmlParser() {
-// srcBuf = new char[Runtime.getRuntime().freeMemory() >= 1048576 ? 8192 : 128];
-
- // XXX: We don't have a Runtime class at this time.
+ // BEGIN android-changed
+ // We don't have a Runtime class at this time.
+ // srcBuf =
+ // new char[Runtime.getRuntime().freeMemory() >= 1048576 ? 8192 : 128];
srcBuf = new char[8192];
+ // END android-changed
}
private final boolean isProp(String n1, boolean prop, String n2) {
@@ -964,7 +966,7 @@ public class KXmlParser implements XmlPullParser {
peekCount = 0;
depth = 0;
- entityMap = new HashMap();
+ entityMap = new Hashtable();
entityMap.put("amp", "&");
entityMap.put("apos", "'");
entityMap.put("gt", ">");
diff --git a/xml/src/main/java/org/kxml2/kdom/Element.java b/xml/src/main/java/org/kxml2/kdom/Element.java
index 61d5111..6a5777b 100644
--- a/xml/src/main/java/org/kxml2/kdom/Element.java
+++ b/xml/src/main/java/org/kxml2/kdom/Element.java
@@ -34,9 +34,9 @@ public class Element extends Node {
protected String namespace;
protected String name;
- protected ArrayList attributes;
+ protected Vector attributes;
protected Node parent;
- protected ArrayList prefixes;
+ protected Vector prefixes;
public Element() {
}
@@ -81,24 +81,22 @@ public class Element extends Node {
}
public String getAttributeNamespace (int index) {
- return ((String []) attributes.get(index)) [0];
+ return ((String []) attributes.elementAt (index)) [0];
}
+/* public String getAttributePrefix (int index) {
+ return ((String []) attributes.elementAt (index)) [1];
+ }*/
+
public String getAttributeName (int index) {
- return ((String []) attributes.get(index)) [1];
+ return ((String []) attributes.elementAt (index)) [1];
}
public String getAttributeValue (int index) {
- return ((String []) attributes.get(index)) [2];
+ return ((String []) attributes.elementAt (index)) [2];
}
-
- public String
- getAttributeValue(String name)
- {
- return getAttributeValue(null, name);
- }
public String getAttributeValue (String namespace, String name) {
for (int i = 0; i < getAttributeCount (); i++) {
@@ -165,11 +163,11 @@ public class Element extends Node {
public String getNamespacePrefix (int i) {
- return ((String []) prefixes.get(i)) [0];
+ return ((String []) prefixes.elementAt (i)) [0];
}
public String getNamespaceUri (int i) {
- return ((String []) prefixes.get(i)) [1];
+ return ((String []) prefixes.elementAt (i)) [1];
}
@@ -240,18 +238,18 @@ public class Element extends Node {
public void setAttribute (String namespace, String name, String value) {
if (attributes == null)
- attributes = new ArrayList();
+ attributes = new Vector ();
if (namespace == null)
namespace = "";
for (int i = attributes.size()-1; i >=0; i--){
- String[] attribut = (String[]) attributes.get(i);
+ String[] attribut = (String[]) attributes.elementAt(i);
if (attribut[0].equals(namespace) &&
attribut[1].equals(name)){
if (value == null) {
- attributes.remove(i);
+ attributes.removeElementAt(i);
}
else {
attribut[2] = value;
@@ -260,7 +258,8 @@ public class Element extends Node {
}
}
- attributes.add(new String[] {namespace, name, value});
+ attributes.addElement
+ (new String [] {namespace, name, value});
}
@@ -269,8 +268,8 @@ public class Element extends Node {
* prefix */
public void setPrefix (String prefix, String namespace) {
- if (prefixes == null) prefixes = new ArrayList();
- prefixes.add(new String [] {prefix, namespace});
+ if (prefixes == null) prefixes = new Vector ();
+ prefixes.addElement (new String [] {prefix, namespace});
}
diff --git a/xml/src/main/java/org/kxml2/kdom/Node.java b/xml/src/main/java/org/kxml2/kdom/Node.java
index 4855893..a3cc78d 100644
--- a/xml/src/main/java/org/kxml2/kdom/Node.java
+++ b/xml/src/main/java/org/kxml2/kdom/Node.java
@@ -38,7 +38,7 @@ public class Node { //implements XmlIO{
public static final int COMMENT = 9;
public static final int DOCDECL = 10;
- protected ArrayList children;
+ protected Vector children;
protected StringBuffer types;
/** inserts the given child object of the given type at the
@@ -50,7 +50,7 @@ public class Node { //implements XmlIO{
throw new NullPointerException();
if (children == null) {
- children = new ArrayList();
+ children = new Vector();
types = new StringBuffer();
}
@@ -63,7 +63,7 @@ public class Node { //implements XmlIO{
else if (!(child instanceof String))
throw new RuntimeException("String expected");
- children.add(index, child);
+ children.insertElementAt(child, index);
types.insert(index, (char) type);
}
@@ -94,7 +94,7 @@ public class Node { //implements XmlIO{
types, a String is returned. */
public Object getChild(int index) {
- return children.get(index);
+ return children.elementAt(index);
}
/** Returns the number of child objects */
@@ -272,7 +272,7 @@ public class Node { //implements XmlIO{
/** Removes the child object at the given index */
public void removeChild(int idx) {
- children.remove(idx);
+ children.removeElementAt(idx);
/*** Modification by HHS - start ***/
// types.deleteCharAt (index);
@@ -324,7 +324,7 @@ public class Node { //implements XmlIO{
for (int i = 0; i < len; i++) {
int type = getType(i);
- Object child = children.get(i);
+ Object child = children.elementAt(i);
switch (type) {
case ELEMENT :
((Element) child).write(writer);
diff --git a/xml/src/main/java/org/kxml2/wap/WbxmlParser.java b/xml/src/main/java/org/kxml2/wap/WbxmlParser.java
index c3852eb..617e1d4 100644
--- a/xml/src/main/java/org/kxml2/wap/WbxmlParser.java
+++ b/xml/src/main/java/org/kxml2/wap/WbxmlParser.java
@@ -20,7 +20,7 @@
// Contributors: Bjorn Aadland, Chris Bartley, Nicola Fankhauser,
// Victor Havin, Christian Kurzke, Bogdan Onoiu,
-// Jain Sanjay, David Santoro.
+// Elias Ross, Jain Sanjay, David Santoro.
package org.kxml2.wap;
@@ -32,6 +32,11 @@ import org.xmlpull.v1.*;
public class WbxmlParser implements XmlPullParser {
+
+ static final String HEX_DIGITS = "0123456789abcdef";
+
+ /** Parser event type for Wbxml-specific events. The Wbxml event code can be
+ * accessed with getWapCode() */
public static final int WAP_EXTENSION = 64;
@@ -64,9 +69,8 @@ public class WbxmlParser implements XmlPullParser {
private Vector tables = new Vector();
- int version;
- int publicIdentifierId;
- int charSet;
+ private int version;
+ private int publicIdentifierId;
// StartTag current;
// ParseEvent next;
@@ -75,16 +79,15 @@ public class WbxmlParser implements XmlPullParser {
private String namespace;
private String name;
private String text;
- // private String encoding;
+
private Object wapExtensionData;
- private int wapExtensionCode;
+ private int wapCode;
private int type;
- private int codePage;
private boolean degenerated;
private boolean isWhitespace;
- private String encoding = null;
+ private String encoding;
public boolean getFeature(String feature) {
if (XmlPullParser
@@ -96,7 +99,6 @@ public class WbxmlParser implements XmlPullParser {
}
public String getInputEncoding() {
- // should return someting depending on charSet here!!!!!
return encoding;
}
@@ -315,6 +317,10 @@ public class WbxmlParser implements XmlPullParser {
return type;
}
+
+ // TODO: Reuse resolveWapExtension here? Raw Wap extensions would still be accessible
+ // via nextToken(); ....?
+
public int next() throws XmlPullParserException, IOException {
isWhitespace = true;
@@ -338,6 +344,7 @@ public class WbxmlParser implements XmlPullParser {
switch(peekId()) {
case Wbxml.ENTITY:
case Wbxml.STR_I:
+ case Wbxml.STR_T:
case Wbxml.LITERAL:
case Wbxml.LITERAL_C:
case Wbxml.LITERAL_A:
@@ -408,7 +415,7 @@ public class WbxmlParser implements XmlPullParser {
|| (namespace != null && !namespace.equals(getNamespace()))
|| (name != null && !name.equals(getName())))
exception(
- "expected: " + TYPES[type] + " {" + namespace + "}" + name);
+ "expected: " + (type == WAP_EXTENSION ? "WAP Ext." : (TYPES[type] + " {" + namespace + "}" + name)));
}
@@ -698,7 +705,10 @@ public class WbxmlParser implements XmlPullParser {
case Wbxml.EXT_1 :
case Wbxml.EXT_2 :
case Wbxml.OPAQUE :
- parseWapExtension(id);
+
+ type = WAP_EXTENSION;
+ wapCode = id;
+ wapExtensionData = parseWapExtension(id);
break;
case Wbxml.PI :
@@ -722,48 +732,42 @@ public class WbxmlParser implements XmlPullParser {
// return next;
}
+ /** Overwrite this method to intercept all wap events */
-
- public void parseWapExtension(int id)
- throws IOException, XmlPullParserException {
-
- type = WAP_EXTENSION;
- wapExtensionCode = id;
+ public Object parseWapExtension(int id) throws IOException, XmlPullParserException {
switch (id) {
case Wbxml.EXT_I_0 :
case Wbxml.EXT_I_1 :
case Wbxml.EXT_I_2 :
- wapExtensionData = readStrI();
- break;
+ return readStrI();
case Wbxml.EXT_T_0 :
case Wbxml.EXT_T_1 :
case Wbxml.EXT_T_2 :
- wapExtensionData = new Integer(readInt());
- break;
+ return new Integer(readInt());
case Wbxml.EXT_0 :
case Wbxml.EXT_1 :
case Wbxml.EXT_2 :
- break;
+ return null;
case Wbxml.OPAQUE :
{
- int len = readInt();
- byte[] buf = new byte[len];
+ int count = readInt();
+ byte[] buf = new byte[count];
- for (int i = 0;
- i < len;
- i++) // enhance with blockread!
- buf[i] = (byte) readByte();
+ while(count > 0){
+ count -= in.read(buf, buf.length-count, count);
+ }
- wapExtensionData = buf;
+ return buf;
} // case OPAQUE
- break;
+
default:
exception("illegal id: "+id);
+ return null; // dead code
} // SWITCH
}
@@ -824,20 +828,8 @@ public class WbxmlParser implements XmlPullParser {
case Wbxml.EXT_1 :
case Wbxml.EXT_2 :
case Wbxml.OPAQUE :
-
- throw new RuntimeException("wap extension in attr not supported yet");
-
- /*
- ParseEvent e = parseWapExtension(id);
- if (!(e.getType() != Xml.TEXT
- && e.getType() != Xml.WHITESPACE))
- throw new RuntimeException("parse WapExtension must return Text Event in order to work inside Attributes!");
-
- value.append(e.getText());
-
- //value.append (handleExtension (id)); // skip EXT in ATTR
- //break;
- */
+ value.append(resolveWapExtension(id, parseWapExtension(id)));
+ break;
case Wbxml.STR_T :
value.append(readStrT());
@@ -869,19 +861,39 @@ public class WbxmlParser implements XmlPullParser {
return nextId;
}
+ /** overwrite for own WAP extension handling in attributes and high level parsing
+ * (above nextToken() level) */
-
+ protected String resolveWapExtension(int id, Object data){
+
+ if(data instanceof byte[]){
+ StringBuffer sb = new StringBuffer();
+ byte[] b = (byte[]) data;
+
+ for (int i = 0; i < b.length; i++) {
+ sb.append(HEX_DIGITS.charAt((b[i] >> 4) & 0x0f));
+ sb.append(HEX_DIGITS.charAt(b[i] & 0x0f));
+ }
+ return sb.toString();
+ }
+
+ return "$("+data+")";
+ }
String resolveId(String[] tab, int id) throws IOException {
int idx = (id & 0x07f) - 5;
- if (idx == -1)
+ if (idx == -1){
+ wapCode = -1;
return readStrT();
+ }
if (idx < 0
|| tab == null
|| idx >= tab.length
|| tab[idx] == null)
throw new IOException("id " + id + " undef.");
+ wapCode = idx+5;
+
return tab[idx];
}
@@ -1022,7 +1034,7 @@ public class WbxmlParser implements XmlPullParser {
}
/** Sets the attribute start Table for a given page.
- * The first string in the array defines attribute
+ * The first string in the array defines attribute
* 5, the second attribute 6 etc. Please use the
* character '=' (without quote!) as delimiter
* between the attribute name and the (start of the) value
@@ -1036,7 +1048,7 @@ public class WbxmlParser implements XmlPullParser {
}
/** Sets the attribute value Table for a given page.
- * The first string in the array defines attribute value 0x85,
+ * The first string in the array defines attribute value 0x85,
* the second attribute value 0x86 etc.
*/
@@ -1047,4 +1059,17 @@ public class WbxmlParser implements XmlPullParser {
setTable(page, ATTR_VALUE_TABLE, table);
}
+ /** Returns the token ID for start tags or the event type for wap proprietary events
+ * such as OPAQUE.
+ */
+
+ public int getWapCode(){
+ return wapCode;
+ }
+
+ public Object getWapExtensionData(){
+ return wapExtensionData;
+ }
+
+
}
diff --git a/xml/src/main/java/org/kxml2/wap/WbxmlSerializer.java b/xml/src/main/java/org/kxml2/wap/WbxmlSerializer.java
index e4447b0..8c1b598 100644
--- a/xml/src/main/java/org/kxml2/wap/WbxmlSerializer.java
+++ b/xml/src/main/java/org/kxml2/wap/WbxmlSerializer.java
@@ -18,7 +18,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE. */
-//Contributors: Bogdan Onoiu (Genderal character encoding abstraction and UTF-8 Support)
+//Contributors: Jonathan Cox, Bogdan Onoiu, Jerry Tian
package org.kxml2.wap;
@@ -38,6 +38,7 @@ import org.xmlpull.v1.*;
public class WbxmlSerializer implements XmlSerializer {
+
Hashtable stringTable = new Hashtable();
OutputStream out;
@@ -58,7 +59,7 @@ public class WbxmlSerializer implements XmlSerializer {
private int attrPage;
private int tagPage;
- private String encoding = null;
+ private String encoding;
public XmlSerializer attribute(String namespace, String name, String value) {
@@ -137,7 +138,7 @@ public class WbxmlSerializer implements XmlSerializer {
/** ATTENTION: flush cannot work since Wbxml documents require
- need buffering. Thus, this call does nothing. */
+ buffering. Thus, this call does nothing. */
public void flush() {
}
@@ -158,12 +159,12 @@ public class WbxmlSerializer implements XmlSerializer {
? (degenerated ? Wbxml.LITERAL : Wbxml.LITERAL_C)
: (degenerated ? Wbxml.LITERAL_A : Wbxml.LITERAL_AC));
- writeStrT(pending);
+ writeStrT(pending, false);
}
else {
if(idx[0] != tagPage){
tagPage=idx[0];
- buf.write(0);
+ buf.write(Wbxml.SWITCH_PAGE);
buf.write(tagPage);
}
@@ -181,11 +182,11 @@ public class WbxmlSerializer implements XmlSerializer {
if (idx == null) {
buf.write(Wbxml.LITERAL);
- writeStrT((String) attributes.elementAt(i));
+ writeStrT((String) attributes.elementAt(i), false);
}
else {
if(idx[0] != attrPage){
- attrPage = idx[1];
+ attrPage = idx[0];
buf.write(0);
buf.write(attrPage);
}
@@ -193,12 +194,11 @@ public class WbxmlSerializer implements XmlSerializer {
}
idx = (int[]) attrValueTable.get(attributes.elementAt(++i));
if (idx == null) {
- buf.write(Wbxml.STR_I);
- writeStrI(buf, (String) attributes.elementAt(i));
+ writeStr((String) attributes.elementAt(i));
}
else {
if(idx[0] != attrPage){
- attrPage = idx[1];
+ attrPage = idx[0];
buf.write(0);
buf.write(attrPage);
}
@@ -232,8 +232,7 @@ public class WbxmlSerializer implements XmlSerializer {
public void setOutput (OutputStream out, String encoding) throws IOException {
- if (encoding != null) throw new IllegalArgumentException ("encoding not yet supported for WBXML");
-
+ this.encoding = encoding == null ? "UTF-8" : encoding;
this.out = out;
buf = new ByteArrayOutputStream();
@@ -258,12 +257,14 @@ public class WbxmlSerializer implements XmlSerializer {
out.write(0x01); // unknown or missing public identifier
// default encoding is UTF-8
- String[] encodings = { "UTF-8", "ISO-8859-1" };
- if (s == null || s.toUpperCase().equals(encodings[0])){
- encoding = encodings[0];
+
+ if(s != null){
+ encoding = s;
+ }
+
+ if (encoding.toUpperCase().equals("UTF-8")){
out.write(106);
- }else if (true == s.toUpperCase().equals(encodings[1])){
- encoding = encodings[1];
+ }else if (encoding.toUpperCase().equals("ISO-8859-1")){
out.write(0x04);
}else{
throw new UnsupportedEncodingException(s);
@@ -286,11 +287,10 @@ public class WbxmlSerializer implements XmlSerializer {
}
public XmlSerializer text(char[] chars, int start, int len) throws IOException {
-
+
checkPending(false);
- buf.write(Wbxml.STR_I);
- writeStrI(buf, new String(chars, start, len));
+ writeStr(new String(chars, start, len));
return this;
}
@@ -299,13 +299,61 @@ public class WbxmlSerializer implements XmlSerializer {
checkPending(false);
- buf.write(Wbxml.STR_I);
- writeStrI(buf, text);
+ writeStr(text);
return this;
}
+ /** Used in text() and attribute() to write text */
+
+ private void writeStr(String text) throws IOException{
+ int p0 = 0;
+ int lastCut = 0;
+ int len = text.length();
+
+ while(p0 < len){
+ while(p0 < len && text.charAt(p0) < 'A' ){ // skip interpunctation
+ p0++;
+ }
+ int p1 = p0;
+ while(p1 < len && text.charAt(p1) >= 'A'){
+ p1++;
+ }
+
+ if(p1 - p0 > 10) {
+
+ if(p0 > lastCut && text.charAt(p0-1) == ' '
+ && stringTable.get(text.substring(p0, p1)) == null){
+
+ buf.write(Wbxml.STR_T);
+ writeStrT(text.substring(lastCut, p1), false);
+ }
+ else {
+
+ if(p0 > lastCut && text.charAt(p0-1) == ' '){
+ p0--;
+ }
+
+ if(p0 > lastCut){
+ buf.write(Wbxml.STR_T);
+ writeStrT(text.substring(lastCut, p0), false);
+ }
+ buf.write(Wbxml.STR_T);
+ writeStrT(text.substring(p0, p1), true);
+ }
+ lastCut = p1;
+ }
+ p0 = p1;
+ }
+
+ if(lastCut < len){
+ buf.write(Wbxml.STR_T);
+ writeStrT(text.substring(lastCut, len), false);
+ }
+ }
+
+
public XmlSerializer endTag(String namespace, String name) throws IOException {
@@ -321,9 +369,39 @@ public class WbxmlSerializer implements XmlSerializer {
return this;
}
- /** currently ignored! */
+ /**
+ * @throws IOException */
- public void writeLegacy(int type, String data) {
+ public void writeWapExtension(int type, Object data) throws IOException {
+ checkPending(false);
+ buf.write(type);
+ switch(type){
+ case Wbxml.EXT_0:
+ case Wbxml.EXT_1:
+ case Wbxml.EXT_2:
+ break;
+
+ case Wbxml.OPAQUE:
+ byte[] bytes = (byte[]) data;
+ writeInt(buf, bytes.length);
+ buf.write(bytes);
+ break;
+
+ case Wbxml.EXT_I_0:
+ case Wbxml.EXT_I_1:
+ case Wbxml.EXT_I_2:
+ writeStrI(buf, (String) data);
+ break;
+
+ case Wbxml.EXT_T_0:
+ case Wbxml.EXT_T_1:
+ case Wbxml.EXT_T_2:
+ writeStrT((String) data, false);
+ break;
+
+ default:
+ throw new IllegalArgumentException();
+ }
}
// ------------- internal methods --------------------------
@@ -344,25 +422,43 @@ public class WbxmlSerializer implements XmlSerializer {
out.write(buf[0]);
}
- static void writeStrI(OutputStream out, String s) throws IOException {
- for (int i = 0; i < s.length(); i++) {
- out.write((byte) s.charAt(i));
- }
+ void writeStrI(OutputStream out, String s) throws IOException {
+ byte[] data = s.getBytes(encoding);
+ out.write(data);
out.write(0);
}
- void writeStrT(String s) throws IOException {
+ private final void writeStrT(String s, boolean mayPrependSpace) throws IOException {
Integer idx = (Integer) stringTable.get(s);
- if (idx == null) {
- idx = new Integer(stringTableBuf.size());
- stringTable.put(s, idx);
+ if (idx != null) {
+ writeInt(buf, idx.intValue());
+ }
+ else{
+ int i = stringTableBuf.size();
+ if(s.charAt(0) >= '0' && mayPrependSpace){
+ s = ' ' + s;
+ writeInt(buf, i+1);
+ }
+ else{
+ writeInt(buf, i);
+ }
+
+ stringTable.put(s, new Integer(i));
+ if(s.charAt(0) == ' '){
+ stringTable.put(s.substring(1), new Integer(i+1));
+ }
+ int j = s.lastIndexOf(' ');
+ if(j > 1){
+ stringTable.put(s.substring(j), new Integer(i+j));
+ stringTable.put(s.substring(j+1), new Integer(i+j+1));
+ }
+
writeStrI(stringTableBuf, s);
stringTableBuf.flush();
}
- writeInt(buf, idx.intValue());
}
/**
@@ -371,9 +467,7 @@ public class WbxmlSerializer implements XmlSerializer {
*/
public void setTagTable(int page, String[] tagTable) {
- // clear entries in tagTable!
- if (page != 0)
- return;
+ // TODO: clear entries in tagTable?
for (int i = 0; i < tagTable.length; i++) {
if (tagTable[i] != null) {