You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/01/16 07:05:59 UTC
[camel] branch master updated: Camel-xml-io: Fixed CS
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new a654032 Camel-xml-io: Fixed CS
a654032 is described below
commit a654032f9b3cc0559107836768ac04317071904a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jan 16 08:05:29 2020 +0100
Camel-xml-io: Fixed CS
---
.../java/org/apache/camel/xml/in/BaseParser.java | 27 +-
.../java/org/apache/camel/xml/in/ModelParser.java | 6 +-
.../java/org/apache/camel/xml/io/MXParser.java | 1966 +++++++++-----------
.../org/apache/camel/xml/io/XmlPullParser.java | 878 +++++----
.../camel/xml/io/XmlPullParserException.java | 36 +-
.../org/apache/camel/xml/io/XmlStreamReader.java | 290 +--
.../camel/xml/io/XmlStreamReaderException.java | 47 +-
.../org/apache/camel/xml/in/ModelParserTest.java | 10 +-
8 files changed, 1620 insertions(+), 1640 deletions(-)
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java
index 281d6f2..d833faa 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/BaseParser.java
@@ -67,11 +67,8 @@ public class BaseParser {
this.namespace = namespace != null ? namespace : "";
}
- protected <T> T doParse(T definition,
- AttributeHandler<T> attributeHandler,
- ElementHandler<T> elementHandler,
- ValueHandler<T> valueHandler)
- throws IOException, XmlPullParserException {
+ protected <T> T doParse(T definition, AttributeHandler<T> attributeHandler, ElementHandler<T> elementHandler, ValueHandler<T> valueHandler)
+ throws IOException, XmlPullParserException {
for (int i = 0; i < parser.getAttributeCount(); i++) {
String name = parser.getAttributeName(i);
String ns = parser.getAttributeNamespace(i);
@@ -103,8 +100,7 @@ public class BaseParser {
} else if (event == XmlPullParser.END_TAG) {
return definition;
} else {
- throw new XmlPullParserException("expected START_TAG or END_TAG not "
- + XmlPullParser.TYPES[ event ], parser, null);
+ throw new XmlPullParserException("expected START_TAG or END_TAG not " + XmlPullParser.TYPES[event], parser, null);
}
}
}
@@ -157,7 +153,7 @@ public class BaseParser {
@SuppressWarnings("unchecked")
protected <T> void doAdd(T element, T[] existing, Consumer<T[]> setter) {
int len = existing != null ? existing.length : 0;
- T[] newArray = (T[]) Array.newInstance(element.getClass(), len + 1);
+ T[] newArray = (T[])Array.newInstance(element.getClass(), len + 1);
if (len > 0) {
System.arraycopy(existing, 0, newArray, 0, len);
}
@@ -192,22 +188,21 @@ public class BaseParser {
protected void expectTag(String name) throws XmlPullParserException, IOException {
if (parser.nextTag() != XmlPullParser.START_TAG) {
- throw new XmlPullParserException("Expected starting tag '{" + namespace + "}" + name + "', read ending tag '{"
- + parser.getNamespace() + "}" + parser.getName() + "' instead");
+ throw new XmlPullParserException("Expected starting tag '{" + namespace + "}" + name + "', read ending tag '{" + parser.getNamespace() + "}" + parser.getName()
+ + "' instead");
}
- if (!Objects.equals(name, parser.getName())
- || !Objects.equals(namespace, parser.getNamespace())) {
- throw new XmlPullParserException("Expected starting tag '{" + namespace + "}" + name + "', read starting tag '{"
- + parser.getNamespace() + "}" + parser.getName() + "' instead");
+ if (!Objects.equals(name, parser.getName()) || !Objects.equals(namespace, parser.getNamespace())) {
+ throw new XmlPullParserException("Expected starting tag '{" + namespace + "}" + name + "', read starting tag '{" + parser.getNamespace() + "}" + parser.getName()
+ + "' instead");
}
}
protected void handleOtherAttribute(Object definition, String name, String ns, String val) throws XmlPullParserException {
if (definition instanceof OtherAttributesAware) {
- Map<QName, Object> others = ((OtherAttributesAware) definition).getOtherAttributes();
+ Map<QName, Object> others = ((OtherAttributesAware)definition).getOtherAttributes();
if (others == null) {
others = new LinkedHashMap<>();
- ((OtherAttributesAware) definition).setOtherAttributes(others);
+ ((OtherAttributesAware)definition).setOtherAttributes(others);
}
others.put(new QName(ns, name), val);
} else {
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/ModelParser.java
index a8d9226..1b4ed77 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/ModelParser.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/in/ModelParser.java
@@ -14,9 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-//CHECKSTYLE:OFF
-
package org.apache.camel.xml.in;
import java.io.IOException;
@@ -3033,5 +3030,4 @@ public class ModelParser extends BaseParser {
default: return null;
}
}
-}
-//CHECKSTYLE:ON
+}
\ No newline at end of file
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/MXParser.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/MXParser.java
index 95c9059..c2f2b5a 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/MXParser.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/MXParser.java
@@ -44,39 +44,37 @@ import java.io.UnsupportedEncodingException;
/**
* Absolutely minimal implementation of XMLPULL V1 API
*
- * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
+ * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander
+ * Slominski</a>
*/
-public class MXParser
- implements XmlPullParser {
- //NOTE: no interning of those strings --> by Java lang spec they MUST be already interned
+public class MXParser implements XmlPullParser {
+ // NOTE: no interning of those strings --> by Java lang spec they MUST be
+ // already interned
protected final static String XML_URI = "http://www.w3.org/XML/1998/namespace";
protected final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
protected final static String FEATURE_XML_ROUNDTRIP =
- //"http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
- "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
- protected final static String FEATURE_NAMES_INTERNED =
- "http://xmlpull.org/v1/doc/features.html#names-interned";
- protected final static String PROPERTY_XMLDECL_VERSION =
- "http://xmlpull.org/v1/doc/properties.html#xmldecl-version";
- protected final static String PROPERTY_XMLDECL_STANDALONE =
- "http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone";
- protected final static String PROPERTY_XMLDECL_CONTENT =
- "http://xmlpull.org/v1/doc/properties.html#xmldecl-content";
- protected final static String PROPERTY_LOCATION =
- "http://xmlpull.org/v1/doc/properties.html#location";
+ // "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
+ "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
+ protected final static String FEATURE_NAMES_INTERNED = "http://xmlpull.org/v1/doc/features.html#names-interned";
+ protected final static String PROPERTY_XMLDECL_VERSION = "http://xmlpull.org/v1/doc/properties.html#xmldecl-version";
+ protected final static String PROPERTY_XMLDECL_STANDALONE = "http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone";
+ protected final static String PROPERTY_XMLDECL_CONTENT = "http://xmlpull.org/v1/doc/properties.html#xmldecl-content";
+ protected final static String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location";
/**
- * Implementation notice:
- * the is instance variable that controls if newString() is interning.
- * <p><b>NOTE:</b> newStringIntern <b>always</b> returns interned strings
- * and newString MAY return interned String depending on this variable.
- * <p><b>NOTE:</b> by default in this minimal implementation it is false!
+ * Implementation notice: the is instance variable that controls if
+ * newString() is interning.
+ * <p>
+ * <b>NOTE:</b> newStringIntern <b>always</b> returns interned strings and
+ * newString MAY return interned String depending on this variable.
+ * <p>
+ * <b>NOTE:</b> by default in this minimal implementation it is false!
*/
protected boolean allStringsInterned;
protected void resetStringCache() {
- //System.out.println("resetStringCache() minimum called");
+ // System.out.println("resetStringCache() minimum called");
}
protected String newString(char[] cbuf, int off, int len) {
@@ -110,10 +108,9 @@ public class MXParser
protected String elName[];
protected String elPrefix[];
protected String elUri[];
- //protected String elValue[];
+ // protected String elValue[];
protected int elNamespaceCount[];
-
/**
* Make sure that we have enough space to keep element stack if passed size.
* It will always create one additional slot then current depth
@@ -122,7 +119,8 @@ public class MXParser
final int elStackSize = elName != null ? elName.length : 0;
if ((depth + 1) >= elStackSize) {
// we add at least one extra slot ...
- final int newSize = (depth >= 7 ? 2 * depth : 8) + 2; // = lucky 7 + 1 //25
+ final int newSize = (depth >= 7 ? 2 * depth : 8) + 2; // = lucky 7 +
+ // 1 //25
if (TRACE_SIZING) {
System.err.println("TRACE_SIZING elStackSize " + elStackSize + " ==> " + newSize);
}
@@ -130,13 +128,16 @@ public class MXParser
String[] arr = null;
// reuse arr local variable slot
arr = new String[newSize];
- if (needsCopying) System.arraycopy(elName, 0, arr, 0, elStackSize);
+ if (needsCopying)
+ System.arraycopy(elName, 0, arr, 0, elStackSize);
elName = arr;
arr = new String[newSize];
- if (needsCopying) System.arraycopy(elPrefix, 0, arr, 0, elStackSize);
+ if (needsCopying)
+ System.arraycopy(elPrefix, 0, arr, 0, elStackSize);
elPrefix = arr;
arr = new String[newSize];
- if (needsCopying) System.arraycopy(elUri, 0, arr, 0, elStackSize);
+ if (needsCopying)
+ System.arraycopy(elUri, 0, arr, 0, elStackSize);
elUri = arr;
int[] iarr = new int[newSize];
@@ -148,7 +149,7 @@ public class MXParser
}
elNamespaceCount = iarr;
- //TODO: avoid using element raw name ...
+ // TODO: avoid using element raw name ...
iarr = new int[newSize];
if (needsCopying) {
System.arraycopy(elRawNameEnd, 0, iarr, 0, elStackSize);
@@ -166,36 +167,37 @@ public class MXParser
System.arraycopy(elRawName, 0, carr, 0, elStackSize);
}
elRawName = carr;
- // arr = new String[newSize];
- // if(needsCopying) System.arraycopy(elLocalName, 0, arr, 0, elStackSize);
- // elLocalName = arr;
- // arr = new String[newSize];
- // if(needsCopying) System.arraycopy(elDefaultNs, 0, arr, 0, elStackSize);
- // elDefaultNs = arr;
- // int[] iarr = new int[newSize];
- // if(needsCopying) System.arraycopy(elNsStackPos, 0, iarr, 0, elStackSize);
- // for (int i = elStackSize; i < iarr.length; i++)
- // {
- // iarr[i] = (i > 0) ? -1 : 0;
- // }
- // elNsStackPos = iarr;
- //assert depth < elName.length;
+ // arr = new String[newSize];
+ // if(needsCopying) System.arraycopy(elLocalName, 0, arr, 0,
+ // elStackSize);
+ // elLocalName = arr;
+ // arr = new String[newSize];
+ // if(needsCopying) System.arraycopy(elDefaultNs, 0, arr, 0,
+ // elStackSize);
+ // elDefaultNs = arr;
+ // int[] iarr = new int[newSize];
+ // if(needsCopying) System.arraycopy(elNsStackPos, 0, iarr, 0,
+ // elStackSize);
+ // for (int i = elStackSize; i < iarr.length; i++)
+ // {
+ // iarr[i] = (i > 0) ? -1 : 0;
+ // }
+ // elNsStackPos = iarr;
+ // assert depth < elName.length;
}
}
-
// attribute stack
protected int attributeCount;
protected String attributeName[];
protected int attributeNameHash[];
- //protected int attributeNameStart[];
- //protected int attributeNameEnd[];
+ // protected int attributeNameStart[];
+ // protected int attributeNameEnd[];
protected String attributePrefix[];
protected String attributeUri[];
protected String attributeValue[];
- //protected int attributeValueStart[];
- //protected int attributeValueEnd[];
-
+ // protected int attributeValueStart[];
+ // protected int attributeValueEnd[];
/**
* Make sure that in attributes temporary array is enough space.
@@ -211,24 +213,29 @@ public class MXParser
String[] arr = null;
arr = new String[newSize];
- if (needsCopying) System.arraycopy(attributeName, 0, arr, 0, attrPosSize);
+ if (needsCopying)
+ System.arraycopy(attributeName, 0, arr, 0, attrPosSize);
attributeName = arr;
arr = new String[newSize];
- if (needsCopying) System.arraycopy(attributePrefix, 0, arr, 0, attrPosSize);
+ if (needsCopying)
+ System.arraycopy(attributePrefix, 0, arr, 0, attrPosSize);
attributePrefix = arr;
arr = new String[newSize];
- if (needsCopying) System.arraycopy(attributeUri, 0, arr, 0, attrPosSize);
+ if (needsCopying)
+ System.arraycopy(attributeUri, 0, arr, 0, attrPosSize);
attributeUri = arr;
arr = new String[newSize];
- if (needsCopying) System.arraycopy(attributeValue, 0, arr, 0, attrPosSize);
+ if (needsCopying)
+ System.arraycopy(attributeValue, 0, arr, 0, attrPosSize);
attributeValue = arr;
if (!allStringsInterned) {
final int[] iarr = new int[newSize];
- if (needsCopying) System.arraycopy(attributeNameHash, 0, iarr, 0, attrPosSize);
+ if (needsCopying)
+ System.arraycopy(attributeNameHash, 0, iarr, 0, attrPosSize);
attributeNameHash = iarr;
}
@@ -253,48 +260,49 @@ public class MXParser
final String[] newNamespacePrefix = new String[newSize];
final String[] newNamespaceUri = new String[newSize];
if (namespacePrefix != null) {
- System.arraycopy(
- namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd);
- System.arraycopy(
- namespaceUri, 0, newNamespaceUri, 0, namespaceEnd);
+ System.arraycopy(namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd);
+ System.arraycopy(namespaceUri, 0, newNamespaceUri, 0, namespaceEnd);
}
namespacePrefix = newNamespacePrefix;
namespaceUri = newNamespaceUri;
-
if (!allStringsInterned) {
final int[] newNamespacePrefixHash = new int[newSize];
if (namespacePrefixHash != null) {
- System.arraycopy(
- namespacePrefixHash, 0, newNamespacePrefixHash, 0, namespaceEnd);
+ System.arraycopy(namespacePrefixHash, 0, newNamespacePrefixHash, 0, namespaceEnd);
}
namespacePrefixHash = newNamespacePrefixHash;
}
- //prefixesSize = newSize;
+ // prefixesSize = newSize;
// //assert nsPrefixes.length > size && nsPrefixes.length == newSize
}
}
/**
- * simplistic implementation of hash function that has <b>constant</b>
- * time to compute - so it also means diminishing hash quality for long strings
+ * simplistic implementation of hash function that has <b>constant</b> time
+ * to compute - so it also means diminishing hash quality for long strings
* but for XML parsing it should be good enough ...
*/
protected static final int fastHash(char ch[], int off, int len) {
- if (len == 0) return 0;
- //assert len >0
+ if (len == 0)
+ return 0;
+ // assert len >0
int hash = ch[off]; // hash at beginning
- //try {
+ // try {
hash = (hash << 7) + ch[off + len - 1]; // hash at the end
- //} catch(ArrayIndexOutOfBoundsException aie) {
- // aie.printStackTrace(); //should never happen ...
- // throw new RuntimeException("this is violation of pre-condition");
- //}
- if (len > 16) hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning
- if (len > 8) hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ...
- // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value
- // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ...
- //assert hash >= 0;
+ // } catch(ArrayIndexOutOfBoundsException aie) {
+ // aie.printStackTrace(); //should never happen ...
+ // throw new RuntimeException("this is violation of pre-condition");
+ // }
+ if (len > 16)
+ hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning
+ if (len > 8)
+ hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ...
+ // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8
+ // bit value
+ // so max result == 29 bits so it is quite just below 31 bits for long
+ // (2^32) ...
+ // assert hash >= 0;
return hash;
}
@@ -311,7 +319,8 @@ public class MXParser
protected void ensureEntityCapacity() {
final int entitySize = entityReplacementBuf != null ? entityReplacementBuf.length : 0;
if (entityEnd >= entitySize) {
- final int newSize = entityEnd > 7 ? 2 * entityEnd : 8; // = lucky 7 + 1 //25
+ final int newSize = entityEnd > 7 ? 2 * entityEnd : 8; // = lucky 7
+ // + 1 //25
if (TRACE_SIZING) {
System.err.println("TRACE_SIZING entitySize " + entitySize + " ==> " + newSize);
}
@@ -341,17 +350,18 @@ public class MXParser
}
// input buffer management
- protected static final int READ_CHUNK_SIZE = 8 * 1024; //max data chars in one read() call
+ protected static final int READ_CHUNK_SIZE = 8 * 1024; // max data chars in
+ // one read() call
protected Reader reader;
protected String inputEncoding;
+ protected int bufLoadFactor = 95; // 99%
+ // protected int bufHardLimit; // only matters when expanding
- protected int bufLoadFactor = 95; // 99%
- //protected int bufHardLimit; // only matters when expanding
-
- protected char buf[] = new char[
- Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 256];
- protected int bufSoftLimit = (bufLoadFactor * buf.length) / 100; // desirable size of buffer
+ protected char buf[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 256];
+ protected int bufSoftLimit = (bufLoadFactor * buf.length) / 100; // desirable
+ // size of
+ // buffer
protected boolean preventBufferCompaction;
protected int bufAbsoluteStart; // this is buf
@@ -361,18 +371,15 @@ public class MXParser
protected int posStart;
protected int posEnd;
- protected char pc[] = new char[
- Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 64];
+ protected char pc[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 64];
protected int pcStart;
protected int pcEnd;
-
// parsing state
- //protected boolean needsMore;
- //protected boolean seenMarkup;
+ // protected boolean needsMore;
+ // protected boolean seenMarkup;
protected boolean usePC;
-
protected boolean seenStartTag;
protected boolean seenEndTag;
protected boolean pastEndTag;
@@ -390,7 +397,7 @@ public class MXParser
protected String xmlDeclContent;
protected void reset() {
- //System.out.println("reset() called");
+ // System.out.println("reset() called");
location = null;
lineNumber = 1;
columnNumber = 0;
@@ -436,42 +443,40 @@ public class MXParser
public MXParser() {
}
-
/**
* Method setFeature
*
- * @param name a String
- * @param state a boolean
+ * @param name a String
+ * @param state a boolean
* @throws XmlPullParserException
*/
- public void setFeature(String name,
- boolean state) throws XmlPullParserException {
- if (name == null) throw new IllegalArgumentException("feature name should not be null");
+ public void setFeature(String name, boolean state) throws XmlPullParserException {
+ if (name == null)
+ throw new IllegalArgumentException("feature name should not be null");
if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
- if (eventType != START_DOCUMENT) throw new XmlPullParserException(
- "namespace processing feature can only be changed before parsing", this, null);
+ if (eventType != START_DOCUMENT)
+ throw new XmlPullParserException("namespace processing feature can only be changed before parsing", this, null);
processNamespaces = state;
- // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
- // if(type != START_DOCUMENT) throw new XmlPullParserException(
- // "namespace reporting feature can only be changed before parsing", this, null);
- // reportNsAttribs = state;
+ // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
+ // if(type != START_DOCUMENT) throw new XmlPullParserException(
+ // "namespace reporting feature can only be changed before parsing",
+ // this, null);
+ // reportNsAttribs = state;
} else if (FEATURE_NAMES_INTERNED.equals(name)) {
if (state != false) {
- throw new XmlPullParserException(
- "interning names in this implementation is not supported");
+ throw new XmlPullParserException("interning names in this implementation is not supported");
}
} else if (FEATURE_PROCESS_DOCDECL.equals(name)) {
if (state != false) {
- throw new XmlPullParserException(
- "processing DOCDECL is not supported");
+ throw new XmlPullParserException("processing DOCDECL is not supported");
}
- //} else if(REPORT_DOCDECL.equals(name)) {
- // paramNotifyDoctype = state;
+ // } else if(REPORT_DOCDECL.equals(name)) {
+ // paramNotifyDoctype = state;
} else if (FEATURE_XML_ROUNDTRIP.equals(name)) {
- //if(state == false) {
- // throw new XmlPullParserException(
- // "roundtrip feature can not be switched off");
- //}
+ // if(state == false) {
+ // throw new XmlPullParserException(
+ // "roundtrip feature can not be switched off");
+ // }
roundtripSupported = state;
} else {
throw new XmlPullParserException("unsupported feature " + name);
@@ -482,37 +487,36 @@ public class MXParser
* Unknown properties are <strong>always</strong> returned as false
*/
public boolean getFeature(String name) {
- if (name == null) throw new IllegalArgumentException("feature name should not be null");
+ if (name == null)
+ throw new IllegalArgumentException("feature name should not be null");
if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
return processNamespaces;
- // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
- // return reportNsAttribs;
+ // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
+ // return reportNsAttribs;
} else if (FEATURE_NAMES_INTERNED.equals(name)) {
return false;
} else if (FEATURE_PROCESS_DOCDECL.equals(name)) {
return false;
- //} else if(REPORT_DOCDECL.equals(name)) {
- // return paramNotifyDoctype;
+ // } else if(REPORT_DOCDECL.equals(name)) {
+ // return paramNotifyDoctype;
} else if (FEATURE_XML_ROUNDTRIP.equals(name)) {
- //return true;
+ // return true;
return roundtripSupported;
}
return false;
}
- public void setProperty(String name,
- Object value)
- throws XmlPullParserException {
+ public void setProperty(String name, Object value) throws XmlPullParserException {
if (PROPERTY_LOCATION.equals(name)) {
- location = (String) value;
+ location = (String)value;
} else {
throw new XmlPullParserException("unsupported property: '" + name + "'");
}
}
-
public Object getProperty(String name) {
- if (name == null) throw new IllegalArgumentException("property name should not be null");
+ if (name == null)
+ throw new IllegalArgumentException("property name should not be null");
if (PROPERTY_XMLDECL_VERSION.equals(name)) {
return xmlDeclVersion;
} else if (PROPERTY_XMLDECL_STANDALONE.equals(name)) {
@@ -525,7 +529,6 @@ public class MXParser
return null;
}
-
public void setInput(Reader in) throws XmlPullParserException {
if (in == null) {
throw new IllegalArgumentException("input reader can not be null");
@@ -534,8 +537,7 @@ public class MXParser
reader = in;
}
- public void setInput(java.io.InputStream inputStream, String inputEncoding)
- throws XmlPullParserException {
+ public void setInput(java.io.InputStream inputStream, String inputEncoding) throws XmlPullParserException {
if (inputStream == null) {
throw new IllegalArgumentException("input stream can not be null");
}
@@ -550,8 +552,7 @@ public class MXParser
this.inputEncoding = xr.getEncoding();
}
} catch (IOException une) {
- throw new XmlPullParserException(
- "could not create reader for encoding " + inputEncoding + " : " + une, this, une);
+ throw new XmlPullParserException("could not create reader for encoding " + inputEncoding + " : " + une, this, une);
}
}
@@ -559,69 +560,65 @@ public class MXParser
return inputEncoding;
}
- public void defineEntityReplacementText(String entityName,
- String replacementText)
- throws XmlPullParserException {
- // throw new XmlPullParserException("not allowed");
+ public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException {
+ // throw new XmlPullParserException("not allowed");
- //protected char[] entityReplacement[];
+ // protected char[] entityReplacement[];
ensureEntityCapacity();
- // this is to make sure that if interning works we will take advantage of it ...
+ // this is to make sure that if interning works we will take advantage
+ // of it ...
this.entityName[entityEnd] = newString(entityName.toCharArray(), 0, entityName.length());
entityNameBuf[entityEnd] = entityName.toCharArray();
entityReplacement[entityEnd] = replacementText;
entityReplacementBuf[entityEnd] = replacementText.toCharArray();
if (!allStringsInterned) {
- entityNameHash[entityEnd] =
- fastHash(entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length);
+ entityNameHash[entityEnd] = fastHash(entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length);
}
++entityEnd;
- //TODO disallow < or & in entity replacement text (or ]]>???)
+ // TODO disallow < or & in entity replacement text (or ]]>???)
// TOOD keepEntityNormalizedForAttributeValue cached as well ...
}
- public int getNamespaceCount(int depth)
- throws XmlPullParserException {
+ public int getNamespaceCount(int depth) throws XmlPullParserException {
if (processNamespaces == false || depth == 0) {
return 0;
}
- //int maxDepth = eventType == END_TAG ? this.depth + 1 : this.depth;
- //if(depth < 0 || depth > maxDepth) throw new IllegalArgumentException(
- if (depth < 0 || depth > this.depth) throw new IllegalArgumentException(
- "allowed namespace depth 0.." + this.depth + " not " + depth);
+ // int maxDepth = eventType == END_TAG ? this.depth + 1 : this.depth;
+ // if(depth < 0 || depth > maxDepth) throw new IllegalArgumentException(
+ if (depth < 0 || depth > this.depth)
+ throw new IllegalArgumentException("allowed namespace depth 0.." + this.depth + " not " + depth);
return elNamespaceCount[depth];
}
- public String getNamespacePrefix(int pos)
- throws XmlPullParserException {
+ public String getNamespacePrefix(int pos) throws XmlPullParserException {
- //int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] : namespaceEnd;
- //if(pos < end) {
+ // int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] :
+ // namespaceEnd;
+ // if(pos < end) {
if (pos < namespaceEnd) {
return namespacePrefix[pos];
} else {
- throw new XmlPullParserException(
- "position " + pos + " exceeded number of available namespaces " + namespaceEnd);
+ throw new XmlPullParserException("position " + pos + " exceeded number of available namespaces " + namespaceEnd);
}
}
public String getNamespaceUri(int pos) throws XmlPullParserException {
- //int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] : namespaceEnd;
- //if(pos < end) {
+ // int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] :
+ // namespaceEnd;
+ // if(pos < end) {
if (pos < namespaceEnd) {
return namespaceUri[pos];
} else {
- throw new XmlPullParserException(
- "position " + pos + " exceeded number of available namespaces " + namespaceEnd);
+ throw new XmlPullParserException("position " + pos + " exceeded number of available namespaces " + namespaceEnd);
}
}
public String getNamespace(String prefix)
- //throws XmlPullParserException
+ // throws XmlPullParserException
{
- //int count = namespaceCount[ depth ];
+ // int count = namespaceCount[ depth ];
if (prefix != null) {
for (int i = namespaceEnd - 1; i >= 0; i--) {
if (prefix.equals(namespacePrefix[i])) {
@@ -635,7 +632,8 @@ public class MXParser
}
} else {
for (int i = namespaceEnd - 1; i >= 0; i--) {
- if (namespacePrefix[i] == null) { //"") { //null ) { //TODO check FIXME Alek
+ if (namespacePrefix[i] == null) { // "") { //null ) { //TODO
+ // check FIXME Alek
return namespaceUri[i];
}
}
@@ -644,17 +642,17 @@ public class MXParser
return null;
}
-
public int getDepth() {
return depth;
}
-
private static int findFragment(int bufMinPos, char[] b, int start, int end) {
- //System.err.println("bufStart="+bufStart+" b="+printable(new String(b, start, end - start))+" start="+start+" end="+end);
+ // System.err.println("bufStart="+bufStart+" b="+printable(new String(b,
+ // start, end - start))+" start="+start+" end="+end);
if (start < bufMinPos) {
start = bufMinPos;
- if (start > end) start = end;
+ if (start > end)
+ start = end;
return start;
}
if (end - start > 65) {
@@ -662,35 +660,35 @@ public class MXParser
}
int i = start + 1;
while (--i > bufMinPos) {
- if ((end - i) > 65) break;
+ if ((end - i) > 65)
+ break;
final char c = b[i];
- if (c == '<' && (start - i) > 10) break;
+ if (c == '<' && (start - i) > 10)
+ break;
}
return i;
}
-
/**
- * Return string describing current position of parsers as
- * text 'STATE [seen %s...] @line:column'.
+ * Return string describing current position of parsers as text 'STATE [seen
+ * %s...] @line:column'.
*/
public String getPositionDescription() {
String fragment = null;
if (posStart <= pos) {
final int start = findFragment(0, buf, posStart, pos);
- //System.err.println("start="+start);
+ // System.err.println("start="+start);
if (start < pos) {
fragment = new String(buf, start, pos - start);
}
- if (bufAbsoluteStart > 0 || start > 0) fragment = "..." + fragment;
+ if (bufAbsoluteStart > 0 || start > 0)
+ fragment = "..." + fragment;
}
- // return " at line "+tokenizerPosRow
- // +" and column "+(tokenizerPosCol-1)
- // +(fragment != null ? " seen "+printable(fragment)+"..." : "");
- return " " + TYPES[eventType] +
- (fragment != null ? " seen " + printable(fragment) + "..." : "")
- + " " + (location != null ? location : "")
- + "@" + getLineNumber() + ":" + getColumnNumber();
+ // return " at line "+tokenizerPosRow
+ // +" and column "+(tokenizerPosCol-1)
+ // +(fragment != null ? " seen "+printable(fragment)+"..." : "");
+ return " " + TYPES[eventType] + (fragment != null ? " seen " + printable(fragment) + "..." : "") + " " + (location != null ? location : "") + "@" + getLineNumber() + ":"
+ + getColumnNumber();
}
public int getLineNumber() {
@@ -701,17 +699,18 @@ public class MXParser
return columnNumber;
}
-
public boolean isWhitespace() throws XmlPullParserException {
if (eventType == TEXT || eventType == CDSECT) {
if (usePC) {
for (int i = pcStart; i < pcEnd; i++) {
- if (!isS(pc[i])) return false;
+ if (!isS(pc[i]))
+ return false;
}
return true;
} else {
for (int i = posStart; i < posEnd; i++) {
- if (!isS(buf[i])) return false;
+ if (!isS(buf[i]))
+ return false;
}
return true;
}
@@ -723,12 +722,12 @@ public class MXParser
public String getText() {
if (eventType == START_DOCUMENT || eventType == END_DOCUMENT) {
- //throw new XmlPullParserException("no content available to read");
- // if(roundtripSupported) {
- // text = new String(buf, posStart, posEnd - posStart);
- // } else {
+ // throw new XmlPullParserException("no content available to read");
+ // if(roundtripSupported) {
+ // text = new String(buf, posStart, posEnd - posStart);
+ // } else {
return null;
- // }
+ // }
} else if (eventType == ENTITY_REF) {
return text;
}
@@ -754,65 +753,58 @@ public class MXParser
return buf;
}
- } else if (eventType == START_TAG
- || eventType == END_TAG
- || eventType == CDSECT
- || eventType == COMMENT
- || eventType == ENTITY_REF
- || eventType == PROCESSING_INSTRUCTION
- || eventType == IGNORABLE_WHITESPACE
- || eventType == DOCDECL) {
+ } else if (eventType == START_TAG || eventType == END_TAG || eventType == CDSECT || eventType == COMMENT || eventType == ENTITY_REF || eventType == PROCESSING_INSTRUCTION
+ || eventType == IGNORABLE_WHITESPACE || eventType == DOCDECL) {
holderForStartAndLength[0] = posStart;
holderForStartAndLength[1] = posEnd - posStart;
return buf;
- } else if (eventType == START_DOCUMENT
- || eventType == END_DOCUMENT) {
- //throw new XmlPullParserException("no content available to read");
+ } else if (eventType == START_DOCUMENT || eventType == END_DOCUMENT) {
+ // throw new XmlPullParserException("no content available to read");
holderForStartAndLength[0] = holderForStartAndLength[1] = -1;
return null;
} else {
throw new IllegalArgumentException("unknown text eventType: " + eventType);
}
- // String s = getText();
- // char[] cb = null;
- // if(s!= null) {
- // cb = s.toCharArray();
- // holderForStartAndLength[0] = 0;
- // holderForStartAndLength[1] = s.length();
- // } else {
- // }
- // return cb;
+ // String s = getText();
+ // char[] cb = null;
+ // if(s!= null) {
+ // cb = s.toCharArray();
+ // holderForStartAndLength[0] = 0;
+ // holderForStartAndLength[1] = s.length();
+ // } else {
+ // }
+ // return cb;
}
public String getNamespace() {
if (eventType == START_TAG) {
- //return processNamespaces ? elUri[ depth - 1 ] : NO_NAMESPACE;
+ // return processNamespaces ? elUri[ depth - 1 ] : NO_NAMESPACE;
return processNamespaces ? elUri[depth] : NO_NAMESPACE;
} else if (eventType == END_TAG) {
return processNamespaces ? elUri[depth] : NO_NAMESPACE;
}
return null;
- // String prefix = elPrefix[ maxDepth ];
- // if(prefix != null) {
- // for( int i = namespaceEnd -1; i >= 0; i--) {
- // if( prefix.equals( namespacePrefix[ i ] ) ) {
- // return namespaceUri[ i ];
- // }
- // }
- // } else {
- // for( int i = namespaceEnd -1; i >= 0; i--) {
- // if( namespacePrefix[ i ] == null ) {
- // return namespaceUri[ i ];
- // }
- // }
+ // String prefix = elPrefix[ maxDepth ];
+ // if(prefix != null) {
+ // for( int i = namespaceEnd -1; i >= 0; i--) {
+ // if( prefix.equals( namespacePrefix[ i ] ) ) {
+ // return namespaceUri[ i ];
+ // }
+ // }
+ // } else {
+ // for( int i = namespaceEnd -1; i >= 0; i--) {
+ // if( namespacePrefix[ i ] == null ) {
+ // return namespaceUri[ i ];
+ // }
+ // }
//
- // }
- // return "";
+ // }
+ // return "";
}
public String getName() {
if (eventType == START_TAG) {
- //return elName[ depth - 1 ] ;
+ // return elName[ depth - 1 ] ;
return elName[depth];
} else if (eventType == END_TAG) {
return elName[depth];
@@ -828,83 +820,84 @@ public class MXParser
public String getPrefix() {
if (eventType == START_TAG) {
- //return elPrefix[ depth - 1 ] ;
+ // return elPrefix[ depth - 1 ] ;
return elPrefix[depth];
} else if (eventType == END_TAG) {
return elPrefix[depth];
}
return null;
- // if(eventType != START_TAG && eventType != END_TAG) return null;
- // int maxDepth = eventType == END_TAG ? depth : depth - 1;
- // return elPrefix[ maxDepth ];
+ // if(eventType != START_TAG && eventType != END_TAG) return null;
+ // int maxDepth = eventType == END_TAG ? depth : depth - 1;
+ // return elPrefix[ maxDepth ];
}
-
public boolean isEmptyElementTag() throws XmlPullParserException {
- if (eventType != START_TAG) throw new XmlPullParserException(
- "parser must be on START_TAG to check for empty element", this, null);
+ if (eventType != START_TAG)
+ throw new XmlPullParserException("parser must be on START_TAG to check for empty element", this, null);
return emptyElementTag;
}
public int getAttributeCount() {
- if (eventType != START_TAG) return -1;
+ if (eventType != START_TAG)
+ return -1;
return attributeCount;
}
public String getAttributeNamespace(int index) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes");
- if (processNamespaces == false) return NO_NAMESPACE;
- if (index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException(
- "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+ if (processNamespaces == false)
+ return NO_NAMESPACE;
+ if (index < 0 || index >= attributeCount)
+ throw new IndexOutOfBoundsException("attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
return attributeUri[index];
}
public String getAttributeName(int index) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes");
- if (index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException(
- "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+ if (index < 0 || index >= attributeCount)
+ throw new IndexOutOfBoundsException("attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
return attributeName[index];
}
public String getAttributePrefix(int index) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes");
- if (processNamespaces == false) return null;
- if (index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException(
- "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+ if (processNamespaces == false)
+ return null;
+ if (index < 0 || index >= attributeCount)
+ throw new IndexOutOfBoundsException("attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
return attributePrefix[index];
}
public String getAttributeType(int index) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes");
- if (index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException(
- "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+ if (index < 0 || index >= attributeCount)
+ throw new IndexOutOfBoundsException("attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
return "CDATA";
}
public boolean isAttributeDefault(int index) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes");
- if (index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException(
- "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+ if (index < 0 || index >= attributeCount)
+ throw new IndexOutOfBoundsException("attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
return false;
}
public String getAttributeValue(int index) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes");
- if (index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException(
- "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+ if (index < 0 || index >= attributeCount)
+ throw new IndexOutOfBoundsException("attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
return attributeValue[index];
}
- public String getAttributeValue(String namespace,
- String name) {
- if (eventType != START_TAG) throw new IndexOutOfBoundsException(
- "only START_TAG can have attributes" + getPositionDescription());
+ public String getAttributeValue(String namespace, String name) {
+ if (eventType != START_TAG)
+ throw new IndexOutOfBoundsException("only START_TAG can have attributes" + getPositionDescription());
if (name == null) {
throw new IllegalArgumentException("attribute name can not be null");
}
@@ -915,11 +908,11 @@ public class MXParser
}
for (int i = 0; i < attributeCount; ++i) {
- if ((namespace == attributeUri[i] ||
- namespace.equals(attributeUri[i]))
- //(namespace != null && namespace.equals(attributeUri[ i ]))
- // taking advantage of String.intern()
- && name.equals(attributeName[i])) {
+ if ((namespace == attributeUri[i] || namespace.equals(attributeUri[i]))
+ // (namespace != null && namespace.equals(attributeUri[ i
+ // ]))
+ // taking advantage of String.intern()
+ && name.equals(attributeName[i])) {
return attributeValue[i];
}
}
@@ -927,8 +920,8 @@ public class MXParser
if (namespace != null && namespace.length() == 0) {
namespace = null;
}
- if (namespace != null) throw new IllegalArgumentException(
- "when namespaces processing is disabled attribute namespace must be null");
+ if (namespace != null)
+ throw new IllegalArgumentException("when namespaces processing is disabled attribute namespace must be null");
for (int i = 0; i < attributeCount; ++i) {
if (name.equals(attributeName[i])) {
return attributeValue[i];
@@ -938,50 +931,33 @@ public class MXParser
return null;
}
-
- public int getEventType()
- throws XmlPullParserException {
+ public int getEventType() throws XmlPullParserException {
return eventType;
}
- public void require(int type, String namespace, String name)
- throws XmlPullParserException, IOException {
+ public void require(int type, String namespace, String name) throws XmlPullParserException, IOException {
if (processNamespaces == false && namespace != null) {
- throw new XmlPullParserException(
- "processing namespaces must be enabled on parser (or factory)" +
- " to have possible namespaces declared on elements"
- + (" (position:" + getPositionDescription()) + ")");
- }
- if (type != getEventType()
- || (namespace != null && !namespace.equals(getNamespace()))
- || (name != null && !name.equals(getName()))) {
- throw new XmlPullParserException(
- "expected event " + TYPES[type]
- + (name != null ? " with name '" + name + "'" : "")
- + (namespace != null && name != null ? " and" : "")
- + (namespace != null ? " with namespace '" + namespace + "'" : "")
- + " but got"
- + (type != getEventType() ? " " + TYPES[getEventType()] : "")
- + (name != null && getName() != null && !name.equals(getName())
- ? " name '" + getName() + "'" : "")
- + (namespace != null && name != null
- && getName() != null && !name.equals(getName())
- && getNamespace() != null && !namespace.equals(getNamespace())
- ? " and" : "")
- + (namespace != null && getNamespace() != null && !namespace.equals(getNamespace())
- ? " namespace '" + getNamespace() + "'" : "")
- + (" (position:" + getPositionDescription()) + ")");
+ throw new XmlPullParserException("processing namespaces must be enabled on parser (or factory)" + " to have possible namespaces declared on elements"
+ + (" (position:" + getPositionDescription()) + ")");
+ }
+ if (type != getEventType() || (namespace != null && !namespace.equals(getNamespace())) || (name != null && !name.equals(getName()))) {
+ throw new XmlPullParserException("expected event " + TYPES[type] + (name != null ? " with name '" + name + "'" : "") + (namespace != null && name != null ? " and" : "")
+ + (namespace != null ? " with namespace '" + namespace + "'" : "") + " but got"
+ + (type != getEventType() ? " " + TYPES[getEventType()] : "")
+ + (name != null && getName() != null && !name.equals(getName()) ? " name '" + getName() + "'" : "")
+ + (namespace != null && name != null && getName() != null && !name.equals(getName()) && getNamespace() != null
+ && !namespace.equals(getNamespace()) ? " and" : "")
+ + (namespace != null && getNamespace() != null && !namespace.equals(getNamespace()) ? " namespace '" + getNamespace() + "'" : "")
+ + (" (position:" + getPositionDescription()) + ")");
}
}
-
/**
- * Skip sub tree that is currently parser positioned on.
- * <br>NOTE: parser must be on START_TAG and when function returns
- * parser will be positioned on corresponding END_TAG
+ * Skip sub tree that is currently parser positioned on. <br>
+ * NOTE: parser must be on START_TAG and when function returns parser will
+ * be positioned on corresponding END_TAG
*/
- public void skipSubTree()
- throws XmlPullParserException, IOException {
+ public void skipSubTree() throws XmlPullParserException, IOException {
require(START_TAG, null, null);
int level = 1;
while (level > 0) {
@@ -994,84 +970,75 @@ public class MXParser
}
}
- // public String readText() throws XmlPullParserException, IOException
- // {
- // if (getEventType() != TEXT) return "";
- // String result = getText();
- // next();
- // return result;
- // }
+ // public String readText() throws XmlPullParserException, IOException
+ // {
+ // if (getEventType() != TEXT) return "";
+ // String result = getText();
+ // next();
+ // return result;
+ // }
public String nextText() throws XmlPullParserException, IOException {
- // String result = null;
- // boolean onStartTag = false;
- // if(eventType == START_TAG) {
- // onStartTag = true;
- // next();
- // }
- // if(eventType == TEXT) {
- // result = getText();
- // next();
- // } else if(onStartTag && eventType == END_TAG) {
- // result = "";
- // } else {
- // throw new XmlPullParserException(
- // "parser must be on START_TAG or TEXT to read text", this, null);
- // }
- // if(eventType != END_TAG) {
- // throw new XmlPullParserException(
- // "event TEXT it must be immediately followed by END_TAG", this, null);
- // }
- // return result;
+ // String result = null;
+ // boolean onStartTag = false;
+ // if(eventType == START_TAG) {
+ // onStartTag = true;
+ // next();
+ // }
+ // if(eventType == TEXT) {
+ // result = getText();
+ // next();
+ // } else if(onStartTag && eventType == END_TAG) {
+ // result = "";
+ // } else {
+ // throw new XmlPullParserException(
+ // "parser must be on START_TAG or TEXT to read text", this, null);
+ // }
+ // if(eventType != END_TAG) {
+ // throw new XmlPullParserException(
+ // "event TEXT it must be immediately followed by END_TAG", this, null);
+ // }
+ // return result;
if (getEventType() != START_TAG) {
- throw new XmlPullParserException(
- "parser must be on START_TAG to read next text", this, null);
+ throw new XmlPullParserException("parser must be on START_TAG to read next text", this, null);
}
int eventType = next();
if (eventType == TEXT) {
final String result = getText();
eventType = next();
if (eventType != END_TAG) {
- throw new XmlPullParserException(
- "TEXT must be immediately followed by END_TAG and not "
- + TYPES[getEventType()], this, null);
+ throw new XmlPullParserException("TEXT must be immediately followed by END_TAG and not " + TYPES[getEventType()], this, null);
}
return result;
} else if (eventType == END_TAG) {
return "";
} else {
- throw new XmlPullParserException(
- "parser must be on START_TAG or TEXT to read text", this, null);
+ throw new XmlPullParserException("parser must be on START_TAG or TEXT to read text", this, null);
}
}
public int nextTag() throws XmlPullParserException, IOException {
next();
- if (eventType == TEXT && isWhitespace()) { // skip whitespace
+ if (eventType == TEXT && isWhitespace()) { // skip whitespace
next();
}
if (eventType != START_TAG && eventType != END_TAG) {
- throw new XmlPullParserException("expected START_TAG or END_TAG not "
- + TYPES[getEventType()], this, null);
+ throw new XmlPullParserException("expected START_TAG or END_TAG not " + TYPES[getEventType()], this, null);
}
return eventType;
}
- public int next()
- throws XmlPullParserException, IOException {
+ public int next() throws XmlPullParserException, IOException {
tokenize = false;
return nextImpl();
}
- public int nextToken()
- throws XmlPullParserException, IOException {
+ public int nextToken() throws XmlPullParserException, IOException {
tokenize = true;
return nextImpl();
}
-
- protected int nextImpl()
- throws XmlPullParserException, IOException {
+ protected int nextImpl() throws XmlPullParserException, IOException {
text = null;
pcEnd = pcStart = 0;
usePC = false;
@@ -1100,9 +1067,10 @@ public class MXParser
}
// ASSUMPTION: we are _on_ first character of content or markup!!!!
- // [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
+ // [43] content ::= CharData? ((element | Reference | CDSect | PI |
+ // Comment) CharData?)*
char ch;
- if (seenMarkup) { // we have read ahead ...
+ if (seenMarkup) { // we have read ahead ...
seenMarkup = false;
ch = '<';
} else if (seenAmpersand) {
@@ -1111,20 +1079,22 @@ public class MXParser
} else {
ch = more();
}
- posStart = pos - 1; // VERY IMPORTANT: this is correct start of event!!!
+ posStart = pos - 1; // VERY IMPORTANT: this is correct start of
+ // event!!!
- // when true there is some potential event TEXT to return - keep gathering
+ // when true there is some potential event TEXT to return - keep
+ // gathering
boolean hadCharData = false;
- // when true TEXT data is not continual (like <![CDATA[text]]>) and requires PC merging
+ // when true TEXT data is not continual (like <![CDATA[text]]>) and
+ // requires PC merging
boolean needsMerging = false;
- MAIN_LOOP:
- while (true) {
+ MAIN_LOOP: while (true) {
// work on MARKUP
if (ch == '<') {
if (hadCharData) {
- //posEnd = pos - 1;
+ // posEnd = pos - 1;
if (tokenize) {
seenMarkup = true;
return eventType = TEXT;
@@ -1134,106 +1104,112 @@ public class MXParser
if (ch == '/') {
if (!tokenize && hadCharData) {
seenEndTag = true;
- //posEnd = pos - 2;
+ // posEnd = pos - 2;
return eventType = TEXT;
}
return eventType = parseEndTag();
} else if (ch == '!') {
ch = more();
if (ch == '-') {
- // note: if(tokenize == false) posStart/End is NOT changed!!!!
+ // note: if(tokenize == false) posStart/End is NOT
+ // changed!!!!
parseComment();
- if (tokenize) return eventType = COMMENT;
+ if (tokenize)
+ return eventType = COMMENT;
if (!usePC && hadCharData) {
needsMerging = true;
} else {
- posStart = pos; //completely ignore comment
+ posStart = pos; // completely ignore comment
}
} else if (ch == '[') {
- //posEnd = pos - 3;
- // must remember previous posStart/End as it merges with content of CDATA
- //int oldStart = posStart + bufAbsoluteStart;
- //int oldEnd = posEnd + bufAbsoluteStart;
+ // posEnd = pos - 3;
+ // must remember previous posStart/End as it merges
+ // with content of CDATA
+ // int oldStart = posStart + bufAbsoluteStart;
+ // int oldEnd = posEnd + bufAbsoluteStart;
parseCDSect(hadCharData);
- if (tokenize) return eventType = CDSECT;
+ if (tokenize)
+ return eventType = CDSECT;
final int cdStart = posStart;
final int cdEnd = posEnd;
final int cdLen = cdEnd - cdStart;
-
- if (cdLen > 0) { // was there anything inside CDATA section?
+ if (cdLen > 0) { // was there anything inside CDATA
+ // section?
hadCharData = true;
if (!usePC) {
needsMerging = true;
}
}
- // posStart = oldStart;
- // posEnd = oldEnd;
- // if(cdLen > 0) { // was there anything inside CDATA section?
- // if(hadCharData) {
- // // do merging if there was anything in CDSect!!!!
- // // if(!usePC) {
- // // // posEnd is correct already!!!
- // // if(posEnd > posStart) {
- // // joinPC();
- // // } else {
- // // usePC = true;
- // // pcStart = pcEnd = 0;
- // // }
- // // }
- // // if(pcEnd + cdLen >= pc.length) ensurePC(pcEnd + cdLen);
- // // // copy [cdStart..cdEnd) into PC
- // // System.arraycopy(buf, cdStart, pc, pcEnd, cdLen);
- // // pcEnd += cdLen;
- // if(!usePC) {
- // needsMerging = true;
- // posStart = cdStart;
- // posEnd = cdEnd;
- // }
- // } else {
- // if(!usePC) {
- // needsMerging = true;
- // posStart = cdStart;
- // posEnd = cdEnd;
- // hadCharData = true;
- // }
- // }
- // //hadCharData = true;
- // } else {
- // if( !usePC && hadCharData ) {
- // needsMerging = true;
- // }
- // }
+ // posStart = oldStart;
+ // posEnd = oldEnd;
+ // if(cdLen > 0) { // was there anything inside
+ // CDATA section?
+ // if(hadCharData) {
+ // // do merging if there was anything in CDSect!!!!
+ // // if(!usePC) {
+ // // // posEnd is correct already!!!
+ // // if(posEnd > posStart) {
+ // // joinPC();
+ // // } else {
+ // // usePC = true;
+ // // pcStart = pcEnd = 0;
+ // // }
+ // // }
+ // // if(pcEnd + cdLen >= pc.length) ensurePC(pcEnd
+ // + cdLen);
+ // // // copy [cdStart..cdEnd) into PC
+ // // System.arraycopy(buf, cdStart, pc, pcEnd,
+ // cdLen);
+ // // pcEnd += cdLen;
+ // if(!usePC) {
+ // needsMerging = true;
+ // posStart = cdStart;
+ // posEnd = cdEnd;
+ // }
+ // } else {
+ // if(!usePC) {
+ // needsMerging = true;
+ // posStart = cdStart;
+ // posEnd = cdEnd;
+ // hadCharData = true;
+ // }
+ // }
+ // //hadCharData = true;
+ // } else {
+ // if( !usePC && hadCharData ) {
+ // needsMerging = true;
+ // }
+ // }
} else {
- throw new XmlPullParserException(
- "unexpected character in markup " + printable(ch), this, null);
+ throw new XmlPullParserException("unexpected character in markup " + printable(ch), this, null);
}
} else if (ch == '?') {
parsePI();
- if (tokenize) return eventType = PROCESSING_INSTRUCTION;
+ if (tokenize)
+ return eventType = PROCESSING_INSTRUCTION;
if (!usePC && hadCharData) {
needsMerging = true;
} else {
- posStart = pos; //completely ignore PI
+ posStart = pos; // completely ignore PI
}
} else if (isNameStartChar(ch)) {
if (!tokenize && hadCharData) {
seenStartTag = true;
- //posEnd = pos - 2;
+ // posEnd = pos - 2;
return eventType = TEXT;
}
return eventType = parseStartTag();
} else {
- throw new XmlPullParserException(
- "unexpected character in markup " + printable(ch), this, null);
+ throw new XmlPullParserException("unexpected character in markup " + printable(ch), this, null);
}
// do content compaction if it makes sense!!!!
} else if (ch == '&') {
// work on ENTITTY
- //posEnd = pos - 1;
+ // posEnd = pos - 1;
if (tokenize && hadCharData) {
seenAmpersand = true;
return eventType = TEXT;
@@ -1241,18 +1217,17 @@ public class MXParser
final int oldStart = posStart + bufAbsoluteStart;
final int oldEnd = posEnd + bufAbsoluteStart;
final char[] resolvedEntity = parseEntityRef();
- if (tokenize) return eventType = ENTITY_REF;
+ if (tokenize)
+ return eventType = ENTITY_REF;
// check if replacement text can be resolved !!!
if (resolvedEntity == null) {
if (entityRefName == null) {
entityRefName = newString(buf, posStart, posEnd - posStart);
}
- throw new XmlPullParserException(
- "could not resolve entity named '" + printable(entityRefName) + "'",
- this, null);
+ throw new XmlPullParserException("could not resolve entity named '" + printable(entityRefName) + "'", this, null);
}
- //int entStart = posStart;
- //int entEnd = posEnd;
+ // int entStart = posStart;
+ // int entEnd = posEnd;
posStart = oldStart - bufAbsoluteStart;
posEnd = oldEnd - bufAbsoluteStart;
if (!usePC) {
@@ -1264,30 +1239,29 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- // write into PC replacement text - do merge for replacement text!!!!
+ // assert usePC == true;
+ // write into PC replacement text - do merge for replacement
+ // text!!!!
for (int i = 0; i < resolvedEntity.length; i++) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = resolvedEntity[i];
}
hadCharData = true;
- //assert needsMerging == false;
+ // assert needsMerging == false;
} else {
if (needsMerging) {
- //assert usePC == false;
- joinPC(); // posEnd is already set correctly!!!
- //posStart = pos - 1;
+ // assert usePC == false;
+ joinPC(); // posEnd is already set correctly!!!
+ // posStart = pos - 1;
needsMerging = false;
}
+ // no MARKUP not ENTITIES so work on character data ...
- //no MARKUP not ENTITIES so work on character data ...
-
-
- // [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
-
+ // [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
hadCharData = true;
@@ -1306,8 +1280,7 @@ public class MXParser
seenBracket = true;
}
} else if (seenBracketBracket && ch == '>') {
- throw new XmlPullParserException(
- "characters ]]> are not allowed in content", this, null);
+ throw new XmlPullParserException("characters ]]> are not allowed in content", this, null);
} else {
if (seenBracket) {
seenBracketBracket = seenBracket = false;
@@ -1328,19 +1301,23 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
- // if(!usePC) { joinPC(); } else { if(pcEnd >= pc.length) ensurePC(); }
+ // if(!usePC) { joinPC(); } else { if(pcEnd >=
+ // pc.length) ensurePC(); }
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
@@ -1350,7 +1327,8 @@ public class MXParser
ch = more();
} while (ch != '<' && ch != '&');
posEnd = pos - 1;
- continue MAIN_LOOP; // skip ch = more() from below - we are alreayd ahead ...
+ continue MAIN_LOOP; // skip ch = more() from below - we are
+ // alreayd ahead ...
}
ch = more();
} // endless while(true)
@@ -1363,10 +1341,9 @@ public class MXParser
}
}
-
- protected int parseProlog()
- throws XmlPullParserException, IOException {
- // [2] prolog: ::= XMLDecl? Misc* (doctypedecl Misc*)? and look for [39] element
+ protected int parseProlog() throws XmlPullParserException, IOException {
+ // [2] prolog: ::= XMLDecl? Misc* (doctypedecl Misc*)? and look for [39]
+ // element
char ch;
if (seenMarkup) {
@@ -1380,9 +1357,7 @@ public class MXParser
// deal with BOM
// detect BOM and drop it (Unicode int Order Mark)
if (ch == '\uFFFE') {
- throw new XmlPullParserException(
- "first character in input was UNICODE noncharacter (0xFFFE)" +
- "- input requires int swapping", this, null);
+ throw new XmlPullParserException("first character in input was UNICODE noncharacter (0xFFFE)" + "- input requires int swapping", this, null);
}
if (ch == '\uFEFF') {
// skipping UNICODE int Order Mark (so called BOM)
@@ -1409,7 +1384,7 @@ public class MXParser
if (ch == '?') {
// check if it is 'xml'
// deal with XMLDecl
- if (parsePI()) { // make sure to skip XMLDecl
+ if (parsePI()) { // make sure to skip XMLDecl
if (tokenize) {
return eventType = PROCESSING_INSTRUCTION;
}
@@ -1423,36 +1398,34 @@ public class MXParser
ch = more();
if (ch == 'D') {
if (seenDocdecl) {
- throw new XmlPullParserException(
- "only one docdecl allowed in XML document", this, null);
+ throw new XmlPullParserException("only one docdecl allowed in XML document", this, null);
}
seenDocdecl = true;
parseDocdecl();
- if (tokenize) return eventType = DOCDECL;
+ if (tokenize)
+ return eventType = DOCDECL;
} else if (ch == '-') {
parseComment();
- if (tokenize) return eventType = COMMENT;
+ if (tokenize)
+ return eventType = COMMENT;
} else {
- throw new XmlPullParserException(
- "unexpected markup <!" + printable(ch), this, null);
+ throw new XmlPullParserException("unexpected markup <!" + printable(ch), this, null);
}
} else if (ch == '/') {
- throw new XmlPullParserException(
- "expected start tag name and not " + printable(ch), this, null);
+ throw new XmlPullParserException("expected start tag name and not " + printable(ch), this, null);
} else if (isNameStartChar(ch)) {
seenRoot = true;
return parseStartTag();
} else {
- throw new XmlPullParserException(
- "expected start tag name and not " + printable(ch), this, null);
+ throw new XmlPullParserException("expected start tag name and not " + printable(ch), this, null);
}
} else if (isS(ch)) {
gotS = true;
if (normalizeIgnorableWS) {
if (ch == '\r') {
normalizedCR = true;
- //posEnd = pos -1;
- //joinPC();
+ // posEnd = pos -1;
+ // joinPC();
// posEnd is already is set
if (!usePC) {
posEnd = pos - 1;
@@ -1463,34 +1436,34 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
}
}
} else {
- throw new XmlPullParserException(
- "only whitespace content allowed before start tag and not " + printable(ch),
- this, null);
+ throw new XmlPullParserException("only whitespace content allowed before start tag and not " + printable(ch), this, null);
}
ch = more();
}
}
- protected int parseEpilog()
- throws XmlPullParserException, IOException {
+ protected int parseEpilog() throws XmlPullParserException, IOException {
if (eventType == END_DOCUMENT) {
throw new XmlPullParserException("already reached end of XML input", this, null);
}
@@ -1528,7 +1501,8 @@ public class MXParser
// check if it is 'xml'
// deal with XMLDecl
parsePI();
- if (tokenize) return eventType = PROCESSING_INSTRUCTION;
+ if (tokenize)
+ return eventType = PROCESSING_INSTRUCTION;
} else if (ch == '!') {
ch = more();
@@ -1536,33 +1510,30 @@ public class MXParser
break;
}
if (ch == 'D') {
- parseDocdecl(); //FIXME
- if (tokenize) return eventType = DOCDECL;
+ parseDocdecl(); // FIXME
+ if (tokenize)
+ return eventType = DOCDECL;
} else if (ch == '-') {
parseComment();
- if (tokenize) return eventType = COMMENT;
+ if (tokenize)
+ return eventType = COMMENT;
} else {
- throw new XmlPullParserException(
- "unexpected markup <!" + printable(ch), this, null);
+ throw new XmlPullParserException("unexpected markup <!" + printable(ch), this, null);
}
} else if (ch == '/') {
- throw new XmlPullParserException(
- "end tag not allowed in epilog but got " + printable(ch), this, null);
+ throw new XmlPullParserException("end tag not allowed in epilog but got " + printable(ch), this, null);
} else if (isNameStartChar(ch)) {
- throw new XmlPullParserException(
- "start tag not allowed in epilog but got " + printable(ch), this, null);
+ throw new XmlPullParserException("start tag not allowed in epilog but got " + printable(ch), this, null);
} else {
- throw new XmlPullParserException(
- "in epilog expected ignorable content and not " + printable(ch),
- this, null);
+ throw new XmlPullParserException("in epilog expected ignorable content and not " + printable(ch), this, null);
}
} else if (isS(ch)) {
gotS = true;
if (normalizeIgnorableWS) {
if (ch == '\r') {
normalizedCR = true;
- //posEnd = pos -1;
- //joinPC();
+ // posEnd = pos -1;
+ // joinPC();
// posEnd is alreadys set
if (!usePC) {
posEnd = pos - 1;
@@ -1573,27 +1544,28 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
}
}
} else {
- throw new XmlPullParserException(
- "in epilog non whitespace content is not allowed but got " + printable(ch),
- this, null);
+ throw new XmlPullParserException("in epilog non whitespace content is not allowed but got " + printable(ch), this, null);
}
ch = more();
if (reachedEnd) {
@@ -1605,7 +1577,7 @@ public class MXParser
// throw Exception("unexpected content in epilog
// catch EOFException return END_DOCUEMENT
- //try {
+ // try {
} catch (EOFException ex) {
reachedEnd = true;
}
@@ -1620,14 +1592,12 @@ public class MXParser
}
}
-
public int parseEndTag() throws XmlPullParserException, IOException {
- //ASSUMPTION ch is past "</"
- // [42] ETag ::= '</' Name S? '>'
+ // ASSUMPTION ch is past "</"
+ // [42] ETag ::= '</' Name S? '>'
char ch = more();
if (!isNameStartChar(ch)) {
- throw new XmlPullParserException(
- "expected name start and not " + printable(ch), this, null);
+ throw new XmlPullParserException("expected name start and not " + printable(ch), this, null);
}
posStart = pos - 3;
final int nameStart = pos - 1 + bufAbsoluteStart;
@@ -1636,32 +1606,29 @@ public class MXParser
} while (isNameChar(ch));
// now we go one level down -- do checks
- //--depth; //FIXME
+ // --depth; //FIXME
// check that end tag name is the same as start tag
- //String name = new String(buf, nameStart - bufAbsoluteStart,
- // (pos - 1) - (nameStart - bufAbsoluteStart));
- //int last = pos - 1;
+ // String name = new String(buf, nameStart - bufAbsoluteStart,
+ // (pos - 1) - (nameStart - bufAbsoluteStart));
+ // int last = pos - 1;
int off = nameStart - bufAbsoluteStart;
- //final int len = last - off;
+ // final int len = last - off;
final int len = (pos - 1) - off;
final char[] cbuf = elRawName[depth];
if (elRawNameEnd[depth] != len) {
// construct strings for exception
final String startname = new String(cbuf, 0, elRawNameEnd[depth]);
final String endname = new String(buf, off, len);
- throw new XmlPullParserException(
- "end tag name </" + endname + "> must match start tag name <" + startname + ">"
- + " from line " + elRawNameLine[depth], this, null);
+ throw new XmlPullParserException("end tag name </" + endname + "> must match start tag name <" + startname + ">" + " from line " + elRawNameLine[depth], this, null);
}
for (int i = 0; i < len; i++) {
if (buf[off++] != cbuf[i]) {
// construct strings for exception
final String startname = new String(cbuf, 0, len);
final String endname = new String(buf, off - i - 1, len);
- throw new XmlPullParserException(
- "end tag name </" + endname + "> must be the same as start tag <" + startname + ">"
- + " from line " + elRawNameLine[depth], this, null);
+ throw new XmlPullParserException("end tag name </" + endname + "> must be the same as start tag <" + startname + ">" + " from line " + elRawNameLine[depth], this,
+ null);
}
}
@@ -1669,13 +1636,10 @@ public class MXParser
ch = more();
} // skip additional white spaces
if (ch != '>') {
- throw new XmlPullParserException(
- "expected > to finish end tag not " + printable(ch)
- + " from line " + elRawNameLine[depth], this, null);
+ throw new XmlPullParserException("expected > to finish end tag not " + printable(ch) + " from line " + elRawNameLine[depth], this, null);
}
-
- //namespaceEnd = elNamespaceCount[ depth ]; //FIXME
+ // namespaceEnd = elNamespaceCount[ depth ]; //FIXME
posEnd = pos;
pastEndTag = true;
@@ -1683,10 +1647,10 @@ public class MXParser
}
public int parseStartTag() throws XmlPullParserException, IOException {
- //ASSUMPTION ch is past <T
- // [40] STag ::= '<' Name (S Attribute)* S? '>'
+ // ASSUMPTION ch is past <T
+ // [40] STag ::= '<' Name (S Attribute)* S? '>'
// [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
- ++depth; //FIXME
+ ++depth; // FIXME
posStart = pos - 2;
@@ -1696,16 +1660,15 @@ public class MXParser
final int nameStart = pos - 1 + bufAbsoluteStart;
int colonPos = -1;
char ch = buf[pos - 1];
- if (ch == ':' && processNamespaces) throw new XmlPullParserException(
- "when namespaces processing enabled colon can not be at element name start",
- this, null);
+ if (ch == ':' && processNamespaces)
+ throw new XmlPullParserException("when namespaces processing enabled colon can not be at element name start", this, null);
while (true) {
ch = more();
- if (!isNameChar(ch)) break;
+ if (!isNameChar(ch))
+ break;
if (ch == ':' && processNamespaces) {
- if (colonPos != -1) throw new XmlPullParserException(
- "only one colon is allowed in name of element when namespaces are enabled",
- this, null);
+ if (colonPos != -1)
+ throw new XmlPullParserException("only one colon is allowed in name of element when namespaces are enabled", this, null);
colonPos = pos - 1 + bufAbsoluteStart;
}
}
@@ -1713,8 +1676,7 @@ public class MXParser
// retrieve name
ensureElementsCapacity();
-
- //TODO check for efficient interning and then use elRawNameInterned!!!!
+ // TODO check for efficient interning and then use elRawNameInterned!!!!
int elLen = (pos - 1) - (nameStart - bufAbsoluteStart);
if (elRawName[depth] == null || elRawName[depth].length < elLen) {
@@ -1730,11 +1692,10 @@ public class MXParser
String prefix = null;
if (processNamespaces) {
if (colonPos != -1) {
- prefix = elPrefix[depth] = newString(buf, nameStart - bufAbsoluteStart,
- colonPos - nameStart);
+ prefix = elPrefix[depth] = newString(buf, nameStart - bufAbsoluteStart, colonPos - nameStart);
name = elName[depth] = newString(buf, colonPos + 1 - bufAbsoluteStart,
- //(pos -1) - (colonPos + 1));
- pos - 2 - (colonPos - bufAbsoluteStart));
+ // (pos -1) - (colonPos + 1));
+ pos - 2 - (colonPos - bufAbsoluteStart));
} else {
prefix = elPrefix[depth] = null;
name = elName[depth] = newString(buf, nameStart - bufAbsoluteStart, elLen);
@@ -1745,7 +1706,6 @@ public class MXParser
}
-
while (true) {
while (isS(ch)) {
@@ -1755,53 +1715,49 @@ public class MXParser
if (ch == '>') {
break;
} else if (ch == '/') {
- if (emptyElementTag) throw new XmlPullParserException(
- "repeated / in tag declaration", this, null);
+ if (emptyElementTag)
+ throw new XmlPullParserException("repeated / in tag declaration", this, null);
emptyElementTag = true;
ch = more();
- if (ch != '>') throw new XmlPullParserException(
- "expected > to end empty tag not " + printable(ch), this, null);
+ if (ch != '>')
+ throw new XmlPullParserException("expected > to end empty tag not " + printable(ch), this, null);
break;
} else if (isNameStartChar(ch)) {
ch = parseAttribute();
ch = more();
continue;
} else {
- throw new XmlPullParserException(
- "start tag unexpected character " + printable(ch), this, null);
+ throw new XmlPullParserException("start tag unexpected character " + printable(ch), this, null);
}
- //ch = more(); // skip space
+ // ch = more(); // skip space
}
// now when namespaces were declared we can resolve them
if (processNamespaces) {
String uri = getNamespace(prefix);
if (uri == null) {
- if (prefix == null) { // no prefix and no uri => use default namespace
+ if (prefix == null) { // no prefix and no uri => use default
+ // namespace
uri = NO_NAMESPACE;
} else {
- throw new XmlPullParserException(
- "could not determine namespace bound to element prefix " + prefix,
- this, null);
+ throw new XmlPullParserException("could not determine namespace bound to element prefix " + prefix, this, null);
}
}
elUri[depth] = uri;
-
- //String uri = getNamespace(prefix);
- //if(uri == null && prefix == null) { // no prefix and no uri => use default namespace
- // uri = "";
- //}
+ // String uri = getNamespace(prefix);
+ // if(uri == null && prefix == null) { // no prefix and no uri =>
+ // use default namespace
+ // uri = "";
+ // }
// resolve attribute namespaces
for (int i = 0; i < attributeCount; i++) {
final String attrPrefix = attributePrefix[i];
if (attrPrefix != null) {
final String attrUri = getNamespace(attrPrefix);
if (attrUri == null) {
- throw new XmlPullParserException(
- "could not determine namespace bound to attribute prefix " + attrPrefix,
- this, null);
+ throw new XmlPullParserException("could not determine namespace bound to attribute prefix " + attrPrefix, this, null);
}
attributeUri[i] = attrUri;
@@ -1810,48 +1766,44 @@ public class MXParser
}
}
- //TODO
- //[ WFC: Unique Att Spec ]
- // check attribute uniqueness constraint for attributes that has namespace!!!
+ // TODO
+ // [ WFC: Unique Att Spec ]
+ // check attribute uniqueness constraint for attributes that has
+ // namespace!!!
for (int i = 1; i < attributeCount; i++) {
for (int j = 0; j < i; j++) {
if (attributeUri[j] == attributeUri[i]
- && (allStringsInterned && attributeName[j].equals(attributeName[i])
- || (!allStringsInterned
- && attributeNameHash[j] == attributeNameHash[i]
- && attributeName[j].equals(attributeName[i])))
+ && (allStringsInterned && attributeName[j].equals(attributeName[i])
+ || (!allStringsInterned && attributeNameHash[j] == attributeNameHash[i] && attributeName[j].equals(attributeName[i])))
) {
// prepare data for nice error message?
String attr1 = attributeName[j];
- if (attributeUri[j] != null) attr1 = attributeUri[j] + ":" + attr1;
+ if (attributeUri[j] != null)
+ attr1 = attributeUri[j] + ":" + attr1;
String attr2 = attributeName[i];
- if (attributeUri[i] != null) attr2 = attributeUri[i] + ":" + attr2;
- throw new XmlPullParserException(
- "duplicated attributes " + attr1 + " and " + attr2, this, null);
+ if (attributeUri[i] != null)
+ attr2 = attributeUri[i] + ":" + attr2;
+ throw new XmlPullParserException("duplicated attributes " + attr1 + " and " + attr2, this, null);
}
}
}
-
} else { // ! processNamespaces
- //[ WFC: Unique Att Spec ]
+ // [ WFC: Unique Att Spec ]
// check raw attribute uniqueness constraint!!!
for (int i = 1; i < attributeCount; i++) {
for (int j = 0; j < i; j++) {
if ((allStringsInterned && attributeName[j].equals(attributeName[i])
- || (!allStringsInterned
- && attributeNameHash[j] == attributeNameHash[i]
- && attributeName[j].equals(attributeName[i])))
+ || (!allStringsInterned && attributeNameHash[j] == attributeNameHash[i] && attributeName[j].equals(attributeName[i])))
) {
// prepare data for nice error message?
final String attr1 = attributeName[j];
final String attr2 = attributeName[i];
- throw new XmlPullParserException(
- "duplicated attributes " + attr1 + " and " + attr2, this, null);
+ throw new XmlPullParserException("duplicated attributes " + attr1 + " and " + attr2, this, null);
}
}
}
@@ -1871,10 +1823,8 @@ public class MXParser
final int nameStart = pos - 1 + bufAbsoluteStart;
int colonPos = -1;
char ch = buf[pos - 1];
- if (ch == ':' && processNamespaces) throw new XmlPullParserException(
- "when namespaces processing enabled colon can not be at attribute name start",
- this, null);
-
+ if (ch == ':' && processNamespaces)
+ throw new XmlPullParserException("when namespaces processing enabled colon can not be at attribute name start", this, null);
boolean startsWithXmlns = processNamespaces && ch == 'x';
int xmlnsPos = 0;
@@ -1885,24 +1835,26 @@ public class MXParser
if (startsWithXmlns && xmlnsPos < 5) {
++xmlnsPos;
if (xmlnsPos == 1) {
- if (ch != 'm') startsWithXmlns = false;
+ if (ch != 'm')
+ startsWithXmlns = false;
} else if (xmlnsPos == 2) {
- if (ch != 'l') startsWithXmlns = false;
+ if (ch != 'l')
+ startsWithXmlns = false;
} else if (xmlnsPos == 3) {
- if (ch != 'n') startsWithXmlns = false;
+ if (ch != 'n')
+ startsWithXmlns = false;
} else if (xmlnsPos == 4) {
- if (ch != 's') startsWithXmlns = false;
+ if (ch != 's')
+ startsWithXmlns = false;
} else {
- if (ch != ':') throw new XmlPullParserException(
- "after xmlns in attribute name must be colon"
- + " when namespaces are enabled", this, null);
- //colonPos = pos - 1 + bufAbsoluteStart;
+ if (ch != ':')
+ throw new XmlPullParserException("after xmlns in attribute name must be colon" + " when namespaces are enabled", this, null);
+ // colonPos = pos - 1 + bufAbsoluteStart;
}
}
if (ch == ':') {
- if (colonPos != -1) throw new XmlPullParserException(
- "only one colon is allowed in attribute name"
- + " when namespaces are enabled", this, null);
+ if (colonPos != -1)
+ throw new XmlPullParserException("only one colon is allowed in attribute name" + " when namespaces are enabled", this, null);
colonPos = pos - 1 + bufAbsoluteStart;
}
}
@@ -1916,37 +1868,32 @@ public class MXParser
String prefix = null;
// work on prefixes and namespace URI
if (processNamespaces) {
- if (xmlnsPos < 4) startsWithXmlns = false;
+ if (xmlnsPos < 4)
+ startsWithXmlns = false;
if (startsWithXmlns) {
if (colonPos != -1) {
- //prefix = attributePrefix[ attributeCount ] = null;
+ // prefix = attributePrefix[ attributeCount ] = null;
final int nameLen = pos - 2 - (colonPos - bufAbsoluteStart);
if (nameLen == 0) {
- throw new XmlPullParserException(
- "namespace prefix is required after xmlns: "
- + " when namespaces are enabled", this, null);
+ throw new XmlPullParserException("namespace prefix is required after xmlns: " + " when namespaces are enabled", this, null);
}
- name = //attributeName[ attributeCount ] =
- newString(buf, colonPos - bufAbsoluteStart + 1, nameLen);
- //pos - 1 - (colonPos + 1 - bufAbsoluteStart)
+ name = // attributeName[ attributeCount ] =
+ newString(buf, colonPos - bufAbsoluteStart + 1, nameLen);
+ // pos - 1 - (colonPos + 1 - bufAbsoluteStart)
}
} else {
if (colonPos != -1) {
int prefixLen = colonPos - nameStart;
- prefix = attributePrefix[attributeCount] =
- newString(buf, nameStart - bufAbsoluteStart, prefixLen);
- //colonPos - (nameStart - bufAbsoluteStart));
+ prefix = attributePrefix[attributeCount] = newString(buf, nameStart - bufAbsoluteStart, prefixLen);
+ // colonPos - (nameStart - bufAbsoluteStart));
int nameLen = pos - 2 - (colonPos - bufAbsoluteStart);
- name = attributeName[attributeCount] =
- newString(buf, colonPos - bufAbsoluteStart + 1, nameLen);
- //pos - 1 - (colonPos + 1 - bufAbsoluteStart));
+ name = attributeName[attributeCount] = newString(buf, colonPos - bufAbsoluteStart + 1, nameLen);
+ // pos - 1 - (colonPos + 1 - bufAbsoluteStart));
- //name.substring(0, colonPos-nameStart);
+ // name.substring(0, colonPos-nameStart);
} else {
prefix = attributePrefix[attributeCount] = null;
- name = attributeName[attributeCount] =
- newString(buf, nameStart - bufAbsoluteStart,
- pos - 1 - (nameStart - bufAbsoluteStart));
+ name = attributeName[attributeCount] = newString(buf, nameStart - bufAbsoluteStart, pos - 1 - (nameStart - bufAbsoluteStart));
}
if (!allStringsInterned) {
attributeNameHash[attributeCount] = name.hashCode();
@@ -1955,36 +1902,32 @@ public class MXParser
} else {
// retrieve name
- name = attributeName[attributeCount] =
- newString(buf, nameStart - bufAbsoluteStart,
- pos - 1 - (nameStart - bufAbsoluteStart));
- ////assert name != null;
+ name = attributeName[attributeCount] = newString(buf, nameStart - bufAbsoluteStart, pos - 1 - (nameStart - bufAbsoluteStart));
+ //// assert name != null;
if (!allStringsInterned) {
attributeNameHash[attributeCount] = name.hashCode();
}
}
- // [25] Eq ::= S? '=' S?
+ // [25] Eq ::= S? '=' S?
while (isS(ch)) {
ch = more();
} // skip additional spaces
- if (ch != '=') throw new XmlPullParserException(
- "expected = after attribute name", this, null);
+ if (ch != '=')
+ throw new XmlPullParserException("expected = after attribute name", this, null);
ch = more();
while (isS(ch)) {
ch = more();
} // skip additional spaces
- // [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
- // | "'" ([^<&'] | Reference)* "'"
+ // [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
+ // | "'" ([^<&'] | Reference)* "'"
final char delimit = ch;
- if (delimit != '"' && delimit != '\'') throw new XmlPullParserException(
- "attribute value must start with quotation or apostrophe not "
- + printable(delimit), this, null);
+ if (delimit != '"' && delimit != '\'')
+ throw new XmlPullParserException("attribute value must start with quotation or apostrophe not " + printable(delimit), this, null);
// parse until delimit or < and resolve Reference
- //[67] Reference ::= EntityRef | CharRef
- //int valueStart = pos + bufAbsoluteStart;
-
+ // [67] Reference ::= EntityRef | CharRef
+ // int valueStart = pos + bufAbsoluteStart;
boolean normalizedCR = false;
usePC = false;
@@ -1997,8 +1940,7 @@ public class MXParser
break;
}
if (ch == '<') {
- throw new XmlPullParserException(
- "markup not allowed inside attribute value - illegal < ", this, null);
+ throw new XmlPullParserException("markup not allowed inside attribute value - illegal < ", this, null);
}
if (ch == '&') {
// extractEntityRef
@@ -2013,7 +1955,7 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
+ // assert usePC == true;
final char[] resolvedEntity = parseEntityRef();
// check if replacement text can be resolved !!!
@@ -2021,13 +1963,13 @@ public class MXParser
if (entityRefName == null) {
entityRefName = newString(buf, posStart, posEnd - posStart);
}
- throw new XmlPullParserException(
- "could not resolve entity named '" + printable(entityRefName) + "'",
- this, null);
+ throw new XmlPullParserException("could not resolve entity named '" + printable(entityRefName) + "'", this, null);
}
- // write into PC replacement text - do merge for replacement text!!!!
+ // write into PC replacement text - do merge for replacement
+ // text!!!!
for (int i = 0; i < resolvedEntity.length; i++) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = resolvedEntity[i];
}
} else if (ch == '\t' || ch == '\n' || ch == '\r') {
@@ -2044,22 +1986,23 @@ public class MXParser
pcEnd = pcStart = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
if (ch != '\n' || !normalizedCR) {
- pc[pcEnd++] = ' '; //'\n';
+ pc[pcEnd++] = ' '; // '\n';
}
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
}
normalizedCR = ch == '\r';
}
-
if (processNamespaces && startsWithXmlns) {
String ns = null;
if (!usePC) {
@@ -2071,8 +2014,7 @@ public class MXParser
int prefixHash = -1;
if (colonPos != -1) {
if (ns.length() == 0) {
- throw new XmlPullParserException(
- "non-default namespace can not be declared to be empty string", this, null);
+ throw new XmlPullParserException("non-default namespace can not be declared to be empty string", this, null);
}
// declare new namespace
namespacePrefix[namespaceEnd] = name;
@@ -2080,8 +2022,9 @@ public class MXParser
prefixHash = namespacePrefixHash[namespaceEnd] = name.hashCode();
}
} else {
- // declare new default namespace ...
- namespacePrefix[namespaceEnd] = null; //""; //null; //TODO check FIXME Alek
+ // declare new default namespace ...
+ namespacePrefix[namespaceEnd] = null; // ""; //null; //TODO
+ // check FIXME Alek
if (!allStringsInterned) {
prefixHash = namespacePrefixHash[namespaceEnd] = -1;
}
@@ -2092,13 +2035,9 @@ public class MXParser
final int startNs = elNamespaceCount[depth - 1];
for (int i = namespaceEnd - 1; i >= startNs; --i) {
if (((allStringsInterned || name == null) && namespacePrefix[i] == name)
- || (!allStringsInterned && name != null &&
- namespacePrefixHash[i] == prefixHash
- && name.equals(namespacePrefix[i])
- )) {
+ || (!allStringsInterned && name != null && namespacePrefixHash[i] == prefixHash && name.equals(namespacePrefix[i]))) {
final String s = name == null ? "default" : "'" + name + "'";
- throw new XmlPullParserException(
- "duplicated namespace declaration for " + s + " prefix", this, null);
+ throw new XmlPullParserException("duplicated namespace declaration for " + s + " prefix", this, null);
}
}
@@ -2106,11 +2045,9 @@ public class MXParser
} else {
if (!usePC) {
- attributeValue[attributeCount] =
- new String(buf, posStart, pos - 1 - posStart);
+ attributeValue[attributeCount] = new String(buf, posStart, pos - 1 - posStart);
} else {
- attributeValue[attributeCount] =
- new String(pc, pcStart, pcEnd - pcStart);
+ attributeValue[attributeCount] = new String(pc, pcStart, pcEnd - pcStart);
}
++attributeCount;
}
@@ -2120,10 +2057,10 @@ public class MXParser
protected char[] charRefOneCharBuf = new char[1];
- protected char[] parseEntityRef()
- throws XmlPullParserException, IOException {
- // entity reference http://www.w3.org/TR/2000/REC-xml-20001006#NT-Reference
- // [67] Reference ::= EntityRef | CharRef
+ protected char[] parseEntityRef() throws XmlPullParserException, IOException {
+ // entity reference
+ // http://www.w3.org/TR/2000/REC-xml-20001006#NT-Reference
+ // [67] Reference ::= EntityRef | CharRef
// ASSUMPTION just after &
entityRefName = null;
@@ -2134,34 +2071,30 @@ public class MXParser
char charRef = 0;
ch = more();
if (ch == 'x') {
- //encoded in hex
+ // encoded in hex
while (true) {
ch = more();
if (ch >= '0' && ch <= '9') {
- charRef = (char) (charRef * 16 + (ch - '0'));
+ charRef = (char)(charRef * 16 + (ch - '0'));
} else if (ch >= 'a' && ch <= 'f') {
- charRef = (char) (charRef * 16 + (ch - ('a' - 10)));
+ charRef = (char)(charRef * 16 + (ch - ('a' - 10)));
} else if (ch >= 'A' && ch <= 'F') {
- charRef = (char) (charRef * 16 + (ch - ('A' - 10)));
+ charRef = (char)(charRef * 16 + (ch - ('A' - 10)));
} else if (ch == ';') {
break;
} else {
- throw new XmlPullParserException(
- "character reference (with hex value) may not contain "
- + printable(ch), this, null);
+ throw new XmlPullParserException("character reference (with hex value) may not contain " + printable(ch), this, null);
}
}
} else {
// encoded in decimal
while (true) {
if (ch >= '0' && ch <= '9') {
- charRef = (char) (charRef * 10 + (ch - '0'));
+ charRef = (char)(charRef * 10 + (ch - '0'));
} else if (ch == ';') {
break;
} else {
- throw new XmlPullParserException(
- "character reference (with decimal value) may not contain "
- + printable(ch), this, null);
+ throw new XmlPullParserException("character reference (with decimal value) may not contain " + printable(ch), this, null);
}
ch = more();
}
@@ -2173,12 +2106,10 @@ public class MXParser
}
return charRefOneCharBuf;
} else {
- // [68] EntityRef ::= '&' Name ';'
+ // [68] EntityRef ::= '&' Name ';'
// scan name until ;
if (!isNameStartChar(ch)) {
- throw new XmlPullParserException(
- "entity reference names can not start with character '"
- + printable(ch) + "'", this, null);
+ throw new XmlPullParserException("entity reference names can not start with character '" + printable(ch) + "'", this, null);
}
while (true) {
ch = more();
@@ -2186,9 +2117,7 @@ public class MXParser
break;
}
if (!isNameChar(ch)) {
- throw new XmlPullParserException(
- "entity reference name can not contain character "
- + printable(ch) + "'", this, null);
+ throw new XmlPullParserException("entity reference name can not contain character " + printable(ch) + "'", this, null);
}
}
posEnd = pos - 1;
@@ -2200,12 +2129,11 @@ public class MXParser
}
charRefOneCharBuf[0] = '<';
return charRefOneCharBuf;
- //if(paramPC || isParserTokenizing) {
- // if(pcEnd >= pc.length) ensurePC();
- // pc[pcEnd++] = '<';
- //}
- } else if (len == 3 && buf[posStart] == 'a'
- && buf[posStart + 1] == 'm' && buf[posStart + 2] == 'p') {
+ // if(paramPC || isParserTokenizing) {
+ // if(pcEnd >= pc.length) ensurePC();
+ // pc[pcEnd++] = '<';
+ // }
+ } else if (len == 3 && buf[posStart] == 'a' && buf[posStart + 1] == 'm' && buf[posStart + 2] == 'p') {
if (tokenize) {
text = "&";
}
@@ -2217,15 +2145,13 @@ public class MXParser
}
charRefOneCharBuf[0] = '>';
return charRefOneCharBuf;
- } else if (len == 4 && buf[posStart] == 'a' && buf[posStart + 1] == 'p'
- && buf[posStart + 2] == 'o' && buf[posStart + 3] == 's') {
+ } else if (len == 4 && buf[posStart] == 'a' && buf[posStart + 1] == 'p' && buf[posStart + 2] == 'o' && buf[posStart + 3] == 's') {
if (tokenize) {
text = "'";
}
charRefOneCharBuf[0] = '\'';
return charRefOneCharBuf;
- } else if (len == 4 && buf[posStart] == 'q' && buf[posStart + 1] == 'u'
- && buf[posStart + 2] == 'o' && buf[posStart + 3] == 't') {
+ } else if (len == 4 && buf[posStart] == 'q' && buf[posStart + 1] == 'u' && buf[posStart + 2] == 'o' && buf[posStart + 3] == 't') {
if (tokenize) {
text = "\"";
}
@@ -2237,23 +2163,24 @@ public class MXParser
return result;
}
}
- if (tokenize) text = null;
+ if (tokenize)
+ text = null;
return null;
}
}
- protected char[] lookuEntityReplacement(int entitNameLen)
- throws XmlPullParserException, IOException {
+ protected char[] lookuEntityReplacement(int entitNameLen) throws XmlPullParserException, IOException {
if (!allStringsInterned) {
final int hash = fastHash(buf, posStart, posEnd - posStart);
- LOOP:
- for (int i = entityEnd - 1; i >= 0; --i) {
+ LOOP: for (int i = entityEnd - 1; i >= 0; --i) {
if (hash == entityNameHash[i] && entitNameLen == entityNameBuf[i].length) {
final char[] entityBuf = entityNameBuf[i];
for (int j = 0; j < entitNameLen; j++) {
- if (buf[posStart + j] != entityBuf[j]) continue LOOP;
+ if (buf[posStart + j] != entityBuf[j])
+ continue LOOP;
}
- if (tokenize) text = entityReplacement[i];
+ if (tokenize)
+ text = entityReplacement[i];
return entityReplacementBuf[i];
}
}
@@ -2262,7 +2189,8 @@ public class MXParser
for (int i = entityEnd - 1; i >= 0; --i) {
// take advantage that interning for newStirng is enforced
if (entityRefName == entityName[i]) {
- if (tokenize) text = entityReplacement[i];
+ if (tokenize)
+ text = entityReplacement[i];
return entityReplacementBuf[i];
}
}
@@ -2270,16 +2198,15 @@ public class MXParser
return null;
}
-
- protected void parseComment()
- throws XmlPullParserException, IOException {
+ protected void parseComment() throws XmlPullParserException, IOException {
// implements XML 1.0 Section 2.5 Comments
- //ASSUMPTION: seen <!-
+ // ASSUMPTION: seen <!-
char ch = more();
- if (ch != '-') throw new XmlPullParserException(
- "expected <!-- for comment start", this, null);
- if (tokenize) posStart = pos;
+ if (ch != '-')
+ throw new XmlPullParserException("expected <!-- for comment start", this, null);
+ if (tokenize)
+ posStart = pos;
final int curLine = lineNumber;
final int curColumn = columnNumber;
@@ -2293,9 +2220,7 @@ public class MXParser
// scan until it hits -->
ch = more();
if (seenDashDash && ch != '>') {
- throw new XmlPullParserException(
- "in comment after two dashes (--) next character must be >"
- + " not " + printable(ch), this, null);
+ throw new XmlPullParserException("in comment after two dashes (--) next character must be >" + " not " + printable(ch), this, null);
}
if (ch == '-') {
if (!seenDash) {
@@ -2306,7 +2231,7 @@ public class MXParser
}
} else if (ch == '>') {
if (seenDashDash) {
- break; // found end sequence!!!!
+ break; // found end sequence!!!!
} else {
seenDashDash = false;
}
@@ -2317,8 +2242,8 @@ public class MXParser
if (normalizeIgnorableWS) {
if (ch == '\r') {
normalizedCR = true;
- //posEnd = pos -1;
- //joinPC();
+ // posEnd = pos -1;
+ // joinPC();
// posEnd is already set
if (!usePC) {
posEnd = pos - 1;
@@ -2329,18 +2254,21 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
@@ -2350,9 +2278,7 @@ public class MXParser
} catch (EOFException ex) {
// detect EOF and create meaningful error ...
- throw new XmlPullParserException(
- "comment started on line " + curLine + " and column " + curColumn + " was not closed",
- this, ex);
+ throw new XmlPullParserException("comment started on line " + curLine + " and column " + curColumn + " was not closed", this, ex);
}
if (tokenize) {
posEnd = pos - 3;
@@ -2362,14 +2288,14 @@ public class MXParser
}
}
- protected boolean parsePI()
- throws XmlPullParserException, IOException {
+ protected boolean parsePI() throws XmlPullParserException, IOException {
// implements XML 1.0 Section 2.6 Processing Instructions
// [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
- // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
- //ASSUMPTION: seen <?
- if (tokenize) posStart = pos;
+ // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
+ // ASSUMPTION: seen <?
+ if (tokenize)
+ posStart = pos;
final int curLine = lineNumber;
final int curColumn = columnNumber;
int piTargetStart = pos + bufAbsoluteStart;
@@ -2381,46 +2307,40 @@ public class MXParser
boolean seenQ = false;
char ch = more();
if (isS(ch)) {
- throw new XmlPullParserException(
- "processing instruction PITarget must be exactly after <? and not white space character",
- this, null);
+ throw new XmlPullParserException("processing instruction PITarget must be exactly after <? and not white space character", this, null);
}
while (true) {
// scan until it hits ?>
- //ch = more();
+ // ch = more();
if (ch == '?') {
seenQ = true;
} else if (ch == '>') {
if (seenQ) {
- break; // found end sequence!!!!
+ break; // found end sequence!!!!
}
seenQ = false;
} else {
if (piTargetEnd == -1 && isS(ch)) {
piTargetEnd = pos - 1 + bufAbsoluteStart;
- // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
+ // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm')
+ // ('L' | 'l'))
if ((piTargetEnd - piTargetStart) == 3) {
- if ((buf[piTargetStart] == 'x' || buf[piTargetStart] == 'X')
- && (buf[piTargetStart + 1] == 'm' || buf[piTargetStart + 1] == 'M')
- && (buf[piTargetStart + 2] == 'l' || buf[piTargetStart + 2] == 'L')
- ) {
- if (piTargetStart > 3) { //<?xml is allowed as first characters in input ...
- throw new XmlPullParserException(
- "processing instruction can not have PITarget with reserveld xml name",
- this, null);
+ if ((buf[piTargetStart] == 'x' || buf[piTargetStart] == 'X') && (buf[piTargetStart + 1] == 'm' || buf[piTargetStart + 1] == 'M')
+ && (buf[piTargetStart + 2] == 'l' || buf[piTargetStart + 2] == 'L')) {
+ if (piTargetStart > 3) { // <?xml is allowed as
+ // first characters in
+ // input ...
+ throw new XmlPullParserException("processing instruction can not have PITarget with reserveld xml name", this, null);
} else {
- if (buf[piTargetStart] != 'x'
- && buf[piTargetStart + 1] != 'm'
- && buf[piTargetStart + 2] != 'l') {
- throw new XmlPullParserException(
- "XMLDecl must have xml name in lowercase",
- this, null);
+ if (buf[piTargetStart] != 'x' && buf[piTargetStart + 1] != 'm' && buf[piTargetStart + 2] != 'l') {
+ throw new XmlPullParserException("XMLDecl must have xml name in lowercase", this, null);
}
}
parseXmlDecl(ch);
- if (tokenize) posEnd = pos - 2;
+ if (tokenize)
+ posEnd = pos - 2;
final int off = piTargetStart - bufAbsoluteStart + 3;
final int len = pos - 2 - off;
xmlDeclContent = newString(buf, off, len);
@@ -2433,8 +2353,8 @@ public class MXParser
if (normalizeIgnorableWS) {
if (ch == '\r') {
normalizedCR = true;
- //posEnd = pos -1;
- //joinPC();
+ // posEnd = pos -1;
+ // joinPC();
// posEnd is already set
if (!usePC) {
posEnd = pos - 1;
@@ -2445,18 +2365,21 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
@@ -2466,15 +2389,12 @@ public class MXParser
}
} catch (EOFException ex) {
// detect EOF and create meaningful error ...
- throw new XmlPullParserException(
- "processing instruction started on line " + curLine + " and column " + curColumn
- + " was not closed",
- this, ex);
+ throw new XmlPullParserException("processing instruction started on line " + curLine + " and column " + curColumn + " was not closed", this, ex);
}
if (piTargetEnd == -1) {
piTargetEnd = pos - 2 + bufAbsoluteStart;
- //throw new XmlPullParserException(
- // "processing instruction must have PITarget name", this, null);
+ // throw new XmlPullParserException(
+ // "processing instruction must have PITarget name", this, null);
}
piTargetStart -= bufAbsoluteStart;
piTargetEnd -= bufAbsoluteStart;
@@ -2487,11 +2407,12 @@ public class MXParser
return true;
}
- // protected final static char[] VERSION = {'v','e','r','s','i','o','n'};
- // protected final static char[] NCODING = {'n','c','o','d','i','n','g'};
- // protected final static char[] TANDALONE = {'t','a','n','d','a','l','o','n','e'};
- // protected final static char[] YES = {'y','e','s'};
- // protected final static char[] NO = {'n','o'};
+ // protected final static char[] VERSION = {'v','e','r','s','i','o','n'};
+ // protected final static char[] NCODING = {'n','c','o','d','i','n','g'};
+ // protected final static char[] TANDALONE =
+ // {'t','a','n','d','a','l','o','n','e'};
+ // protected final static char[] YES = {'y','e','s'};
+ // protected final static char[] NO = {'n','o'};
protected final static char[] VERSION = "version".toCharArray();
protected final static char[] NCODING = "ncoding".toCharArray();
@@ -2499,9 +2420,7 @@ public class MXParser
protected final static char[] YES = "yes".toCharArray();
protected final static char[] NO = "no".toCharArray();
-
- protected void parseXmlDecl(char ch)
- throws XmlPullParserException, IOException {
+ protected void parseXmlDecl(char ch) throws XmlPullParserException, IOException {
// [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
// first make sure that relative positions will stay OK
@@ -2510,57 +2429,50 @@ public class MXParser
// --- parse VersionInfo
- // [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
+ // [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"'
+ // VersionNum '"')
// parse is positioned just on first S past <?xml
ch = skipS(ch);
ch = requireInput(ch, VERSION);
// [25] Eq ::= S? '=' S?
ch = skipS(ch);
if (ch != '=') {
- throw new XmlPullParserException(
- "expected equals sign (=) after version and not " + printable(ch), this, null);
+ throw new XmlPullParserException("expected equals sign (=) after version and not " + printable(ch), this, null);
}
ch = more();
ch = skipS(ch);
if (ch != '\'' && ch != '"') {
- throw new XmlPullParserException(
- "expected apostrophe (') or quotation mark (\") after version and not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected apostrophe (') or quotation mark (\") after version and not " + printable(ch), this, null);
}
final char quotChar = ch;
- //int versionStart = pos + bufAbsoluteStart; // required if preventBufferCompaction==false
+ // int versionStart = pos + bufAbsoluteStart; // required if
+ // preventBufferCompaction==false
final int versionStart = pos;
ch = more();
// [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
while (ch != quotChar) {
- if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9')
- && ch != '_' && ch != '.' && ch != ':' && ch != '-') {
- throw new XmlPullParserException(
- "<?xml version value expected to be in ([a-zA-Z0-9_.:] | '-')"
- + " not " + printable(ch), this, null);
+ if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9') && ch != '_' && ch != '.' && ch != ':' && ch != '-') {
+ throw new XmlPullParserException("<?xml version value expected to be in ([a-zA-Z0-9_.:] | '-')" + " not " + printable(ch), this, null);
}
ch = more();
}
final int versionEnd = pos - 1;
parseXmlDeclWithVersion(versionStart, versionEnd);
- preventBufferCompaction = false; // alow again buffer commpaction - pos MAY chnage
+ preventBufferCompaction = false; // alow again buffer commpaction - pos
+ // MAY chnage
}
- //protected String xmlDeclVersion;
+ // protected String xmlDeclVersion;
- protected void parseXmlDeclWithVersion(int versionStart, int versionEnd)
- throws XmlPullParserException, IOException {
+ protected void parseXmlDeclWithVersion(int versionStart, int versionEnd) throws XmlPullParserException, IOException {
// check version is "1.0"
- if ((versionEnd - versionStart != 3)
- || buf[versionStart] != '1'
- || buf[versionStart + 1] != '.'
- || buf[versionStart + 2] != '0') {
- throw new XmlPullParserException(
- "only 1.0 is supported as <?xml version not '"
- + printable(new String(buf, versionStart, versionEnd - versionStart)) + "'", this, null);
+ if ((versionEnd - versionStart != 3) || buf[versionStart] != '1' || buf[versionStart + 1] != '.' || buf[versionStart + 2] != '0') {
+ throw new XmlPullParserException("only 1.0 is supported as <?xml version not '" + printable(new String(buf, versionStart, versionEnd - versionStart)) + "'", this,
+ null);
}
xmlDeclVersion = newString(buf, versionStart, versionEnd - versionStart);
- // [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
+ // [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName
+ // "'" )
char ch = more();
ch = skipS(ch);
if (ch == 'e') {
@@ -2568,32 +2480,24 @@ public class MXParser
ch = requireInput(ch, NCODING);
ch = skipS(ch);
if (ch != '=') {
- throw new XmlPullParserException(
- "expected equals sign (=) after encoding and not " + printable(ch), this, null);
+ throw new XmlPullParserException("expected equals sign (=) after encoding and not " + printable(ch), this, null);
}
ch = more();
ch = skipS(ch);
if (ch != '\'' && ch != '"') {
- throw new XmlPullParserException(
- "expected apostrophe (') or quotation mark (\") after encoding and not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected apostrophe (') or quotation mark (\") after encoding and not " + printable(ch), this, null);
}
final char quotChar = ch;
final int encodingStart = pos;
ch = more();
// [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z')) {
- throw new XmlPullParserException(
- "<?xml encoding name expected to start with [A-Za-z]"
- + " not " + printable(ch), this, null);
+ throw new XmlPullParserException("<?xml encoding name expected to start with [A-Za-z]" + " not " + printable(ch), this, null);
}
ch = more();
while (ch != quotChar) {
- if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9')
- && ch != '.' && ch != '_' && ch != '-') {
- throw new XmlPullParserException(
- "<?xml encoding value expected to be in ([A-Za-z0-9._] | '-')"
- + " not " + printable(ch), this, null);
+ if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9') && ch != '.' && ch != '_' && ch != '-') {
+ throw new XmlPullParserException("<?xml encoding value expected to be in ([A-Za-z0-9._] | '-')" + " not " + printable(ch), this, null);
}
ch = more();
}
@@ -2605,59 +2509,47 @@ public class MXParser
}
ch = skipS(ch);
- // [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
+ // [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"'
+ // ('yes' | 'no') '"'))
if (ch == 's') {
ch = more();
ch = requireInput(ch, TANDALONE);
ch = skipS(ch);
if (ch != '=') {
- throw new XmlPullParserException(
- "expected equals sign (=) after standalone and not " + printable(ch),
- this, null);
+ throw new XmlPullParserException("expected equals sign (=) after standalone and not " + printable(ch), this, null);
}
ch = more();
ch = skipS(ch);
if (ch != '\'' && ch != '"') {
- throw new XmlPullParserException(
- "expected apostrophe (') or quotation mark (\") after encoding and not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected apostrophe (') or quotation mark (\") after encoding and not " + printable(ch), this, null);
}
char quotChar = ch;
int standaloneStart = pos;
ch = more();
if (ch == 'y') {
ch = requireInput(ch, YES);
- //Boolean standalone = new Boolean(true);
+ // Boolean standalone = new Boolean(true);
xmlDeclStandalone = new Boolean(true);
} else if (ch == 'n') {
ch = requireInput(ch, NO);
- //Boolean standalone = new Boolean(false);
+ // Boolean standalone = new Boolean(false);
xmlDeclStandalone = new Boolean(false);
} else {
- throw new XmlPullParserException(
- "expected 'yes' or 'no' after standalone and not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected 'yes' or 'no' after standalone and not " + printable(ch), this, null);
}
if (ch != quotChar) {
- throw new XmlPullParserException(
- "expected " + quotChar + " after standalone value not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected " + quotChar + " after standalone value not " + printable(ch), this, null);
}
ch = more();
}
-
ch = skipS(ch);
if (ch != '?') {
- throw new XmlPullParserException(
- "expected ?> as last part of <?xml not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected ?> as last part of <?xml not " + printable(ch), this, null);
}
ch = more();
if (ch != '>') {
- throw new XmlPullParserException(
- "expected ?> as last part of <?xml not "
- + printable(ch), this, null);
+ throw new XmlPullParserException("expected ?> as last part of <?xml not " + printable(ch), this, null);
}
// NOTE: this code is broken as for some types of input streams (URLConnection ...)
@@ -2665,7 +2557,7 @@ public class MXParser
// as it somehow detects it and closes undelrying inout stram (b.....d!)
// In future one will need better low level byte-by-byte reading of prolog and then doing InputStream ...
// for more details see http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=135
- // //reset input stream
+ // //reset input stream
// if ((this.inputEncoding != oldEncoding) && (this.inputStream != null)) {
// if ((this.inputEncoding != null) && (!this.inputEncoding.equalsIgnoreCase(oldEncoding))) {
// // //there is need to reparse input to set location OK
@@ -2680,45 +2572,47 @@ public class MXParser
// }
}
- protected void parseDocdecl()
- throws XmlPullParserException, IOException {
- //ASSUMPTION: seen <!D
+ protected void parseDocdecl() throws XmlPullParserException, IOException {
+ // ASSUMPTION: seen <!D
char ch = more();
- if (ch != 'O') throw new XmlPullParserException(
- "expected <!DOCTYPE", this, null);
+ if (ch != 'O')
+ throw new XmlPullParserException("expected <!DOCTYPE", this, null);
ch = more();
- if (ch != 'C') throw new XmlPullParserException(
- "expected <!DOCTYPE", this, null);
+ if (ch != 'C')
+ throw new XmlPullParserException("expected <!DOCTYPE", this, null);
ch = more();
- if (ch != 'T') throw new XmlPullParserException(
- "expected <!DOCTYPE", this, null);
+ if (ch != 'T')
+ throw new XmlPullParserException("expected <!DOCTYPE", this, null);
ch = more();
- if (ch != 'Y') throw new XmlPullParserException(
- "expected <!DOCTYPE", this, null);
+ if (ch != 'Y')
+ throw new XmlPullParserException("expected <!DOCTYPE", this, null);
ch = more();
- if (ch != 'P') throw new XmlPullParserException(
- "expected <!DOCTYPE", this, null);
+ if (ch != 'P')
+ throw new XmlPullParserException("expected <!DOCTYPE", this, null);
ch = more();
- if (ch != 'E') throw new XmlPullParserException(
- "expected <!DOCTYPE", this, null);
+ if (ch != 'E')
+ throw new XmlPullParserException("expected <!DOCTYPE", this, null);
posStart = pos;
// do simple and crude scanning for end of doctype
- // [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('['
- // (markupdecl | DeclSep)* ']' S?)? '>'
+ // [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('['
+ // (markupdecl | DeclSep)* ']' S?)? '>'
int bracketLevel = 0;
final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false;
boolean normalizedCR = false;
while (true) {
ch = more();
- if (ch == '[') ++bracketLevel;
- if (ch == ']') --bracketLevel;
- if (ch == '>' && bracketLevel == 0) break;
+ if (ch == '[')
+ ++bracketLevel;
+ if (ch == ']')
+ --bracketLevel;
+ if (ch == '>' && bracketLevel == 0)
+ break;
if (normalizeIgnorableWS) {
if (ch == '\r') {
normalizedCR = true;
- //posEnd = pos -1;
- //joinPC();
+ // posEnd = pos -1;
+ // joinPC();
// posEnd is alreadys set
if (!usePC) {
posEnd = pos - 1;
@@ -2729,18 +2623,21 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
@@ -2751,36 +2648,35 @@ public class MXParser
posEnd = pos - 1;
}
- protected void parseCDSect(boolean hadCharData)
- throws XmlPullParserException, IOException {
+ protected void parseCDSect(boolean hadCharData) throws XmlPullParserException, IOException {
// implements XML 1.0 Section 2.7 CDATA Sections
// [18] CDSect ::= CDStart CData CDEnd
- // [19] CDStart ::= '<![CDATA['
+ // [19] CDStart ::= '<![CDATA['
// [20] CData ::= (Char* - (Char* ']]>' Char*))
// [21] CDEnd ::= ']]>'
- //ASSUMPTION: seen <![
+ // ASSUMPTION: seen <![
char ch = more();
- if (ch != 'C') throw new XmlPullParserException(
- "expected <[CDATA[ for comment start", this, null);
+ if (ch != 'C')
+ throw new XmlPullParserException("expected <[CDATA[ for comment start", this, null);
ch = more();
- if (ch != 'D') throw new XmlPullParserException(
- "expected <[CDATA[ for comment start", this, null);
+ if (ch != 'D')
+ throw new XmlPullParserException("expected <[CDATA[ for comment start", this, null);
ch = more();
- if (ch != 'A') throw new XmlPullParserException(
- "expected <[CDATA[ for comment start", this, null);
+ if (ch != 'A')
+ throw new XmlPullParserException("expected <[CDATA[ for comment start", this, null);
ch = more();
- if (ch != 'T') throw new XmlPullParserException(
- "expected <[CDATA[ for comment start", this, null);
+ if (ch != 'T')
+ throw new XmlPullParserException("expected <[CDATA[ for comment start", this, null);
ch = more();
- if (ch != 'A') throw new XmlPullParserException(
- "expected <[CDATA[ for comment start", this, null);
+ if (ch != 'A')
+ throw new XmlPullParserException("expected <[CDATA[ for comment start", this, null);
ch = more();
- if (ch != '[') throw new XmlPullParserException(
- "expected <![CDATA[ for comment start", this, null);
+ if (ch != '[')
+ throw new XmlPullParserException("expected <![CDATA[ for comment start", this, null);
- //if(tokenize) {
+ // if(tokenize) {
final int cdStart = pos + bufAbsoluteStart;
final int curLine = lineNumber;
final int curColumn = columnNumber;
@@ -2810,11 +2706,11 @@ public class MXParser
seenBracket = true;
} else {
seenBracketBracket = true;
- //seenBracket = false;
+ // seenBracket = false;
}
} else if (ch == '>') {
if (seenBracket && seenBracketBracket) {
- break; // found end sequence!!!!
+ break; // found end sequence!!!!
} else {
seenBracketBracket = false;
}
@@ -2838,18 +2734,21 @@ public class MXParser
pcStart = pcEnd = 0;
}
}
- //assert usePC == true;
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ // assert usePC == true;
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
} else if (ch == '\n') {
if (!normalizedCR && usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = '\n';
}
normalizedCR = false;
} else {
if (usePC) {
- if (pcEnd >= pc.length) ensurePC(pcEnd);
+ if (pcEnd >= pc.length)
+ ensurePC(pcEnd);
pc[pcEnd++] = ch;
}
normalizedCR = false;
@@ -2858,9 +2757,7 @@ public class MXParser
}
} catch (EOFException ex) {
// detect EOF and create meaningful error ...
- throw new XmlPullParserException(
- "CDATA section started on line " + curLine + " and column " + curColumn + " was not closed",
- this, ex);
+ throw new XmlPullParserException("CDATA section started on line " + curLine + " and column " + curColumn + " was not closed", this, ex);
}
if (normalizeInput) {
if (usePC) {
@@ -2872,8 +2769,8 @@ public class MXParser
}
protected void fillBuf() throws IOException, XmlPullParserException {
- if (reader == null) throw new XmlPullParserException(
- "reader must be set before parsing is started");
+ if (reader == null)
+ throw new XmlPullParserException("reader must be set before parsing is started");
// see if we are in compaction area
if (bufEnd > bufSoftLimit) {
@@ -2885,37 +2782,37 @@ public class MXParser
compact = false;
expand = true;
} else if (!compact) {
- //freeSpace
+ // freeSpace
if (bufStart < buf.length / 2) {
- // less then half buffer available forcompactin --> expand instead!!!
+ // less then half buffer available forcompactin --> expand
+ // instead!!!
expand = true;
} else {
- // at least half of buffer can be reclaimed --> worthwhile effort!!!
+ // at least half of buffer can be reclaimed --> worthwhile
+ // effort!!!
compact = true;
}
}
// if buffer almost full then compact it
if (compact) {
- //TODO: look on trashing
+ // TODO: look on trashing
// //assert bufStart > 0
System.arraycopy(buf, bufStart, buf, 0, bufEnd - bufStart);
- if (TRACE_SIZING) System.out.println(
- "TRACE_SIZING fillBuf() compacting " + bufStart
- + " bufEnd=" + bufEnd
- + " pos=" + pos + " posStart=" + posStart + " posEnd=" + posEnd
- + " buf first 100 chars:" + new String(buf, bufStart,
- bufEnd - bufStart < 100 ? bufEnd - bufStart : 100));
+ if (TRACE_SIZING)
+ System.out.println("TRACE_SIZING fillBuf() compacting " + bufStart + " bufEnd=" + bufEnd + " pos=" + pos + " posStart=" + posStart + " posEnd=" + posEnd
+ + " buf first 100 chars:" + new String(buf, bufStart, bufEnd - bufStart < 100 ? bufEnd - bufStart : 100));
} else if (expand) {
final int newSize = 2 * buf.length;
final char newBuf[] = new char[newSize];
- if (TRACE_SIZING) System.out.println("TRACE_SIZING fillBuf() " + buf.length + " => " + newSize);
+ if (TRACE_SIZING)
+ System.out.println("TRACE_SIZING fillBuf() " + buf.length + " => " + newSize);
System.arraycopy(buf, bufStart, newBuf, 0, bufEnd - bufStart);
buf = newBuf;
if (bufLoadFactor > 0) {
- //bufSoftLimit = ( bufLoadFactor * buf.length ) /100;
- bufSoftLimit = (int) ((((long) bufLoadFactor) * buf.length) / 100);
+ // bufSoftLimit = ( bufLoadFactor * buf.length ) /100;
+ bufSoftLimit = (int)((((long)bufLoadFactor) * buf.length) / 100);
}
} else {
@@ -2927,19 +2824,17 @@ public class MXParser
posEnd -= bufStart;
bufAbsoluteStart += bufStart;
bufStart = 0;
- if (TRACE_SIZING) System.out.println(
- "TRACE_SIZING fillBuf() after bufEnd=" + bufEnd
- + " pos=" + pos + " posStart=" + posStart + " posEnd=" + posEnd
- + " buf first 100 chars:" + new String(buf, 0, bufEnd < 100 ? bufEnd : 100));
+ if (TRACE_SIZING)
+ System.out.println("TRACE_SIZING fillBuf() after bufEnd=" + bufEnd + " pos=" + pos + " posStart=" + posStart + " posEnd=" + posEnd + " buf first 100 chars:"
+ + new String(buf, 0, bufEnd < 100 ? bufEnd : 100));
}
// at least one character must be read or error
final int len = buf.length - bufEnd > READ_CHUNK_SIZE ? READ_CHUNK_SIZE : buf.length - bufEnd;
final int ret = reader.read(buf, bufEnd, len);
if (ret > 0) {
bufEnd += ret;
- if (TRACE_SIZING) System.out.println(
- "TRACE_SIZING fillBuf() after filling in buffer"
- + " buf first 100 chars:" + new String(buf, 0, bufEnd < 100 ? bufEnd : 100));
+ if (TRACE_SIZING)
+ System.out.println("TRACE_SIZING fillBuf() after filling in buffer" + " buf first 100 chars:" + new String(buf, 0, bufEnd < 100 ? bufEnd : 100));
return;
}
@@ -2953,11 +2848,13 @@ public class MXParser
} else {
StringBuffer expectedTagStack = new StringBuffer();
if (depth > 0) {
- //final char[] cbuf = elRawName[depth];
- //final String startname = new String(cbuf, 0, elRawNameEnd[depth]);
+ // final char[] cbuf = elRawName[depth];
+ // final String startname = new String(cbuf, 0,
+ // elRawNameEnd[depth]);
expectedTagStack.append(" - expected end tag");
if (depth > 1) {
- expectedTagStack.append("s"); //more than one end tag
+ expectedTagStack.append("s"); // more than one end
+ // tag
}
expectedTagStack.append(" ");
for (int i = depth; i > 0; i--) {
@@ -2967,7 +2864,8 @@ public class MXParser
expectedTagStack.append(" to close");
for (int i = depth; i > 0; i--) {
if (i != depth) {
- expectedTagStack.append(" and"); //more than one end tag
+ expectedTagStack.append(" and"); // more than
+ // one end tag
}
String tagName = new String(elRawName[i], 0, elRawNameEnd[i]);
expectedTagStack.append(" start tag <" + tagName + ">");
@@ -2975,8 +2873,7 @@ public class MXParser
}
expectedTagStack.append(", parser stopped on");
}
- throw new EOFException("no more data available"
- + expectedTagStack.toString() + getPositionDescription());
+ throw new EOFException("no more data available" + expectedTagStack.toString() + getPositionDescription());
}
}
} else {
@@ -2987,102 +2884,101 @@ public class MXParser
protected char more() throws IOException, XmlPullParserException {
if (pos >= bufEnd) {
fillBuf();
- // this return value should be ignonored as it is used in epilog parsing ...
- if (reachedEnd) return (char) -1;
+ // this return value should be ignonored as it is used in epilog
+ // parsing ...
+ if (reachedEnd)
+ return (char)-1;
}
final char ch = buf[pos++];
- //line/columnNumber
+ // line/columnNumber
if (ch == '\n') {
++lineNumber;
columnNumber = 1;
} else {
++columnNumber;
}
- //System.out.print(ch);
+ // System.out.print(ch);
return ch;
}
- // /**
- // * This function returns position of parser in XML input stream
- // * (how many <b>characters</b> were processed.
- // * <p><b>NOTE:</b> this logical position and not byte offset as encodings
- // * such as UTF8 may use more than one byte to encode one character.
- // */
- // public int getCurrentInputPosition() {
- // return pos + bufAbsoluteStart;
- // }
+ // /**
+ // * This function returns position of parser in XML input stream
+ // * (how many <b>characters</b> were processed.
+ // * <p><b>NOTE:</b> this logical position and not byte offset as encodings
+ // * such as UTF8 may use more than one byte to encode one character.
+ // */
+ // public int getCurrentInputPosition() {
+ // return pos + bufAbsoluteStart;
+ // }
protected void ensurePC(int end) {
- //assert end >= pc.length;
+ // assert end >= pc.length;
final int newSize = end > READ_CHUNK_SIZE ? 2 * end : 2 * READ_CHUNK_SIZE;
final char[] newPC = new char[newSize];
if (TRACE_SIZING)
System.out.println("TRACE_SIZING ensurePC() " + pc.length + " ==> " + newSize + " end=" + end);
System.arraycopy(pc, 0, newPC, 0, pcEnd);
pc = newPC;
- //assert end < pc.length;
+ // assert end < pc.length;
}
protected void joinPC() {
- //assert usePC == false;
- //assert posEnd > posStart;
+ // assert usePC == false;
+ // assert posEnd > posStart;
final int len = posEnd - posStart;
final int newEnd = pcEnd + len + 1;
- if (newEnd >= pc.length) ensurePC(newEnd); // add 1 for extra space for one char
- //assert newEnd < pc.length;
+ if (newEnd >= pc.length)
+ ensurePC(newEnd); // add 1 for extra space for one char
+ // assert newEnd < pc.length;
System.arraycopy(buf, posStart, pc, pcEnd, len);
pcEnd += len;
usePC = true;
}
- protected char requireInput(char ch, char[] input)
- throws XmlPullParserException, IOException {
+ protected char requireInput(char ch, char[] input) throws XmlPullParserException, IOException {
for (int i = 0; i < input.length; i++) {
if (ch != input[i]) {
- throw new XmlPullParserException(
- "expected " + printable(input[i]) + " in " + new String(input)
- + " and not " + printable(ch), this, null);
+ throw new XmlPullParserException("expected " + printable(input[i]) + " in " + new String(input) + " and not " + printable(ch), this, null);
}
ch = more();
}
return ch;
}
- protected char requireNextS()
- throws XmlPullParserException, IOException {
+ protected char requireNextS() throws XmlPullParserException, IOException {
final char ch = more();
if (!isS(ch)) {
- throw new XmlPullParserException(
- "white space is required and not " + printable(ch), this, null);
+ throw new XmlPullParserException("white space is required and not " + printable(ch), this, null);
}
return skipS(ch);
}
- protected char skipS(char ch)
- throws XmlPullParserException, IOException {
+ protected char skipS(char ch) throws XmlPullParserException, IOException {
while (isS(ch)) {
ch = more();
} // skip additional spaces
return ch;
}
- // nameStart / name lookup tables based on XML 1.1 http://www.w3.org/TR/2001/WD-xml11-20011213/
+ // nameStart / name lookup tables based on XML 1.1
+ // http://www.w3.org/TR/2001/WD-xml11-20011213/
protected static final int LOOKUP_MAX = 0x400;
- protected static final char LOOKUP_MAX_CHAR = (char) LOOKUP_MAX;
- // protected static int lookupNameStartChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
- // protected static int lookupNameChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
+ protected static final char LOOKUP_MAX_CHAR = (char)LOOKUP_MAX;
+ // protected static int lookupNameStartChar[] = new int[ LOOKUP_MAX_CHAR /
+ // 32 ];
+ // protected static int lookupNameChar[] = new int[ LOOKUP_MAX_CHAR / 32 ];
protected static boolean lookupNameStartChar[] = new boolean[LOOKUP_MAX];
protected static boolean lookupNameChar[] = new boolean[LOOKUP_MAX];
private static final void setName(char ch)
- //{ lookupNameChar[ (int)ch / 32 ] |= (1 << (ch % 32)); }
+ // { lookupNameChar[ (int)ch / 32 ] |= (1 << (ch % 32)); }
{
lookupNameChar[ch] = true;
}
private static final void setNameStart(char ch)
- //{ lookupNameStartChar[ (int)ch / 32 ] |= (1 << (ch % 32)); setName(ch); }
+ // { lookupNameStartChar[ (int)ch / 32 ] |= (1 << (ch % 32)); setName(ch); }
{
lookupNameStartChar[ch] = true;
setName(ch);
@@ -3090,75 +2986,83 @@ public class MXParser
static {
setNameStart(':');
- for (char ch = 'A'; ch <= 'Z'; ++ch) setNameStart(ch);
+ for (char ch = 'A'; ch <= 'Z'; ++ch)
+ setNameStart(ch);
setNameStart('_');
- for (char ch = 'a'; ch <= 'z'; ++ch) setNameStart(ch);
- for (char ch = '\u00c0'; ch <= '\u02FF'; ++ch) setNameStart(ch);
- for (char ch = '\u0370'; ch <= '\u037d'; ++ch) setNameStart(ch);
- for (char ch = '\u037f'; ch < '\u0400'; ++ch) setNameStart(ch);
+ for (char ch = 'a'; ch <= 'z'; ++ch)
+ setNameStart(ch);
+ for (char ch = '\u00c0'; ch <= '\u02FF'; ++ch)
+ setNameStart(ch);
+ for (char ch = '\u0370'; ch <= '\u037d'; ++ch)
+ setNameStart(ch);
+ for (char ch = '\u037f'; ch < '\u0400'; ++ch)
+ setNameStart(ch);
setName('-');
setName('.');
- for (char ch = '0'; ch <= '9'; ++ch) setName(ch);
+ for (char ch = '0'; ch <= '9'; ++ch)
+ setName(ch);
setName('\u00b7');
- for (char ch = '\u0300'; ch <= '\u036f'; ++ch) setName(ch);
+ for (char ch = '\u0300'; ch <= '\u036f'; ++ch)
+ setName(ch);
}
- //private final static boolean isNameStartChar(char ch) {
+ // private final static boolean isNameStartChar(char ch) {
protected boolean isNameStartChar(char ch) {
- return (ch < LOOKUP_MAX_CHAR && lookupNameStartChar[ch])
- || (ch >= LOOKUP_MAX_CHAR && ch <= '\u2027')
- || (ch >= '\u202A' && ch <= '\u218F')
- || (ch >= '\u2800' && ch <= '\uFFEF')
- ;
-
- // if(ch < LOOKUP_MAX_CHAR) return lookupNameStartChar[ ch ];
- // else return ch <= '\u2027'
- // || (ch >= '\u202A' && ch <= '\u218F')
- // || (ch >= '\u2800' && ch <= '\uFFEF')
- // ;
- //return false;
- // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ':'
- // || (ch >= '0' && ch <= '9');
- // if(ch < LOOKUP_MAX_CHAR) return (lookupNameStartChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0;
- // if(ch <= '\u2027') return true;
- // //[#x202A-#x218F]
- // if(ch < '\u202A') return false;
- // if(ch <= '\u218F') return true;
- // // added pairts [#x2800-#xD7FF] | [#xE000-#xFDCF] | [#xFDE0-#xFFEF] | [#x10000-#x10FFFF]
- // if(ch < '\u2800') return false;
- // if(ch <= '\uFFEF') return true;
- // return false;
-
-
- // else return (supportXml11 && ( (ch < '\u2027') || (ch > '\u2029' && ch < '\u2200') ...
- }
-
- //private final static boolean isNameChar(char ch) {
+ return (ch < LOOKUP_MAX_CHAR && lookupNameStartChar[ch]) || (ch >= LOOKUP_MAX_CHAR && ch <= '\u2027') || (ch >= '\u202A' && ch <= '\u218F')
+ || (ch >= '\u2800' && ch <= '\uFFEF');
+
+ // if(ch < LOOKUP_MAX_CHAR) return lookupNameStartChar[ ch ];
+ // else return ch <= '\u2027'
+ // || (ch >= '\u202A' && ch <= '\u218F')
+ // || (ch >= '\u2800' && ch <= '\uFFEF')
+ // ;
+ // return false;
+ // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch ==
+ // ':'
+ // || (ch >= '0' && ch <= '9');
+ // if(ch < LOOKUP_MAX_CHAR) return (lookupNameStartChar[ (int)ch / 32 ]
+ // & (1 << (ch % 32))) != 0;
+ // if(ch <= '\u2027') return true;
+ // //[#x202A-#x218F]
+ // if(ch < '\u202A') return false;
+ // if(ch <= '\u218F') return true;
+ // // added pairts [#x2800-#xD7FF] | [#xE000-#xFDCF] | [#xFDE0-#xFFEF] |
+ // [#x10000-#x10FFFF]
+ // if(ch < '\u2800') return false;
+ // if(ch <= '\uFFEF') return true;
+ // return false;
+
+ // else return (supportXml11 && ( (ch < '\u2027') || (ch > '\u2029' &&
+ // ch < '\u2200') ...
+ }
+
+ // private final static boolean isNameChar(char ch) {
protected boolean isNameChar(char ch) {
- //return isNameStartChar(ch);
-
- // if(ch < LOOKUP_MAX_CHAR) return (lookupNameChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0;
-
- return (ch < LOOKUP_MAX_CHAR && lookupNameChar[ch])
- || (ch >= LOOKUP_MAX_CHAR && ch <= '\u2027')
- || (ch >= '\u202A' && ch <= '\u218F')
- || (ch >= '\u2800' && ch <= '\uFFEF')
- ;
- //return false;
- // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ':'
- // || (ch >= '0' && ch <= '9');
- // if(ch < LOOKUP_MAX_CHAR) return (lookupNameStartChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0;
-
- //else return
- // else if(ch <= '\u2027') return true;
- // //[#x202A-#x218F]
- // else if(ch < '\u202A') return false;
- // else if(ch <= '\u218F') return true;
- // // added pairts [#x2800-#xD7FF] | [#xE000-#xFDCF] | [#xFDE0-#xFFEF] | [#x10000-#x10FFFF]
- // else if(ch < '\u2800') return false;
- // else if(ch <= '\uFFEF') return true;
- //else return false;
+ // return isNameStartChar(ch);
+
+ // if(ch < LOOKUP_MAX_CHAR) return (lookupNameChar[ (int)ch / 32 ] & (1
+ // << (ch % 32))) != 0;
+
+ return (ch < LOOKUP_MAX_CHAR && lookupNameChar[ch]) || (ch >= LOOKUP_MAX_CHAR && ch <= '\u2027') || (ch >= '\u202A' && ch <= '\u218F')
+ || (ch >= '\u2800' && ch <= '\uFFEF');
+ // return false;
+ // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch ==
+ // ':'
+ // || (ch >= '0' && ch <= '9');
+ // if(ch < LOOKUP_MAX_CHAR) return (lookupNameStartChar[ (int)ch / 32 ]
+ // & (1 << (ch % 32))) != 0;
+
+ // else return
+ // else if(ch <= '\u2027') return true;
+ // //[#x202A-#x218F]
+ // else if(ch < '\u202A') return false;
+ // else if(ch <= '\u218F') return true;
+ // // added pairts [#x2800-#xD7FF] | [#xE000-#xFDCF] | [#xFDE0-#xFFEF] |
+ // [#x10000-#x10FFFF]
+ // else if(ch < '\u2800') return false;
+ // else if(ch <= '\uFFEF') return true;
+ // else return false;
}
protected boolean isS(char ch) {
@@ -3166,11 +3070,11 @@ public class MXParser
// || (supportXml11 && (ch == '\u0085' || ch == '\u2028');
}
- //protected boolean isChar(char ch) { return (ch < '\uD800' || ch > '\uDFFF')
- // ch != '\u0000' ch < '\uFFFE'
-
+ // protected boolean isChar(char ch) { return (ch < '\uD800' || ch >
+ // '\uDFFF')
+ // ch != '\u0000' ch < '\uFFFE'
- //protected char printable(char ch) { return ch; }
+ // protected char printable(char ch) { return ch; }
protected String printable(char ch) {
if (ch == '\n') {
return "\\n";
@@ -3182,13 +3086,14 @@ public class MXParser
return "\\'";
}
if (ch > 127 || ch < 32) {
- return "\\u" + Integer.toHexString((int) ch);
+ return "\\u" + Integer.toHexString((int)ch);
}
return "" + ch;
}
protected String printable(String s) {
- if (s == null) return null;
+ if (s == null)
+ return null;
final int sLen = s.length();
StringBuffer buf = new StringBuffer(sLen + 10);
for (int i = 0; i < sLen; ++i) {
@@ -3199,64 +3104,41 @@ public class MXParser
}
}
-
/*
- * Indiana University Extreme! Lab Software License, Version 1.2
- *
- * Copyright (C) 2003 The Trustees of Indiana University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1) All redistributions of source code must retain the above
- * copyright notice, the list of authors in the original source
- * code, this list of conditions and the disclaimer listed in this
- * license;
- *
- * 2) All redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the disclaimer
- * listed in this license in the documentation and/or other
- * materials provided with the distribution;
- *
- * 3) Any documentation included with all redistributions must include
- * the following acknowledgement:
- *
- * "This product includes software developed by the Indiana
- * University Extreme! Lab. For further information please visit
- * http://www.extreme.indiana.edu/"
- *
- * Alternatively, this acknowledgment may appear in the software
- * itself, and wherever such third-party acknowledgments normally
- * appear.
- *
- * 4) The name "Indiana University" or "Indiana University
- * Extreme! Lab" shall not be used to endorse or promote
- * products derived from this software without prior written
- * permission from Indiana University. For written permission,
- * please contact http://www.extreme.indiana.edu/.
- *
- * 5) Products derived from this software may not use "Indiana
- * University" name nor may "Indiana University" appear in their name,
- * without prior written permission of the Indiana University.
- *
- * Indiana University provides no reassurances that the source code
- * provided does not infringe the patent or any other intellectual
- * property rights of any other entity. Indiana University disclaims any
- * liability to any recipient for claims brought by any other entity
- * based on infringement of intellectual property rights or otherwise.
- *
- * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
- * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
- * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
- * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
- * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
+ * Indiana University Extreme! Lab Software License, Version 1.2 Copyright (C)
+ * 2003 The Trustees of Indiana University. All rights reserved. Redistribution
+ * and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met: 1) All
+ * redistributions of source code must retain the above copyright notice, the
+ * list of authors in the original source code, this list of conditions and the
+ * disclaimer listed in this license; 2) All redistributions in binary form must
+ * reproduce the above copyright notice, this list of conditions and the
+ * disclaimer listed in this license in the documentation and/or other materials
+ * provided with the distribution; 3) Any documentation included with all
+ * redistributions must include the following acknowledgement: "This product
+ * includes software developed by the Indiana University Extreme! Lab. For
+ * further information please visit http://www.extreme.indiana.edu/"
+ * Alternatively, this acknowledgment may appear in the software itself, and
+ * wherever such third-party acknowledgments normally appear. 4) The name
+ * "Indiana University" or "Indiana University Extreme! Lab" shall not be used
+ * to endorse or promote products derived from this software without prior
+ * written permission from Indiana University. For written permission, please
+ * contact http://www.extreme.indiana.edu/. 5) Products derived from this
+ * software may not use "Indiana University" name nor may "Indiana University"
+ * appear in their name, without prior written permission of the Indiana
+ * University. Indiana University provides no reassurances that the source code
+ * provided does not infringe the patent or any other intellectual property
+ * rights of any other entity. Indiana University disclaims any liability to any
+ * recipient for claims brought by any other entity based on infringement of
+ * intellectual property rights or otherwise. LICENSEE UNDERSTANDS THAT SOFTWARE
+ * IS PROVIDED "AS IS" FOR WHICH NO WARRANTIES AS TO CAPABILITIES OR ACCURACY
+ * ARE MADE. INDIANA UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION
+ * THAT SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
+ * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
* SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
- * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
- * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
- * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
- * SOFTWARE.
+ * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE RISK AS
+ * TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS, AND TO THE
+ * PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING SOFTWARE.
*/
-// CHECKSTYLE:ON
\ No newline at end of file
+// CHECKSTYLE:ON
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParser.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParser.java
index 4f8083a..51ea68e 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParser.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParser.java
@@ -26,56 +26,69 @@ import java.io.IOException;
import java.io.Reader;
/**
- * XML Pull Parser is an interface that defines parsing functionality provided in
- * <a href="http://www.xmlpull.org/">XMLPULL V1 API</a> (visit this website to learn more about API and its
- * implementations).
+ * XML Pull Parser is an interface that defines parsing functionality provided
+ * in <a href="http://www.xmlpull.org/">XMLPULL V1 API</a> (visit this website
+ * to learn more about API and its implementations).
* <p>
- * There are following different kinds of parser depending on which features are set:
+ * There are following different kinds of parser depending on which features are
+ * set:
* <ul>
- * <li><b>non-validating</b> parser as defined in XML 1.0 spec when FEATURE_PROCESS_DOCDECL is set to true
- * <li><b>validating parser</b> as defined in XML 1.0 spec when FEATURE_VALIDATION is true (and that implies that
- * FEATURE_PROCESS_DOCDECL is true)
- * <li>when FEATURE_PROCESS_DOCDECL is false (this is default and if different value is required necessary must be
- * changed before parsing is started) then parser behaves like XML 1.0 compliant non-validating parser under condition
- * that <em>no DOCDECL is present</em> in XML documents (internal entities can still be defined with
- * defineEntityReplacementText()). This mode of operation is intended <b>for operation in constrained environments</b>
- * such as J2ME.
+ * <li><b>non-validating</b> parser as defined in XML 1.0 spec when
+ * FEATURE_PROCESS_DOCDECL is set to true
+ * <li><b>validating parser</b> as defined in XML 1.0 spec when
+ * FEATURE_VALIDATION is true (and that implies that FEATURE_PROCESS_DOCDECL is
+ * true)
+ * <li>when FEATURE_PROCESS_DOCDECL is false (this is default and if different
+ * value is required necessary must be changed before parsing is started) then
+ * parser behaves like XML 1.0 compliant non-validating parser under condition
+ * that <em>no DOCDECL is present</em> in XML documents (internal entities can
+ * still be defined with defineEntityReplacementText()). This mode of operation
+ * is intended <b>for operation in constrained environments</b> such as J2ME.
* </ul>
* <p>
- * There are two key methods: next() and nextToken(). While next() provides access to high level parsing events,
- * nextToken() allows access to lower level tokens.
+ * There are two key methods: next() and nextToken(). While next() provides
+ * access to high level parsing events, nextToken() allows access to lower level
+ * tokens.
* <p>
- * The current event state of the parser can be determined by calling the <a href="#getEventType()">getEventType()</a>
- * method. Initially, the parser is in the <a href="#START_DOCUMENT">START_DOCUMENT</a> state.
+ * The current event state of the parser can be determined by calling the
+ * <a href="#getEventType()">getEventType()</a> method. Initially, the parser is
+ * in the <a href="#START_DOCUMENT">START_DOCUMENT</a> state.
* <p>
- * The method <a href="#next()">next()</a> advances the parser to the next event. The int value returned from next
- * determines the current parser state and is identical to the value returned from following calls to getEventType ().
+ * The method <a href="#next()">next()</a> advances the parser to the next
+ * event. The int value returned from next determines the current parser state
+ * and is identical to the value returned from following calls to getEventType
+ * ().
* <p>
* The following event types are seen by next()
* <dl>
* <dt><a href="#START_TAG">START_TAG</a>
* <dd>An XML start tag was read.
* <dt><a href="#TEXT">TEXT</a>
- * <dd>Text content was read; the text content can be retrieved using the getText() method. (when in validating mode
- * next() will not report ignorable whitespaces, use nextToken() instead)
+ * <dd>Text content was read; the text content can be retrieved using the
+ * getText() method. (when in validating mode next() will not report ignorable
+ * whitespaces, use nextToken() instead)
* <dt><a href="#END_TAG">END_TAG</a>
* <dd>An end tag was read
* <dt><a href="#END_DOCUMENT">END_DOCUMENT</a>
* <dd>No more events are available
* </dl>
* <p>
- * after first next() or nextToken() (or any other next*() method) is called user application can obtain XML version,
- * standalone and encoding from XML declaration in following ways:
+ * after first next() or nextToken() (or any other next*() method) is called
+ * user application can obtain XML version, standalone and encoding from XML
+ * declaration in following ways:
* <ul>
* <li><b>version</b>: getProperty("<a href=
* "http://xmlpull.org/v1/doc/properties.html#xmldecl-version">http://xmlpull.org/v1/doc/properties.html#xmldecl-version</a>")
- * returns String ("1.0") or null if XMLDecl was not read or if property is not supported
+ * returns String ("1.0") or null if XMLDecl was not read or if property is not
+ * supported
* <li><b>standalone</b>: getProperty("<a href=
* "http://xmlpull.org/v1/doc/features.html#xmldecl-standalone">http://xmlpull.org/v1/doc/features.html#xmldecl-standalone</a>")
- * returns Boolean: null if there was no standalone declaration or if property is not supported otherwise returns
- * Boolean(true) if standalone="yes" and Boolean(false) when standalone="no"
- * <li><b>encoding</b>: obtained from getInputEncoding() null if stream had unknown encoding (not set in setInputStream)
- * and it was not declared in XMLDecl
+ * returns Boolean: null if there was no standalone declaration or if property
+ * is not supported otherwise returns Boolean(true) if standalone="yes" and
+ * Boolean(false) when standalone="no"
+ * <li><b>encoding</b>: obtained from getInputEncoding() null if stream had
+ * unknown encoding (not set in setInputStream) and it was not declared in
+ * XMLDecl
* </ul>
* A minimal example for using this API may look as follows:
*
@@ -87,31 +100,28 @@ import java.io.Reader;
* import org.xmlpull.v1.XmlPullParserException;
* import org.xmlpull.v1.XmlPullParserFactory;
*
- * public class SimpleXmlPullApp
- * {
+ * public class SimpleXmlPullApp {
*
- * public static void main (String args[])
- * throws XmlPullParserException, IOException
- * {
+ * public static void main(String args[]) throws XmlPullParserException, IOException {
* XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
* factory.setNamespaceAware(true);
* XmlPullParser xpp = factory.newPullParser();
*
- * xpp.setInput( new StringReader ( "<foo%gt;Hello World!</foo>" ) );
+ * xpp.setInput(new StringReader("<foo%gt;Hello World!</foo>"));
* int eventType = xpp.getEventType();
* while (eventType != xpp.END_DOCUMENT) {
- * if(eventType == xpp.START_DOCUMENT) {
- * System.out.println("Start document");
- * } else if(eventType == xpp.END_DOCUMENT) {
- * System.out.println("End document");
- * } else if(eventType == xpp.START_TAG) {
- * System.out.println("Start tag "+xpp.getName());
- * } else if(eventType == xpp.END_TAG) {
- * System.out.println("End tag "+xpp.getName());
- * } else if(eventType == xpp.TEXT) {
- * System.out.println("Text "+xpp.getText());
- * }
- * eventType = xpp.next();
+ * if (eventType == xpp.START_DOCUMENT) {
+ * System.out.println("Start document");
+ * } else if (eventType == xpp.END_DOCUMENT) {
+ * System.out.println("End document");
+ * } else if (eventType == xpp.START_TAG) {
+ * System.out.println("Start tag " + xpp.getName());
+ * } else if (eventType == xpp.END_TAG) {
+ * System.out.println("End tag " + xpp.getName());
+ * } else if (eventType == xpp.TEXT) {
+ * System.out.println("Text " + xpp.getText());
+ * }
+ * eventType = xpp.next();
* }
* }
* }
@@ -126,8 +136,8 @@ import java.io.Reader;
* End tag foo
* </pre>
*
- * For more details on API usage, please refer to the quick Introduction available at
- * <a href="http://www.xmlpull.org">http://www.xmlpull.org</a>
+ * For more details on API usage, please refer to the quick Introduction
+ * available at <a href="http://www.xmlpull.org">http://www.xmlpull.org</a>
*
* @see #defineEntityReplacementText
* @see #getName
@@ -143,12 +153,14 @@ import java.io.Reader;
* @see #TEXT
* @see #END_TAG
* @see #END_DOCUMENT
- * @author <a href="http://www-ai.cs.uni-dortmund.de/PERSONAL/haustein.html">Stefan Haustein</a>
- * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
+ * @author <a href=
+ * "http://www-ai.cs.uni-dortmund.de/PERSONAL/haustein.html">Stefan
+ * Haustein</a>
+ * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander
+ * Slominski</a>
*/
-public interface XmlPullParser
-{
+public interface XmlPullParser {
/** This constant represents the default namespace (empty string "") */
String NO_NAMESPACE = "";
@@ -157,8 +169,9 @@ public interface XmlPullParser
// EVENT TYPES as reported by next()
/**
- * Signalize that parser is at the very beginning of the document and nothing was read yet. This event type can only
- * be observed by calling getEvent() before the first call to next(), nextToken, or nextTag()).
+ * Signalize that parser is at the very beginning of the document and
+ * nothing was read yet. This event type can only be observed by calling
+ * getEvent() before the first call to next(), nextToken, or nextTag()).
*
* @see #next
* @see #nextToken
@@ -166,11 +179,12 @@ public interface XmlPullParser
int START_DOCUMENT = 0;
/**
- * Logical end of the xml document. Returned from getEventType, next() and nextToken() when the end of the input
- * document has been reached.
+ * Logical end of the xml document. Returned from getEventType, next() and
+ * nextToken() when the end of the input document has been reached.
* <p>
- * <strong>NOTE:</strong> calling again <a href="#next()">next()</a> or <a href="#nextToken()">nextToken()</a> will
- * result in exception being thrown.
+ * <strong>NOTE:</strong> calling again <a href="#next()">next()</a> or
+ * <a href="#nextToken()">nextToken()</a> will result in exception being
+ * thrown.
*
* @see #next
* @see #nextToken
@@ -178,11 +192,13 @@ public interface XmlPullParser
int END_DOCUMENT = 1;
/**
- * Returned from getEventType(), <a href="#next()">next()</a>, <a href="#nextToken()">nextToken()</a> when a start
- * tag was read. The name of start tag is available from getName(), its namespace and prefix are available from
- * getNamespace() and getPrefix() if <a href='#FEATURE_PROCESS_NAMESPACES'>namespaces are enabled</a>. See
- * getAttribute* methods to retrieve element attributes. See getNamespace* methods to retrieve newly declared
- * namespaces.
+ * Returned from getEventType(), <a href="#next()">next()</a>,
+ * <a href="#nextToken()">nextToken()</a> when a start tag was read. The
+ * name of start tag is available from getName(), its namespace and prefix
+ * are available from getNamespace() and getPrefix() if
+ * <a href='#FEATURE_PROCESS_NAMESPACES'>namespaces are enabled</a>. See
+ * getAttribute* methods to retrieve element attributes. See getNamespace*
+ * methods to retrieve newly declared namespaces.
*
* @see #next
* @see #nextToken
@@ -198,9 +214,10 @@ public interface XmlPullParser
int START_TAG = 2;
/**
- * Returned from getEventType(), <a href="#next()">next()</a>, or <a href="#nextToken()">nextToken()</a> when an end
- * tag was read. The name of start tag is available from getName(), its namespace and prefix are available from
- * getNamespace() and getPrefix().
+ * Returned from getEventType(), <a href="#next()">next()</a>, or
+ * <a href="#nextToken()">nextToken()</a> when an end tag was read. The name
+ * of start tag is available from getName(), its namespace and prefix are
+ * available from getNamespace() and getPrefix().
*
* @see #next
* @see #nextToken
@@ -214,12 +231,16 @@ public interface XmlPullParser
/**
* Character data was read and will is available by calling getText().
* <p>
- * <strong>Please note:</strong> <a href="#next()">next()</a> will accumulate multiple events into one TEXT event,
- * skipping IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION and COMMENT events, In contrast,
- * <a href="#nextToken()">nextToken()</a> will stop reading text when any other event is observed. Also, when the
- * state was reached by calling next(), the text value will be normalized, whereas getText() will return
- * unnormalized content in the case of nextToken(). This allows an exact roundtrip without changing line ends when
- * examining low level events, whereas for high level applications the text is normalized appropriately.
+ * <strong>Please note:</strong> <a href="#next()">next()</a> will
+ * accumulate multiple events into one TEXT event, skipping
+ * IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION and COMMENT events, In
+ * contrast, <a href="#nextToken()">nextToken()</a> will stop reading text
+ * when any other event is observed. Also, when the state was reached by
+ * calling next(), the text value will be normalized, whereas getText() will
+ * return unnormalized content in the case of nextToken(). This allows an
+ * exact roundtrip without changing line ends when examining low level
+ * events, whereas for high level applications the text is normalized
+ * appropriately.
*
* @see #next
* @see #nextToken
@@ -231,9 +252,10 @@ public interface XmlPullParser
// additional events exposed by lower level nextToken()
/**
- * A CDATA sections was just read; this token is available only from calls to
- * <a href="#nextToken()">nextToken()</a>. A call to next() will accumulate various text events into a single event
- * of type TEXT. The text contained in the CDATA section is available by calling getText().
+ * A CDATA sections was just read; this token is available only from calls
+ * to <a href="#nextToken()">nextToken()</a>. A call to next() will
+ * accumulate various text events into a single event of type TEXT. The text
+ * contained in the CDATA section is available by calling getText().
*
* @see #nextToken
* @see #getText
@@ -241,10 +263,13 @@ public interface XmlPullParser
int CDSECT = 5;
/**
- * An entity reference was just read; this token is available from <a href="#nextToken()">nextToken()</a> only. The
- * entity name is available by calling getName(). If available, the replacement text can be obtained by calling
- * getTextt(); otherwise, the user is responsible for resolving the entity reference. This event type is never
- * returned from next(); next() will accumulate the replacement text and other text events to a single TEXT event.
+ * An entity reference was just read; this token is available from
+ * <a href="#nextToken()">nextToken()</a> only. The entity name is available
+ * by calling getName(). If available, the replacement text can be obtained
+ * by calling getTextt(); otherwise, the user is responsible for resolving
+ * the entity reference. This event type is never returned from next();
+ * next() will accumulate the replacement text and other text events to a
+ * single TEXT event.
*
* @see #nextToken
* @see #getText
@@ -252,13 +277,16 @@ public interface XmlPullParser
int ENTITY_REF = 6;
/**
- * Ignorable whitespace was just read. This token is available only from <a href="#nextToken()">nextToken()</a>).
- * For non-validating parsers, this event is only reported by nextToken() when outside the root element. Validating
- * parsers may be able to detect ignorable whitespace at other locations. The ignorable whitespace string is
- * available by calling getText()
+ * Ignorable whitespace was just read. This token is available only from
+ * <a href="#nextToken()">nextToken()</a>). For non-validating parsers, this
+ * event is only reported by nextToken() when outside the root element.
+ * Validating parsers may be able to detect ignorable whitespace at other
+ * locations. The ignorable whitespace string is available by calling
+ * getText()
* <p>
- * <strong>NOTE:</strong> this is different from calling the isWhitespace() method, since text content may be
- * whitespace but not ignorable. Ignorable whitespace is skipped by next() automatically; this event type is never
+ * <strong>NOTE:</strong> this is different from calling the isWhitespace()
+ * method, since text content may be whitespace but not ignorable. Ignorable
+ * whitespace is skipped by next() automatically; this event type is never
* returned from next().
*
* @see #nextToken
@@ -267,9 +295,10 @@ public interface XmlPullParser
int IGNORABLE_WHITESPACE = 7;
/**
- * An XML processing instruction declaration was just read. This event type is available only via
- * <a href="#nextToken()">nextToken()</a>. getText() will return text that is inside the processing instruction.
- * Calls to next() will skip processing instructions automatically.
+ * An XML processing instruction declaration was just read. This event type
+ * is available only via <a href="#nextToken()">nextToken()</a>. getText()
+ * will return text that is inside the processing instruction. Calls to
+ * next() will skip processing instructions automatically.
*
* @see #nextToken
* @see #getText
@@ -277,9 +306,10 @@ public interface XmlPullParser
int PROCESSING_INSTRUCTION = 8;
/**
- * An XML comment was just read. This event type is this token is available via
- * <a href="#nextToken()">nextToken()</a> only; calls to next() will skip comments automatically. The content of the
- * comment can be accessed using the getText() method.
+ * An XML comment was just read. This event type is this token is available
+ * via <a href="#nextToken()">nextToken()</a> only; calls to next() will
+ * skip comments automatically. The content of the comment can be accessed
+ * using the getText() method.
*
* @see #nextToken
* @see #getText
@@ -287,9 +317,9 @@ public interface XmlPullParser
int COMMENT = 9;
/**
- * An XML document type declaration was just read. This token is available from
- * <a href="#nextToken()">nextToken()</a> only. The unparsed text inside the doctype is available via the getText()
- * method.
+ * An XML document type declaration was just read. This token is available
+ * from <a href="#nextToken()">nextToken()</a> only. The unparsed text
+ * inside the doctype is available via the getText() method.
*
* @see #nextToken
* @see #getText
@@ -297,21 +327,25 @@ public interface XmlPullParser
int DOCDECL = 10;
/**
- * This array can be used to convert the event type integer constants such as START_TAG or TEXT to to a string. For
- * example, the value of TYPES[START_TAG] is the string "START_TAG". This array is intended for diagnostic output
- * only. Relying on the contents of the array may be dangerous since malicious applications may alter the array,
- * although it is final, due to limitations of the Java language.
+ * This array can be used to convert the event type integer constants such
+ * as START_TAG or TEXT to to a string. For example, the value of
+ * TYPES[START_TAG] is the string "START_TAG". This array is intended for
+ * diagnostic output only. Relying on the contents of the array may be
+ * dangerous since malicious applications may alter the array, although it
+ * is final, due to limitations of the Java language.
*/
- String[] TYPES = { "START_DOCUMENT", "END_DOCUMENT", "START_TAG", "END_TAG", "TEXT", "CDSECT", "ENTITY_REF",
- "IGNORABLE_WHITESPACE", "PROCESSING_INSTRUCTION", "COMMENT", "DOCDECL" };
+ String[] TYPES = {"START_DOCUMENT", "END_DOCUMENT", "START_TAG", "END_TAG", "TEXT", "CDSECT", "ENTITY_REF", "IGNORABLE_WHITESPACE", "PROCESSING_INSTRUCTION", "COMMENT",
+ "DOCDECL"};
// ----------------------------------------------------------------------------
// namespace related features
/**
- * This feature determines whether the parser processes namespaces. As for all features, the default value is false.
+ * This feature determines whether the parser processes namespaces. As for
+ * all features, the default value is false.
* <p>
- * <strong>NOTE:</strong> The value can not be changed during parsing an must be set before parsing.
+ * <strong>NOTE:</strong> The value can not be changed during parsing an
+ * must be set before parsing.
*
* @see #getFeature
* @see #setFeature
@@ -319,8 +353,9 @@ public interface XmlPullParser
String FEATURE_PROCESS_NAMESPACES = "http://xmlpull.org/v1/doc/features.html#process-namespaces";
/**
- * This feature determines whether namespace attributes are exposed via the attribute access methods. Like all
- * features, the default value is false. This feature cannot be changed during parsing.
+ * This feature determines whether namespace attributes are exposed via the
+ * attribute access methods. Like all features, the default value is false.
+ * This feature cannot be changed during parsing.
*
* @see #getFeature
* @see #setFeature
@@ -328,13 +363,15 @@ public interface XmlPullParser
String FEATURE_REPORT_NAMESPACE_ATTRIBUTES = "http://xmlpull.org/v1/doc/features.html#report-namespace-prefixes";
/**
- * This feature determines whether the document declaration is processed. If set to false, the DOCDECL event type is
- * reported by nextToken() and ignored by next(). If this feature is activated, then the document declaration must
- * be processed by the parser.
+ * This feature determines whether the document declaration is processed. If
+ * set to false, the DOCDECL event type is reported by nextToken() and
+ * ignored by next(). If this feature is activated, then the document
+ * declaration must be processed by the parser.
* <p>
- * <strong>Please note:</strong> If the document type declaration was ignored, entity references may cause
- * exceptions later in the parsing process. The default value of this feature is false. It cannot be changed during
- * parsing.
+ * <strong>Please note:</strong> If the document type declaration was
+ * ignored, entity references may cause exceptions later in the parsing
+ * process. The default value of this feature is false. It cannot be changed
+ * during parsing.
*
* @see #getFeature
* @see #setFeature
@@ -342,11 +379,13 @@ public interface XmlPullParser
String FEATURE_PROCESS_DOCDECL = "http://xmlpull.org/v1/doc/features.html#process-docdecl";
/**
- * If this feature is activated, all validation errors as defined in the XML 1.0 specification are reported. This
- * implies that FEATURE_PROCESS_DOCDECL is true and both, the internal and external document type declaration will
- * be processed.
+ * If this feature is activated, all validation errors as defined in the XML
+ * 1.0 specification are reported. This implies that FEATURE_PROCESS_DOCDECL
+ * is true and both, the internal and external document type declaration
+ * will be processed.
* <p>
- * <strong>Please Note:</strong> This feature can not be changed during parsing. The default value is false.
+ * <strong>Please Note:</strong> This feature can not be changed during
+ * parsing. The default value is false.
*
* @see #getFeature
* @see #setFeature
@@ -354,120 +393,139 @@ public interface XmlPullParser
String FEATURE_VALIDATION = "http://xmlpull.org/v1/doc/features.html#validation";
/**
- * Use this call to change the general behaviour of the parser, such as namespace processing or doctype declaration
- * handling. This method must be called before the first call to next or nextToken. Otherwise, an exception is
- * thrown.
+ * Use this call to change the general behaviour of the parser, such as
+ * namespace processing or doctype declaration handling. This method must be
+ * called before the first call to next or nextToken. Otherwise, an
+ * exception is thrown.
* <p>
- * Example: call setFeature(FEATURE_PROCESS_NAMESPACES, true) in order to switch on namespace processing. The
- * initial settings correspond to the properties requested from the XML Pull Parser factory. If none were requested,
- * all features are deactivated by default.
+ * Example: call setFeature(FEATURE_PROCESS_NAMESPACES, true) in order to
+ * switch on namespace processing. The initial settings correspond to the
+ * properties requested from the XML Pull Parser factory. If none were
+ * requested, all features are deactivated by default.
*
- * @exception XmlPullParserException If the feature is not supported or can not be set
- * @exception IllegalArgumentException If string with the feature name is null
+ * @exception XmlPullParserException If the feature is not supported or can
+ * not be set
+ * @exception IllegalArgumentException If string with the feature name is
+ * null
*/
- void setFeature( String name, boolean state )
- throws XmlPullParserException;
+ void setFeature(String name, boolean state) throws XmlPullParserException;
/**
* Returns the current value of the given feature.
* <p>
- * <strong>Please note:</strong> unknown features are <strong>always</strong> returned as false.
+ * <strong>Please note:</strong> unknown features are
+ * <strong>always</strong> returned as false.
*
* @param name The name of feature to be retrieved.
* @return The value of the feature.
* @exception IllegalArgumentException if string the feature name is null
*/
- boolean getFeature( String name );
+ boolean getFeature(String name);
/**
- * Set the value of a property. The property name is any fully-qualified URI.
+ * Set the value of a property. The property name is any fully-qualified
+ * URI.
*
- * @exception XmlPullParserException If the property is not supported or can not be set
- * @exception IllegalArgumentException If string with the property name is null
+ * @exception XmlPullParserException If the property is not supported or can
+ * not be set
+ * @exception IllegalArgumentException If string with the property name is
+ * null
*/
- void setProperty( String name, Object value )
- throws XmlPullParserException;
+ void setProperty(String name, Object value) throws XmlPullParserException;
/**
- * Look up the value of a property. The property name is any fully-qualified URI.
+ * Look up the value of a property. The property name is any fully-qualified
+ * URI.
* <p>
- * <strong>NOTE:</strong> unknown properties are <strong>always</strong> returned as null.
+ * <strong>NOTE:</strong> unknown properties are <strong>always</strong>
+ * returned as null.
*
* @param name The name of property to be retrieved.
* @return The value of named property.
*/
- Object getProperty( String name );
+ Object getProperty(String name);
/**
- * Set the input source for parser to the given reader and resets the parser. The event type is set to the initial
- * value START_DOCUMENT. Setting the reader to null will just stop parsing and reset parser state, allowing the
- * parser to free internal resources such as parsing buffers.
+ * Set the input source for parser to the given reader and resets the
+ * parser. The event type is set to the initial value START_DOCUMENT.
+ * Setting the reader to null will just stop parsing and reset parser state,
+ * allowing the parser to free internal resources such as parsing buffers.
*/
- void setInput( Reader in )
- throws XmlPullParserException;
+ void setInput(Reader in) throws XmlPullParserException;
/**
- * Sets the input stream the parser is going to process. This call resets the parser state and sets the event type
- * to the initial value START_DOCUMENT.
+ * Sets the input stream the parser is going to process. This call resets
+ * the parser state and sets the event type to the initial value
+ * START_DOCUMENT.
* <p>
- * <strong>NOTE:</strong> If an input encoding string is passed, it MUST be used. Otherwise, if inputEncoding is
- * null, the parser SHOULD try to determine input encoding following XML 1.0 specification (see below). If encoding
- * detection is supported then following feature <a href=
+ * <strong>NOTE:</strong> If an input encoding string is passed, it MUST be
+ * used. Otherwise, if inputEncoding is null, the parser SHOULD try to
+ * determine input encoding following XML 1.0 specification (see below). If
+ * encoding detection is supported then following feature <a href=
* "http://xmlpull.org/v1/doc/features.html#detect-encoding">http://xmlpull.org/v1/doc/features.html#detect-encoding</a>
* MUST be true and otherwise it must be false
*
- * @param inputStream contains a raw byte input stream of possibly unknown encoding (when inputEncoding is null).
- * @param inputEncoding if not null it MUST be used as encoding for inputStream
+ * @param inputStream contains a raw byte input stream of possibly unknown
+ * encoding (when inputEncoding is null).
+ * @param inputEncoding if not null it MUST be used as encoding for
+ * inputStream
*/
- void setInput( InputStream inputStream, String inputEncoding )
- throws XmlPullParserException;
+ void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException;
/**
- * Returns the input encoding if known, null otherwise. If setInput(InputStream, inputEncoding) was called with an
- * inputEncoding value other than null, this value must be returned from this method. Otherwise, if inputEncoding is
- * null and the parser supports the encoding detection feature
- * (http://xmlpull.org/v1/doc/features.html#detect-encoding), it must return the detected encoding. If
- * setInput(Reader) was called, null is returned. After first call to next if XML declaration was present this
- * method will return encoding declared.
+ * Returns the input encoding if known, null otherwise. If
+ * setInput(InputStream, inputEncoding) was called with an inputEncoding
+ * value other than null, this value must be returned from this method.
+ * Otherwise, if inputEncoding is null and the parser supports the encoding
+ * detection feature
+ * (http://xmlpull.org/v1/doc/features.html#detect-encoding), it must return
+ * the detected encoding. If setInput(Reader) was called, null is returned.
+ * After first call to next if XML declaration was present this method will
+ * return encoding declared.
*/
String getInputEncoding();
/**
* Set new value for entity replacement text as defined in
- * <a href="http://www.w3.org/TR/REC-xml#intern-replacement">XML 1.0 Section 4.5 Construction of Internal Entity
- * Replacement Text</a>. If FEATURE_PROCESS_DOCDECL or FEATURE_VALIDATION are set, calling this function will result
- * in an exception -- when processing of DOCDECL is enabled, there is no need to the entity replacement text
- * manually.
+ * <a href="http://www.w3.org/TR/REC-xml#intern-replacement">XML 1.0 Section
+ * 4.5 Construction of Internal Entity Replacement Text</a>. If
+ * FEATURE_PROCESS_DOCDECL or FEATURE_VALIDATION are set, calling this
+ * function will result in an exception -- when processing of DOCDECL is
+ * enabled, there is no need to the entity replacement text manually.
* <p>
- * The motivation for this function is to allow very small implementations of XMLPULL that will work in J2ME
- * environments. Though these implementations may not be able to process the document type declaration, they still
- * can work with known DTDs by using this function.
+ * The motivation for this function is to allow very small implementations
+ * of XMLPULL that will work in J2ME environments. Though these
+ * implementations may not be able to process the document type declaration,
+ * they still can work with known DTDs by using this function.
* <p>
- * <b>Please notes:</b> The given value is used literally as replacement text and it corresponds to declaring entity
- * in DTD that has all special characters escaped: left angle bracket is replaced with &lt;, ampersand with
- * &amp; and so on.
+ * <b>Please notes:</b> The given value is used literally as replacement
+ * text and it corresponds to declaring entity in DTD that has all special
+ * characters escaped: left angle bracket is replaced with &lt;,
+ * ampersand with &amp; and so on.
* <p>
- * <b>Note:</b> The given value is the literal replacement text and must not contain any other entity reference (if
- * it contains any entity reference there will be no further replacement).
+ * <b>Note:</b> The given value is the literal replacement text and must not
+ * contain any other entity reference (if it contains any entity reference
+ * there will be no further replacement).
* <p>
- * <b>Note:</b> The list of pre-defined entity names will always contain standard XML entities such as amp
- * (&amp;), lt (&lt;), gt (&gt;), quot (&quot;), and apos (&apos;). Those cannot be redefined by
- * this method!
+ * <b>Note:</b> The list of pre-defined entity names will always contain
+ * standard XML entities such as amp (&amp;), lt (&lt;), gt
+ * (&gt;), quot (&quot;), and apos (&apos;). Those cannot be
+ * redefined by this method!
*
* @see #setInput
* @see #FEATURE_PROCESS_DOCDECL
* @see #FEATURE_VALIDATION
*/
- void defineEntityReplacementText( String entityName, String replacementText )
- throws XmlPullParserException;
+ void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException;
/**
- * Returns the numbers of elements in the namespace stack for the given depth. If namespaces are not enabled, 0 is
- * returned.
+ * Returns the numbers of elements in the namespace stack for the given
+ * depth. If namespaces are not enabled, 0 is returned.
* <p>
- * <b>NOTE:</b> when parser is on END_TAG then it is allowed to call this function with getDepth()+1 argument to
- * retrieve position of namespace prefixes and URIs that were declared on corresponding START_TAG.
+ * <b>NOTE:</b> when parser is on END_TAG then it is allowed to call this
+ * function with getDepth()+1 argument to retrieve position of namespace
+ * prefixes and URIs that were declared on corresponding START_TAG.
* <p>
* <b>NOTE:</b> to retrieve lsit of namespaces declared in current element:
*
@@ -487,65 +545,68 @@ public interface XmlPullParser
* @see #getNamespace()
* @see #getNamespace(String)
*/
- int getNamespaceCount( int depth )
- throws XmlPullParserException;
+ int getNamespaceCount(int depth) throws XmlPullParserException;
/**
- * Returns the namespace prefix for the given position in the namespace stack. Default namespace declaration
- * (xmlns='...') will have null as prefix. If the given index is out of range, an exception is thrown.
+ * Returns the namespace prefix for the given position in the namespace
+ * stack. Default namespace declaration (xmlns='...') will have null as
+ * prefix. If the given index is out of range, an exception is thrown.
* <p>
- * <b>Please note:</b> when the parser is on an END_TAG, namespace prefixes that were declared in the corresponding
- * START_TAG are still accessible although they are no longer in scope.
+ * <b>Please note:</b> when the parser is on an END_TAG, namespace prefixes
+ * that were declared in the corresponding START_TAG are still accessible
+ * although they are no longer in scope.
*/
- String getNamespacePrefix( int pos )
- throws XmlPullParserException;
+ String getNamespacePrefix(int pos) throws XmlPullParserException;
/**
- * Returns the namespace URI for the given position in the namespace stack If the position is out of range, an
- * exception is thrown.
+ * Returns the namespace URI for the given position in the namespace stack
+ * If the position is out of range, an exception is thrown.
* <p>
- * <b>NOTE:</b> when parser is on END_TAG then namespace prefixes that were declared in corresponding START_TAG are
- * still accessible even though they are not in scope
+ * <b>NOTE:</b> when parser is on END_TAG then namespace prefixes that were
+ * declared in corresponding START_TAG are still accessible even though they
+ * are not in scope
*/
- String getNamespaceUri( int pos )
- throws XmlPullParserException;
+ String getNamespaceUri(int pos) throws XmlPullParserException;
/**
- * Returns the URI corresponding to the given prefix, depending on current state of the parser.
+ * Returns the URI corresponding to the given prefix, depending on current
+ * state of the parser.
* <p>
- * If the prefix was not declared in the current scope, null is returned. The default namespace is included in the
- * namespace table and is available via getNamespace (null).
+ * If the prefix was not declared in the current scope, null is returned.
+ * The default namespace is included in the namespace table and is available
+ * via getNamespace (null).
* <p>
* This method is a convenience method for
*
* <pre>
- * for ( int i = getNamespaceCount( getDepth() ) - 1; i >= 0; i-- )
- * {
- * if ( getNamespacePrefix( i ).equals( prefix ) )
- * {
- * return getNamespaceUri( i );
+ * for (int i = getNamespaceCount(getDepth()) - 1; i >= 0; i--) {
+ * if (getNamespacePrefix(i).equals(prefix)) {
+ * return getNamespaceUri(i);
* }
* }
* return null;
* </pre>
* <p>
- * <strong>Please note:</strong> parser implementations may provide more efficient lookup, e.g. using a Hashtable.
- * The 'xml' prefix is bound to "http://www.w3.org/XML/1998/namespace", as defined in the
- * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in XML</a> specification. Analogous, the
- * 'xmlns' prefix is resolved to <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>
+ * <strong>Please note:</strong> parser implementations may provide more
+ * efficient lookup, e.g. using a Hashtable. The 'xml' prefix is bound to
+ * "http://www.w3.org/XML/1998/namespace", as defined in the
+ * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in
+ * XML</a> specification. Analogous, the 'xmlns' prefix is resolved to
+ * <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>
*
* @see #getNamespaceCount
* @see #getNamespacePrefix
* @see #getNamespaceUri
*/
- String getNamespace( String prefix );
+ String getNamespace(String prefix);
// --------------------------------------------------------------------------
// miscellaneous reporting methods
/**
- * Returns the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1
- * when a start tag is reached. The depth is decremented AFTER the end tag event was observed.
+ * Returns the current depth of the element. Outside the root element, the
+ * depth is 0. The depth is incremented by 1 when a start tag is reached.
+ * The depth is decremented AFTER the end tag event was observed.
*
* <pre>
* <!-- outside --> 0
@@ -560,23 +621,26 @@ public interface XmlPullParser
int getDepth();
/**
- * Returns a short text describing the current parser state, including the position, a description of the current
- * event and the data source if known. This method is especially useful to provide meaningful error messages and for
- * debugging purposes.
+ * Returns a short text describing the current parser state, including the
+ * position, a description of the current event and the data source if
+ * known. This method is especially useful to provide meaningful error
+ * messages and for debugging purposes.
*/
String getPositionDescription();
/**
- * Returns the current line number, starting from 1. When the parser does not know the current line number or can
- * not determine it, -1 is returned (e.g. for WBXML).
+ * Returns the current line number, starting from 1. When the parser does
+ * not know the current line number or can not determine it, -1 is returned
+ * (e.g. for WBXML).
*
* @return current line number or -1 if unknown.
*/
int getLineNumber();
/**
- * Returns the current column number, starting from 0. When the parser does not know the current column number or
- * can not determine it, -1 is returned (e.g. for WBXML).
+ * Returns the current column number, starting from 0. When the parser does
+ * not know the current column number or can not determine it, -1 is
+ * returned (e.g. for WBXML).
*
* @return current column number or -1 if unknown.
*/
@@ -586,24 +650,29 @@ public interface XmlPullParser
// TEXT related methods
/**
- * Checks whether the current TEXT event contains only whitespace characters. For IGNORABLE_WHITESPACE, this is
- * always true. For TEXT and CDSECT, false is returned when the current event text contains at least one non-white
- * space character. For any other event type an exception is thrown.
+ * Checks whether the current TEXT event contains only whitespace
+ * characters. For IGNORABLE_WHITESPACE, this is always true. For TEXT and
+ * CDSECT, false is returned when the current event text contains at least
+ * one non-white space character. For any other event type an exception is
+ * thrown.
* <p>
- * <b>Please note:</b> non-validating parsers are not able to distinguish whitespace and ignorable whitespace,
- * except from whitespace outside the root element. Ignorable whitespace is reported as separate event, which is
- * exposed via nextToken only.
+ * <b>Please note:</b> non-validating parsers are not able to distinguish
+ * whitespace and ignorable whitespace, except from whitespace outside the
+ * root element. Ignorable whitespace is reported as separate event, which
+ * is exposed via nextToken only.
*/
- boolean isWhitespace()
- throws XmlPullParserException;
+ boolean isWhitespace() throws XmlPullParserException;
/**
- * Returns the text content of the current event as String. The value returned depends on current event type, for
- * example for TEXT event it is element content (this is typical case when next() is used). See description of
- * nextToken() for detailed description of possible returned values for different types of events.
+ * Returns the text content of the current event as String. The value
+ * returned depends on current event type, for example for TEXT event it is
+ * element content (this is typical case when next() is used). See
+ * description of nextToken() for detailed description of possible returned
+ * values for different types of events.
* <p>
- * <strong>NOTE:</strong> in case of ENTITY_REF, this method returns the entity replacement text (or null if not
- * available). This is the only case where getText() and getTextCharacters() return different values.
+ * <strong>NOTE:</strong> in case of ENTITY_REF, this method returns the
+ * entity replacement text (or null if not available). This is the only case
+ * where getText() and getTextCharacters() return different values.
*
* @see #getEventType
* @see #next
@@ -612,64 +681,76 @@ public interface XmlPullParser
String getText();
/**
- * Returns the buffer that contains the text of the current event, as well as the start offset and length relevant
- * for the current event. See getText(), next() and nextToken() for description of possible returned values.
+ * Returns the buffer that contains the text of the current event, as well
+ * as the start offset and length relevant for the current event. See
+ * getText(), next() and nextToken() for description of possible returned
+ * values.
* <p>
- * <strong>Please note:</strong> this buffer must not be modified and its content MAY change after a call to next()
- * or nextToken(). This method will always return the same value as getText(), except for ENTITY_REF. In the case of
- * ENTITY ref, getText() returns the replacement text and this method returns the actual input buffer containing the
- * entity name. If getText() returns null, this method returns null as well and the values returned in the holder
- * array MUST be -1 (both start and length).
+ * <strong>Please note:</strong> this buffer must not be modified and its
+ * content MAY change after a call to next() or nextToken(). This method
+ * will always return the same value as getText(), except for ENTITY_REF. In
+ * the case of ENTITY ref, getText() returns the replacement text and this
+ * method returns the actual input buffer containing the entity name. If
+ * getText() returns null, this method returns null as well and the values
+ * returned in the holder array MUST be -1 (both start and length).
*
* @see #getText
* @see #next
* @see #nextToken
- * @param holderForStartAndLength Must hold an 2-element int array into which the start offset and length values
- * will be written.
- * @return char buffer that contains the text of the current event (null if the current event has no text
- * associated).
+ * @param holderForStartAndLength Must hold an 2-element int array into
+ * which the start offset and length values will be written.
+ * @return char buffer that contains the text of the current event (null if
+ * the current event has no text associated).
*/
- char[] getTextCharacters( int[] holderForStartAndLength );
+ char[] getTextCharacters(int[] holderForStartAndLength);
// --------------------------------------------------------------------------
// START_TAG / END_TAG shared methods
/**
- * Returns the namespace URI of the current element. The default namespace is represented as empty string. If
- * namespaces are not enabled, an empty String ("") is always returned. The current event must be START_TAG or
+ * Returns the namespace URI of the current element. The default namespace
+ * is represented as empty string. If namespaces are not enabled, an empty
+ * String ("") is always returned. The current event must be START_TAG or
* END_TAG; otherwise, null is returned.
*/
String getNamespace();
/**
- * For START_TAG or END_TAG events, the (local) name of the current element is returned when namespaces are enabled.
- * When namespace processing is disabled, the raw name is returned. For ENTITY_REF events, the entity name is
- * returned. If the current event is not START_TAG, END_TAG, or ENTITY_REF, null is returned.
+ * For START_TAG or END_TAG events, the (local) name of the current element
+ * is returned when namespaces are enabled. When namespace processing is
+ * disabled, the raw name is returned. For ENTITY_REF events, the entity
+ * name is returned. If the current event is not START_TAG, END_TAG, or
+ * ENTITY_REF, null is returned.
* <p>
- * <b>Please note:</b> To reconstruct the raw element name when namespaces are enabled and the prefix is not null,
- * you will need to add the prefix and a colon to localName..
+ * <b>Please note:</b> To reconstruct the raw element name when namespaces
+ * are enabled and the prefix is not null, you will need to add the prefix
+ * and a colon to localName..
*/
String getName();
/**
- * Returns the prefix of the current element. If the element is in the default namespace (has no prefix), null is
- * returned. If namespaces are not enabled, or the current event is not START_TAG or END_TAG, null is returned.
+ * Returns the prefix of the current element. If the element is in the
+ * default namespace (has no prefix), null is returned. If namespaces are
+ * not enabled, or the current event is not START_TAG or END_TAG, null is
+ * returned.
*/
String getPrefix();
/**
- * Returns true if the current event is START_TAG and the tag is degenerated (e.g. <foobar/>).
+ * Returns true if the current event is START_TAG and the tag is degenerated
+ * (e.g. <foobar/>).
* <p>
- * <b>NOTE:</b> if the parser is not on START_TAG, an exception will be thrown.
+ * <b>NOTE:</b> if the parser is not on START_TAG, an exception will be
+ * thrown.
*/
- boolean isEmptyElementTag()
- throws XmlPullParserException;
+ boolean isEmptyElementTag() throws XmlPullParserException;
// --------------------------------------------------------------------------
// START_TAG Attributes retrieval methods
/**
- * Returns the number of attributes of the current start tag, or -1 if the current event type is not START_TAG
+ * Returns the number of attributes of the current start tag, or -1 if the
+ * current event type is not START_TAG
*
* @see #getAttributeNamespace
* @see #getAttributeName
@@ -679,89 +760,104 @@ public interface XmlPullParser
int getAttributeCount();
/**
- * Returns the namespace URI of the attribute with the given index (starts from 0). Returns an empty string ("") if
- * namespaces are not enabled or the attribute has no namespace. Throws an IndexOutOfBoundsException if the index is
- * out of range or the current event type is not START_TAG.
+ * Returns the namespace URI of the attribute with the given index (starts
+ * from 0). Returns an empty string ("") if namespaces are not enabled or
+ * the attribute has no namespace. Throws an IndexOutOfBoundsException if
+ * the index is out of range or the current event type is not START_TAG.
* <p>
- * <strong>NOTE:</strong> if FEATURE_REPORT_NAMESPACE_ATTRIBUTES is set then namespace attributes (xmlns:ns='...')
- * must be reported with namespace <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a> (visit
- * this URL for description!). The default namespace attribute (xmlns="...") will be reported with empty namespace.
+ * <strong>NOTE:</strong> if FEATURE_REPORT_NAMESPACE_ATTRIBUTES is set then
+ * namespace attributes (xmlns:ns='...') must be reported with namespace
+ * <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>
+ * (visit this URL for description!). The default namespace attribute
+ * (xmlns="...") will be reported with empty namespace.
* <p>
* <strong>NOTE:</strong>The xml prefix is bound as defined in
- * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in XML</a> specification to
- * "http://www.w3.org/XML/1998/namespace".
+ * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in
+ * XML</a> specification to "http://www.w3.org/XML/1998/namespace".
*
* @param index zero based index of attribute
- * @return attribute namespace, empty string ("") is returned if namespaces processing is not enabled or namespaces
- * processing is enabled but attribute has no namespace (it has no prefix).
+ * @return attribute namespace, empty string ("") is returned if namespaces
+ * processing is not enabled or namespaces processing is enabled but
+ * attribute has no namespace (it has no prefix).
*/
- String getAttributeNamespace( int index );
+ String getAttributeNamespace(int index);
/**
- * Returns the local name of the specified attribute if namespaces are enabled or just attribute name if namespaces
- * are disabled. Throws an IndexOutOfBoundsException if the index is out of range or current event type is not
- * START_TAG.
+ * Returns the local name of the specified attribute if namespaces are
+ * enabled or just attribute name if namespaces are disabled. Throws an
+ * IndexOutOfBoundsException if the index is out of range or current event
+ * type is not START_TAG.
*
* @param index zero based index of attribute
* @return attribute name (null is never returned)
*/
- String getAttributeName( int index );
+ String getAttributeName(int index);
/**
- * Returns the prefix of the specified attribute Returns null if the element has no prefix. If namespaces are
- * disabled it will always return null. Throws an IndexOutOfBoundsException if the index is out of range or current
- * event type is not START_TAG.
+ * Returns the prefix of the specified attribute Returns null if the element
+ * has no prefix. If namespaces are disabled it will always return null.
+ * Throws an IndexOutOfBoundsException if the index is out of range or
+ * current event type is not START_TAG.
*
* @param index zero based index of attribute
* @return attribute prefix or null if namespaces processing is not enabled.
*/
- String getAttributePrefix( int index );
+ String getAttributePrefix(int index);
/**
- * Returns the type of the specified attribute If parser is non-validating it MUST return CDATA.
+ * Returns the type of the specified attribute If parser is non-validating
+ * it MUST return CDATA.
*
* @param index zero based index of attribute
* @return attribute type (null is never returned)
*/
- String getAttributeType( int index );
+ String getAttributeType(int index);
/**
- * Returns if the specified attribute was not in input was declared in XML. If parser is non-validating it MUST
- * always return false. This information is part of XML infoset:
+ * Returns if the specified attribute was not in input was declared in XML.
+ * If parser is non-validating it MUST always return false. This information
+ * is part of XML infoset:
*
* @param index zero based index of attribute
* @return false if attribute was in input
*/
- boolean isAttributeDefault( int index );
+ boolean isAttributeDefault(int index);
/**
- * Returns the given attributes value. Throws an IndexOutOfBoundsException if the index is out of range or current
- * event type is not START_TAG.
+ * Returns the given attributes value. Throws an IndexOutOfBoundsException
+ * if the index is out of range or current event type is not START_TAG.
* <p>
- * <strong>NOTE:</strong> attribute value must be normalized (including entity replacement text if PROCESS_DOCDECL
- * is false) as described in <a href="http://www.w3.org/TR/REC-xml#AVNormalize">XML 1.0 section 3.3.3
+ * <strong>NOTE:</strong> attribute value must be normalized (including
+ * entity replacement text if PROCESS_DOCDECL is false) as described in
+ * <a href="http://www.w3.org/TR/REC-xml#AVNormalize">XML 1.0 section 3.3.3
* Attribute-Value Normalization</a>
*
* @see #defineEntityReplacementText
* @param index zero based index of attribute
* @return value of attribute (null is never returned)
*/
- String getAttributeValue( int index );
+ String getAttributeValue(int index);
/**
- * Returns the attributes value identified by namespace URI and namespace localName. If namespaces are disabled
- * namespace must be null. If current event type is not START_TAG then IndexOutOfBoundsException will be thrown.
+ * Returns the attributes value identified by namespace URI and namespace
+ * localName. If namespaces are disabled namespace must be null. If current
+ * event type is not START_TAG then IndexOutOfBoundsException will be
+ * thrown.
* <p>
- * <strong>NOTE:</strong> attribute value must be normalized (including entity replacement text if PROCESS_DOCDECL
- * is false) as described in <a href="http://www.w3.org/TR/REC-xml#AVNormalize">XML 1.0 section 3.3.3
+ * <strong>NOTE:</strong> attribute value must be normalized (including
+ * entity replacement text if PROCESS_DOCDECL is false) as described in
+ * <a href="http://www.w3.org/TR/REC-xml#AVNormalize">XML 1.0 section 3.3.3
* Attribute-Value Normalization</a>
*
* @see #defineEntityReplacementText
- * @param namespace Namespace of the attribute if namespaces are enabled otherwise must be null
- * @param name If namespaces enabled local name of attribute otherwise just attribute name
- * @return value of attribute or null if attribute with given name does not exist
+ * @param namespace Namespace of the attribute if namespaces are enabled
+ * otherwise must be null
+ * @param name If namespaces enabled local name of attribute otherwise just
+ * attribute name
+ * @return value of attribute or null if attribute with given name does not
+ * exist
*/
- String getAttributeValue( String namespace, String name );
+ String getAttributeValue(String namespace, String name);
// --------------------------------------------------------------------------
// actual parsing methods
@@ -772,17 +868,20 @@ public interface XmlPullParser
* @see #next()
* @see #nextToken()
*/
- int getEventType()
- throws XmlPullParserException;
+ int getEventType() throws XmlPullParserException;
/**
- * Get next parsing event - element content wil be coalesced and only one TEXT event must be returned for whole
- * element content (comments and processing instructions will be ignored and entity references must be expanded or
- * exception mus be thrown if entity reference can not be expanded). If element content is empty (content is "")
- * then no TEXT event will be reported.
+ * Get next parsing event - element content wil be coalesced and only one
+ * TEXT event must be returned for whole element content (comments and
+ * processing instructions will be ignored and entity references must be
+ * expanded or exception mus be thrown if entity reference can not be
+ * expanded). If element content is empty (content is "") then no TEXT event
+ * will be reported.
* <p>
- * <b>NOTE:</b> empty element (such as <tag/>) will be reported with two separate events: START_TAG, END_TAG - it
- * must be so to preserve parsing equivalency of empty element to <tag></tag>. (see isEmptyElementTag ())
+ * <b>NOTE:</b> empty element (such as <tag/>) will be reported with
+ * two separate events: START_TAG, END_TAG - it must be so to preserve
+ * parsing equivalency of empty element to <tag></tag>. (see
+ * isEmptyElementTag ())
*
* @see #isEmptyElementTag
* @see #START_TAG
@@ -791,61 +890,77 @@ public interface XmlPullParser
* @see #END_DOCUMENT
*/
- int next()
- throws XmlPullParserException, IOException;
+ int next() throws XmlPullParserException, IOException;
/**
- * This method works similarly to next() but will expose additional event types (COMMENT, CDSECT, DOCDECL,
- * ENTITY_REF, PROCESSING_INSTRUCTION, or IGNORABLE_WHITESPACE) if they are available in input.
+ * This method works similarly to next() but will expose additional event
+ * types (COMMENT, CDSECT, DOCDECL, ENTITY_REF, PROCESSING_INSTRUCTION, or
+ * IGNORABLE_WHITESPACE) if they are available in input.
* <p>
- * If special feature <a href="http://xmlpull.org/v1/doc/features.html#xml-roundtrip">FEATURE_XML_ROUNDTRIP</a>
- * (identified by URI: http://xmlpull.org/v1/doc/features.html#xml-roundtrip) is enabled it is possible to do XML
- * document round trip ie. reproduce exactly on output the XML input using getText(): returned content is always
- * unnormalized (exactly as in input). Otherwise returned content is end-of-line normalized as described
- * <a href="http://www.w3.org/TR/REC-xml#sec-line-ends">XML 1.0 End-of-Line Handling</a> and. Also when this feature
- * is enabled exact content of START_TAG, END_TAG, DOCDECL and PROCESSING_INSTRUCTION is available.
+ * If special feature <a href=
+ * "http://xmlpull.org/v1/doc/features.html#xml-roundtrip">FEATURE_XML_ROUNDTRIP</a>
+ * (identified by URI:
+ * http://xmlpull.org/v1/doc/features.html#xml-roundtrip) is enabled it is
+ * possible to do XML document round trip ie. reproduce exactly on output
+ * the XML input using getText(): returned content is always unnormalized
+ * (exactly as in input). Otherwise returned content is end-of-line
+ * normalized as described
+ * <a href="http://www.w3.org/TR/REC-xml#sec-line-ends">XML 1.0 End-of-Line
+ * Handling</a> and. Also when this feature is enabled exact content of
+ * START_TAG, END_TAG, DOCDECL and PROCESSING_INSTRUCTION is available.
* <p>
- * Here is the list of tokens that can be returned from nextToken() and what getText() and getTextCharacters()
- * returns:
+ * Here is the list of tokens that can be returned from nextToken() and what
+ * getText() and getTextCharacters() returns:
* <dl>
* <dt>START_DOCUMENT
* <dd>null
* <dt>END_DOCUMENT
* <dd>null
* <dt>START_TAG
- * <dd>null unless FEATURE_XML_ROUNDTRIP enabled and then returns XML tag, ex: <tag attr='val'>
+ * <dd>null unless FEATURE_XML_ROUNDTRIP enabled and then returns XML tag,
+ * ex: <tag attr='val'>
* <dt>END_TAG
- * <dd>null unless FEATURE_XML_ROUNDTRIP id enabled and then returns XML tag, ex: </tag>
+ * <dd>null unless FEATURE_XML_ROUNDTRIP id enabled and then returns XML
+ * tag, ex: </tag>
* <dt>TEXT
* <dd>return element content. <br>
- * Note: that element content may be delivered in multiple consecutive TEXT events.
+ * Note: that element content may be delivered in multiple consecutive TEXT
+ * events.
* <dt>IGNORABLE_WHITESPACE
- * <dd>return characters that are determined to be ignorable white space. If the FEATURE_XML_ROUNDTRIP is enabled
- * all whitespace content outside root element will always reported as IGNORABLE_WHITESPACE otherwise reporting is
- * optional. <br>
- * Note: that element content may be delivered in multiple consecutive IGNORABLE_WHITESPACE events.
+ * <dd>return characters that are determined to be ignorable white space. If
+ * the FEATURE_XML_ROUNDTRIP is enabled all whitespace content outside root
+ * element will always reported as IGNORABLE_WHITESPACE otherwise reporting
+ * is optional. <br>
+ * Note: that element content may be delivered in multiple consecutive
+ * IGNORABLE_WHITESPACE events.
* <dt>CDSECT
- * <dd>return text <em>inside</em> CDATA (ex. 'fo<o' from <!CDATA[fo<o]]>)
+ * <dd>return text <em>inside</em> CDATA (ex. 'fo<o' from
+ * <!CDATA[fo<o]]>)
* <dt>PROCESSING_INSTRUCTION
- * <dd>if FEATURE_XML_ROUNDTRIP is true return exact PI content ex: 'pi foo' from <?pi foo?> otherwise it may be
- * exact PI content or concatenation of PI target, space and data so for example for <?target data?> string
- * "target data" may be returned if FEATURE_XML_ROUNDTRIP is false.
+ * <dd>if FEATURE_XML_ROUNDTRIP is true return exact PI content ex: 'pi foo'
+ * from <?pi foo?> otherwise it may be exact PI content or
+ * concatenation of PI target, space and data so for example for <?target
+ * data?> string "target data" may be returned if
+ * FEATURE_XML_ROUNDTRIP is false.
* <dt>COMMENT
* <dd>return comment content ex. 'foo bar' from <!--foo bar-->
* <dt>ENTITY_REF
- * <dd>getText() MUST return entity replacement text if PROCESS_DOCDECL is false otherwise getText() MAY return
- * null, additionally getTextCharacters() MUST return entity name (for example 'entity_name' for &entity_name;).
- * <br>
- * <b>NOTE:</b> this is the only place where value returned from getText() and getTextCharacters() <b>are
- * different</b> <br>
- * <b>NOTE:</b> it is user responsibility to resolve entity reference if PROCESS_DOCDECL is false and there is no
- * entity replacement text set in defineEntityReplacementText() method (getText() will be null) <br>
- * <b>NOTE:</b> character entities (ex. &#32;) and standard entities such as &amp; &lt; &gt;
- * &quot; &apos; are reported as well and are <b>not</b> reported as TEXT tokens but as ENTITY_REF tokens!
+ * <dd>getText() MUST return entity replacement text if PROCESS_DOCDECL is
+ * false otherwise getText() MAY return null, additionally
+ * getTextCharacters() MUST return entity name (for example 'entity_name'
+ * for &entity_name;). <br>
+ * <b>NOTE:</b> this is the only place where value returned from getText()
+ * and getTextCharacters() <b>are different</b> <br>
+ * <b>NOTE:</b> it is user responsibility to resolve entity reference if
+ * PROCESS_DOCDECL is false and there is no entity replacement text set in
+ * defineEntityReplacementText() method (getText() will be null) <br>
+ * <b>NOTE:</b> character entities (ex. &#32;) and standard entities
+ * such as &amp; &lt; &gt; &quot; &apos; are reported as
+ * well and are <b>not</b> reported as TEXT tokens but as ENTITY_REF tokens!
* This requirement is added to allow to do roundtrip of XML documents!
* <dt>DOCDECL
- * <dd>if FEATURE_XML_ROUNDTRIP is true or PROCESS_DOCDECL is false then return what is inside of DOCDECL for
- * example it returns:
+ * <dd>if FEATURE_XML_ROUNDTRIP is true or PROCESS_DOCDECL is false then
+ * return what is inside of DOCDECL for example it returns:
*
* <pre>
* " titlepage SYSTEM "http://www.foo.bar/dtds/typo.dtd"
@@ -859,19 +974,21 @@ public interface XmlPullParser
* [<!ENTITY % active.links "INCLUDE">]>
* </pre>
*
- * otherwise if FEATURE_XML_ROUNDTRIP is false and PROCESS_DOCDECL is true then what is returned is undefined (it
- * may be even null)</dd>
+ * otherwise if FEATURE_XML_ROUNDTRIP is false and PROCESS_DOCDECL is true
+ * then what is returned is undefined (it may be even null)</dd>
* </dl>
* <p>
- * <strong>NOTE:</strong> there is no guarantee that there will only one TEXT or IGNORABLE_WHITESPACE event from
- * nextToken() as parser may chose to deliver element content in multiple tokens (dividing element content into
- * chunks)
+ * <strong>NOTE:</strong> there is no guarantee that there will only one
+ * TEXT or IGNORABLE_WHITESPACE event from nextToken() as parser may chose
+ * to deliver element content in multiple tokens (dividing element content
+ * into chunks)
* <p>
- * <strong>NOTE:</strong> whether returned text of token is end-of-line normalized is depending on
- * FEATURE_XML_ROUNDTRIP.
+ * <strong>NOTE:</strong> whether returned text of token is end-of-line
+ * normalized is depending on FEATURE_XML_ROUNDTRIP.
* <p>
- * <strong>NOTE:</strong> XMLDecl (<?xml ...?>) is not reported but its content is available through optional
- * properties (see class description above).
+ * <strong>NOTE:</strong> XMLDecl (<?xml ...?>) is not reported but
+ * its content is available through optional properties (see class
+ * description above).
*
* @see #next
* @see #START_TAG
@@ -884,100 +1001,95 @@ public interface XmlPullParser
* @see #ENTITY_REF
* @see #IGNORABLE_WHITESPACE
*/
- int nextToken()
- throws XmlPullParserException, IOException;
+ int nextToken() throws XmlPullParserException, IOException;
// -----------------------------------------------------------------------------
// utility methods to mak XML parsing easier ...
/**
- * Test if the current event is of the given type and if the namespace and name do match. null will match any
- * namespace and any name. If the test is not passed, an exception is thrown. The exception text indicates the
- * parser position, the expected event and the current event that is not meeting the requirement.
+ * Test if the current event is of the given type and if the namespace and
+ * name do match. null will match any namespace and any name. If the test is
+ * not passed, an exception is thrown. The exception text indicates the
+ * parser position, the expected event and the current event that is not
+ * meeting the requirement.
* <p>
* Essentially it does this
*
* <pre>
- * if ( type != getEventType() || ( namespace != null && !namespace.equals( getNamespace() ) )
- * || ( name != null && !name.equals( getName() ) ) )
- * throw new XmlPullParserException( "expected " + TYPES[type] + getPositionDescription() );
+ * if (type != getEventType() || (namespace != null && !namespace.equals(getNamespace())) || (name != null && !name.equals(getName())))
+ * throw new XmlPullParserException("expected " + TYPES[type] + getPositionDescription());
* </pre>
*/
- void require( int type, String namespace, String name )
- throws XmlPullParserException, IOException;
+ void require(int type, String namespace, String name) throws XmlPullParserException, IOException;
/**
- * If current event is START_TAG then if next element is TEXT then element content is returned or if next event is
- * END_TAG then empty string is returned, otherwise exception is thrown. After calling this function successfully
- * parser will be positioned on END_TAG.
+ * If current event is START_TAG then if next element is TEXT then element
+ * content is returned or if next event is END_TAG then empty string is
+ * returned, otherwise exception is thrown. After calling this function
+ * successfully parser will be positioned on END_TAG.
* <p>
- * The motivation for this function is to allow to parse consistently both empty elements and elements that has non
- * empty content, for example for input:
+ * The motivation for this function is to allow to parse consistently both
+ * empty elements and elements that has non empty content, for example for
+ * input:
* <ol>
* <li><tag>foo</tag>
- * <li><tag></tag> (which is equivalent to <tag/> both input can be parsed with the same code:
+ * <li><tag></tag> (which is equivalent to <tag/> both
+ * input can be parsed with the same code:
*
* <pre>
* p.nextTag()
* p.requireEvent(p.START_TAG, "", "tag");
* String content = p.nextText();
* p.requireEvent(p.END_TAG, "", "tag");
- * </pre></li></ol>
- *
- * This function together with nextTag make it very easy to parse XML that has no mixed content.
+ * </pre>
+ *
+ * </li>
+ * </ol>
+ * This function together with nextTag make it very easy to parse XML that
+ * has no mixed content.
* <p>
* Essentially it does this
*
* <pre>
- * if ( getEventType() != START_TAG )
- * {
- * throw new XmlPullParserException( "parser must be on START_TAG to read next text", this, null );
+ * if (getEventType() != START_TAG) {
+ * throw new XmlPullParserException("parser must be on START_TAG to read next text", this, null);
* }
* int eventType = next();
- * if ( eventType == TEXT )
- * {
+ * if (eventType == TEXT) {
* String result = getText();
* eventType = next();
- * if ( eventType != END_TAG )
- * {
- * throw new XmlPullParserException( "event TEXT it must be immediately followed by END_TAG", this, null );
+ * if (eventType != END_TAG) {
+ * throw new XmlPullParserException("event TEXT it must be immediately followed by END_TAG", this, null);
* }
* return result;
- * }
- * else if ( eventType == END_TAG )
- * {
+ * } else if (eventType == END_TAG) {
* return "";
- * }
- * else
- * {
- * throw new XmlPullParserException( "parser must be on START_TAG or TEXT to read text", this, null );
+ * } else {
+ * throw new XmlPullParserException("parser must be on START_TAG or TEXT to read text", this, null);
* }
* </pre>
*/
- String nextText()
- throws XmlPullParserException, IOException;
+ String nextText() throws XmlPullParserException, IOException;
/**
- * Call next() and return event if it is START_TAG or END_TAG otherwise throw an exception. It will skip whitespace
- * TEXT before actual tag if any.
+ * Call next() and return event if it is START_TAG or END_TAG otherwise
+ * throw an exception. It will skip whitespace TEXT before actual tag if
+ * any.
* <p>
* essentially it does this
*
* <pre>
* int eventType = next();
- * if ( eventType == TEXT && isWhitespace() )
- * { // skip whitespace
+ * if (eventType == TEXT && isWhitespace()) { // skip whitespace
* eventType = next();
* }
- * if ( eventType != START_TAG && eventType != END_TAG )
- * {
- * throw new XmlPullParserException( "expected start or end tag", this, null );
+ * if (eventType != START_TAG && eventType != END_TAG) {
+ * throw new XmlPullParserException("expected start or end tag", this, null);
* }
* return eventType;
* </pre>
*/
- int nextTag()
- throws XmlPullParserException, IOException;
+ int nextTag() throws XmlPullParserException, IOException;
}
-// CHECKSTYLE:ON
\ No newline at end of file
+// CHECKSTYLE:ON
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParserException.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParserException.java
index c4d564a..9f4d139 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParserException.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlPullParserException.java
@@ -24,49 +24,41 @@ package org.apache.camel.xml.io;
/**
* This exception is thrown to signal XML Pull Parser related faults.
*
- * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
+ * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander
+ * Slominski</a>
*/
-public class XmlPullParserException
- extends Exception
-{
+public class XmlPullParserException extends Exception {
protected int row = -1;
protected int column = -1;
- public XmlPullParserException( String s )
- {
- super( s );
+ public XmlPullParserException(String s) {
+ super(s);
}
/*
- * public XmlPullParserException(String s, Throwable throwable) { super(s); this.detail = throwable; } public
- * XmlPullParserException(String s, int row, int column) { super(s); this.row = row; this.column = column; }
+ * public XmlPullParserException(String s, Throwable throwable) { super(s);
+ * this.detail = throwable; } public XmlPullParserException(String s, int
+ * row, int column) { super(s); this.row = row; this.column = column; }
*/
- public XmlPullParserException(String msg, XmlPullParser parser, Throwable cause )
- {
- super( ( msg == null ? "" : msg + " " )
- + ( parser == null ? "" : "(position:" + parser.getPositionDescription() + ") " )
- + ( cause == null ? "" : "caused by: " + cause ), cause );
+ public XmlPullParserException(String msg, XmlPullParser parser, Throwable cause) {
+ super((msg == null ? "" : msg + " ") + (parser == null ? "" : "(position:" + parser.getPositionDescription() + ") ") + (cause == null ? "" : "caused by: " + cause), cause);
- if ( parser != null )
- {
+ if (parser != null) {
this.row = parser.getLineNumber();
this.column = parser.getColumnNumber();
}
- if (cause != null)
- {
+ if (cause != null) {
initCause(cause);
}
}
- public int getLineNumber()
- {
+ public int getLineNumber() {
return row;
}
- public int getColumnNumber()
- {
+ public int getColumnNumber() {
return column;
}
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReader.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReader.java
index 6e0bc62..89eca22 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReader.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReader.java
@@ -52,24 +52,26 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * Character stream that handles (or at least attemtps to) all the necessary Voodo to figure out the
- * charset encoding of the XML document within the stream.
+ * Character stream that handles (or at least attemtps to) all the necessary
+ * Voodo to figure out the charset encoding of the XML document within the
+ * stream.
* <p>
- * IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader. This one IS a
- * character stream.
+ * IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader.
+ * This one IS a character stream.
* <p>
- * All this has to be done without consuming characters from the stream, if not the XML parser will
- * not recognized the document as a valid XML. This is not 100% true, but it's close enough (UTF-8
- * BOM is not handled by all parsers right now, XmlReader handles it and things work in all
- * parsers).
+ * All this has to be done without consuming characters from the stream, if not
+ * the XML parser will not recognized the document as a valid XML. This is not
+ * 100% true, but it's close enough (UTF-8 BOM is not handled by all parsers
+ * right now, XmlReader handles it and things work in all parsers).
* <p>
- * The XmlReader class handles the charset encoding of XML documents in Files, raw streams and HTTP
- * streams by offering a wide set of constructors.
+ * The XmlReader class handles the charset encoding of XML documents in Files,
+ * raw streams and HTTP streams by offering a wide set of constructors.
* <P>
- * By default the charset encoding detection is lenient, the constructor with the lenient flag can
- * be used for an script (following HTTP MIME and XML specifications). All this is nicely explained
- * by Mark Pilgrim in his blog, <a
- * href="https://web.archive.org/web/20060706153721/http://diveintomark.org/archives/2004/02/13/xml-media-types">
+ * By default the charset encoding detection is lenient, the constructor with
+ * the lenient flag can be used for an script (following HTTP MIME and XML
+ * specifications). All this is nicely explained by Mark Pilgrim in his blog,
+ * <a href=
+ * "https://web.archive.org/web/20060706153721/http://diveintomark.org/archives/2004/02/13/xml-media-types">
* Determining the character encoding of a feed</a>.
*/
public class XmlStreamReader extends Reader {
@@ -85,12 +87,9 @@ public class XmlStreamReader extends Reader {
private static final Pattern ENCODING_PATTERN = Pattern.compile("<\\?xml.*encoding[\\s]*=[\\s]*((?:\".[^\"]*\")|(?:'.[^']*'))", Pattern.MULTILINE);
private static final MessageFormat RAW_EX_1 = new MessageFormat("Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] encoding mismatch");
private static final MessageFormat RAW_EX_2 = new MessageFormat("Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] unknown BOM");
- private static final MessageFormat HTTP_EX_1 = new MessageFormat(
- "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], BOM must be NULL");
- private static final MessageFormat HTTP_EX_2 = new MessageFormat(
- "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], encoding mismatch");
- private static final MessageFormat HTTP_EX_3 = new MessageFormat(
- "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME");
+ private static final MessageFormat HTTP_EX_1 = new MessageFormat("Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], BOM must be NULL");
+ private static final MessageFormat HTTP_EX_2 = new MessageFormat("Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], encoding mismatch");
+ private static final MessageFormat HTTP_EX_3 = new MessageFormat("Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME");
private static String staticDefaultEncoding = null;
@@ -102,16 +101,15 @@ public class XmlStreamReader extends Reader {
/**
* Creates a Reader for a File.
* <p>
- * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, if this is also
- * missing defaults to UTF-8.
+ * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset,
+ * if this is also missing defaults to UTF-8.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param file File to create a Reader from.
* @throws IOException thrown if there is a problem reading the file.
- *
*/
public XmlStreamReader(final File file) throws IOException {
this(new FileInputStream(file));
@@ -122,29 +120,28 @@ public class XmlStreamReader extends Reader {
* <p>
* It follows the same logic used for files.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param is InputStream to create a Reader from.
* @throws IOException thrown if there is a problem reading the stream.
- *
*/
public XmlStreamReader(final InputStream is) throws IOException {
this(is, true);
}
/**
- * Creates a Reader for a raw InputStream and uses the provided default encoding if none is
- * determined.
+ * Creates a Reader for a raw InputStream and uses the provided default
+ * encoding if none is determined.
* <p>
* It follows the same logic used for files.
* <p>
- * If lenient detection is indicated and the detection above fails as per specifications it then
- * attempts the following:
+ * If lenient detection is indicated and the detection above fails as per
+ * specifications it then attempts the following:
* <p>
- * If the content type was 'text/html' it replaces it with 'text/xml' and tries the detection
- * again.
+ * If the content type was 'text/html' it replaces it with 'text/xml' and
+ * tries the detection again.
* <p>
* Else if the XML prolog had a charset encoding that encoding is used.
* <p>
@@ -152,16 +149,17 @@ public class XmlStreamReader extends Reader {
* <p>
* Else 'UTF-8' is used.
* <p>
- * If lenient detection is indicated an XmlStreamReaderException is never thrown.
+ * If lenient detection is indicated an XmlStreamReaderException is never
+ * thrown.
* <p>
*
* @param is InputStream to create a Reader from.
- * @param lenient indicates if the charset encoding detection should be relaxed.
+ * @param lenient indicates if the charset encoding detection should be
+ * relaxed.
* @param defaultEncoding default encoding to use if one cannot be detected.
* @throws IOException thrown if there is a problem reading the stream.
- * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according
- * to the specs.
- *
+ * @throws XmlStreamReaderException thrown if the charset encoding could not
+ * be determined according to the specs.
*/
public XmlStreamReader(final InputStream is, final boolean lenient, final String defaultEncoding) throws IOException, XmlStreamReaderException {
if (defaultEncoding == null) {
@@ -185,11 +183,11 @@ public class XmlStreamReader extends Reader {
* <p>
* It follows the same logic used for files.
* <p>
- * If lenient detection is indicated and the detection above fails as per specifications it then
- * attempts the following:
+ * If lenient detection is indicated and the detection above fails as per
+ * specifications it then attempts the following:
* <p>
- * If the content type was 'text/html' it replaces it with 'text/xml' and tries the detection
- * again.
+ * If the content type was 'text/html' it replaces it with 'text/xml' and
+ * tries the detection again.
* <p>
* Else if the XML prolog had a charset encoding that encoding is used.
* <p>
@@ -197,15 +195,16 @@ public class XmlStreamReader extends Reader {
* <p>
* Else 'UTF-8' is used.
* <p>
- * If lenient detection is indicated an XmlStreamReaderException is never thrown.
+ * If lenient detection is indicated an XmlStreamReaderException is never
+ * thrown.
* <p>
*
* @param is InputStream to create a Reader from.
- * @param lenient indicates if the charset encoding detection should be relaxed.
+ * @param lenient indicates if the charset encoding detection should be
+ * relaxed.
* @throws IOException thrown if there is a problem reading the stream.
- * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according
- * to the specs.
- *
+ * @throws XmlStreamReaderException thrown if the charset encoding could not
+ * be determined according to the specs.
*/
public XmlStreamReader(final InputStream is, final boolean lenient) throws IOException, XmlStreamReaderException {
this(is, lenient, null);
@@ -214,19 +213,20 @@ public class XmlStreamReader extends Reader {
/**
* Creates a Reader using the InputStream of a URL.
* <p>
- * If the URL is not of type HTTP and there is not 'content-type' header in the fetched data it
- * uses the same logic used for Files.
+ * If the URL is not of type HTTP and there is not 'content-type' header in
+ * the fetched data it uses the same logic used for Files.
* <p>
- * If the URL is a HTTP Url or there is a 'content-type' header in the fetched data it uses the
- * same logic used for an InputStream with content-type.
+ * If the URL is a HTTP Url or there is a 'content-type' header in the
+ * fetched data it uses the same logic used for an InputStream with
+ * content-type.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param url URL to create a Reader from.
- * @throws IOException thrown if there is a problem reading the stream of the URL.
- *
+ * @throws IOException thrown if there is a problem reading the stream of
+ * the URL.
*/
public XmlStreamReader(final URL url) throws IOException {
this(url, null);
@@ -235,20 +235,21 @@ public class XmlStreamReader extends Reader {
/**
* Creates a Reader using the InputStream of a URL.
* <p>
- * If the URL is not of type HTTP and there is not 'content-type' header in the fetched data it
- * uses the same logic used for Files.
+ * If the URL is not of type HTTP and there is not 'content-type' header in
+ * the fetched data it uses the same logic used for Files.
* <p>
- * If the URL is a HTTP Url or there is a 'content-type' header in the fetched data it uses the
- * same logic used for an InputStream with content-type.
+ * If the URL is a HTTP Url or there is a 'content-type' header in the
+ * fetched data it uses the same logic used for an InputStream with
+ * content-type.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param url URL to create a Reader from.
* @param requestHeaders optional Map of headers to set on http request.
- * @throws IOException thrown if there is a problem reading the stream of the URL.
- *
+ * @throws IOException thrown if there is a problem reading the stream of
+ * the URL.
*/
public XmlStreamReader(final URL url, final Map<String, String> requestHeaders) throws IOException {
this(url.openConnection(), requestHeaders);
@@ -257,19 +258,21 @@ public class XmlStreamReader extends Reader {
/**
* Creates a Reader using the InputStream of a URLConnection.
* <p>
- * If the URLConnection is not of type HttpURLConnection and there is not 'content-type' header
- * in the fetched data it uses the same logic used for files.
+ * If the URLConnection is not of type HttpURLConnection and there is not
+ * 'content-type' header in the fetched data it uses the same logic used for
+ * files.
* <p>
- * If the URLConnection is a HTTP Url or there is a 'content-type' header in the fetched data it
- * uses the same logic used for an InputStream with content-type.
+ * If the URLConnection is a HTTP Url or there is a 'content-type' header in
+ * the fetched data it uses the same logic used for an InputStream with
+ * content-type.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param conn URLConnection to create a Reader from.
- * @throws IOException thrown if there is a problem reading the stream of the URLConnection.
- *
+ * @throws IOException thrown if there is a problem reading the stream of
+ * the URLConnection.
*/
public XmlStreamReader(final URLConnection conn) throws IOException {
this(conn, null);
@@ -278,20 +281,22 @@ public class XmlStreamReader extends Reader {
/**
* Creates a Reader using the InputStream of a URLConnection.
* <p>
- * If the URLConnection is not of type HttpURLConnection and there is not 'content-type' header
- * in the fetched data it uses the same logic used for files.
+ * If the URLConnection is not of type HttpURLConnection and there is not
+ * 'content-type' header in the fetched data it uses the same logic used for
+ * files.
* <p>
- * If the URLConnection is a HTTP Url or there is a 'content-type' header in the fetched data it
- * uses the same logic used for an InputStream with content-type.
+ * If the URLConnection is a HTTP Url or there is a 'content-type' header in
+ * the fetched data it uses the same logic used for an InputStream with
+ * content-type.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param conn URLConnection to create a Reader from.
* @param requestHeaders optional Map of headers to set on http request.
- * @throws IOException thrown if there is a problem reading the stream of the URLConnection.
- *
+ * @throws IOException thrown if there is a problem reading the stream of
+ * the URLConnection.
*/
public XmlStreamReader(final URLConnection conn, final Map<String, String> requestHeaders) throws IOException {
defaultEncoding = staticDefaultEncoding;
@@ -320,37 +325,41 @@ public class XmlStreamReader extends Reader {
}
/**
- * Creates a Reader using an InputStream and the associated content-type header.
+ * Creates a Reader using an InputStream and the associated content-type
+ * header.
* <p>
- * First it checks if the stream has BOM. If there is not BOM checks the content-type encoding.
- * If there is not content-type encoding checks the XML prolog encoding. If there is not XML
- * prolog encoding uses the default encoding mandated by the content-type MIME type.
+ * First it checks if the stream has BOM. If there is not BOM checks the
+ * content-type encoding. If there is not content-type encoding checks the
+ * XML prolog encoding. If there is not XML prolog encoding uses the default
+ * encoding mandated by the content-type MIME type.
* <p>
- * It does a lenient charset encoding detection, check the constructor with the lenient
- * parameter for details.
+ * It does a lenient charset encoding detection, check the constructor with
+ * the lenient parameter for details.
* <p>
*
* @param is InputStream to create the reader from.
- * @param httpContentType content-type header to use for the resolution of the charset encoding.
+ * @param httpContentType content-type header to use for the resolution of
+ * the charset encoding.
* @throws IOException thrown if there is a problem reading the file.
- *
*/
public XmlStreamReader(final InputStream is, final String httpContentType) throws IOException {
this(is, httpContentType, true);
}
/**
- * Creates a Reader using an InputStream and the associated content-type header.
+ * Creates a Reader using an InputStream and the associated content-type
+ * header.
* <p>
- * First it checks if the stream has BOM. If there is not BOM checks the content-type encoding.
- * If there is not content-type encoding checks the XML prolog encoding. If there is not XML
- * prolog encoding uses the default encoding mandated by the content-type MIME type.
+ * First it checks if the stream has BOM. If there is not BOM checks the
+ * content-type encoding. If there is not content-type encoding checks the
+ * XML prolog encoding. If there is not XML prolog encoding uses the default
+ * encoding mandated by the content-type MIME type.
* <p>
- * If lenient detection is indicated and the detection above fails as per specifications it then
- * attempts the following:
+ * If lenient detection is indicated and the detection above fails as per
+ * specifications it then attempts the following:
* <p>
- * If the content type was 'text/html' it replaces it with 'text/xml' and tries the detection
- * again.
+ * If the content type was 'text/html' it replaces it with 'text/xml' and
+ * tries the detection again.
* <p>
* Else if the XML prolog had a charset encoding that encoding is used.
* <p>
@@ -358,20 +367,21 @@ public class XmlStreamReader extends Reader {
* <p>
* Else 'UTF-8' is used.
* <p>
- * If lenient detection is indicated and XmlStreamReaderException is never thrown.
+ * If lenient detection is indicated and XmlStreamReaderException is never
+ * thrown.
* <p>
*
* @param is InputStream to create the reader from.
- * @param httpContentType content-type header to use for the resolution of the charset encoding.
- * @param lenient indicates if the charset encoding detection should be relaxed.
+ * @param httpContentType content-type header to use for the resolution of
+ * the charset encoding.
+ * @param lenient indicates if the charset encoding detection should be
+ * relaxed.
* @param defaultEncoding default encoding to use if one cannot be detected.
* @throws IOException thrown if there is a problem reading the file.
- * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according
- * to the specs.
- *
+ * @throws XmlStreamReaderException thrown if the charset encoding could not
+ * be determined according to the specs.
*/
- public XmlStreamReader(final InputStream is, final String httpContentType, final boolean lenient, final String defaultEncoding) throws IOException,
- XmlStreamReaderException {
+ public XmlStreamReader(final InputStream is, final String httpContentType, final boolean lenient, final String defaultEncoding) throws IOException, XmlStreamReaderException {
if (defaultEncoding == null) {
this.defaultEncoding = staticDefaultEncoding;
} else {
@@ -389,17 +399,19 @@ public class XmlStreamReader extends Reader {
}
/**
- * Creates a Reader using an InputStream and the associated content-type header.
+ * Creates a Reader using an InputStream and the associated content-type
+ * header.
* <p>
- * First it checks if the stream has BOM. If there is not BOM checks the content-type encoding.
- * If there is not content-type encoding checks the XML prolog encoding. If there is not XML
- * prolog encoding uses the default encoding mandated by the content-type MIME type.
+ * First it checks if the stream has BOM. If there is not BOM checks the
+ * content-type encoding. If there is not content-type encoding checks the
+ * XML prolog encoding. If there is not XML prolog encoding uses the default
+ * encoding mandated by the content-type MIME type.
* <p>
- * If lenient detection is indicated and the detection above fails as per specifications it then
- * attempts the following:
+ * If lenient detection is indicated and the detection above fails as per
+ * specifications it then attempts the following:
* <p>
- * If the content type was 'text/html' it replaces it with 'text/xml' and tries the detection
- * again.
+ * If the content type was 'text/html' it replaces it with 'text/xml' and
+ * tries the detection again.
* <p>
* Else if the XML prolog had a charset encoding that encoding is used.
* <p>
@@ -407,24 +419,26 @@ public class XmlStreamReader extends Reader {
* <p>
* Else 'UTF-8' is used.
* <p>
- * If lenient detection is indicated and XmlStreamReaderException is never thrown.
+ * If lenient detection is indicated and XmlStreamReaderException is never
+ * thrown.
* <p>
*
* @param is InputStream to create the reader from.
- * @param httpContentType content-type header to use for the resolution of the charset encoding.
- * @param lenient indicates if the charset encoding detection should be relaxed.
+ * @param httpContentType content-type header to use for the resolution of
+ * the charset encoding.
+ * @param lenient indicates if the charset encoding detection should be
+ * relaxed.
* @throws IOException thrown if there is a problem reading the file.
- * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according
- * to the specs.
- *
+ * @throws XmlStreamReaderException thrown if the charset encoding could not
+ * be determined according to the specs.
*/
public XmlStreamReader(final InputStream is, final String httpContentType, final boolean lenient) throws IOException, XmlStreamReaderException {
this(is, httpContentType, lenient, null);
}
/**
- * Returns the default encoding to use if none is set in HTTP content-type, XML prolog and the
- * rules based on content-type are not adequate.
+ * Returns the default encoding to use if none is set in HTTP content-type,
+ * XML prolog and the rules based on content-type are not adequate.
* <p/>
* If it is NULL the content-type based rules are used.
* <p/>
@@ -436,8 +450,8 @@ public class XmlStreamReader extends Reader {
}
/**
- * Sets the default encoding to use if none is set in HTTP content-type, XML prolog and the
- * rules based on content-type are not adequate.
+ * Sets the default encoding to use if none is set in HTTP content-type, XML
+ * prolog and the rules based on content-type are not adequate.
* <p/>
* If it is set to NULL the content-type based rules are used.
* <p/>
@@ -455,7 +469,6 @@ public class XmlStreamReader extends Reader {
* <p>
*
* @return charset encoding.
- *
*/
public String getEncoding() {
return encoding;
@@ -500,7 +513,6 @@ public class XmlStreamReader extends Reader {
* <p>
*
* @throws IOException thrown if there was a problem closing the stream.
- *
*/
@Override
public void close() throws IOException {
@@ -549,22 +561,22 @@ public class XmlStreamReader extends Reader {
}
} else if (bomEnc.equals(UTF_8)) {
if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
- throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
+ throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is);
}
if (xmlEnc != null && !xmlEnc.equals(UTF_8)) {
- throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
+ throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is);
}
encoding = UTF_8;
} else if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) {
if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
- throw new IOException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }));
+ throw new IOException(RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}));
}
if (xmlEnc != null && !xmlEnc.equals(UTF_16) && !xmlEnc.equals(bomEnc)) {
- throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
+ throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is);
}
encoding = bomEnc;
} else {
- throw new XmlStreamReaderException(RAW_EX_2.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
+ throw new XmlStreamReaderException(RAW_EX_2.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is);
}
return encoding;
}
@@ -584,8 +596,9 @@ public class XmlStreamReader extends Reader {
}
// InputStream is passed for XmlStreamReaderException creation only
- private String calculateHttpEncoding(final String cTMime, final String cTEnc, final String bomEnc, final String xmlGuessEnc, final String xmlEnc,
- final InputStream is, final boolean lenient) throws IOException {
+ private String calculateHttpEncoding(final String cTMime, final String cTEnc, final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final InputStream is,
+ final boolean lenient)
+ throws IOException {
String encoding;
if (lenient && xmlEnc != null) {
encoding = xmlEnc;
@@ -604,21 +617,19 @@ public class XmlStreamReader extends Reader {
}
}
} else if (bomEnc != null && (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE))) {
- throw new XmlStreamReaderException(HTTP_EX_1.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc,
- xmlGuessEnc, xmlEnc, is);
+ throw new XmlStreamReaderException(HTTP_EX_1.format(new Object[] {cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc}), cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, is);
} else if (cTEnc.equals(UTF_16)) {
if (bomEnc != null && bomEnc.startsWith(UTF_16)) {
encoding = bomEnc;
} else {
- throw new XmlStreamReaderException(HTTP_EX_2.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc,
- xmlGuessEnc, xmlEnc, is);
+ throw new XmlStreamReaderException(HTTP_EX_2.format(new Object[] {cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc}), cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc,
+ is);
}
} else {
encoding = cTEnc;
}
} else {
- throw new XmlStreamReaderException(HTTP_EX_3.format(new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc, xmlGuessEnc,
- xmlEnc, is);
+ throw new XmlStreamReaderException(HTTP_EX_3.format(new Object[] {cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc}), cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, is);
}
}
return encoding;
@@ -752,9 +763,8 @@ public class XmlStreamReader extends Reader {
// indicates if the MIME type belongs to the APPLICATION XML family
private static boolean isAppXml(final String mime) {
- return mime != null
- && (mime.equals("application/xml") || mime.equals("application/xml-dtd") || mime.equals("application/xml-external-parsed-entity") || mime
- .startsWith("application/") && mime.endsWith("+xml"));
+ return mime != null && (mime.equals("application/xml") || mime.equals("application/xml-dtd") || mime.equals("application/xml-external-parsed-entity")
+ || mime.startsWith("application/") && mime.endsWith("+xml"));
}
// indicates if the MIME type belongs to the TEXT XML family
diff --git a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReaderException.java b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReaderException.java
index 5336ed4..9233076 100644
--- a/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReaderException.java
+++ b/core/camel-xml-io/src/main/java/org/apache/camel/xml/io/XmlStreamReaderException.java
@@ -38,12 +38,14 @@ import java.io.InputStream;
import java.io.IOException;
/**
- * The XmlReaderException is thrown by the XmlReader constructors if the charset encoding can not be
- * determined according to the XML 1.0 specification and RFC 3023.
+ * The XmlReaderException is thrown by the XmlReader constructors if the charset
+ * encoding can not be determined according to the XML 1.0 specification and RFC
+ * 3023.
* <p>
- * The exception returns the unconsumed InputStream to allow the application to do an alternate
- * processing with the stream. Note that the original InputStream given to the XmlReader cannot be
- * used as that one has been already read.
+ * The exception returns the unconsumed InputStream to allow the application to
+ * do an alternate processing with the stream. Note that the original
+ * InputStream given to the XmlReader cannot be used as that one has been
+ * already read.
*/
public class XmlStreamReaderException extends IOException {
private static final long serialVersionUID = 1L;
@@ -55,7 +57,8 @@ public class XmlStreamReaderException extends IOException {
private final InputStream is;
/**
- * Creates an exception instance if the charset encoding could not be determined.
+ * Creates an exception instance if the charset encoding could not be
+ * determined.
* <p>
* Instances of this exception are thrown by the XmlReader.
* <p>
@@ -65,14 +68,14 @@ public class XmlStreamReaderException extends IOException {
* @param xmlGuessEnc XML guess encoding.
* @param xmlEnc XML prolog encoding.
* @param is the unconsumed InputStream.
- *
*/
public XmlStreamReaderException(final String msg, final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final InputStream is) {
this(msg, null, null, bomEnc, xmlGuessEnc, xmlEnc, is);
}
/**
- * Creates an exception instance if the charset encoding could not be determined.
+ * Creates an exception instance if the charset encoding could not be
+ * determined.
* <p>
* Instances of this exception are thrown by the XmlReader.
* <p>
@@ -84,7 +87,6 @@ public class XmlStreamReaderException extends IOException {
* @param xmlGuessEnc XML guess encoding.
* @param xmlEnc XML prolog encoding.
* @param is the unconsumed InputStream.
- *
*/
public XmlStreamReaderException(final String msg, final String ctMime, final String ctEnc, final String bomEnc, final String xmlGuessEnc, final String xmlEnc,
final InputStream is) {
@@ -102,7 +104,6 @@ public class XmlStreamReaderException extends IOException {
* <p>
*
* @return the BOM encoding, null if none.
- *
*/
public String getBomEncoding() {
return bomEncoding;
@@ -113,7 +114,6 @@ public class XmlStreamReaderException extends IOException {
* <p>
*
* @return the encoding guess, null if it couldn't be guessed.
- *
*/
public String getXmlGuessEncoding() {
return xmlGuessEncoding;
@@ -124,46 +124,45 @@ public class XmlStreamReaderException extends IOException {
* <p>
*
* @return the encoding of the XML prolog, null if none.
- *
*/
public String getXmlEncoding() {
return xmlEncoding;
}
/**
- * Returns the MIME type in the content-type used to attempt determining the encoding.
+ * Returns the MIME type in the content-type used to attempt determining the
+ * encoding.
* <p>
*
- * @return the MIME type in the content-type, null if there was not content-type or the encoding
- * detection did not involve HTTP.
- *
+ * @return the MIME type in the content-type, null if there was not
+ * content-type or the encoding detection did not involve HTTP.
*/
public String getContentTypeMime() {
return contentTypeMime;
}
/**
- * Returns the encoding in the content-type used to attempt determining the encoding.
+ * Returns the encoding in the content-type used to attempt determining the
+ * encoding.
* <p>
*
- * @return the encoding in the content-type, null if there was not content-type, no encoding in
- * it or the encoding detection did not involve HTTP.
- *
+ * @return the encoding in the content-type, null if there was not
+ * content-type, no encoding in it or the encoding detection did not
+ * involve HTTP.
*/
public String getContentTypeEncoding() {
return contentTypeEncoding;
}
/**
- * Returns the unconsumed InputStream to allow the application to do an alternate encoding
- * detection on the InputStream.
+ * Returns the unconsumed InputStream to allow the application to do an
+ * alternate encoding detection on the InputStream.
* <p>
*
* @return the unconsumed InputStream.
- *
*/
public InputStream getInputStream() {
return is;
}
}
-// CHECKSTYLE:ON
\ No newline at end of file
+// CHECKSTYLE:ON
diff --git a/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java b/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
index 2ca21f5..05322bb 100644
--- a/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
+++ b/core/camel-xml-io/src/test/java/org/apache/camel/xml/in/ModelParserTest.java
@@ -54,14 +54,8 @@ public class ModelParserTest {
@Test
public void testSimpleString() throws Exception {
- RoutesDefinition routes = new ModelParser(new StringReader(
- "<routes>"
- + " <route id='foo'>"
- + " <from uri='my:bar'/>"
- + " <to uri='mock:res'/>"
- + " </route>"
- + "</routes>"
- )).parseRoutesDefinition();
+ RoutesDefinition routes = new ModelParser(new StringReader("<routes>" + " <route id='foo'>" + " <from uri='my:bar'/>" + " <to uri='mock:res'/>" + " </route>"
+ + "</routes>")).parseRoutesDefinition();
assertNotNull(routes);
}