-- *
-- *
-- * NOTE: Param node must be a DOM node which will be used
-- * during the xpath execution and iteration through the results.
-- * A call of node.dispose() must be done after reading all results.
-- *
-- *
-- * @param node The node, nodeset or Context object for evaluation.
-- * This value can be null.
-- * @return The List of all items selected
-- * by this XPath expression.
-- */
-- public List selectNodes(Object node)
-- {
-- try
-- {
-- Node contextNode = (Node)node;
-- XPathEvaluator xpe = new XPathEvaluator();
-- Configuration config = new Configuration();
-- config.setDOMLevel(2);
-- config.setTreeModel(net.sf.saxon.event.Builder.STANDARD_TREE);
-- IndependentContext sc = new IndependentContext(config);
-- // Declare ns bindings
-- if (defaultNS != null)
-- sc.setDefaultElementNamespace(defaultNS);
--
-- for (int i = 0; i < namespaceMap.length; i++)
-- {
-- Map.Entry entry = (Map.Entry) namespaceMap[i];
-- sc.declareNamespace((String) entry.getKey(),
-- (String) entry.getValue());
-- }
-- xpe.setStaticContext(sc);
-- XPathVariable thisVar = xpe.declareVariable("", contextVar);
-- XPathExpression xpath = xpe.createExpression(path);
-- NodeInfo contextItem =
-- //config.buildDocument(new DOMSource(contextNode));
-- config.unravel(new DOMSource(contextNode));
-- XPathDynamicContext dc = xpath.createDynamicContext(null);
-- dc.setContextItem(contextItem);
-- dc.setVariable(thisVar, contextItem);
--
-- List saxonNodes = xpath.evaluate(dc);
-- for (ListIterator it = saxonNodes.listIterator(); it.hasNext(); )
-- {
-- Object o = it.next();
-- if (o instanceof NodeInfo)
-- {
-- if (o instanceof NodeWrapper)
-- {
-- Node n = getUnderlyingNode((NodeWrapper)o);
-- it.set(n);
-- }
-- else
-- {
-- it.set(((NodeInfo)o).getStringValue());
-- }
-- }
-- else if (o instanceof Item)
-- it.set(Value.convertToJava((Item)o));
-- }
-- return saxonNodes;
-- }
-- catch (TransformerException e)
-- {
-- throw new RuntimeException(e);
-- }
-- }
--
-- public List selectPath(Object node)
-- {
-- return selectNodes(node);
-- }
--
-- /**
-- * According to the Saxon javadoc:
-- * getUnderlyingNode in NodeWrapper implements
-- * the method specified in the interface VirtualNode, and
-- * the specification of the latter says that it may return another
-- * VirtualNode, and you may have to drill down through
-- * several layers of wrapping.
-- * To be safe, this method is provided to drill down through multiple
-- * layers of wrapping.
-- * @param v The VirtualNode
-- * @return The underlying node
-- */
-- private static Node getUnderlyingNode(VirtualNode v)
-- {
-- Object o = v;
-- while (o instanceof VirtualNode)
-- {
-- o = ((VirtualNode)o).getUnderlyingNode();
-- }
-- return (Node)o;
-- }
--
--}
---- a/src/xpath_xquery/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
-+++ /dev/null
-@@ -1,125 +0,0 @@
--/* Copyright 2004 The Apache Software Foundation
-- *
-- * Licensed under the Apache License, Version 2.0 (the "License");
-- * you may not use this file except in compliance with the License.
-- * You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.xmlbeans.impl.xquery.saxon;
--
--import java.util.List;
--import java.util.Map;
--import java.util.Iterator;
--import java.util.ListIterator;
--
--import javax.xml.transform.dom.DOMSource;
--import javax.xml.transform.TransformerException;
--
--import org.w3c.dom.Node;
--
--import net.sf.saxon.Configuration;
--import net.sf.saxon.dom.NodeOverNodeInfo;
--import net.sf.saxon.om.NodeInfo;
--import net.sf.saxon.query.DynamicQueryContext;
--import net.sf.saxon.query.StaticQueryContext;
--import net.sf.saxon.query.XQueryExpression;
--
--import org.apache.xmlbeans.XmlRuntimeException;
--import org.apache.xmlbeans.XmlTokenSource;
--import org.apache.xmlbeans.impl.store.QueryDelegate;
--
--public class XBeansXQuery
-- implements QueryDelegate.QueryInterface
--{
-- private XQueryExpression xquery;
-- private String contextVar;
-- private Configuration config;
--
-- /**
-- * Construct given an XQuery expression string.
-- * @param query The XQuery expression
-- * @param contextVar The name of the context variable
-- * @param boundary The offset of the end of the prolog
-- */
-- public XBeansXQuery(String query, String contextVar, Integer boundary)
-- {
-- config = new Configuration();
-- config.setDOMLevel(2);
-- config.setTreeModel(net.sf.saxon.event.Builder.STANDARD_TREE);
-- StaticQueryContext sc = new StaticQueryContext(config);
-- this.contextVar = contextVar;
-- int bdry = boundary.intValue();
-- //Saxon requires external variables at the end of the prolog...
-- query = (bdry == 0) ?
-- "declare variable $" +
-- contextVar + " external;" + query :
-- query.substring(0, bdry) +
-- "declare variable $" +
-- contextVar + " external;" +
-- query.substring(bdry);
-- try
-- {
-- xquery = sc.compileQuery(query);
-- }
-- catch (TransformerException e)
-- {
-- throw new XmlRuntimeException(e);
-- }
-- }
--
-- public List execQuery(Object node, Map variableBindings)
-- {
-- try
-- {
-- Node contextNode = (Node)node;
-- NodeInfo contextItem =
-- config.buildDocument(new DOMSource(contextNode));
-- //config.unravel(new DOMSource(contextNode));
-- DynamicQueryContext dc = new DynamicQueryContext(config);
-- dc.setContextItem(contextItem);
-- dc.setParameter(contextVar, contextItem);
-- // Set the other variables
-- if (variableBindings != null)
-- {
-- for (Iterator it = variableBindings.entrySet().iterator();
-- it.hasNext(); )
-- {
-- Map.Entry entry = (Map.Entry)it.next();
-- String key = (String)entry.getKey();
-- Object value = entry.getValue();
-- if (value instanceof XmlTokenSource)
-- {
-- Node paramObject = ((XmlTokenSource)value).getDomNode();
-- dc.setParameter(key, paramObject);
-- }
-- else if (value instanceof String)
-- dc.setParameter(key, value);
-- }
-- }
--
-- List saxonNodes = xquery.evaluate(dc);
-- for (ListIterator it = saxonNodes.listIterator(); it.hasNext(); )
-- {
-- Object o = it.next();
-- if(o instanceof NodeInfo)
-- {
-- Node n = NodeOverNodeInfo.wrap((NodeInfo)o);
-- it.set(n);
-- }
-- }
-- return saxonNodes;
-- }
-- catch (TransformerException e)
-- {
-- throw new RuntimeException("Error binding " + contextVar, e);
-- }
-- }
--}
diff --git a/debian/patches/scripts.patch b/debian/patches/scripts.patch
index 74b7a73..56898fe 100644
--- a/debian/patches/scripts.patch
+++ b/debian/patches/scripts.patch
@@ -3,8 +3,8 @@ Description: Fix XMLBEANS_LIB variables in all CLI scripts
Author: Damien Raude-Morvan
Last-Update: 2010-03-26
Forwarded: not-needed
---- a/bin/dumpxsb
-+++ b/bin/dumpxsb
+--- a/src/main/shell/dumpxsb
++++ b/src/main/shell/dumpxsb
@@ -18,11 +18,9 @@
#XSB file dumper
#Prints the contents of an xsb file in human-readmble form
@@ -14,13 +14,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
-
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/inst2xsd
-+++ b/bin/inst2xsd
+--- a/src/main/shell/inst2xsd
++++ b/src/main/shell/inst2xsd
@@ -18,9 +18,9 @@
#Instance to Schema tool
#Builds xsd files from xml instance files.
@@ -28,13 +28,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/scomp
-+++ b/bin/scomp
+--- a/src/main/shell/scomp
++++ b/src/main/shell/scomp
@@ -18,9 +18,9 @@
#Schema compiler
#Builds XBean types from xsd files.
@@ -42,13 +42,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$JAVA_HOME/lib/tools.jar:$XMLBEANS_LIB/resolver.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$JAVA_HOME/lib/tools.jar:$XMLBEANS_LIB/resolver.jar
+-cp=$XMLBEANS_LIB/*:$JAVA_HOME/lib/tools.jar
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$JAVA_HOME/lib/tools.jar:$XMLBEANS_LIB/resolver.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/sdownload
-+++ b/bin/sdownload
+--- a/src/main/shell/sdownload
++++ b/src/main/shell/sdownload
@@ -18,9 +18,9 @@
#Schema downloader
#Tool to download Schema files
@@ -56,13 +56,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/sfactor
-+++ b/bin/sfactor
+--- a/src/main/shell/sfactor
++++ b/src/main/shell/sfactor
@@ -20,9 +20,9 @@
## Factors redundant definitions out of a set of schemas and
## uses imports instead.
@@ -70,13 +70,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/resolver.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/resolver.jar
+-cp=$XMLBEANS_LIB/*:$XMLBEANS_LIB/resolver.jar
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/resolver.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/svalidate
-+++ b/bin/svalidate
+--- a/src/main/shell/svalidate
++++ b/src/main/shell/svalidate
@@ -19,9 +19,9 @@
#
# Validates an instance against a schema.
@@ -84,13 +84,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/jsr173_1.0_ri.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/jsr173_1.0_ri.jar
+-cp=$XMLBEANS_LIB/*:$XMLBEANS_LIB/jsr173_1.0_ri.jar
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/jsr173_1.0_ri.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/validate
-+++ b/bin/validate
+--- a/src/main/shell/validate
++++ b/src/main/shell/validate
@@ -19,9 +19,9 @@
#
# Validates an instance against a schema.
@@ -98,13 +98,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/xpretty
-+++ b/bin/xpretty
+--- a/src/main/shell/xpretty
++++ b/src/main/shell/xpretty
@@ -17,9 +17,9 @@
#Invokes pretty printer
@@ -112,13 +112,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/xsd2inst
-+++ b/bin/xsd2inst
+--- a/src/main/shell/xsd2inst
++++ b/src/main/shell/xsd2inst
@@ -17,9 +17,9 @@
#Schema to instance tool
@@ -126,13 +126,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/xsdtree
-+++ b/bin/xsdtree
+--- a/src/main/shell/xsdtree
++++ b/src/main/shell/xsdtree
@@ -17,9 +17,9 @@
# Invokes type hierarchy printer
@@ -140,13 +140,13 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar
+-cp=$XMLBEANS_LIB/*
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
---- a/bin/xstc
-+++ b/bin/xstc
+--- a/src/main/shell/xstc
++++ b/src/main/shell/xstc
@@ -17,9 +17,9 @@
# Invokes XSTC
@@ -154,8 +154,8 @@ Forwarded: not-needed
-if [ -z "$XMLBEANS_LIB" ]; then . `dirname $0`/_setlib; fi
+XMLBEANS_LIB=/usr/share/java
--cp=$XMLBEANS_LIB/xbean.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/resolver.jar
-+cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/xmlbeans-qname.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/resolver.jar
+-cp=$XMLBEANS_LIB/*:$XMLBEANS_LIB/resolver.jar
++cp=$XMLBEANS_LIB/xmlbeans.jar:$XMLBEANS_LIB/jsr173_1.0_api.jar:$XMLBEANS_LIB/resolver.jar:/usr/share/java/javaparser-core.jar
case "`uname`" in
CYGWIN*)
diff --git a/debian/patches/series b/debian/patches/series
index 8b37b09..641da24 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,4 @@
scripts.patch
-saxon_9.7.patch
+saxon-compatibility.patch
+xmlbeans-compatibility.patch
+javasource-option.patch
diff --git a/debian/patches/xmlbeans-compatibility.patch b/debian/patches/xmlbeans-compatibility.patch
new file mode 100644
index 0000000..db09ffe
--- /dev/null
+++ b/debian/patches/xmlbeans-compatibility.patch
@@ -0,0 +1,14 @@
+Description: Fixes a build failure with xmlbeans 3
+Author: Emmanuel Bourg
+Forwarded: not-needed
+--- a/build.xml
++++ b/build.xml
+@@ -307,7 +307,7 @@
+
+
+
+-
++
+
+
+
diff --git a/debian/poms/xmlbeans.xml b/debian/poms/xmlbeans.xml
index 8e356f7..59d3afd 100644
--- a/debian/poms/xmlbeans.xml
+++ b/debian/poms/xmlbeans.xml
@@ -1,8 +1,28 @@
+
+
+
4.0.0org.apache.xmlbeansxmlbeans
- 3.0.2
+ 4.0.0XmlBeansXmlBeans main jar
@@ -10,7 +30,7 @@
jira
- http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10436
+ https://issues.apache.org/jira/browse/XMLBEANS
@@ -26,7 +46,7 @@
dev-unsubscribe@poi.apache.orghttp://mail-archives.apache.org/mod_mbox/poi-dev/
-
+
@@ -38,9 +58,7 @@
scm:svn:https://svn.apache.org/repos/asf/xmlbeans/
-
- scm:svn:https://${maven.username}@svn.apache.org/repos/asf/xmlbeans/
-
+ scm:svn:https://${maven.username}@svn.apache.org/repos/asf/xmlbeans/https://svn.apache.org/repos/asf/xmlbeans/
@@ -50,36 +68,6 @@
-
- Cezar Andrei
- cezar
- cezar.andrei@no#spam#!gma|l.com
-
-
-
- Radu Preotiuc
- radup
- radupr@nos#pam.gm@il.com
-
-
-
- Radu Preotiuc
- radup
- radu.preotiuc-pietro@nos#pam.bea.com
-
-
-
- Wing Yew Poon
- wpoon
- wing-yew.poon@nos#pam.oracle.com
-
-
-
- Jacob Danner
- jdanner
- jacob.danner@nos#pam.oracle.com
-
- POI Teampoi
@@ -88,6 +76,34 @@
-
+
+
+ net.sf.saxon
+ Saxon-HE
+ 10.2
+ provided
+
+
+ com.github.javaparser
+ javaparser-core
+ 3.16.1
+ provided
+
+
+
+
+ java8
+
+ 1.8
+
+
+
+ xml-apis
+ xml-apis
+ 1.4.01
+
+
+
+
diff --git a/debian/rules b/debian/rules
index 845f4f1..6c577a7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,19 +1,13 @@
#!/usr/bin/make -f
-export CLASSPATH=/usr/share/java/xmlbeans.jar
-
%:
dh $@ --with maven-repo-helper
override_dh_auto_build:
- mkdir -p external/lib/
- ln -s /usr/share/java/xmlbeans.jar external/lib/oldxbean.jar
- ln -s /usr/share/java/junit.jar external/lib/junit.jar
-
- mkdir -p build/lib/
- ln -s /usr/share/java/geronimo-stax-1.0-spec.jar build/lib/jsr173_1.0_api.jar
+ mkdir -p src/xpath_xquery
+ mkdir -p lib/main
- ANT_OPTS=-Dfile.encoding=iso-8859-1 dh_auto_build -- xbean.jar
+ ANT_OPTS=-Dfile.encoding=iso-8859-1 dh_auto_build -- package -Djars.present=true
override_dh_install:
dh_install
@@ -21,8 +15,7 @@ override_dh_install:
# Rename to fix filename conflict: See #578032
mv debian/xmlbeans/usr/bin/validate debian/xmlbeans/usr/bin/xsdvalidate
-POM_VERSION := 3.0.2
+POM_VERSION := 4.0.0
get-orig-pom:
wget -O debian/poms/xmlbeans.xml https://repo1.maven.org/maven2/org/apache/xmlbeans/xmlbeans/$(POM_VERSION)/xmlbeans-$(POM_VERSION).pom
- wget -O debian/poms/xpath.xml https://repo1.maven.org/maven2/org/apache/xmlbeans/xmlbeans-xpath/$(POM_VERSION)/xmlbeans-xpath-$(POM_VERSION).pom
diff --git a/debian/watch b/debian/watch
index bb62b49..cce8bba 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,3 +1,3 @@
version=3
-opts="dversionmangle=s/\+dfsg//,repack,compression=xz" \
-https://github.com/apache/xmlbeans/tags .*/([\d\.]+).tar.gz
+opts="dversionmangle=s/\+dfsg//,uversionmangle=s/_/./g,repack,compression=xz" \
+https://github.com/apache/xmlbeans/tags .*/(?:REL_)?([\d\._]+).tar.gz
diff --git a/debian/xmlbeans.install b/debian/xmlbeans.install
index 96d11c4..e370eec 100644
--- a/debian/xmlbeans.install
+++ b/debian/xmlbeans.install
@@ -1,11 +1,11 @@
-bin/dumpxsb /usr/bin/
-bin/inst2xsd /usr/bin/
-bin/scomp /usr/bin/
-bin/sdownload /usr/bin/
-bin/sfactor /usr/bin/
-bin/svalidate /usr/bin/
-bin/validate /usr/bin/
-bin/xpretty /usr/bin/
-bin/xsd2inst /usr/bin/
-bin/xsdtree /usr/bin/
-bin/xstc /usr/bin/
+src/main/shell/dumpxsb /usr/bin/
+src/main/shell/inst2xsd /usr/bin/
+src/main/shell/scomp /usr/bin/
+src/main/shell/sdownload /usr/bin/
+src/main/shell/sfactor /usr/bin/
+src/main/shell/svalidate /usr/bin/
+src/main/shell/validate /usr/bin/
+src/main/shell/xpretty /usr/bin/
+src/main/shell/xsd2inst /usr/bin/
+src/main/shell/xsdtree /usr/bin/
+src/main/shell/xstc /usr/bin/
diff --git a/docs/guide/antXmlbean.html b/docs/guide/antXmlbean.html
index bc0b228..8bdead1 100644
--- a/docs/guide/antXmlbean.html
+++ b/docs/guide/antXmlbean.html
@@ -215,6 +215,12 @@
Parameters
the executing VM in the classpath; defaults to no.
No
+
+
nowarn
+
Whether the -nowarn switch should be passed to
+ the JDK compiler; defaults to no.
+
No
+
fork
Whether to execute javac using the JDK compiler
diff --git a/docs/guide/conSelectingXMLwithXQueryPathXPath.html b/docs/guide/conSelectingXMLwithXQueryPathXPath.html
index 648cde6..41b7849 100644
--- a/docs/guide/conSelectingXMLwithXQueryPathXPath.html
+++ b/docs/guide/conSelectingXMLwithXQueryPathXPath.html
@@ -225,9 +225,9 @@
Using XQuery with the execQuery Method
You use the execQuery method to execute XQuery
expressions. With XQuery expressions, XML returned is a copy of XML in the document queried against. In other words, changes your code makes to the values returned by execQuery are not reflected in the document queried against.
-
Note: To execute XQuery expressions, you must have the SaxonB 8.6.1 versions of the saxon8.jar and saxon8-dom.jar files on your classpath. These are two of the jars from inside the zip file saxonb8-6-1.zip
+
Note: To execute XQuery expressions, you must have the SaxonB 9.0.0.4 versions of the saxon9.jar and saxon9-dom.jar files on your classpath. These are two of the jars from inside the zip file saxonb9-0-0-4j.zip
which can be downloaded from the Saxon web site.
- If you build XMLBeans from source then the saxonb8-6-1.zip file and the two Saxon jar files are available in the external/lib directory.
+ If you build XMLBeans from source then the saxonb9-0-0-4j.zip file and the two Saxon jar files are available in the external/lib directory.
Calling XmlObject.execQuery
As with selectPath, calling execQuery
diff --git a/docs/stylesheet.css b/docs/stylesheet.css
deleted file mode 100644
index df91b48..0000000
--- a/docs/stylesheet.css
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* Javadoc style sheet */
-
-/* Define colors, fonts and other style attributes here to override the defaults */
-
-/* Page background color */
-body {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- background-color: #FFFFFF
-}
-
-body {
-/* padding: 0px 0px 0px 15px; */
- background: #ffffff;
- color: #00000;
- font-size: 80%;
-}
-
-/* Table colors */
-.TableHeadingColor { background: #CCCCFF } /* Dark mauve */
-.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */
-.TableRowColor { background: #FFFFFF } /* White */
-
-/* Font used in left-hand frame lists */
-.FrameTitleFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
-.FrameHeadingFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
-.FrameItemFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
-
-/* Example of smaller, sans-serif font in frames */
-/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
-
-/* Navigation bar fonts and colors */
-.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */
-.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */
-.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
-.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
-
-.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
-.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
-
diff --git a/external/lib/jam-0.1.0-src.jar b/external/lib/jam-0.1.0-src.jar
deleted file mode 100644
index 158a023..0000000
Binary files a/external/lib/jam-0.1.0-src.jar and /dev/null differ
diff --git a/external/lib/jam.LICENSE.txt b/external/lib/jam.LICENSE.txt
deleted file mode 100644
index 57bc88a..0000000
--- a/external/lib/jam.LICENSE.txt
+++ /dev/null
@@ -1,202 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
diff --git a/release-guide.txt b/release-guide.txt
new file mode 100644
index 0000000..e2eee97
--- /dev/null
+++ b/release-guide.txt
@@ -0,0 +1,235 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+ ==============================
+ XMLBeans Release Guide
+ ==============================
+
+
+(I) Prerequisites
+
+ 1. You should read the Apache Release FAQ
+ 2a. You must have shell access to people.apache.org; and you should
+ have key-based authentication set up
+ 1. Generate ssh key with ssh-keygen -t rsa -b 4096
+ (e.g. how to.)
+ 2. Add contents of id_rsa.pub to SSH Key (authorized_keys) line on https://id.apache.org/
+ 3. ssh -v username@people.apache.org
+ Verify authenticity of host: https://www.apache.org/dev/machines
+ 4. Only sftp access is necessary
+ 2b. You must be a member of the committee group
+ 3. Release manager must have their public key appended to the KEYS file checked in to SVN and the key published on one of the public key servers.
+ More info can be found here: https://www.apache.org/dev/release-signing.html
+ 4. You must have Java JDK 8 installed and active.
+ 5. You must have the following utilities installed on your local machine and available in your path:
+ * ssh
+ * gnupg
+ * openssl
+ For Windows users, install Cygwin and make sure you have the above utilities
+ 6a. The POI build system requires two components to perform a build
+ * Ant 1.9.x or higher
+ * Forrest 0.90.
+ Make sure ANT_HOME and FORREST_HOME are set.
+
+ 6b. Ensure you can log in to https://repository.apache.org/ with your Apache
+ credentials, and that you can see the "Staging Repositories" area on
+ the left hand side.
+
+ 6c. It's a good idea to check at
+ https://builds.apache.org/view/P/view/POI/job/POI-XMLBeans-DSL-1.8/
+ that Jenkins is in a good state (i.e. most recent build passed
+ and is up to date with SVN). You probably also want to e-mail
+ the dev list with a note to say you're building a release.
+
+ 7. Before building, you should run the "rat-check" build task, which
+ uses Apache Rat
+ to check the source tree for files lacking license headers. Files
+ without headers should be either fixed, or added to the exclude list
+
+ 8. Check file permissions are correct in SVN.
+ There can be files in the SVN tree marked executable (have the
+ svn:executable property set), but which should not be. Checking them
+ out will cause the executable bit to be set for them on filesystems
+ which support it. The flag can be removed in batch using
+
+{code:sh}
+svn pd 'svn:executable' $(find -name .svn -prune -or -type f ! -name \*.sh \
+ -print0 | xargs -0 svn pg 'svn:executable' | cut -d ' ' -f 1)
+{code}
+
+ 9. Before building, review any new or updated dependencies to ensure that
+ if they required LICENSE or NOTICE updates then these were done.
+
+ 10. Ensure that CHANGES.txt is up to date
+
+ 11. Ensure that the KEYS files in the dist areas are up-to-date with the
+ latest ones in POI svn:
+ https://dist.apache.org/repos/dist/dev/poi/KEYS
+ https://dist.apache.org/repos/dist/release/poi/KEYS
+ Dist is a regular svn repo that can be checked out and committed to.
+ To upload to dist: https://www.apache.org/dev/release-distribution
+
+
+(II) Making release artifacts
+
+ 1. Grab the output from a successful Jenkins build for the desired revision:
+ https://builds.apache.org/view/P/view/POI/job/POI-XMLBeans-DSL-1.8/lastBuild/artifact/build/
+ - xmlbeans-VERSION.jar
+ - xmlbeans-VERSION-javadoc.jar
+ - xmlbeans-VERSION-sources.jar
+ - xmlbeans-bin-VERSION-DATE.zip
+ - xmlbeans-bin-VERSION-DATE.tgz
+ - xmlbeans-src-VERSION-DATE.zip
+ - xmlbeans-src-VERSION-DATE.tgz
+
+ 2. Grab the current deployed POM, and edit the version # and anything else that has changed:
+ https://repository.apache.org/service/local/repo_groups/public/content/org/apache/xmlbeans/xmlbeans/VERSION/xmlbeans-VERSION.pom
+
+ 3. Sign the jars, zip, tgz, and pom with your key (gpg doesn't sign via --multifile yet):
+ for f in *.jar *.zip *.tgz *.pom; do gpg --default-key 1556F3A4 -ab $f; done
+
+ 4. Build the nexus bundle.jar to upload to
+ repository.apache.org:
+ jar -cvf bundle.jar *.pom *.pom.asc *.jar *.jar.asc
+
+ 5. Upload the bundle to https://repository.apache.org/
+
+ 6. Generate checksums (sha256sum, sha512sum) for the *.zip and *.tgz files
+
+ for f in *.zip *.tgz
+ do
+ for b in 256 512
+ do
+ sha${b}sum $f > $f.sha$b
+ done
+ done
+
+ 7. Commit the *.tgz and *.zip files, their signatures, and sha256 and sha512
+ checksums to the release candidate repo at
+ https://dist.apache.org/repos/dist/dev/poi/xmlbeans/
+
+
+ (III) Calling the vote:
+
+ 1. The release manager should call the vote
+ 2. Include the URL of the release artifacts
+ 3. Include the time for the vote to run (3 day minimum, can be longer)
+ 4. Provide guidance on what needs to be checked
+ 5. Complete a tally, and send a result once the time has passed
+
+ (IV) After the vote:
+
+Deploy the artifacts from the staging area (https://dist.apache.org/repos/dist/dev/poi/xmlbeans)
+to the release area of the dist repo:
+ https://dist.apache.org/repos/dist/release/poi/xmlbeans/release/
+
+Perform a sparse checkout of the dist repo to move artifacts in the staging area to the release area
+In the following example, replace FIXME3.0.2 or FIXME3.1.0 with the version you are releasing
+
+{code:sh}
+svn checkout https://dist.apache.org/repos/dist/ --depth immediates
+svn update --set-depth immediates dist/dev/poi/
+svn update --set-depth infinity dist/dev/poi/xmlbeans/
+svn update --set-depth infinity dist/release/poi/xmlbeans/
+svn rm dist/release/poi/xmlbeans/release/src/* dist/release/poi/xmlbeans/release/bin/*
+svn mv dist/dev/poi/xmlbeans/src/* dist/release/poi/xmlbeans/release/src/
+svn mv dist/dev/poi/xmlbeans/bin/* dist/release/poi/xmlbeans/release/bin/
+svn mv dist/release/poi/xmlbeans/release/dev/RELEASE-NOTES-FIXME3.0.2.txt dist/release/poi/xmlbeans/dev/
+# non-SVN copy to create a new artifact with its own history
+cp dist/release/poi/xmlbeans/dev/RELEASE-NOTES-FIXME3.0.2.txt dist/release/poi/xmlbeans/release/dev/RELEASE-NOTES-FIXME3.1.0.txt
+# edit the RELEASE-NOTES file to reflect the current version
+svn add dist/release/poi/xmlbeans/release/dev/RELEASE-NOTES-FIXME3.1.0.txt
+svn ci dist/ -m "deploy FIXME3.1.0 release artifacts from staging area"
+{code}
+
+
+You should get an email from the Apache Reporter Service (no-reply@reporter.apache.org)
+at your Apache email address.
+The email instructions will ask you to log on to https://reporter.apache.org/addrelease.html?poi
+and add your release data (version and date) to the database.
+
+Log into https://repository.apache.org/ and go to the "Staging Repositories" area.
+Find the "orgapachexmlbeans" entry, check it has the right content, then Close the repository
+Select all artifacts and Release (and Automatically Drop) them.
+Refresh to verify that the artifacts are no longer in the Staging Repositories area.
+
+2. Wait for the distributions to appear on your favourite mirror (anywhere from 3-24 hours)
+ https://www.apache.org/dyn/closer.lua/xmlbeans/dev/
+
+3. Wait for the maven artifacts to appear on Maven Central, and ensure they work:
+ Maven Central: https://search.maven.org/#search|ga|1|g%3A%22org.apache.xmlbeans%22
+
+4. Edit the website homepage and list the new release there.
+ https://xmlbeans.apache.org/index.html
+ https://xmlbeans.apache.org/changes.html
+ remove older releases.
+
+5. Edit the website, in particular the download page, listing the new release there.
+ This should reference the checksums, so take care when updating
+
+ site/src/documentation/content/xdocs/index.xml
+ site/src/documentation/content/xdocs/news.xml
+ site/src/documentation/content/xdocs/site.xml
+ site/src/documentation/content/xdocs/status.xml
+ site/src/documentation/content/xdocs/download/index.xml
+
+6. Build site using a recent version of Java 1.8
+ Generating with Forrest may result in line ending changes, making change diffs
+ hard to read. That may be fixed eventually, but for now dos2linux and linux2dos
+ are your friend to minimize these.
+
+ Or, you can follow this process to only replace generated files where you know
+ the source changed:
+
+ forrest run
+ * inspect the generated changed pages in a local browser
+ * save the generated HTML, replacing originals in the site/build/ directory
+ * compare new HTML with SVN source, and pass files through dos2unix or unix2dos as needed
+ ** some files generate with line endings different than stored in SVN, making diffs annoying
+
+6a.Commit the site changes to svn, and publish live
+
+7. Don't forget to upload the latest version of the site and javadocs
+
+8. Send announcements:
+From: your @apache.org e-mail address
+To: user@poi.apache.org, dev@poi.apache.org, general@poi.apache.org, and announce@apache.org
+Subject: [ANNOUNCE] Apache XMLBeans FIXME3.1.0 released
+Body:
+"""
+The Apache POI PMC is pleased to announce the release of Apache XMLBeans FIXME3.1.0.
+
+Apache XMLBeans is a technology for accessing XML by binding it to Java types.
+
+For detailed changes in this release, refer to the release notes [1] and the changelog [2].
+
+Thank you to all our contributors for making this release possible.
+
+On behalf of the Apache POI PMC,
+Your Name
+
+[1] Release notes: https://www.apache.org/dyn/closer.lua/poi/xmlbeans/release/dev/RELEASE-NOTES-FIXME3.1.0.txt
+[2] Changelog: https://xmlbeans.apache.org/status.html#rel_FIXME310
+"""
+
+Note, announcements should be sent from your @apache.org e-mail address.
+
+9. Add the version to the DOAP file too
+ https://svn.apache.org/repos/asf/xmlbeans/trunk/xkit/doap_XMLBeans.rdf
+
+11. Delete directory that held RC, if any.
diff --git a/samples/AbstractTypes/build.xml b/samples/AbstractTypes/build.xml
index e7e8dd3..d90fb66 100644
--- a/samples/AbstractTypes/build.xml
+++ b/samples/AbstractTypes/build.xml
@@ -70,7 +70,7 @@
-
+
diff --git a/samples/Any/build.xml b/samples/Any/build.xml
index 3b8a564..7555baf 100644
--- a/samples/Any/build.xml
+++ b/samples/Any/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="Any.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/DateTime/build.xml b/samples/DateTime/build.xml
index 0704a6d..d6fd9ef 100644
--- a/samples/DateTime/build.xml
+++ b/samples/DateTime/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="DateTime.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/MixedContent/build.xml b/samples/MixedContent/build.xml
index c450919..ab2f525 100644
--- a/samples/MixedContent/build.xml
+++ b/samples/MixedContent/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="MixedContent.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/OrderMatters/build.xml b/samples/OrderMatters/build.xml
index 44d94a2..4253690 100644
--- a/samples/OrderMatters/build.xml
+++ b/samples/OrderMatters/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="OrderMatters.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/SampleTemplate/build.xml b/samples/SampleTemplate/build.xml
index 7eb97e6..639a1c7 100644
--- a/samples/SampleTemplate/build.xml
+++ b/samples/SampleTemplate/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="SampleTemplate.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/SchemaEnum/build.xml b/samples/SchemaEnum/build.xml
index 6c78e93..77d16ce 100644
--- a/samples/SchemaEnum/build.xml
+++ b/samples/SchemaEnum/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="SchemaEnum.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/SchemaEnum/src/org/apache/xmlbeans/samples/enumeration/SchemaEnum.java b/samples/SchemaEnum/src/org/apache/xmlbeans/samples/enumeration/SchemaEnum.java
index f48104b..50d6f50 100644
--- a/samples/SchemaEnum/src/org/apache/xmlbeans/samples/enumeration/SchemaEnum.java
+++ b/samples/SchemaEnum/src/org/apache/xmlbeans/samples/enumeration/SchemaEnum.java
@@ -163,13 +163,13 @@ public String sortByThreshold(PriceSummaryDocument summaryDoc)
PriceSummaryDocument.PriceSummary summary = summaryDoc.getPriceSummary();
PriceType[] priceElements = summary.getPriceArray();
- StringBuffer responseBuffer = new StringBuffer();
+ StringBuilder responseBuffer = new StringBuilder();
// Create string buffers to hold the sorted results of the values
// retrieved.
- StringBuffer zeroBuffer = new StringBuffer("\nItems under 10 dollars: \n");
- StringBuffer tenBuffer = new StringBuffer("\nItems between 10 and 20 dollars: \n");
- StringBuffer twentyBuffer = new StringBuffer("\nItems more than 20 dollars: \n");
+ StringBuilder zeroBuffer = new StringBuilder("\nItems under 10 dollars: \n");
+ StringBuilder tenBuffer = new StringBuilder("\nItems between 10 and 20 dollars: \n");
+ StringBuilder twentyBuffer = new StringBuilder("\nItems more than 20 dollars: \n");
// Loop through the price elements, extracting the array of child
// elements in each.
diff --git a/samples/SubstitutionGroup/build.xml b/samples/SubstitutionGroup/build.xml
index 524b4c6..d56d0f9 100644
--- a/samples/SubstitutionGroup/build.xml
+++ b/samples/SubstitutionGroup/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="SubstitutionGroup.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/Validation/build.xml b/samples/Validation/build.xml
index 777ecce..19afee5 100644
--- a/samples/Validation/build.xml
+++ b/samples/Validation/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="Validation.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/XQueryXPath/build.xml b/samples/XQueryXPath/build.xml
index 96b11af..1f20a72 100644
--- a/samples/XQueryXPath/build.xml
+++ b/samples/XQueryXPath/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="XQueryXPath.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/XmlSort/build.xml b/samples/XmlSort/build.xml
index 4389038..5fd27b7 100644
--- a/samples/XmlSort/build.xml
+++ b/samples/XmlSort/build.xml
@@ -65,7 +65,7 @@ limitations under the License.
destdir="build/classes"
classpathref="XmlSort.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/XmlTree/build.xml b/samples/XmlTree/build.xml
index 6d44c54..be193b6 100644
--- a/samples/XmlTree/build.xml
+++ b/samples/XmlTree/build.xml
@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="XmlTree.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/samples/XsdConfig/build.xml b/samples/XsdConfig/build.xml
index af78db9..c43b427 100644
--- a/samples/XsdConfig/build.xml
+++ b/samples/XsdConfig/build.xml
@@ -120,13 +120,13 @@ limitations under the License.
destdir="build/classes"
classpathref="XsdConfig.path"
debug="on"
- source="1.6"
+ source="1.8"
/>
diff --git a/src/common/org/apache/xmlbeans/impl/common/EncodingMap.java b/src/common/org/apache/xmlbeans/impl/common/EncodingMap.java
deleted file mode 100644
index 984e0d4..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/EncodingMap.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.nio.charset.Charset;
-
-public class EncodingMap
-{
- public static String getJava2IANAMapping ( String java )
- {
- String iana = (String) _java_to_iana.get( java.toUpperCase() );
- if (iana != null)
- return iana;
- // Try to use the information in the JDK to see if it is an encoding it supports
- if (Charset.isSupported( java ))
- {
- try
- {
- iana = Charset.forName( java ).name();
- return iana;
- }
- catch (IllegalArgumentException iae)
- {
- return null;
- }
- }
- return null;
- }
-
- public static String getIANA2JavaMapping ( String iana )
- {
- String java = (String) _iana_to_java.get( iana.toUpperCase() );
- if (java != null)
- return java;
- else if (Charset.isSupported( iana ))
- return iana;
- else
- return null;
- }
-
- private EncodingMap ( ) { }
-
- private final static HashMap _iana_to_java = new HashMap();
- private final static HashMap _java_to_iana = new HashMap();
-
- private final static void addMapping (
- String java, String iana, boolean isDefault )
- {
- assert !_iana_to_java.containsKey( iana );
- assert java.toUpperCase().equals( java );
- assert iana.toUpperCase().equals( iana );
-
- _iana_to_java.put( iana, java );
-
- if (isDefault)
- {
- assert !_java_to_iana.containsKey( java );
- _java_to_iana.put( java, iana );
- }
- }
-
- private final static boolean completeMappings ( )
- {
- HashMap m = new HashMap();
-
- for ( Iterator i = _iana_to_java.keySet().iterator() ; i.hasNext() ; )
- m.put( _iana_to_java.get( i.next() ), null );
-
- for ( Iterator i = m.keySet().iterator() ; i.hasNext() ; )
- {
- Object k = i.next();
- assert _java_to_iana.containsKey( k ): k;
- }
-
- return true;
- }
-
- static
- {
- addMapping( "ASCII", "ANSI_X3.4-1986", false );
- addMapping( "ASCII", "ASCII", true );
- addMapping( "ASCII", "CP367", false );
- addMapping( "ASCII", "CSASCII", false );
- addMapping( "ASCII", "IBM-367", false );
- addMapping( "ASCII", "IBM367", false );
- addMapping( "ASCII", "ISO-IR-6", false );
- addMapping( "ASCII", "ISO646-US", false );
- addMapping( "ASCII", "ISO_646.IRV:1991", false );
- addMapping( "ASCII", "US", false );
- addMapping( "ASCII", "US-ASCII", false );
- addMapping( "BIG5", "BIG5", true );
- addMapping( "BIG5", "CSBIG5", false );
- addMapping( "CP037", "CP037", false );
- addMapping( "CP037", "CSIBM037", false );
- addMapping( "CP037", "EBCDIC-CP-CA", false );
- addMapping( "CP037", "EBCDIC-CP-NL", false );
- addMapping( "CP037", "EBCDIC-CP-US", true );
- addMapping( "CP037", "EBCDIC-CP-WT", false );
- addMapping( "CP037", "IBM-37", false );
- addMapping( "CP037", "IBM037", false );
- addMapping( "CP1026", "CP1026", false );
- addMapping( "CP1026", "CSIBM1026", false );
- addMapping( "CP1026", "IBM-1026", false );
- addMapping( "CP1026", "IBM1026", true );
- addMapping( "CP1047", "CP1047", false );
- addMapping( "CP1047", "IBM-1047", false );
- addMapping( "CP1047", "IBM1047", true );
- addMapping( "CP1140", "CCSID01140", false );
- addMapping( "CP1140", "CP01140", false );
- addMapping( "CP1140", "IBM-1140", false );
- addMapping( "CP1140", "IBM01140", true );
- addMapping( "CP1141", "CCSID01141", false );
- addMapping( "CP1141", "CP01141", false );
- addMapping( "CP1141", "IBM-1141", false );
- addMapping( "CP1141", "IBM01141", true );
- addMapping( "CP1142", "CCSID01142", false );
- addMapping( "CP1142", "CP01142", false );
- addMapping( "CP1142", "IBM-1142", false );
- addMapping( "CP1142", "IBM01142", true );
- addMapping( "CP1143", "CCSID01143", false );
- addMapping( "CP1143", "CP01143", false );
- addMapping( "CP1143", "IBM-1143", false );
- addMapping( "CP1143", "IBM01143", true );
- addMapping( "CP1144", "CCSID01144", false );
- addMapping( "CP1144", "CP01144", false );
- addMapping( "CP1144", "IBM-1144", false );
- addMapping( "CP1144", "IBM01144", true );
- addMapping( "CP1145", "CCSID01145", false );
- addMapping( "CP1145", "CP01145", false );
- addMapping( "CP1145", "IBM-1145", false );
- addMapping( "CP1145", "IBM01145", true );
- addMapping( "CP1146", "CCSID01146", false );
- addMapping( "CP1146", "CP01146", false );
- addMapping( "CP1146", "IBM-1146", false );
- addMapping( "CP1146", "IBM01146", true );
- addMapping( "CP1147", "CCSID01147", false );
- addMapping( "CP1147", "CP01147", false );
- addMapping( "CP1147", "IBM-1147", false );
- addMapping( "CP1147", "IBM01147", true );
- addMapping( "CP1148", "CCSID01148", false );
- addMapping( "CP1148", "CP01148", false );
- addMapping( "CP1148", "IBM-1148", false );
- addMapping( "CP1148", "IBM01148", true );
- addMapping( "CP1149", "CCSID01149", false );
- addMapping( "CP1149", "CP01149", false );
- addMapping( "CP1149", "IBM-1149", false );
- addMapping( "CP1149", "IBM01149", true );
- addMapping( "CP1250", "WINDOWS-1250", true );
- addMapping( "CP1251", "WINDOWS-1251", true );
- addMapping( "CP1252", "WINDOWS-1252", true );
- addMapping( "CP1253", "WINDOWS-1253", true );
- addMapping( "CP1254", "WINDOWS-1254", true );
- addMapping( "CP1255", "WINDOWS-1255", true );
- addMapping( "CP1256", "WINDOWS-1256", true );
- addMapping( "CP1257", "WINDOWS-1257", true );
- addMapping( "CP1258", "WINDOWS-1258", true );
- addMapping( "CP273", "CP273", false );
- addMapping( "CP273", "CSIBM273", false );
- addMapping( "CP273", "IBM-273", false );
- addMapping( "CP273", "IBM273", true );
- addMapping( "CP277", "CP277", false );
- addMapping( "CP277", "CSIBM277", false );
- addMapping( "CP277", "EBCDIC-CP-DK", true );
- addMapping( "CP277", "EBCDIC-CP-NO", false );
- addMapping( "CP277", "IBM-277", false );
- addMapping( "CP277", "IBM277", false );
- addMapping( "CP278", "CP278", false );
- addMapping( "CP278", "CSIBM278", false );
- addMapping( "CP278", "EBCDIC-CP-FI", true );
- addMapping( "CP278", "EBCDIC-CP-SE", false );
- addMapping( "CP278", "IBM-278", false );
- addMapping( "CP278", "IBM278", false );
- addMapping( "CP280", "CP280", false );
- addMapping( "CP280", "CSIBM280", false );
- addMapping( "CP280", "EBCDIC-CP-IT", true );
- addMapping( "CP280", "IBM-280", false );
- addMapping( "CP280", "IBM280", false );
- addMapping( "CP284", "CP284", false );
- addMapping( "CP284", "CSIBM284", false );
- addMapping( "CP284", "EBCDIC-CP-ES", true );
- addMapping( "CP284", "IBM-284", false );
- addMapping( "CP284", "IBM284", false );
- addMapping( "CP285", "CP285", false );
- addMapping( "CP285", "CSIBM285", false );
- addMapping( "CP285", "EBCDIC-CP-GB", true );
- addMapping( "CP285", "IBM-285", false );
- addMapping( "CP285", "IBM285", false );
- addMapping( "CP290", "CP290", false );
- addMapping( "CP290", "CSIBM290", false );
- addMapping( "CP290", "EBCDIC-JP-KANA", true );
- addMapping( "CP290", "IBM-290", false );
- addMapping( "CP290", "IBM290", false );
- addMapping( "CP297", "CP297", false );
- addMapping( "CP297", "CSIBM297", false );
- addMapping( "CP297", "EBCDIC-CP-FR", true );
- addMapping( "CP297", "IBM-297", false );
- addMapping( "CP297", "IBM297", false );
- addMapping( "CP420", "CP420", false );
- addMapping( "CP420", "CSIBM420", false );
- addMapping( "CP420", "EBCDIC-CP-AR1", true );
- addMapping( "CP420", "IBM-420", false );
- addMapping( "CP420", "IBM420", false );
- addMapping( "CP424", "CP424", false );
- addMapping( "CP424", "CSIBM424", false );
- addMapping( "CP424", "EBCDIC-CP-HE", true );
- addMapping( "CP424", "IBM-424", false );
- addMapping( "CP424", "IBM424", false );
- addMapping( "CP437", "437", false );
- addMapping( "CP437", "CP437", false );
- addMapping( "CP437", "CSPC8CODEPAGE437", false );
- addMapping( "CP437", "IBM-437", false );
- addMapping( "CP437", "IBM437", true );
- addMapping( "CP500", "CP500", false );
- addMapping( "CP500", "CSIBM500", false );
- addMapping( "CP500", "EBCDIC-CP-BE", false );
- addMapping( "CP500", "EBCDIC-CP-CH", true );
- addMapping( "CP500", "IBM-500", false );
- addMapping( "CP500", "IBM500", false );
- addMapping( "CP775", "CP775", false );
- addMapping( "CP775", "CSPC775BALTIC", false );
- addMapping( "CP775", "IBM-775", false );
- addMapping( "CP775", "IBM775", true );
- addMapping( "CP850", "850", false );
- addMapping( "CP850", "CP850", false );
- addMapping( "CP850", "CSPC850MULTILINGUAL", false );
- addMapping( "CP850", "IBM-850", false );
- addMapping( "CP850", "IBM850", true );
- addMapping( "CP852", "852", false );
- addMapping( "CP852", "CP852", false );
- addMapping( "CP852", "CSPCP852", false );
- addMapping( "CP852", "IBM-852", false );
- addMapping( "CP852", "IBM852", true );
- addMapping( "CP855", "855", false );
- addMapping( "CP855", "CP855", false );
- addMapping( "CP855", "CSIBM855", false );
- addMapping( "CP855", "IBM-855", false );
- addMapping( "CP855", "IBM855", true );
- addMapping( "CP857", "857", false );
- addMapping( "CP857", "CP857", false );
- addMapping( "CP857", "CSIBM857", false );
- addMapping( "CP857", "IBM-857", false );
- addMapping( "CP857", "IBM857", true );
- addMapping( "CP858", "CCSID00858", false );
- addMapping( "CP858", "CP00858", false );
- addMapping( "CP858", "IBM-858", false );
- addMapping( "CP858", "IBM00858", true );
- addMapping( "CP860", "860", false );
- addMapping( "CP860", "CP860", false );
- addMapping( "CP860", "CSIBM860", false );
- addMapping( "CP860", "IBM-860", false );
- addMapping( "CP860", "IBM860", true );
- addMapping( "CP861", "861", false );
- addMapping( "CP861", "CP-IS", false );
- addMapping( "CP861", "CP861", false );
- addMapping( "CP861", "CSIBM861", false );
- addMapping( "CP861", "IBM-861", false );
- addMapping( "CP861", "IBM861", true );
- addMapping( "CP862", "862", false );
- addMapping( "CP862", "CP862", false );
- addMapping( "CP862", "CSPC862LATINHEBREW", false );
- addMapping( "CP862", "IBM-862", false );
- addMapping( "CP862", "IBM862", true );
- addMapping( "CP863", "863", false );
- addMapping( "CP863", "CP863", false );
- addMapping( "CP863", "CSIBM863", false );
- addMapping( "CP863", "IBM-863", false );
- addMapping( "CP863", "IBM863", true );
- addMapping( "CP864", "CP864", false );
- addMapping( "CP864", "CSIBM864", false );
- addMapping( "CP864", "IBM-864", false );
- addMapping( "CP864", "IBM864", true );
- addMapping( "CP865", "865", false );
- addMapping( "CP865", "CP865", false );
- addMapping( "CP865", "CSIBM865", false );
- addMapping( "CP865", "IBM-865", false );
- addMapping( "CP865", "IBM865", true );
- addMapping( "CP866", "866", false );
- addMapping( "CP866", "CP866", false );
- addMapping( "CP866", "CSIBM866", false );
- addMapping( "CP866", "IBM-866", false );
- addMapping( "CP866", "IBM866", true );
- addMapping( "CP868", "CP-AR", false );
- addMapping( "CP868", "CP868", false );
- addMapping( "CP868", "CSIBM868", false );
- addMapping( "CP868", "IBM-868", false );
- addMapping( "CP868", "IBM868", true );
- addMapping( "CP869", "CP-GR", false );
- addMapping( "CP869", "CP869", false );
- addMapping( "CP869", "CSIBM869", false );
- addMapping( "CP869", "IBM-869", false );
- addMapping( "CP869", "IBM869", true );
- addMapping( "CP870", "CP870", false );
- addMapping( "CP870", "CSIBM870", false );
- addMapping( "CP870", "EBCDIC-CP-ROECE", true );
- addMapping( "CP870", "EBCDIC-CP-YU", false );
- addMapping( "CP870", "IBM-870", false );
- addMapping( "CP870", "IBM870", false );
- addMapping( "CP871", "CP871", false );
- addMapping( "CP871", "CSIBM871", false );
- addMapping( "CP871", "EBCDIC-CP-IS", true );
- addMapping( "CP871", "IBM-871", false );
- addMapping( "CP871", "IBM871", false );
- addMapping( "CP918", "CP918", false );
- addMapping( "CP918", "CSIBM918", false );
- addMapping( "CP918", "EBCDIC-CP-AR2", true );
- addMapping( "CP918", "IBM-918", false );
- addMapping( "CP918", "IBM918", false );
- addMapping( "CP924", "CCSID00924", false );
- addMapping( "CP924", "CP00924", false );
- addMapping( "CP924", "EBCDIC-LATIN9--EURO", false );
- addMapping( "CP924", "IBM-924", false );
- addMapping( "CP924", "IBM00924", true );
- addMapping( "CP936", "GBK", true );
- addMapping( "CP936", "CP936", false );
- addMapping( "CP936", "MS936", false );
- addMapping( "CP936", "WINDOWS-936", false );
- addMapping( "EUCJIS", "CSEUCPKDFMTJAPANESE", false );
- addMapping( "EUCJIS", "EUC-JP", true );
- addMapping( "EUCJIS", "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", false );
- addMapping( "GB18030", "GB18030", true );
- addMapping( "GB2312", "CSGB2312", false );
- addMapping( "GB2312", "GB2312", true );
- addMapping( "ISO2022CN", "ISO-2022-CN", true );
- addMapping( "ISO2022KR", "CSISO2022KR", false );
- addMapping( "ISO2022KR", "ISO-2022-KR", true );
- addMapping( "ISO8859_1", "CP819", false );
- addMapping( "ISO8859_1", "CSISOLATIN1", false );
- addMapping( "ISO8859_1", "IBM-819", false );
- addMapping( "ISO8859_1", "IBM819", false );
- addMapping( "ISO8859_1", "ISO-8859-1", true );
- addMapping( "ISO8859_1", "ISO-IR-100", false );
- addMapping( "ISO8859_1", "ISO_8859-1", false );
- addMapping( "ISO8859_1", "L1", false );
- addMapping( "ISO8859_1", "LATIN1", false );
- addMapping( "ISO8859_2", "CSISOLATIN2", false );
- addMapping( "ISO8859_2", "ISO-8859-2", true );
- addMapping( "ISO8859_2", "ISO-IR-101", false );
- addMapping( "ISO8859_2", "ISO_8859-2", false );
- addMapping( "ISO8859_2", "L2", false );
- addMapping( "ISO8859_2", "LATIN2", false );
- addMapping( "ISO8859_3", "CSISOLATIN3", false );
- addMapping( "ISO8859_3", "ISO-8859-3", true );
- addMapping( "ISO8859_3", "ISO-IR-109", false );
- addMapping( "ISO8859_3", "ISO_8859-3", false );
- addMapping( "ISO8859_3", "L3", false );
- addMapping( "ISO8859_3", "LATIN3", false );
- addMapping( "ISO8859_4", "CSISOLATIN4", false );
- addMapping( "ISO8859_4", "ISO-8859-4", true );
- addMapping( "ISO8859_4", "ISO-IR-110", false );
- addMapping( "ISO8859_4", "ISO_8859-4", false );
- addMapping( "ISO8859_4", "L4", false );
- addMapping( "ISO8859_4", "LATIN4", false );
- addMapping( "ISO8859_5", "CSISOLATINCYRILLIC", false );
- addMapping( "ISO8859_5", "CYRILLIC", false );
- addMapping( "ISO8859_5", "ISO-8859-5", true );
- addMapping( "ISO8859_5", "ISO-IR-144", false );
- addMapping( "ISO8859_5", "ISO_8859-5", false );
- addMapping( "ISO8859_6", "ARABIC", false );
- addMapping( "ISO8859_6", "ASMO-708", false );
- addMapping( "ISO8859_6", "CSISOLATINARABIC", false );
- addMapping( "ISO8859_6", "ECMA-114", false );
- addMapping( "ISO8859_6", "ISO-8859-6", true );
- addMapping( "ISO8859_6", "ISO-IR-127", false );
- addMapping( "ISO8859_6", "ISO_8859-6", false );
- addMapping( "ISO8859_7", "CSISOLATINGREEK", false );
- addMapping( "ISO8859_7", "ECMA-118", false );
- addMapping( "ISO8859_7", "ELOT_928", false );
- addMapping( "ISO8859_7", "GREEK", false );
- addMapping( "ISO8859_7", "GREEK8", false );
- addMapping( "ISO8859_7", "ISO-8859-7", true );
- addMapping( "ISO8859_7", "ISO-IR-126", false );
- addMapping( "ISO8859_7", "ISO_8859-7", false );
- addMapping( "ISO8859_8", "CSISOLATINHEBREW", false );
- addMapping( "ISO8859_8", "HEBREW", false );
- addMapping( "ISO8859_8", "ISO-8859-8", true );
- addMapping( "ISO8859_8", "ISO-8859-8-I", false );
- addMapping( "ISO8859_8", "ISO-IR-138", false );
- addMapping( "ISO8859_8", "ISO_8859-8", false );
- addMapping( "ISO8859_9", "CSISOLATIN5", false );
- addMapping( "ISO8859_9", "ISO-8859-9", true );
- addMapping( "ISO8859_9", "ISO-IR-148", false );
- addMapping( "ISO8859_9", "ISO_8859-9", false );
- addMapping( "ISO8859_9", "L5", false );
- addMapping( "ISO8859_9", "LATIN5", false );
- addMapping( "JIS", "CSISO2022JP", false );
- addMapping( "JIS", "ISO-2022-JP", true );
- addMapping( "JIS0201", "CSISO13JISC6220JP", false );
- addMapping( "JIS0201", "X0201", true );
- addMapping( "JIS0208", "CSISO87JISX0208", false );
- addMapping( "JIS0208", "ISO-IR-87", false );
- addMapping( "JIS0208", "X0208", true );
- addMapping( "JIS0208", "X0208DBIJIS_X0208-1983", false );
- addMapping( "JIS0212", "CSISO159JISX02121990", false );
- addMapping( "JIS0212", "ISO-IR-159", true );
- addMapping( "JIS0212", "X0212", false );
- addMapping( "KOI8_R", "CSKOI8R", false );
- addMapping( "KOI8_R", "KOI8-R", true );
- addMapping( "KSC5601", "EUC-KR", true );
- addMapping( "MS932", "CSWINDOWS31J", false );
- addMapping( "MS932", "WINDOWS-31J", true );
- addMapping( "SJIS", "CSSHIFTJIS", false );
- addMapping( "SJIS", "MS_KANJI", false );
- addMapping( "SJIS", "SHIFT_JIS", true );
- addMapping( "TIS620", "TIS-620", true );
- addMapping( "UNICODE", "UTF-16", true );
- addMapping( "UTF-16BE", "UTF-16BE", true );
- addMapping( "UTF-16BE", "UTF_16BE", false );
- addMapping( "ISO-10646-UCS-2","ISO-10646-UCS-2", true );
- addMapping( "UTF-16LE", "UTF-16LE", true );
- addMapping( "UTF-16LE", "UTF_16LE", false );
- addMapping( "UTF8", "UTF-8", true );
-
- assert completeMappings();
- };
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/GenericXmlInputStream.java b/src/common/org/apache/xmlbeans/impl/common/GenericXmlInputStream.java
deleted file mode 100644
index e70dfa0..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/GenericXmlInputStream.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import org.apache.xmlbeans.xml.stream.ReferenceResolver;
-import org.apache.xmlbeans.xml.stream.XMLEvent;
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
-import org.apache.xmlbeans.xml.stream.XMLName;
-import org.apache.xmlbeans.xml.stream.XMLStreamException;
-
-/**
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
- */
-public class GenericXmlInputStream implements XMLInputStream
-{
- public GenericXmlInputStream ( )
- {
- _master = this;
- _elementCount = 1; // Go all the way
- }
-
- private GenericXmlInputStream ( GenericXmlInputStream master )
- {
- (_master = master).ensureInit();
- _nextEvent = master._nextEvent;
- }
-
- //
- // The source for all events
- //
-
- protected XMLEvent nextEvent ( ) throws XMLStreamException
- {
- throw new RuntimeException( "nextEvent not overridden" );
- }
-
- //
- //
- //
-
- private class EventItem
- {
- EventItem ( XMLEvent e )
- {
- _event = e;
- }
-
- int getType ( ) { return _event.getType(); }
- boolean hasName ( ) { return _event.hasName(); }
- XMLName getName ( ) { return _event.getName(); }
-
- final XMLEvent _event;
-
- EventItem _next;
- }
-
- private void ensureInit ( )
- {
- if (!_master._initialized)
- {
- try
- {
- _master._nextEvent = getNextEvent();
- }
- catch ( XMLStreamException e )
- {
- throw new RuntimeException( e );
- }
-
- _master._initialized = true;
- }
- }
-
- private EventItem getNextEvent ( ) throws XMLStreamException
- {
- XMLEvent e = nextEvent();
-
- return e == null ? null : new EventItem( e );
- }
-
- public XMLEvent next ( ) throws XMLStreamException
- {
- ensureInit();
-
- EventItem currentEvent = _nextEvent;
-
- if (_nextEvent != null)
- {
- if (_nextEvent._next == null)
- _nextEvent._next = _master.getNextEvent();
-
- _nextEvent = _nextEvent._next;
- }
-
- if (currentEvent == null)
- return null;
-
- if (currentEvent.getType() == XMLEvent.END_ELEMENT)
- {
- if (--_elementCount <= 0)
- _nextEvent = null;
- }
- else if (currentEvent.getType() == XMLEvent.START_ELEMENT)
- _elementCount++;
-
- return currentEvent._event;
- }
-
- public boolean hasNext ( ) throws XMLStreamException
- {
- ensureInit();
-
- return _nextEvent != null;
- }
-
- public void skip ( ) throws XMLStreamException
- {
- next();
- }
-
- public void skipElement ( ) throws XMLStreamException
- {
- ensureInit();
-
- for ( ; _nextEvent != null ; next() )
- {
- if (_nextEvent.getType() == XMLEvent.START_ELEMENT)
- break;
- }
-
- int count = 0;
-
- for ( ; _nextEvent != null ; next() )
- {
- int type = next().getType();
-
- if (type == XMLEvent.START_ELEMENT)
- count++;
- else if (type == XMLEvent.END_ELEMENT && --count == 0)
- break;
- }
- }
-
- public XMLEvent peek ( ) throws XMLStreamException
- {
- ensureInit();
-
- return _nextEvent._event;
- }
-
- public boolean skip ( int eventType ) throws XMLStreamException
- {
- ensureInit();
-
- for ( ; _nextEvent != null ; next() )
- {
- if (_nextEvent.getType() == eventType)
- return true;
- }
-
- return false;
- }
-
- public boolean skip ( XMLName name ) throws XMLStreamException
- {
- ensureInit();
-
- for ( ; _nextEvent != null ; next() )
- {
- if (_nextEvent.hasName() && _nextEvent.getName().equals( name ))
- return true;
- }
-
- return false;
- }
-
- public boolean skip ( XMLName name, int eventType ) throws XMLStreamException
- {
- ensureInit();
-
- for ( ; _nextEvent != null ; next() )
- {
- if (_nextEvent.getType() == eventType &&
- _nextEvent.hasName() &&
- _nextEvent.getName().equals( name ))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public XMLInputStream getSubStream ( ) throws XMLStreamException
- {
- ensureInit();
-
- GenericXmlInputStream subStream = new GenericXmlInputStream( this );
-
- subStream.skip( XMLEvent.START_ELEMENT );
-
- return subStream;
- }
-
- public void close ( ) throws XMLStreamException
- {
- // BUGBUG - can I do anything here, really?
- // SHould I count the number of open sub streams?
- // I have no destructor, how can I close properly?
- }
-
- public ReferenceResolver getReferenceResolver ( )
- {
- ensureInit();
-
- throw new RuntimeException( "Not impl" );
- }
-
- public void setReferenceResolver ( ReferenceResolver resolver )
- {
- ensureInit();
-
- throw new RuntimeException( "Not impl" );
- }
-
- private boolean _initialized;
- private EventItem _nextEvent;
- private int _elementCount;
- private GenericXmlInputStream _master;
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/IdentityConstraint.java b/src/common/org/apache/xmlbeans/impl/common/IdentityConstraint.java
deleted file mode 100644
index f959be2..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/IdentityConstraint.java
+++ /dev/null
@@ -1,668 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import org.apache.xmlbeans.impl.common.ValidatorListener.Event;
-import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
-
-import org.apache.xmlbeans.*;
-import java.util.*;
-
-/**
- * Identity constraint engine. Performs streaming validation of identity constraints.
- * This includes key, keyref, & unique, as well as ID & IDRef.
- */
-public class IdentityConstraint {
-
- private ConstraintState _constraintStack;
- private ElementState _elementStack;
- private Collection _errorListener;
- private boolean _invalid;
- private boolean _trackIdrefs; // We only track idrefs if validating from the root element
-
- public IdentityConstraint(Collection errorListener, boolean trackIdrefs) {
- _errorListener = errorListener;
- _trackIdrefs = trackIdrefs;
- }
-
- public void element(Event e, SchemaType st, SchemaIdentityConstraint[] ics) {
-
- // Construct a new state for the element
- newState();
-
- // First dispatch this element event
- for (ConstraintState cs = _constraintStack ; cs != null ; cs = cs._next)
- cs.element(e, st);
-
- // Create a new SelectorState for each new Identity Constraint
-
- for (int i = 0 ; ics != null && i < ics.length ; i++)
- newConstraintState(ics[i], e, st);
- }
-
- public void endElement(Event e) {
- // Pop the element state stack and any constraints at this depth
- if (_elementStack._hasConstraints)
- {
- for (ConstraintState cs = _constraintStack ; cs != null && cs != _elementStack._savePoint ; cs = cs._next)
- cs.remove( e );
-
- _constraintStack = _elementStack._savePoint;
- }
-
- _elementStack = _elementStack._next;
-
- // Dispatch the event
- for (ConstraintState cs = _constraintStack ; cs != null ; cs = cs._next)
- cs.endElement(e);
-
- }
-
- public void attr(Event e, QName name, SchemaType st, String value) {
- for (ConstraintState cs = _constraintStack ; cs != null ; cs = cs._next)
- cs.attr(e, name, st, value);
- }
-
- public void text(Event e, SchemaType st, String value, boolean emptyContent) {
- for (ConstraintState cs = _constraintStack ; cs != null ; cs = cs._next)
- cs.text(e, st, value, emptyContent);
- }
-
- public boolean isValid() {
- return !_invalid;
- }
-
- private void newConstraintState(SchemaIdentityConstraint ic, Event e, SchemaType st)
- {
- if (ic.getConstraintCategory() == SchemaIdentityConstraint.CC_KEYREF)
- new KeyrefState(ic, e, st);
- else
- new SelectorState(ic, e, st);
- }
-
- private void buildIdStates()
- {
- // Construct states to hold the values for IDs and IDRefs
- IdState ids = new IdState();
- if (_trackIdrefs)
- new IdRefState(ids);
- }
-
- private void newState() {
- boolean firstTime = _elementStack == null;
-
- ElementState st = new ElementState();
- st._next = _elementStack;
- _elementStack = st;
-
- if (firstTime)
- buildIdStates();
- }
-
- private void emitError ( Event event, String code, Object[] args )
- {
- _invalid = true;
-
- if (_errorListener != null)
- {
- assert event != null;
-
- _errorListener.add(errorForEvent(code, args, XmlError.SEVERITY_ERROR, event));
- }
- }
-
- public static XmlError errorForEvent(String code, Object[] args, int severity, Event event)
- {
- XmlCursor loc = event.getLocationAsCursor();
- XmlError error;
- if (loc!=null)
- error = XmlError.forCursor(code, args, severity, loc);
- else
- {
- Location location = event.getLocation();
- if (location!=null)
- {
- error = XmlError.forLocation(code, args, severity,
- location.getSystemId(), location.getLineNumber(),
- location.getColumnNumber(), location.getCharacterOffset());
- }
- else
- {
- error = XmlError.forMessage(code, args, severity);
- }
- }
- return error;
- }
-
- private void emitError ( Event event, String msg )
- {
- _invalid = true;
-
- if (_errorListener != null)
- {
- assert event != null;
-
- _errorListener.add(errorForEvent(msg, XmlError.SEVERITY_ERROR, event));
- }
- }
-
- public static XmlError errorForEvent(String msg, int severity, Event event)
- {
- XmlCursor loc = event.getLocationAsCursor();
- XmlError error;
- if (loc!=null)
- error = XmlError.forCursor(msg, severity, loc);
- else
- {
- Location location = event.getLocation();
- if (location!=null)
- {
- error = XmlError.forLocation(msg, severity,
- location.getSystemId(), location.getLineNumber(),
- location.getColumnNumber(), location.getCharacterOffset());
- }
- else
- {
- error = XmlError.forMessage(msg, severity);
- }
- }
- return error;
- }
-
- private void setSavePoint( ConstraintState cs )
- {
- if (! _elementStack._hasConstraints)
- _elementStack._savePoint = cs;
-
- _elementStack._hasConstraints = true;
- }
-
- private static XmlObject newValue(SchemaType st, String value)
- {
- try {
- return st.newValue(value);
- }
- catch (IllegalArgumentException e) {
- // This is a bit hacky. newValue throws XmlValueOutOfRangeException which is
- // unchecked and declared in typeimpl. I can only catch its parent class,
- // typeimpl is built after common.
-
- // Ignore these exceptions. Assume that validation will catch them.
- return null;
- }
- }
-
- /**
- * Return the simple type for schema type. If the schema type is already
- * simple, just return it. If it is a complex type with simple content,
- * return the simple type it extends.
- */
- static SchemaType getSimpleType(SchemaType st)
- {
- assert st.isSimpleType() || st.getContentType() == SchemaType.SIMPLE_CONTENT :
- st + " does not have simple content.";
-
- while (! st.isSimpleType() )
- st = st.getBaseType();
-
- return st;
- }
-
- static boolean hasSimpleContent(SchemaType st)
- {
- return st.isSimpleType() || st.getContentType() == SchemaType.SIMPLE_CONTENT;
- }
-
- public abstract class ConstraintState {
- ConstraintState _next;
-
- ConstraintState()
- {
- setSavePoint(_constraintStack);
- _next = _constraintStack;
- _constraintStack = this;
- }
-
- abstract void element(Event e, SchemaType st);
- abstract void endElement(Event e);
- abstract void attr(Event e, QName name, SchemaType st, String value);
- abstract void text(Event e, SchemaType st, String value, boolean emptyContent);
- abstract void remove(Event e);
-
- }
-
- public class SelectorState extends ConstraintState {
- SchemaIdentityConstraint _constraint;
- Set _values = new LinkedHashSet();
- XPath.ExecutionContext _context;
-
- SelectorState(SchemaIdentityConstraint constraint, Event e, SchemaType st) {
- _constraint = constraint;
- _context = new XPath.ExecutionContext();
- _context.init((XPath)_constraint.getSelectorPath());
-
- if ( ( _context.start() & XPath.ExecutionContext.HIT ) != 0 )
- createFieldState(e, st);
- }
-
- void addFields(XmlObjectList fields, Event e)
- {
- if (_constraint.getConstraintCategory() == SchemaIdentityConstraint.CC_KEYREF)
- _values.add(fields);
- else if (_values.contains(fields))
- {
- if (_constraint.getConstraintCategory() == SchemaIdentityConstraint.CC_UNIQUE)
- emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$DUPLICATE_UNIQUE,
- new Object[] { fields, QNameHelper.pretty(_constraint.getName()) });
- else
- emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$DUPLICATE_KEY,
- new Object[] { fields, QNameHelper.pretty(_constraint.getName()) });
- }
- else
- _values.add(fields);
- }
-
- void element(Event e, SchemaType st)
- {
- if ( ( _context.element(e.getName()) & XPath.ExecutionContext.HIT) != 0 )
- createFieldState(e, st);
- }
-
- void endElement(Event e)
- {
- _context.end();
- }
-
- void createFieldState(Event e, SchemaType st) {
- new FieldState(this, e, st);
- }
-
- void remove(Event e) {
- // Bubble up key, unique values to keyrefs
- for (ConstraintState cs = _next ; cs != null ; cs = cs._next )
- {
- if (cs instanceof KeyrefState)
- {
- KeyrefState kr = (KeyrefState)cs;
- if (kr._constraint.getReferencedKey() == this._constraint)
- kr.addKeyValues(_values, true);
- }
- }
- }
-
- void attr(Event e, QName name, SchemaType st, String value) {}
- void text(Event e, SchemaType st, String value, boolean emptyContent) {}
- }
-
- public class KeyrefState extends SelectorState {
- Map _keyValues = new HashMap();
- private Object CHILD_ADDED = new Object();
- private Object CHILD_REMOVED = new Object();
- private Object SELF_ADDED = new Object();
-
- KeyrefState(SchemaIdentityConstraint constraint, Event e, SchemaType st) {
- super(constraint, e, st);
- }
-
- void addKeyValues(final Set values, boolean child)
- {
- /** If the key values are added by children, then if two or
- more children add the same value, the value dissapears from the map
- but if is added by the element in question directly then it will
- be present in the map regardless of what children contained */
- for (Iterator it = values.iterator(); it.hasNext();)
- {
- Object key = it.next();
- Object value = _keyValues.get(key);
- if (value == null)
- _keyValues.put(key, child ? CHILD_ADDED : SELF_ADDED);
- else if (value == CHILD_ADDED)
- {
- if (child)
- _keyValues.put(key, CHILD_REMOVED);
- else
- _keyValues.put(key, SELF_ADDED);
- }
- else if (value == CHILD_REMOVED)
- {
- if (!child)
- _keyValues.put(key, SELF_ADDED);
- }
- }
- }
-
- private boolean hasKeyValue(Object key)
- {
- Object value = _keyValues.get(key);
- return value != null && value != CHILD_REMOVED;
- }
-
- void remove(Event e) {
- // First check if there are any keys at the same stack level as this
- // that may contribute key values to me
- for (ConstraintState cs = _next ; cs != null && cs != _elementStack._savePoint ; cs = cs._next)
- {
- if (cs instanceof SelectorState)
- {
- SelectorState sel = (SelectorState)cs;
- if (sel._constraint == _constraint.getReferencedKey())
- addKeyValues(sel._values, false);
- }
- }
-
-
- // validate all values have been seen
- for (Iterator it = _values.iterator() ; it.hasNext() ; )
- {
-
- XmlObjectList fields = (XmlObjectList)it.next();
- if (fields.unfilled() < 0 && ! hasKeyValue(fields))
- {
- // KHK: cvc-identity-constraint.4.3 ?
- emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$KEYREF_KEY_NOT_FOUND,
- new Object[] {fields, QNameHelper.pretty(_constraint.getName())});
- return;
- }
- }
- }
- }
-
- public class FieldState extends ConstraintState {
- SelectorState _selector;
- XPath.ExecutionContext[] _contexts;
- boolean[] _needsValue;
- XmlObjectList _value;
-
- FieldState(SelectorState selector, Event e, SchemaType st) {
-
- // System.out.println("Creating new Field State for: " + e.getName());
-
- _selector = selector;
- SchemaIdentityConstraint ic = selector._constraint;
-
- int fieldCount = ic.getFields().length;
- _contexts = new XPath.ExecutionContext[fieldCount];
- _needsValue = new boolean[fieldCount];
- _value = new XmlObjectList(fieldCount);
-
- for (int i = 0 ; i < fieldCount ; i++)
- {
- _contexts[i] = new XPath.ExecutionContext();
- _contexts[i].init((XPath)ic.getFieldPath(i));
- if ( ( _contexts[i].start() & XPath.ExecutionContext.HIT ) != 0 )
- {
- // System.out.println("hit for element: " + e.getName());
-
- if (!hasSimpleContent(st))
- // KHK: cvc-identity-constraint.3
- emitError(e, "Identity constraint field must have simple content");
- else
- _needsValue[i] = true;
- }
- }
-
- }
-
- void element(Event e, SchemaType st)
- {
- for (int i = 0 ; i < _contexts.length ; i++) {
- if (_needsValue[i])
- {
- // KHK: cvc-identity-constraint.3
- emitError(e, "Identity constraint field must have simple content");
- _needsValue[i] = false;
- }
- }
-
- for (int i = 0 ; i < _contexts.length ; i++) {
- if ( ( _contexts[i].element(e.getName()) & XPath.ExecutionContext.HIT) != 0 )
- {
- if (! hasSimpleContent(st))
- // KHK: cvc-identity-constraint.3
- emitError(e, "Identity constraint field must have simple content");
- else
- _needsValue[i] = true;
- }
- }
- }
-
- void attr(Event e, QName name, SchemaType st, String value) {
-
- // Null value indicates previously reported validation problem
- if (value == null) return;
-
- for (int i = 0 ; i < _contexts.length ; i++) {
- if ( _contexts[i].attr(name) ) {
- XmlObject o = newValue(st, value);
-
- // Ignore invalid values. Assume that validation catches these
- if (o == null) return;
-
- boolean set = _value.set(o, i);
-
- // KHK: ?
- if (! set)
- emitError(e, "Multiple instances of field with xpath: '"
- + _selector._constraint.getFields()[i] + "' for a selector");
- }
-
- }
- }
-
-
- void text(Event e, SchemaType st, String value, boolean emptyContent) {
-
- // Null value indicates previously reported validation problem
- if (value == null && !emptyContent) return;
-
- for (int i = 0 ; i < _contexts.length ; i++) {
- if ( _needsValue[i] ) {
-
- if (emptyContent || !hasSimpleContent(st))
- {
- // KHK: cvc-identity-constraint.3
- emitError(e, "Identity constraint field must have simple content");
- return;
- }
-
- SchemaType simpleType = getSimpleType(st);
- XmlObject o = newValue(simpleType, value);
-
- // Ignore invalid values. Assume that validation catches these
- if (o == null) return;
-
- boolean set = _value.set(o, i);
-
- // KHK: ?
- if (! set)
- emitError(e, "Multiple instances of field with xpath: '"
- + _selector._constraint.getFields()[i] + "' for a selector");
- }
- }
- }
-
- void endElement(Event e) {
- // reset any _needsValue flags
- // assume that if we didn't see the text, it was because of another validation
- // error, so don't emit another one.
- for (int i = 0 ; i < _needsValue.length ; i++)
- {
- _contexts[i].end();
- _needsValue[i] = false;
- }
-
- }
-
- void remove(Event e)
- {
-
- if (_selector._constraint.getConstraintCategory() == SchemaIdentityConstraint.CC_KEY &&
- _value.unfilled() >= 0 )
- {
- // KHK: cvc-identity-constraint.4.2.1 ?
- // keys must have all values supplied
- emitError(e, "Key " + QNameHelper.pretty(_selector._constraint.getName()) + " is missing field with xpath: '" + _selector._constraint.getFields()[_value.unfilled()] + "'");
- }
- else
- {
- // Finished. Add these fields to the selector state
- _selector.addFields(_value, e);
- }
- }
-
- }
-
- public class IdState extends ConstraintState
- {
- Set _values = new LinkedHashSet();
-
- IdState() { }
-
- void attr(Event e, QName name, SchemaType st, String value)
- {
- handleValue(e, st, value);
- }
-
- void text(Event e, SchemaType st, String value, boolean emptyContent)
- {
- if (emptyContent)
- return;
-
- handleValue(e, st, value);
- }
-
- private void handleValue(Event e, SchemaType st, String value)
- {
-
- // Null value indicates previously reported validation problem
- if (value == null) return;
-
- if (st == null || st.isNoType())
- {
- // ignore invalid values. Assume that validation catches these
- return;
- }
-
- if (XmlID.type.isAssignableFrom(st))
- {
- XmlObjectList xmlValue = new XmlObjectList(1);
- XmlObject o = newValue(XmlID.type, value);
-
- // Ignore invalid values. Assume that validation catches these
- if (o == null) return;
-
- xmlValue.set(o, 0);
-
- if (_values.contains(xmlValue))
- emitError(e, XmlErrorCodes.ID_VALID$DUPLICATE, new Object[] { value });
- else
- _values.add(xmlValue);
- }
- }
-
- void element(Event e, SchemaType st) {}
- void endElement(Event e){}
- void remove(Event e){}
-
- }
-
- public class IdRefState extends ConstraintState
- {
- IdState _ids;
- List _values;
-
- IdRefState(IdState ids)
- {
- _ids = ids;
- _values = new ArrayList();
- }
-
- private void handleValue(Event e, SchemaType st, String value)
- {
- // Null value indicates previously reported validation problem
- if (value == null) return;
-
- if (st == null || st.isNoType())
- {
- // ignore invalid values. Assume that validation catches these
- return;
- }
- if (XmlIDREFS.type.isAssignableFrom(st))
- {
- XmlIDREFS lv = (XmlIDREFS)newValue(XmlIDREFS.type, value);
-
- // Ignore invalid values. Assume that validation catches these
- if (lv == null) return;
-
- List l = lv.xgetListValue();
-
- // Add one value for each idref in the list
- for (int i = 0 ; i < l.size() ; i++)
- {
- XmlObjectList xmlValue = new XmlObjectList(1);
- XmlIDREF idref = (XmlIDREF)l.get(i);
- xmlValue.set(idref, 0);
- _values.add(xmlValue);
- }
- }
- else if (XmlIDREF.type.isAssignableFrom(st))
- {
- XmlObjectList xmlValue = new XmlObjectList(1);
- XmlIDREF idref = (XmlIDREF)st.newValue(value);
-
- // Ignore invalid values. Assume that validation catches these
- if (idref == null) return;
-
- xmlValue.set(idref, 0);
- _values.add(xmlValue);
- }
- }
-
- void attr(Event e, QName name, SchemaType st, String value)
- {
- handleValue(e, st, value);
- }
- void text(Event e, SchemaType st, String value, boolean emptyContent)
- {
- if (emptyContent)
- return;
-
- handleValue(e, st, value);
- }
- void remove(Event e)
- {
- // Validate each ref has a corresponding ID
- for (Iterator it = _values.iterator() ; it.hasNext() ; )
- {
- Object o = it.next();
- if (! _ids._values.contains(o))
- {
- // KHK: cvc-id.1
- emitError(e, "ID not found for IDRef value '" + o + "'");
- }
- }
- }
- void element(Event e, SchemaType st) { }
- void endElement(Event e) { }
- }
-
- private static class ElementState {
- ElementState _next;
- boolean _hasConstraints;
- ConstraintState _savePoint;
- }
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/NameUtil.java b/src/common/org/apache/xmlbeans/impl/common/NameUtil.java
deleted file mode 100644
index 7278f86..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/NameUtil.java
+++ /dev/null
@@ -1,815 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import javax.xml.namespace.QName;
-
-import java.util.*;
-
-public class NameUtil
-{
- // punctuation characters
- public final static char HYPHEN = '\u002D';
- public final static char PERIOD = '\u002E';
- public final static char COLON = '\u003A';
- public final static char USCORE = '\u005F';
- public final static char DOT = '\u00B7';
- public final static char TELEIA = '\u0387';
- public final static char AYAH = '\u06DD';
- public final static char ELHIZB = '\u06DE';
-
- private final static boolean DEBUG = false;
-
- private final static Set javaWords = new HashSet(Arrays.asList(
- new String[]
- {
- "assert",
- "abstract",
- "boolean",
- "break",
- "byte",
- "case",
- "catch",
- "char",
- "class",
- "const",
- "continue",
- "default",
- "do",
- "double",
- "else",
- "enum", // since JDK1.5
- "extends",
- "false", // not a keyword
- "final",
- "finally",
- "float",
- "for",
- "goto",
- "if",
- "implements",
- "import",
- "instanceof",
- "int",
- "interface",
- "long",
- "native",
- "new",
- "null", // not a keyword
- "package",
- "private",
- "protected",
- "public",
- "return",
- "short",
- "static",
- "strictfp",
- "super",
- "switch",
- "synchronized",
- "this",
- "threadsafe",
- "throw",
- "throws",
- "transient",
- "true", // not a keyword
- "try",
- "void",
- "volatile",
- "while",
- }
- ));
-
- private final static Set extraWords = new HashSet(Arrays.asList(
- new String[]
- {
- "i", // used for indexes
- "target", // used for parameter
- "org", // used for package names
- "com", // used for package names
- }
- ));
-
- /*
- private final static Set javaNames = new HashSet(Arrays.asList(
- new String[]
- {
- "CharSequence",
- "Cloneable",
- "Comparable",
- "Runnable",
-
- "Boolean",
- "Byte",
- "Character",
- "Class",
- "ClassLoader",
- "Compiler",
- "Double",
- "Float",
- "InheritableThreadLocal",
- "Integer",
- "Long",
- "Math",
- "Number",
- "Object",
- "Package",
- "Process",
- "Runtime",
- "RuntimePermission",
- "SecurityManager",
- "Short",
- "StackTraceElement",
- "StrictMath",
- "String",
- "StringBuffer",
- "System",
- "Thread",
- "ThreadGroup",
- "ThreadLocal",
- "Throwable",
- "Void",
-
- "ArithmeticException",
- "ArrayIndexOutOfBoundsException",
- "ArrayStoreException",
- "ClassCastException",
- "ClassNotFoundException",
- "CloneNotSupportedException",
- "Exception",
- "IllegalAccessException",
- "IllegalArgumentException",
- "IllegalMonitorStateException",
- "IllegalStateException",
- "IllegalThreadStateException",
- "IndexOutOfBoundsException",
- "InstantiationException",
- "InterruptedException",
- "NegativeArraySizeException",
- "NoSuchFieldException",
- "NoSuchMethodException",
- "NullPointerException",
- "NumberFormatException",
- "RuntimeException",
- "SecurityException",
- "StringIndexOutOfBoundsException",
- "UnsupportedOperationException",
-
- "AbstractMethodError",
- "AssertionError",
- "ClassCircularityError",
- "ClassFormatError",
- "Error",
- "ExceptionInInitializerError",
- "IllegalAccessError",
- "IncompatibleClassChangeError",
- "InstantiationError",
- "InternalError",
- "LinkageError",
- "NoClassDefFoundError",
- "NoSuchFieldError",
- "NoSuchMethodError",
- "OutOfMemoryError",
- "StackOverflowError",
- "ThreadDeath",
- "UnknownError",
- "UnsatisfiedLinkError",
- "UnsupportedClassVersionError",
- "VerifyError",
- "VirtualMachineError",
- }
- ));
- */
-
- private final static Set javaNames = new HashSet(Arrays.asList(
- new String[]
- {
- // 1. all the Java.lang classes [1.4.1 JDK].
- "CharSequence",
- "Cloneable",
- "Comparable",
- "Runnable",
-
- "Boolean",
- "Byte",
- "Character",
- "Class",
- "ClassLoader",
- "Compiler",
- "Double",
- "Float",
- "InheritableThreadLocal",
- "Integer",
- "Long",
- "Math",
- "Number",
- "Object",
- "Package",
- "Process",
- "Runtime",
- "RuntimePermission",
- "SecurityManager",
- "Short",
- "StackTraceElement",
- "StrictMath",
- "String",
- "StringBuffer",
- "System",
- "Thread",
- "ThreadGroup",
- "ThreadLocal",
- "Throwable",
- "Void",
-
- "ArithmeticException",
- "ArrayIndexOutOfBoundsException",
- "ArrayStoreException",
- "ClassCastException",
- "ClassNotFoundException",
- "CloneNotSupportedException",
- "Exception",
- "IllegalAccessException",
- "IllegalArgumentException",
- "IllegalMonitorStateException",
- "IllegalStateException",
- "IllegalThreadStateException",
- "IndexOutOfBoundsException",
- "InstantiationException",
- "InterruptedException",
- "NegativeArraySizeException",
- "NoSuchFieldException",
- "NoSuchMethodException",
- "NullPointerException",
- "NumberFormatException",
- "RuntimeException",
- "SecurityException",
- "StringIndexOutOfBoundsException",
- "UnsupportedOperationException",
-
- "AbstractMethodError",
- "AssertionError",
- "ClassCircularityError",
- "ClassFormatError",
- "Error",
- "ExceptionInInitializerError",
- "IllegalAccessError",
- "IncompatibleClassChangeError",
- "InstantiationError",
- "InternalError",
- "LinkageError",
- "NoClassDefFoundError",
- "NoSuchFieldError",
- "NoSuchMethodError",
- "OutOfMemoryError",
- "StackOverflowError",
- "ThreadDeath",
- "UnknownError",
- "UnsatisfiedLinkError",
- "UnsupportedClassVersionError",
- "VerifyError",
- "VirtualMachineError",
-
- // 2. other classes used as primitive types by xml beans
- "BigInteger",
- "BigDecimal",
- "Enum",
- "Date",
- "GDate",
- "GDuration",
- "QName",
- "List",
-
- // 3. the top few org.apache.xmlbeans names
- "XmlObject",
- "XmlCursor",
- "XmlBeans",
- "SchemaType",
- }
- ));
-
- public static boolean isValidJavaIdentifier(String id)
- {
- if (id == null)
- throw new IllegalArgumentException("id cannot be null");
-
- int len = id.length();
- if (len == 0)
- return false;
-
- if (javaWords.contains(id))
- return false;
-
- if (!Character.isJavaIdentifierStart(id.charAt(0)))
- return false;
-
- for (int i = 1; i < len; i++)
- {
- if (!Character.isJavaIdentifierPart(id.charAt(i)))
- return false;
- }
-
- return true;
- }
-
- public static String getClassNameFromQName(QName qname)
- {
- return getClassNameFromQName(qname, false);
- }
-
- public static String getClassNameFromQName(QName qname, boolean useJaxRpcRules)
- {
- String java_type = upperCamelCase(qname.getLocalPart(), useJaxRpcRules);
-
- String uri = qname.getNamespaceURI();
- String java_pkg = null;
-
- java_pkg = getPackageFromNamespace(uri, useJaxRpcRules);
-
- if (java_pkg != null)
- return java_pkg + "." + java_type;
- else
- return java_type;
- }
-
- private static final String JAVA_NS_PREFIX="java:";
- private static final String LANG_PREFIX = "java.";
-
- public static String getNamespaceFromPackage(final Class clazz)
- {
- Class curr_clazz = clazz;
-
- while (curr_clazz.isArray())
- curr_clazz = curr_clazz.getComponentType();
-
- String fullname = clazz.getName();
- int lastdot = fullname.lastIndexOf('.');
- String pkg_name = lastdot < 0 ? "" : fullname.substring(0, lastdot);
-
- //special case for builtin types
- /*
- if (curr_clazz.isPrimitive())
- {
- pkg_name = c.getJavaLanguageNamespaceUri();
- }
- else if (pkg_name.startsWith(LANG_PREFIX))
- {
- final String rem_str = pkg_name.substring(LANG_PREFIX.length());
- pkg_name = c.getJavaLanguageNamespaceUri() + "." + rem_str;
- }
- */
- return JAVA_NS_PREFIX + pkg_name;
- }
-
- private static boolean isUriSchemeChar(char ch)
- {
- return (ch >= 'a' && ch <='z' ||
- ch >= 'A' && ch <='Z' ||
- ch >= '0' && ch <='9' ||
- ch == '-' || ch == '.' || ch == '+');
- }
-
- private static boolean isUriAlphaChar(char ch)
- {
- return (ch >= 'a' && ch <='z' || ch >= 'A' && ch <= 'Z');
- }
-
- private static int findSchemeColon(String uri)
- {
- int len = uri.length();
- if (len == 0)
- return -1;
- if (!isUriAlphaChar(uri.charAt(0)))
- return -1;
- int i;
- for (i = 1; i < len; i++)
- if (!isUriSchemeChar(uri.charAt(i)))
- break;
- if (i == len)
- return -1;
- if (uri.charAt(i) != ':')
- return -1;
- // consume consecutive colons
- for (; i < len; i++)
- if (uri.charAt(i) != ':')
- break;
- // for the "scheme:::" case, return len-1
- return i-1;
- }
-
- private static String jls77String(String name)
- {
- StringBuffer buf = new StringBuffer(name);
- for (int i = 0; i < name.length(); i++)
- {
- // We need to also make sure that our package names don't contain the
- // "$" character in them, which, although a valid Java identifier part,
- // would create confusion when trying to generate fully-qualified names
- if (!Character.isJavaIdentifierPart(buf.charAt(i)) || '$' == buf.charAt(i))
- buf.setCharAt(i, '_');
- }
- if (buf.length() == 0 || !Character.isJavaIdentifierStart(buf.charAt(0)))
- buf.insert(0, '_');
- if (isJavaReservedWord(name))
- buf.append('_');
- return buf.toString();
- }
-
- private static List splitDNS(String dns)
- {
- // JAXB says: only split+reverse DNS if TLD matches known TLDs or ISO 3166
- // We are ignoring this now (TH)
-
- List result = new ArrayList();
-
- int end = dns.length();
- int begin = dns.lastIndexOf('.');
- for ( ; begin != -1 ; begin--)
- {
- if (dns.charAt(begin) == '.') {
- result.add(jls77String(dns.substring(begin + 1, end)));
- end = begin;
- }
- }
- result.add(jls77String(dns.substring(0, end)));
-
- // JAXB draft example implies removal of www
- if (result.size() >= 3 &&
- ((String)result.get(result.size() - 1)).toLowerCase().equals("www"))
- result.remove(result.size() - 1);
-
- return result;
- }
-
- private static String processFilename(String filename)
- {
- // JAXB says: strip 2 or 3 letter extension or ".html"
-
- int i = filename.lastIndexOf('.');
- if (i > 0 && (
- i + 1 + 2 == filename.length() ||
- i + 1 + 3 == filename.length() ||
- filename.substring(i + 1).toLowerCase() == "html"))
- {
- return filename.substring(0, i);
- }
-
- return filename;
- }
-
- public static String getPackageFromNamespace(String uri)
- {
- return getPackageFromNamespace(uri, false);
- }
-
- public static String getPackageFromNamespace(String uri, boolean useJaxRpcRules)
- {
- // special case: no namespace -> package "noNamespace"
- if (uri == null || uri.length() == 0)
- return "noNamespace";
-
- // apply draft JAXB rules
- int len = uri.length();
- int i = findSchemeColon(uri);
- List result = null;
-
- if (i == len-1)
- {
- // XMLBEANS-57: colon is at end so just use scheme as the package name
- result = new ArrayList();
- result.add(uri.substring(0, i));
- }
- else if (i >= 0 && uri.substring(0, i).equals("java"))
- {
- result = Arrays.asList(uri.substring(i + 1).split("\\."));
- }
- else {
- result = new ArrayList();
- outer: for (i = i + 1; i < len; )
- {
- while (uri.charAt(i) == '/')
- if (++i >= len) break outer;
- int start = i;
- while (uri.charAt(i) != '/')
- if (++i >= len) break;
- int end = i;
- result.add(uri.substring(start, end));
- }
- if (result.size() > 1)
- result.set(result.size() - 1, processFilename((String)result.get(result.size() - 1)));
-
- if (result.size() > 0)
- {
- List splitdns = splitDNS((String)result.get(0));
- result.remove(0);
- result.addAll(0, splitdns);
- }
- }
-
- StringBuffer buf = new StringBuffer();
- for (Iterator it = result.iterator(); it.hasNext(); )
- {
- String part = nonJavaKeyword(lowerCamelCase((String)it.next(), useJaxRpcRules, true));
- if (part.length() > 0)
- {
- buf.append(part);
- buf.append('.');
- }
- }
- if (buf.length() == 0)
- return "noNamespace";
- if (useJaxRpcRules)
- return buf.substring(0, buf.length() - 1).toLowerCase();
- return buf.substring(0, buf.length() - 1); // chop off extra dot
- }
-
- public static void main(String[] args)
- {
- for (int i = 0; i < args.length; i++)
- System.out.println(upperCaseUnderbar(args[i]));
- }
-
- /**
- * Returns a upper-case-and-underbar string using the JAXB rules.
- * Always starts with a capital letter that is a valid
- * java identifier start. (If JAXB rules don't produce
- * one, then "X_" is prepended.)
- */
- public static String upperCaseUnderbar(String xml_name)
- {
- StringBuffer buf = new StringBuffer();
- List words = splitWords(xml_name, false);
-
- final int sz = words.size() - 1;
- if (sz >= 0 && !Character.isJavaIdentifierStart(((String)words.get(0)).charAt(0)))
- buf.append("X_");
-
- for(int i = 0 ; i < sz ; i++)
- {
- buf.append((String)words.get(i));
- buf.append(USCORE);
- }
-
- if (sz >= 0)
- {
- buf.append((String)words.get(sz));
- }
-
- //upcase entire buffer
- final int len = buf.length();
- for(int j = 0 ; j < len ; j++)
- {
- char c = buf.charAt(j);
- buf.setCharAt(j, Character.toUpperCase(c));
- }
-
- return buf.toString();
- }
-
- /**
- * Returns a camel-cased string using the JAXB rules.
- * Always starts with a capital letter that is a valid
- * java identifier start. (If JAXB rules don't produce
- * one, then "X" is prepended.)
- */
- public static String upperCamelCase(String xml_name)
- {
- return upperCamelCase(xml_name, false);
- }
-
- /**
- * Returns a camel-cased string, but either JAXB or JAX-RPC rules
- * are used
- */
- public static String upperCamelCase(String xml_name, boolean useJaxRpcRules)
- {
- StringBuffer buf = new StringBuffer();
- List words = splitWords(xml_name, useJaxRpcRules);
-
- if (words.size() > 0)
- {
- if (!Character.isJavaIdentifierStart(((String)words.get(0)).charAt(0)))
- buf.append("X");
-
- Iterator itr = words.iterator();
- while(itr.hasNext())
- buf.append((String)itr.next());
- }
- return buf.toString();
- }
-
- /**
- * Returns a camel-cased string using the JAXB rules,
- * where the first component is lowercased. Note that
- * if the first component is an acronym, the whole
- * thigns gets lowercased.
- * Always starts with a lowercase letter that is a valid
- * java identifier start. (If JAXB rules don't produce
- * one, then "x" is prepended.)
- */
- public static String lowerCamelCase(String xml_name)
- {
- return lowerCamelCase(xml_name, false, true);
- }
-
- /**
- * Returns a camel-cased string using the JAXB or JAX-RPC rules
- */
- public static String lowerCamelCase(String xml_name, boolean useJaxRpcRules,
- boolean fixGeneratedName)
- {
- StringBuffer buf = new StringBuffer();
- List words = splitWords(xml_name, useJaxRpcRules);
-
- if (words.size() > 0)
- {
- String first = ((String)words.get(0)).toLowerCase();
- char f = first.charAt(0);
- if (!Character.isJavaIdentifierStart(f) && fixGeneratedName)
- buf.append("x");
- buf.append(first);
-
- Iterator itr = words.iterator();
- itr.next(); // skip already-lowercased word
- while(itr.hasNext())
- buf.append((String)itr.next());
- }
- return buf.toString();
- }
-
- public static String upperCaseFirstLetter(String s)
- {
- if (s.length() == 0 || Character.isUpperCase(s.charAt(0)))
- return s;
-
- StringBuffer buf = new StringBuffer(s);
- buf.setCharAt(0, Character.toUpperCase(buf.charAt(0)));
- return buf.toString();
- }
-
-
- /**
- split an xml name into words via JAXB approach, upcasing first
- letter of each word as needed, if upcase is true
-
- ncname is xml ncname (i.e. no colons).
- */
- private static void addCapped(List list, String str)
- {
- if (str.length() > 0)
- list.add(upperCaseFirstLetter(str));
- }
-
- public static List splitWords(String name, boolean useJaxRpcRules)
- {
- List list = new ArrayList();
- int len = name.length();
- int start = 0;
- int prefix = START;
- for (int i = 0; i < len; i++)
- {
- int current = getCharClass(name.charAt(i), useJaxRpcRules);
- if (prefix != PUNCT && current == PUNCT)
- {
- addCapped(list, name.substring(start, i));
- while ((current = getCharClass(name.charAt(i), useJaxRpcRules)) == PUNCT)
- if (++i >= len) return list;
- start = i;
- }
- else if ((prefix == DIGIT) != (current == DIGIT) ||
- (prefix == LOWER && current != LOWER) ||
- (isLetter(prefix) != isLetter(current)))
- {
- addCapped(list, name.substring(start, i));
- start = i;
- }
- else if (prefix == UPPER && current == LOWER && i > start + 1)
- {
- addCapped(list, name.substring(start, i - 1));
- start = i - 1;
- }
- prefix = current;
- }
- addCapped(list, name.substring(start));
- return list;
- }
-
- //char classes
- private final static int START = 0;
- private final static int PUNCT = 1;
- private final static int DIGIT = 2;
- private final static int MARK = 3;
- private final static int UPPER = 4;
- private final static int LOWER= 5;
- private final static int NOCASE= 6;
-
- public static int getCharClass(char c, boolean useJaxRpcRules)
- {
- //ordering is important here.
- if (isPunctuation(c, useJaxRpcRules))
- return PUNCT;
- else if (Character.isDigit(c))
- return DIGIT;
- else if (Character.isUpperCase(c))
- return UPPER;
- else if (Character.isLowerCase(c))
- return LOWER;
- else if (Character.isLetter(c))
- return NOCASE;
- else if (Character.isJavaIdentifierPart(c))
- return MARK;
- else
- return PUNCT; // not covered by JAXB: treat it as punctuation
- }
-
- private static boolean isLetter(int state)
- {
- return (state==UPPER
- || state==LOWER
- || state==NOCASE);
- }
-
- public static boolean isPunctuation(char c, boolean useJaxRpcRules)
- {
- return (c == HYPHEN
- || c == PERIOD
- || c == COLON
- || c == DOT
- || (c == USCORE && !useJaxRpcRules)
- || c == TELEIA
- || c == AYAH
- || c == ELHIZB);
- }
-
- /**
- * Intended to be applied to a lowercase-starting identifier that
- * may collide with a Java keyword. If it does collide, this
- * prepends the letter "x".
- */
- public static String nonJavaKeyword(String word)
- {
- if (isJavaReservedWord(word))
- return 'x' + word;
- return word;
- }
-
- /**
- * Intended to be applied to a lowercase-starting identifier that
- * may collide with a Java keyword. If it does collide, this
- * prepends the letter "x".
- */
- public static String nonExtraKeyword(String word)
- {
- if (isExtraReservedWord(word, true))
- return word + "Value";
- return word;
- }
-
- /**
- * Intended to be applied to an uppercase-starting identifier that
- * may collide with a java.lang.* classname. If it does collide, this
- * prepends the letter "X".
- */
- public static String nonJavaCommonClassName(String name)
- {
- if (isJavaCommonClassName(name))
- return "X" + name;
- return name;
- }
-
- private static boolean isJavaReservedWord(String word)
- {
- return isJavaReservedWord(word, true);
- }
-
- private static boolean isJavaReservedWord(String word, boolean ignore_case)
- {
- if (ignore_case)
- word = word.toLowerCase();
- return javaWords.contains(word);
- }
-
- private static boolean isExtraReservedWord(String word, boolean ignore_case)
- {
- if (ignore_case)
- word = word.toLowerCase();
- return extraWords.contains(word);
- }
-
- public static boolean isJavaCommonClassName(String word)
- {
- return javaNames.contains(word);
- }
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/ResolverUtil.java b/src/common/org/apache/xmlbeans/impl/common/ResolverUtil.java
deleted file mode 100644
index 626e48b..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/ResolverUtil.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import org.apache.xmlbeans.SystemProperties;
-
-import org.xml.sax.EntityResolver;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * Author: Cezar Andrei (cezar.andrei at bea.com)
- * Date: Dec 3, 2003
- */
-public class ResolverUtil
-{
- private static EntityResolver _entityResolver = null;
-
- static
- {
- try
- {
- String erClassName = SystemProperties.getProperty("xmlbean.entityResolver");
- if (erClassName != null) {
- Object o = Class.forName(erClassName).newInstance();
- _entityResolver = (EntityResolver)o;
- }
- }
- catch (Exception e)
- {
- _entityResolver = null;
- }
- }
-
- public static EntityResolver getGlobalEntityResolver()
- {
- return _entityResolver;
- }
-
- public static EntityResolver resolverForCatalog(String catalogFile)
- {
- if (catalogFile==null)
- return null;
-
- try
- {
- Class cmClass = Class.forName("org.apache.xml.resolver.CatalogManager");
- Constructor cstrCm = cmClass.getConstructor(new Class[] {});
- Object cmObj = cstrCm.newInstance(new Object[] {});
- Method cmMethod = cmClass.getMethod("setCatalogFiles", new Class[] {String.class});
- cmMethod.invoke(cmObj, new String[] {catalogFile});
-
- Class crClass = Class.forName("org.apache.xml.resolver.tools.CatalogResolver");
- Constructor cstrCr = crClass.getConstructor(new Class[] {cmClass});
- Object crObj = cstrCr.newInstance(new Object[] {cmObj});
-
- return (EntityResolver)crObj;
- }
- catch( Exception e )
- {
- return null;
- }
- }
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/SniffedXmlInputStream.java b/src/common/org/apache/xmlbeans/impl/common/SniffedXmlInputStream.java
deleted file mode 100644
index 611af92..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/SniffedXmlInputStream.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import java.io.InputStream;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.Charset;
-
-public class SniffedXmlInputStream extends BufferedInputStream
-{
- // We don't sniff more than 192 bytes.
- public static int MAX_SNIFFED_BYTES = 192;
-
- public SniffedXmlInputStream(InputStream stream) throws IOException
- {
- super(stream);
-
- // read byte order marks and detect EBCDIC etc
- _encoding = sniffFourBytes();
-
- if (_encoding != null && _encoding.equals("IBM037"))
- {
- // First four bytes suggest EBCDIC with
- // assuming we can read it as UTF-8.
- _encoding = sniffForXmlDecl("UTF-8");
- }
-
- if (_encoding == null)
- {
- // The XML spec says these two things:
-
- // (1) "In the absence of external character encoding information
- // (such as MIME headers), parsed entities which are stored in an
- // encoding other than UTF-8 or UTF-16 must begin with a text
- // declaration (see 4.3.1 The Text Declaration) containing an
- // encoding declaration:"
-
- // (2) "In the absence of information provided by an external
- // transport protocol (e.g. HTTP or MIME), it is an error
- // for an entity including an encoding declaration to be
- // presented to the XML processor in an encoding other than
- // that named in the declaration, or for an entity which begins
- // with neither a Byte Order Mark nor an encoding declaration
- // to use an encoding other than UTF-8."
-
- // Since we're using a sniffed stream, we do not have external
- // character encoding information.
-
- // Since we're here, we also don't have a recognized byte order
- // mark or an explicit encoding declaration that can be read in
- // either ASCII or EBDIC style.
-
- // Therefore, we must use UTF-8.
-
- _encoding = "UTF-8";
- }
- }
-
- private int readAsMuchAsPossible(byte[] buf, int startAt, int len) throws IOException
- {
- int total = 0;
- while (total < len)
- {
- int count = read(buf, startAt + total, len - total);
- if (count < 0)
- break;
- total += count;
- }
- return total;
- }
-
- private String sniffFourBytes() throws IOException
- {
- mark(4);
- int skip = 0;
- try
- {
- byte[] buf = new byte[4];
- if (readAsMuchAsPossible(buf, 0, 4) < 4)
- return null;
- long result = 0xFF000000 & (buf[0] << 24) | 0x00FF0000 & (buf[1] << 16) | 0x0000FF00 & (buf[2] << 8) | 0x000000FF & buf[3];
-
- if (result == 0x0000FEFF)
- return "UCS-4";
- else if (result == 0xFFFE0000)
- return "UCS-4";
- else if (result == 0x0000003C)
- return "UCS-4BE";
- else if (result == 0x3C000000)
- return "UCS-4LE";
- else if (result == 0x003C003F)
- return "UTF-16BE";
- else if (result == 0x3C003F00)
- return "UTF-16LE";
- else if (result == 0x3C3F786D)
- return null; // looks like US-ASCII with = 0)
- {
- int i = xmlpi + 5;
- ScannedAttribute attr = new ScannedAttribute();
- while (i < limit)
- {
- i = scanAttribute(buf, i, limit, attr);
- if (i < 0)
- return null;
- if (attr.name.equals("encoding"))
- return attr.value;
- }
- }
- return null;
- }
-
- private static int firstIndexOf(String s, char[] buf, int startAt, int limit)
- {
- assert(s.length() > 0);
- char[] lookFor = s.toCharArray();
-
- char firstchar = lookFor[0];
- searching: for (limit -= lookFor.length; startAt < limit; startAt++)
- {
- if (buf[startAt] == firstchar)
- {
- for (int i = 1; i < lookFor.length; i++)
- {
- if (buf[startAt + i] != lookFor[i])
- {
- continue searching;
- }
- }
- return startAt;
- }
- }
-
- return -1;
- }
-
- private static int nextNonmatchingByte(char[] lookFor, char[] buf, int startAt, int limit)
- {
- searching: for (; startAt < limit; startAt++)
- {
- int thischar = buf[startAt];
- for (int i = 0; i < lookFor.length; i++)
- if (thischar == lookFor[i])
- continue searching;
- return startAt;
- }
- return -1;
- }
-
- private static int nextMatchingByte(char[] lookFor, char[] buf, int startAt, int limit)
- {
- searching: for (; startAt < limit; startAt++)
- {
- int thischar = buf[startAt];
- for (int i = 0; i < lookFor.length; i++)
- if (thischar == lookFor[i])
- return startAt;
- }
- return -1;
- }
-
- private static int nextMatchingByte(char lookFor, char[] buf, int startAt, int limit)
- {
- searching: for (; startAt < limit; startAt++)
- {
- if (buf[startAt] == lookFor)
- return startAt;
- }
- return -1;
- }
- private static char[] WHITESPACE = new char[] { ' ', '\r', '\t', '\n' };
- private static char[] NOTNAME = new char[] { '=', ' ', '\r', '\t', '\n', '?', '>', '<', '\'', '\"' };
-
- private static class ScannedAttribute
- {
- public String name;
- public String value;
- }
-
- private static int scanAttribute(char[] buf, int startAt, int limit, ScannedAttribute attr)
- {
- int nameStart = nextNonmatchingByte(WHITESPACE, buf, startAt, limit);
- if (nameStart < 0)
- return -1;
- int nameEnd = nextMatchingByte(NOTNAME, buf, nameStart, limit);
- if (nameEnd < 0)
- return -1;
- int equals = nextNonmatchingByte(WHITESPACE, buf, nameEnd, limit);
- if (equals < 0)
- return -1;
- if (buf[equals] != '=')
- return -1;
- int valQuote = nextNonmatchingByte(WHITESPACE, buf, equals + 1, limit);
- if (buf[valQuote] != '\'' && buf[valQuote] != '\"')
- return -1;
- int valEndquote = nextMatchingByte(buf[valQuote], buf, valQuote + 1, limit);
- if (valEndquote < 0)
- return -1;
- attr.name = new String(buf, nameStart, nameEnd - nameStart);
- attr.value = new String(buf, valQuote + 1, valEndquote - valQuote - 1);
- return valEndquote + 1;
- }
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/SystemCache.java b/src/common/org/apache/xmlbeans/impl/common/SystemCache.java
deleted file mode 100644
index 580a1f7..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/SystemCache.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.xmlbeans.impl.common;
-
-import java.lang.ref.SoftReference;
-import java.util.ArrayList;
-
-import org.apache.xmlbeans.SchemaTypeLoader;
-import org.apache.xmlbeans.SystemProperties;
-
-/**
- * This class encapsulates the caching strategy for XmlBeans.
- * By subclassing this, a client of XmlBeans can implement caches that are
- * more suitable for different applications using information that XmlBeans
- * cannot know.
- *
- * This class works as a singleton and as a default implementation for the cache.
- * You can set a particular implementation using the "xmlbean.systemcacheimpl"
- * system property or using the static {@link set} method.
- * Subclasses of this need to be thread-safe. An implementation can be replaced
- * at any time, so use of static variables is discouraged to ensure proper cleanup.
- */
-public class SystemCache
-{
- private static SystemCache INSTANCE = new SystemCache();
-
- static
- {
- String cacheClass = SystemProperties.getProperty("xmlbean.systemcacheimpl");
- Object impl = null;
- if (cacheClass != null)
- {
- try
- {
- impl = Class.forName(cacheClass).newInstance();
- if (!(impl instanceof SystemCache))
- throw new ClassCastException("Value for system property " +
- "\"xmlbean.systemcacheimpl\" points to a class (" + cacheClass +
- ") which does not derive from SystemCache");
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new RuntimeException("Cache class " + cacheClass +
- " specified by \"xmlbean.systemcacheimpl\" was not found.",
- cnfe);
- }
- catch (InstantiationException ie)
- {
- throw new RuntimeException("Could not instantiate class " +
- cacheClass + " as specified by \"xmlbean.systemcacheimpl\"." +
- " An empty constructor may be missing.", ie);
- }
- catch (IllegalAccessException iae)
- {
- throw new RuntimeException("Could not instantiate class " +
- cacheClass + " as specified by \"xmlbean.systemcacheimpl\"." +
- " A public empty constructor may be missing.", iae);
- }
- }
- if (impl != null)
- INSTANCE = (SystemCache) impl;
- }
-
- public static synchronized final void set(SystemCache instance)
- {
- INSTANCE = instance;
- }
-
- public static final SystemCache get()
- {
- return INSTANCE;
- }
-
- public SchemaTypeLoader getFromTypeLoaderCache(ClassLoader cl)
- {
- return null;
- }
-
- public void addToTypeLoaderCache(SchemaTypeLoader stl, ClassLoader cl)
- {
- return;
- }
-
- private ThreadLocal tl_saxLoaders = new ThreadLocal();
-
- public Object getSaxLoader()
- {
- SoftReference s = (SoftReference) tl_saxLoaders.get();
- if (s == null)
- return null;
- else
- return s.get();
- }
-
- public void setSaxLoader(Object saxLoader)
- {
- tl_saxLoaders.set(new SoftReference(saxLoader));
- }
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/XBeanDebug.java b/src/common/org/apache/xmlbeans/impl/common/XBeanDebug.java
deleted file mode 100644
index 19f2c4a..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/XBeanDebug.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import org.apache.xmlbeans.SystemProperties;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-public class XBeanDebug
-{
- public static final int TRACE_SCHEMA_LOADING = 0x0001;
- public static final String traceProp = "org.apache.xmlbeans.impl.debug";
- public static final String defaultProp = ""; // "TRACE_SCHEMA_LOADING";
-
- private static int _enabled = initializeBitsFromProperty();
- private static int _indent = 0;
- private static String _indentspace = " ";
-
- private static int initializeBitsFromProperty()
- {
- int bits = 0;
- String prop = SystemProperties.getProperty(traceProp, defaultProp);
- if (prop.indexOf("TRACE_SCHEMA_LOADING") >= 0)
- bits |= TRACE_SCHEMA_LOADING;
- return bits;
- }
- public static void enable(int bits)
- {
- _enabled = _enabled | bits;
- }
-
- public static void disable(int bits)
- {
- _enabled = _enabled & ~bits;
- }
-
- public static void trace(int bits, String message, int indent)
- {
- if (test(bits))
- {
- synchronized (XBeanDebug.class)
- {
- if (indent < 0)
- _indent += indent;
-
- String spaces = _indent < 0 ? "" : _indent > _indentspace.length() ? _indentspace : _indentspace.substring(0, _indent);
- String logmessage = Thread.currentThread().getName() + ": " + spaces + message + "\n";
- System.err.print(logmessage);
-
- if (indent > 0)
- _indent += indent;
- }
- }
- }
-
- public static boolean test(int bits)
- {
- return (_enabled & bits) != 0;
- }
-
- static PrintStream _err;
-
- public static String log(String message)
- {
- log(message, null);
- return message;
- }
-
- public static String logStackTrace(String message)
- {
- log(message, new Throwable());
- return message;
- }
-
- private synchronized static String log(String message, Throwable stackTrace)
- {
- if (_err == null)
- {
- try
- {
- File diagnosticFile = File.createTempFile("xmlbeandebug", ".log");
- _err = new PrintStream(new FileOutputStream(diagnosticFile));
- System.err.println("Diagnostic XML Bean debug log file created: " + diagnosticFile);
- }
- catch (IOException e)
- {
- _err = System.err;
- }
- }
- _err.println(message);
- if (stackTrace != null)
- {
- stackTrace.printStackTrace(_err);
- }
- return message;
- }
-
- public static Throwable logException(Throwable t)
- {
- log(t.getMessage(), t);
- return t;
- }
-}
diff --git a/src/common/org/apache/xmlbeans/impl/common/XPath.java b/src/common/org/apache/xmlbeans/impl/common/XPath.java
deleted file mode 100644
index e3edd92..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/XPath.java
+++ /dev/null
@@ -1,1119 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import javax.xml.namespace.QName;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.impl.common.XMLChar;
-
-
-public class XPath
-{
- public static class XPathCompileException extends XmlException
- {
- XPathCompileException ( XmlError err )
- {
- super( err.toString(), null, err );
- }
- }
-
- //
- //
- //
-
- public static class ExecutionContext
- {
- public ExecutionContext ( )
- {
- _stack = new ArrayList();
- }
-
- public static final int HIT = 0x1;
- public static final int DESCEND = 0x2;
- public static final int ATTRS = 0x4;
-
- public final void init ( XPath xpath )
- {
- if (_xpath != xpath)
- {
- _xpath = xpath;
-
- _paths = new PathContext [ xpath._selector._paths.length ];
-
- for ( int i = 0 ; i < _paths.length ; i++ )
- _paths[ i ] = new PathContext();
- }
-
- _stack.clear();
-
- for ( int i = 0 ; i < _paths.length ; i++ )
- _paths[ i ].init( xpath._selector._paths[ i ] );
- }
-
- public final int start ( )
- {
- int result = 0;
-
- for ( int i = 0 ; i < _paths.length ; i++ )
- result |= _paths[ i ].start();
-
- return result;
- }
-
- public final int element ( QName name )
- {
- assert name != null;
-
- _stack.add( name );
-
- int result = 0;
-
- for ( int i = 0 ; i < _paths.length ; i++ )
- result |= _paths[ i ].element( name );
-
- return result;
- }
-
- public final boolean attr ( QName name )
- {
- boolean hit = false;
-
- for ( int i = 0 ; i < _paths.length ; i++ )
- hit = hit | _paths[ i ].attr( name );
-
- return hit;
- }
-
- public final void end ( )
- {
- _stack.remove( _stack.size() - 1 );
-
- for ( int i = 0 ; i < _paths.length ; i++ )
- _paths[ i ].end();
- }
-
- private final class PathContext
- {
- PathContext ( )
- {
- _prev = new ArrayList();
- }
-
- void init ( Step steps )
- {
- _curr = steps;
- _prev.clear();
- }
-
- private QName top ( int i )
- {
- return (QName) ExecutionContext.this._stack.get( _stack.size() - 1 - i );
- }
-
- // goes back to the begining of the sequence since last // wildcard
- private void backtrack ( )
- {
- assert _curr != null;
-
- if (_curr._hasBacktrack)
- { // _backtrack seems to be a pointer to the step that follows a // wildcard
- // ex: for .//b/c/d steps c and d should backtrack to b in case there isn't a match
- _curr = _curr._backtrack;
- return;
- }
-
- assert !_curr._deep;
-
- _curr = _curr._prev;
-
- search: for ( ; !_curr._deep ; _curr = _curr._prev )
- {
- int t = 0;
-
- for ( Step s = _curr ; !s._deep ; s = s._prev )
- {
- if (!s.match( top( t++ )))
- continue search;
- }
-
- break;
- }
- }
-
- int start ( )
- {
- assert _curr != null;
- assert _curr._prev == null;
-
- if (_curr._name != null)
- return _curr._flags;
-
- // If the steps consist on only a terminator, then the path can
- // only be '.'. In this case, we get a hit, but there is
- // nothing else to match. No need to backtrack.
-
- _curr = null;
-
- return HIT;
- }
-
- int element ( QName name )
- {
- //System.out.println(" Path.element: " + name);
- _prev.add( _curr );
-
- if (_curr == null)
- return 0;
-
- assert _curr._name != null;
-
- if (!_curr._attr && _curr.match( name ))
- {
- if ((_curr = _curr._next)._name != null)
- return _curr._flags;
-
- backtrack();
-
- //System.out.println(" element - HIT " + _curr._flags);
- return _curr == null ? HIT : HIT | _curr._flags;
- }
-
- for ( ; ; )
- {
- backtrack();
-
- if (_curr == null)
- return 0;
-
- if (_curr.match( name ))
- {
- _curr = _curr._next;
- break;
- }
-
- if (_curr._deep)
- break;
- }
-
- return _curr._flags;
- }
-
- boolean attr ( QName name )
- {
- return _curr != null && _curr._attr && _curr.match( name );
- }
-
- void end ( )
- {
- //System.out.println(" Path.end ");
- _curr = (Step) _prev.remove( _prev.size() - 1 );
- }
-
- private Step _curr;
- private List _prev;
- }
-
- private XPath _xpath;
- private ArrayList _stack;
- private PathContext[] _paths;
- }
-
- //
- //
- //
-
- public static XPath compileXPath ( String xpath )
- throws XPathCompileException
- {
- return compileXPath( xpath, "$this", null );
- }
-
- public static XPath compileXPath ( String xpath, String currentNodeVar )
- throws XPathCompileException
- {
- return compileXPath( xpath, currentNodeVar, null );
- }
-
- public static XPath compileXPath ( String xpath, Map namespaces )
- throws XPathCompileException
- {
- return compileXPath( xpath, "$this", namespaces );
- }
-
- public static XPath compileXPath (
- String xpath, String currentNodeVar, Map namespaces )
- throws XPathCompileException
- {
- return
- new CompilationContext( namespaces, currentNodeVar ).
- compile( xpath );
- }
-
- private static class CompilationContext
- {
- CompilationContext ( Map namespaces, String currentNodeVar )
- {
- assert
- _currentNodeVar == null ||
- _currentNodeVar.startsWith( "$" );
-
- if (currentNodeVar == null)
- _currentNodeVar = "$this";
- else
- _currentNodeVar = currentNodeVar;
-
- _namespaces = new HashMap();
-
- _externalNamespaces =
- namespaces == null ? new HashMap() : namespaces;
- }
-
- XPath compile ( String expr ) throws XPathCompileException
- {
- _offset = 0;
- _line = 1;
- _column = 1;
- _expr = expr;
-
- return tokenizeXPath();
- }
-
- int currChar ( )
- {
- return currChar( 0 );
- }
-
- int currChar ( int offset )
- {
- return
- _offset + offset >= _expr.length()
- ? -1
- : _expr.charAt( _offset + offset );
- }
-
- void advance ( )
- {
- if (_offset < _expr.length())
- {
- char ch = _expr.charAt( _offset );
-
- _offset++;
- _column++;
-
- if (ch == '\r' || ch == '\n')
- {
- _line++;
- _column = 1;
-
- if (_offset + 1 < _expr.length())
- {
- char nextCh = _expr.charAt( _offset + 1 );
-
- if ((nextCh == '\r' || nextCh == '\n') && ch != nextCh)
- _offset++;
- }
- }
- }
- }
-
- void advance ( int count )
- {
- assert count >= 0;
-
- while ( count-- > 0 )
- advance();
- }
-
- boolean isWhitespace ( )
- {
- return isWhitespace( 0 );
- }
-
- boolean isWhitespace ( int offset )
- {
- int ch = currChar( offset );
- return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
- }
-
- boolean isNCNameStart ( )
- {
- return
- currChar() == -1
- ? false :
- XMLChar.isNCNameStart( currChar() );
- }
-
- boolean isNCName ( )
- {
- return
- currChar() == -1
- ? false :
- XMLChar.isNCName( currChar() );
- }
-
- boolean startsWith ( String s )
- {
- return startsWith( s, 0 );
- }
-
- boolean startsWith ( String s, int offset )
- {
- if (_offset + offset >= _expr.length())
- return false;
-
- return _expr.startsWith( s, _offset + offset );
- }
-
- private XPathCompileException newError ( String msg )
- {
- XmlError err =
- XmlError.forLocation(
- msg, XmlError.SEVERITY_ERROR, null,
- _line, _column, _offset );
-
- return new XPathCompileException( err );
- }
-
- String lookupPrefix ( String prefix ) throws XPathCompileException
- {
- if (_namespaces.containsKey( prefix ))
- return (String) _namespaces.get( prefix );
-
- if (_externalNamespaces.containsKey( prefix ))
- return (String) _externalNamespaces.get( prefix );
-
- if (prefix.equals( "xml" ))
- return "http://www.w3.org/XML/1998/namespace";
-
- if (prefix.equals( "xs" ))
- return "http://www.w3.org/2001/XMLSchema";
-
- if (prefix.equals( "xsi" ))
- return "http://www.w3.org/2001/XMLSchema-instance";
-
- if (prefix.equals( "fn" ))
- return "http://www.w3.org/2002/11/xquery-functions";
-
- if (prefix.equals( "xdt" ))
- return "http://www.w3.org/2003/11/xpath-datatypes";
-
- if (prefix.equals( "local" ))
- return "http://www.w3.org/2003/11/xquery-local-functions";
-
- throw newError( "Undefined prefix: " + prefix );
- }
-
- private boolean parseWhitespace ( ) throws XPathCompileException
- {
- boolean sawSpace = false;
-
- while ( isWhitespace() )
- {
- advance();
- sawSpace = true;
- }
-
- return sawSpace;
- }
-
- //
- // Tokenizing will consume whitespace followed by the tokens, separated
- // by whitespace. The whitespace following the last token is not
- // consumed.
- //
-
- private boolean tokenize ( String s )
- {
- assert s.length() > 0;
-
- int offset = 0;
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s, offset ))
- return false;
-
- offset += s.length();
-
- advance( offset );
-
- return true;
- }
-
- private boolean tokenize ( String s1, String s2 )
- {
- assert s1.length() > 0;
- assert s2.length() > 0;
-
- int offset = 0;
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s1, offset ))
- return false;
-
- offset += s1.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s2, offset ))
- return false;
-
- offset += s2.length();
-
- advance( offset );
-
- return true;
- }
-
- private boolean tokenize ( String s1, String s2, String s3)
- {
- assert s1.length() > 0;
- assert s2.length() > 0;
- assert s3.length() > 0;
-
- int offset = 0;
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s1, offset ))
- return false;
-
- offset += s1.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s2, offset ))
- return false;
-
- offset += s2.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s3, offset ))
- return false;
-
- offset += s3.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- advance( offset );
-
- return true;
- }
- private boolean tokenize ( String s1, String s2, String s3,String s4) {
- assert s1.length() > 0;
- assert s2.length() > 0;
- assert s3.length() > 0;
- assert s4.length() > 0;
-
- int offset = 0;
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s1, offset ))
- return false;
-
- offset += s1.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s2, offset ))
- return false;
-
- offset += s2.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s3, offset ))
- return false;
-
- offset += s3.length();
-
- while ( isWhitespace( offset ) )
- offset++;
-
- if (!startsWith( s4, offset ))
- return false;
-
- offset += s4.length();
-
- advance( offset );
-
- return true;
- }
-
-
- private String tokenizeNCName ( ) throws XPathCompileException
- {
- parseWhitespace();
-
- if (!isNCNameStart())
- throw newError( "Expected non-colonized name" );
-
- StringBuffer sb = new StringBuffer();
-
- sb.append( (char) currChar() );
-
- for ( advance() ; isNCName() ; advance() )
- sb.append( (char) currChar() );
-
- return sb.toString();
- }
-
- private QName getAnyQName ( )
- {
- return new QName( "", "" );
- }
-
- private QName tokenizeQName ( ) throws XPathCompileException
- {
- if (tokenize( "*" ))
- return getAnyQName();
-
- String ncName = tokenizeNCName();
-
- if (!tokenize( ":" ))
- return new QName( lookupPrefix( "" ), ncName );
-
- return
- new QName(
- lookupPrefix( ncName ),
- tokenize( "*" ) ? "" : tokenizeNCName() );
- }
-
- private String tokenizeQuotedUri ( ) throws XPathCompileException
- {
- char quote;
-
- if (tokenize( "\"" ))
- quote = '"';
- else if (tokenize( "'" ))
- quote = '\'';
- else
- throw newError( "Expected quote (\" or ')" );
-
- StringBuffer sb = new StringBuffer();
-
- for ( ; ; )
- {
- if (currChar() == -1)
- throw newError( "Path terminated in URI literal" );
-
- if (currChar() == quote)
- {
- advance();
-
- if (currChar() != quote)
- break;
- }
-
- sb.append( (char) currChar() );
-
- advance();
- }
-
- return sb.toString();
- }
-
- private Step addStep ( boolean deep, boolean attr, QName name, Step steps )
- {
- Step step = new Step( deep, attr, name );
-
- if (steps == null)
- return step;
-
- Step s = steps;
-
- while ( steps._next != null )
- steps = steps._next;
-
- steps._next = step;
- step._prev = steps;
-
- return s;
- }
-
- private Step tokenizeSteps ( ) throws XPathCompileException
- {
- if (tokenize( "/" ))
- throw newError( "Absolute paths unsupported" );
-
- boolean deep;
-
- if (tokenize( "$", _currentNodeVar, "//" ) || tokenize( ".", "//" ))
- deep = true;
- else if (tokenize( "$", _currentNodeVar, "/" ) || tokenize( ".", "/" ))
- deep = false;
- else if (tokenize( "$", _currentNodeVar ) || tokenize( "." ))
- return addStep( false, false, null, null );
- else
- deep = false;
-
- Step steps = null;
-
- // Compile the steps removing /. and mergind //. with the next step
-
- boolean deepDot = false;
-
- for ( ; ; )
- {
- if (tokenize( "attribute", "::" ) || tokenize( "@" ))
- {
- steps = addStep( deep, true, tokenizeQName(), steps );
- break;
- }
-
- QName name;
-
- if (tokenize( "." ))
- deepDot = deepDot || deep;
- else
- {
- tokenize( "child", "::" );
- if ((name = tokenizeQName()) != null)
- {
- steps = addStep( deep, false, name, steps );
- deep = false; // only this step needs to be deep
- // other folowing steps will be deep only if they are preceded by // wildcard
- }
- }
-
- if (tokenize( "//" ))
- {
- deep = true;
- deepDot = false;
- }
- else if (tokenize( "/" ))
- {
- if (deepDot)
- deep = true;
- }
- else
- break;
- }
-
- // If there was a //. at the end of th path, then we need to make
- // two paths, one with * at the end and another with @* at the end.
-
- if ((_lastDeepDot = deepDot))
- {
- _lastDeepDot = true;
- steps = addStep( true, false, getAnyQName(), steps );
- }
-
- // Add sentinal step (_name == null)
-
- return addStep( false, false, null, steps );
- }
-
- private void computeBacktrack ( Step steps )
- throws XPathCompileException
- {
- //
- // Compute static backtrack information
- //
- // Note that I use the fact that _hasBacktrack is initialized to
- // false and _backtrack to null in the following code.
- //
-
- Step s, t;
-
- for ( s = steps ; s != null ; s = t )
- {
- // Compute the segment from [ s, t )
-
- for ( t = s._next ; t != null && !t._deep ; )
- t = t._next;
-
- // If the segment is NOT rooted at //, then the backtrack is
- // null for the entire segment, including possible attr and/or
- // sentinal
-
- if (!s._deep)
- {
- for ( Step u = s ; u != t ; u = u._next )
- u._hasBacktrack = true;
-
- continue;
- }
-
- // Compute the sequence [ s, u ) of length n which contain no
- // wild steps.
-
- int n = 0;
- Step u = s;
-
- while ( u != t && u._name != null && !u.isWild() && !u._attr )
- {
- n++;
- u = u._next;
- }
-
- // Now, apply KMP to [ s, u ) for fast backtracking
-
- QName [] pattern = new QName [ n + 1 ];
- int [] kmp = new int [ n + 1 ];
-
- Step v = s;
-
- for ( int i = 0 ; i < n ; i++ )
- {
- pattern[ i ] = v._name;
- v = v._next;
- }
-
- pattern[ n ] = getAnyQName();
-
- int i = 0;
- int j = kmp[ 0 ] = -1;
-
- while ( i < n )
- {
- while ( j > -1 && !pattern[ i ].equals( pattern[ j ] ) )
- j = kmp[ j ];
-
- if (pattern[ ++i ].equals( pattern[ ++j ] ))
- kmp[ i ] = kmp[ j ];
- else
- kmp[ i ] = j;
- }
-
- i = 0;
-
- for ( v = s ; v != u ; v = v._next )
- {
- v._hasBacktrack = true;
- v._backtrack = s;
-
- for ( j = kmp[ i ] ; j > 0 ; j-- )
- v._backtrack = v._backtrack._next;
-
- i++;
- }
-
- // Compute the success backtrack and stuff it into an attr and
- // sentinal if they exist for this segment
-
- v = s;
-
- if (n > 1)
- {
- for ( j = kmp[ n - 1 ] ; j > 0 ; j-- )
- v = v._next;
- }
-
- if (u != t && u._attr)
- {
- u._hasBacktrack = true;
- u._backtrack = v;
- u = u._next;
- }
-
- if (u != t && u._name == null)
- {
- u._hasBacktrack = true;
- u._backtrack = v;
- }
-
- // The first part of a deep segment always backtracks to itself
-
- assert s._deep;
-
- s._hasBacktrack = true;
- s._backtrack = s;
- }
- }
-
- private void tokenizePath ( ArrayList paths )
- throws XPathCompileException
- {
- _lastDeepDot = false;
-
- Step steps = tokenizeSteps();
-
- computeBacktrack( steps );
-
- paths.add( steps );
-
- // If the last path ended in //., that path will match all
- // elements, here I make a path which matches all attributes.
-
- if (_lastDeepDot)
- {
- _sawDeepDot = true;
-
- Step s = null;
-
- for ( Step t = steps ; t != null ; t = t._next )
- {
- if (t._next != null && t._next._next == null)
- s = addStep( t._deep, true, t._name, s );
- else
- s = addStep( t._deep, t._attr, t._name, s );
- }
-
- computeBacktrack( s );
-
- paths.add( s );
- }
- }
-
- private Selector tokenizeSelector ( ) throws XPathCompileException
- {
- ArrayList paths = new ArrayList();
-
- tokenizePath( paths );
-
- while ( tokenize( "|" ) )
- tokenizePath( paths );
-
- return new Selector( (Step[]) paths.toArray( new Step [ 0 ] ) );
- }
-
- private XPath tokenizeXPath ( ) throws XPathCompileException
- {
- for ( ; ; )
- {
- if (tokenize( "declare", "namespace" ))
- {
- if (!parseWhitespace())
- throw newError( "Expected prefix after 'declare namespace'" );
-
- String prefix = tokenizeNCName();
-
- if (!tokenize( "=" ))
- throw newError( "Expected '='" );
-
- String uri = tokenizeQuotedUri();
-
- if (_namespaces.containsKey( prefix ))
- {
- throw newError(
- "Redefinition of namespace prefix: " + prefix );
- }
-
- _namespaces.put( prefix, uri );
-
- //return these to saxon:? Is it an error to pass external NS
- //that conflicts? or should we just override it?
- if (_externalNamespaces.containsKey( prefix ))
- {
- throw newError(
- "Redefinition of namespace prefix: " + prefix );
- }
- _externalNamespaces.put( prefix, uri );
-
- if (! tokenize( ";" ))
- {
-// throw newError(
-// "Namespace declaration must end with ;" );
- }
-
- _externalNamespaces.put(_NS_BOUNDARY,new Integer(_offset));
-
- continue;
- }
-
- if (tokenize( "declare","default", "element", "namespace" ))
- {
- String uri = tokenizeQuotedUri();
-
- if (_namespaces.containsKey( "" ))
- {
- throw newError(
- "Redefinition of default element namespace" );
- }
-
- _namespaces.put( "", uri );
-
- //return these to saxon:? Is it an error to pass external NS
- //that conflicts? or should we just override it?
- if (_externalNamespaces.containsKey( XPath._DEFAULT_ELT_NS ))
- {
- throw newError("Redefinition of default element namespace : ");
- }
- _externalNamespaces.put( XPath._DEFAULT_ELT_NS, uri );
-
- if (! tokenize( ";" ))
- throw newError("Default Namespace declaration must end with ;" );
- //the boundary is the last ; in the prolog...
- _externalNamespaces.put(_NS_BOUNDARY,new Integer(_offset));
-
- continue;
- }
-
- break;
- }
-
- // Add the default prefix mapping if it has not been redefined
-
- if (!_namespaces.containsKey( "" ))
- _namespaces.put( "", "" );
-
- Selector selector = tokenizeSelector();
-
- parseWhitespace();
-
- if (currChar() != -1)
- {
- throw newError(
- "Unexpected char '" + (char) currChar() + "'" );
- }
-
- return new XPath( selector, _sawDeepDot );
- }
-
- //split of prolog decls that are not standard XPath syntax
- //but work in v1
- private void processNonXpathDecls(){
-
- }
-
- private String _expr;
-
- private boolean _sawDeepDot; // Saw one overall
- private boolean _lastDeepDot;
-
- private String _currentNodeVar;
-
- // private Map _namespaces;
- protected Map _namespaces;
- private Map _externalNamespaces;
-
- private int _offset;
- private int _line;
- private int _column;
- }
-
- private static final class Step
- {
- Step ( boolean deep, boolean attr, QName name )
- {
- _name = name;
-
- _deep = deep;
- _attr = attr;
-
- int flags = 0;
-
- if (_deep || !_attr)
- flags |= ExecutionContext.DESCEND;
-
- if (_attr)
- flags |= ExecutionContext.ATTRS;
-
- _flags = flags;
- }
-
- boolean isWild ( )
- {
- return _name.getLocalPart().length() == 0;
- }
-
- boolean match ( QName name )
- {
- String local = _name.getLocalPart();
- String nameLocal = name.getLocalPart();
- String uri;
- String nameUri;
-
- int localLength = local.length();
- int uriLength;
-
- // match any name to _name when _name is empty ""@""
- if (localLength==0)
- {
- uri = _name.getNamespaceURI();
- uriLength = uri.length();
-
- if (uriLength==0)
- return true;
-
- return uri.equals(name.getNamespaceURI());
- }
-
- if (localLength!=nameLocal.length())
- return false;
-
- uri = _name.getNamespaceURI();
- nameUri = name.getNamespaceURI();
-
- if (uri.length()!=nameUri.length())
- return false;
-
- return local.equals(nameLocal) && uri.equals(nameUri);
- }
-
- final boolean _attr;
- final boolean _deep;
-
- int _flags;
-
- final QName _name;
-
- Step _next, _prev;
-
- boolean _hasBacktrack;
- Step _backtrack;
- }
-
- private static final class Selector
- {
- Selector ( Step[] paths )
- {
- _paths = paths;
- }
-
- final Step[] _paths;
- }
-
- //
- //
- //
-
- private XPath ( Selector selector, boolean sawDeepDot )
- {
- _selector = selector;
- _sawDeepDot = sawDeepDot;
- }
-
- public boolean sawDeepDot ( )
- {
- return _sawDeepDot;
- }
-
- public static final String _NS_BOUNDARY = "$xmlbeans!ns_boundary";
- public static final String _DEFAULT_ELT_NS = "$xmlbeans!default_uri";
- private final Selector _selector;
- private final boolean _sawDeepDot;
-}
\ No newline at end of file
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlErrorPrinter.java b/src/common/org/apache/xmlbeans/impl/common/XmlErrorPrinter.java
deleted file mode 100644
index eae88ac..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/XmlErrorPrinter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import org.apache.xmlbeans.XmlError;
-
-import java.util.AbstractCollection;
-import java.util.Iterator;
-import java.util.Collections;
-import java.net.URI;
-
-public class XmlErrorPrinter extends AbstractCollection
-{
- private boolean _noisy;
- private URI _baseURI;
-
- public XmlErrorPrinter(boolean noisy, URI baseURI)
- {
- _noisy = noisy;
- _baseURI = baseURI;
- }
-
- public boolean add(Object o)
- {
- if (o instanceof XmlError)
- {
- XmlError err = (XmlError)o;
- if (err.getSeverity() == XmlError.SEVERITY_ERROR ||
- err.getSeverity() == XmlError.SEVERITY_WARNING)
- System.err.println(err.toString(_baseURI));
- else if (_noisy)
- System.out.println(err.toString(_baseURI));
- }
- return false;
- }
-
- public Iterator iterator()
- {
- return Collections.EMPTY_LIST.iterator();
- }
-
- public int size()
- {
- return 0;
- }
-}
-
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlErrorWatcher.java b/src/common/org/apache/xmlbeans/impl/common/XmlErrorWatcher.java
deleted file mode 100644
index d802590..0000000
--- a/src/common/org/apache/xmlbeans/impl/common/XmlErrorWatcher.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.xmlbeans.impl.common;
-
-import org.apache.xmlbeans.XmlError;
-
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Collections;
-
-public class XmlErrorWatcher extends AbstractCollection
-{
- private Collection _underlying;
- private XmlError _firstError;
-
- public XmlErrorWatcher(Collection underlying)
- {
- _underlying = underlying;
- }
-
- public boolean add(Object o)
- {
- if (_firstError == null && o instanceof XmlError && ((XmlError)o).getSeverity() == XmlError.SEVERITY_ERROR)
- _firstError = (XmlError)o;
- if (_underlying == null)
- return false;
- return _underlying.add(o);
- }
-
- public Iterator iterator()
- {
- if (_underlying == null)
- return Collections.EMPTY_LIST.iterator();
-
- return _underlying.iterator();
- }
-
- public int size()
- {
- if (_underlying == null)
- return 0;
-
- return _underlying.size();
- }
-
- public boolean hasError()
- {
- return _firstError != null;
- }
-
- public XmlError firstError()
- {
- return _firstError;
- }
-}
diff --git a/src/jamsupport/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocTigerDelegateImpl_150.java b/src/jamsupport/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocTigerDelegateImpl_150.java
deleted file mode 100644
index a5583f4..0000000
--- a/src/jamsupport/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocTigerDelegateImpl_150.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.xmlbeans.impl.jam.internal.javadoc;
-
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.ExecutableMemberDoc;
-import com.sun.javadoc.Parameter;
-import com.sun.javadoc.ProgramElementDoc;
-import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
-import org.apache.xmlbeans.impl.jam.provider.JamLogger;
-import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
-import org.apache.xmlbeans.impl.jam.mutable.MClass;
-
-
-/**
- * This class is required by JAM so it runs under JDK1.5
- * Since XmlBeans doesn't require 1.5 in order to run
- * this stub replaces the real impl.
- */
-public final class JavadocTigerDelegateImpl_150 extends JavadocTigerDelegate
-{
- public void init(ElementContext ctx)
- {}
-
- public void init(JamLogger logger)
- {}
-
- public void populateAnnotationTypeIfNecessary(ClassDoc cd,
- MClass clazz,
- JavadocClassBuilder builder)
- {
- }
-
-
- // ========================================================================
- // OLD STUFF remove someday
-
-
- public void extractAnnotations(MAnnotatedElement dest, ProgramElementDoc src)
- {
- }
-
- public void extractAnnotations(MAnnotatedElement dest,
- ExecutableMemberDoc method,
- Parameter src)
- {
- }
-
- public boolean isEnum(ClassDoc cd)
- {
- return false; // under 1.4, nothing is enum
- }
-}
diff --git a/src/jamsupport/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegateImpl_150.java b/src/jamsupport/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegateImpl_150.java
deleted file mode 100644
index 0fe8a42..0000000
--- a/src/jamsupport/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegateImpl_150.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.xmlbeans.impl.jam.internal.reflect;
-
-import org.apache.xmlbeans.impl.jam.JClass;
-import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
-import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
-import org.apache.xmlbeans.impl.jam.mutable.MClass;
-import org.apache.xmlbeans.impl.jam.mutable.MConstructor;
-import org.apache.xmlbeans.impl.jam.mutable.MField;
-import org.apache.xmlbeans.impl.jam.mutable.MMember;
-import org.apache.xmlbeans.impl.jam.mutable.MParameter;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-
-/**
- * This class is required by JAM so it runs under JDK1.5
- * Since XmlBeans doesn't require 1.5 in order to run
- * this stub replaces the real impl.
- */
-public final class ReflectTigerDelegateImpl_150 extends ReflectTigerDelegate
-{
- // ========================================================================
- // Reflect15Delegate implementation
-
- public void populateAnnotationTypeIfNecessary(Class cd,
- MClass clazz,
- ReflectClassBuilder builder)
- {
- }
-
- public void extractAnnotations(MMember dest, Method src)
- {
- }
-
- public void extractAnnotations(MConstructor dest, Constructor src)
- {
- }
-
- public void extractAnnotations(MField dest, Field src)
- {
- }
-
- public void extractAnnotations(MClass dest, Class src)
- {
- }
-
- public void extractAnnotations(MParameter dest, Method src,
- int paramNum)
- {
- }
-
- public void extractAnnotations(MParameter dest, Constructor src,
- int paramNum)
- {
- }
-
- public boolean isEnum(Class clazz)
- { return false; }
-
- public Constructor getEnclosingConstructor(Class clazz)
- {
- return null; // JDK1.4 doesn't support this
- }
-
- public Method getEnclosingMethod(Class clazz)
- {
- return null; // JDK1.4 doesn't support this
- }
-}
diff --git a/src/main/java/org/apache/xmlbeans/BindingConfig.java b/src/main/java/org/apache/xmlbeans/BindingConfig.java
new file mode 100755
index 0000000..93bd145
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/BindingConfig.java
@@ -0,0 +1,118 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The BindingConfig class is used during compilation to control the generation of java source files.
+ * The default BindingConfig does nothing, but sub-classes should provide more interesting behavior.
+ *
+ * @see XmlBeans#compileXmlBeans(String, SchemaTypeSystem, XmlObject[], BindingConfig, SchemaTypeLoader, Filer, XmlOptions) XmlBeans.compileXmlBeans()
+ */
+public class BindingConfig {
+ private static final InterfaceExtension[] EMPTY_INTERFACE_EXT_ARRAY = new InterfaceExtension[0];
+ private static final PrePostExtension[] EMPTY_PREPOST_EXT_ARRAY = new PrePostExtension[0];
+ private static final UserType[] EMPTY_USER_TYPE_ARRY = new UserType[0];
+
+ public static final int QNAME_TYPE = 1;
+ public static final int QNAME_DOCUMENT_TYPE = 2;
+ public static final int QNAME_ACCESSOR_ELEMENT = 3;
+ public static final int QNAME_ACCESSOR_ATTRIBUTE = 4;
+
+ /**
+ * @param uri the namespace uri
+ * @return the package name for a namespace or null.
+ */
+ public String lookupPackageForNamespace(String uri) {
+ return null;
+ }
+
+ /**
+ * @param uri the namespace uri
+ * @return the prefix applied to each java name for a namespace or null.
+ */
+ public String lookupPrefixForNamespace(String uri) {
+ return null;
+ }
+
+ /**
+ * @param uri the namespace uri
+ * @return Get the suffix applied to each java name for a namespace or null.
+ */
+ public String lookupSuffixForNamespace(String uri) {
+ return null;
+ }
+
+
+ /**
+ * @param qname the qname of the java name
+ * @param kind the type of the qname, which one of {@link #QNAME_TYPE}, {@link #QNAME_DOCUMENT_TYPE},
+ * {@link #QNAME_ACCESSOR_ELEMENT}, {@link #QNAME_ACCESSOR_ATTRIBUTE}
+ * @return Get the java name for a QName of a specific component kind, or null.
+ */
+ public String lookupJavanameForQName(QName qname, int kind) {
+ return null;
+ }
+
+ /**
+ * @return all configured InterfaceExtensions or an empty array.
+ */
+ public InterfaceExtension[] getInterfaceExtensions() {
+ return EMPTY_INTERFACE_EXT_ARRAY;
+ }
+
+ /**
+ * @param fullJavaName the fully qualified java type name
+ * @return all InterfaceExtensions defined for the fully qualified java
+ * type generated from schema compilation or an empty array.
+ */
+ public InterfaceExtension[] getInterfaceExtensions(String fullJavaName) {
+ return EMPTY_INTERFACE_EXT_ARRAY;
+ }
+
+ /**
+ * @return all configued PrePostExtensions or an empty array.
+ */
+ public PrePostExtension[] getPrePostExtensions() {
+ return EMPTY_PREPOST_EXT_ARRAY;
+ }
+
+ /**
+ * @param fullJavaName the fully qualified java type name
+ * @return the PrePostExtension defined for the fully qualified java
+ * type generated from schema compilation or null.
+ */
+ public PrePostExtension getPrePostExtension(String fullJavaName) {
+ return null;
+ }
+
+ /**
+ * @return all defined user types.
+ */
+ public UserType[] getUserTypes() {
+ return EMPTY_USER_TYPE_ARRY;
+ }
+
+ /**
+ * @param qname the qname of the user type
+ * @return a user defined Java type for a given QName.
+ */
+ public UserType lookupUserTypeForQName(QName qname) {
+ return null;
+ }
+
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/CDataBookmark.java b/src/main/java/org/apache/xmlbeans/CDataBookmark.java
similarity index 87%
rename from src/xmlpublic/org/apache/xmlbeans/CDataBookmark.java
rename to src/main/java/org/apache/xmlbeans/CDataBookmark.java
index 7f3cd2a..57f9766 100644
--- a/src/xmlpublic/org/apache/xmlbeans/CDataBookmark.java
+++ b/src/main/java/org/apache/xmlbeans/CDataBookmark.java
@@ -16,19 +16,19 @@
/**
* Represents a CDATA bookmark.
- *
+ *
* When XmlOption UseCDataBookmarks is setted on parse methods,
* the loader will set these CDataBookmarks in the store on the respective
* TEXT fields that were represented as CDATA.
- *
+ *
* Users can modify the 'look' of TEXT fields, by annotating them with
* this bookmark, or remove the bookmark.
- *
+ *
* Additionaly if setted on save methods, the output will look for these
* bookmarks and will output the text as CDATA.
* Note: The SaveCDataEntityCountThreshold and SaveCDataLengthThreshold
* options and their default values still apply.
- *
+ *
* Note: Due to the store representation, a CDATA will not be recognized
* if it is imediately after non CDATA text and all text following it will
* be considered CDATA.
@@ -42,17 +42,14 @@
* @see XmlOptions#setUseCDataBookmarks()
* @see org.apache.xmlbeans.XmlObject.Factory#parse(String, XmlOptions)
* @see org.apache.xmlbeans.XmlObject#save(java.io.OutputStream, XmlOptions)
- * @see XmlOptions#setSaveCDataEntityCountThreshold(int)
+ * @see XmlOptions#setSaveCDataEntityCountThreshold(int)
* @see XmlOptions#setSaveCDataLengthThreshold(int)
- * @author Cezar Andrei (cezar dot andrei at gmail dot com)
*/
-public class CDataBookmark
- extends XmlCursor.XmlBookmark
-{
+public class CDataBookmark extends XmlCursor.XmlBookmark {
/**
* The actual bookmark object representing CData.
* Users must use this bookmark in addition to UseCDataBookmarks
* option to make use of CDATA representation in XML text.
*/
- public static CDataBookmark CDATA_BOOKMARK = new CDataBookmark();
+ public static final CDataBookmark CDATA_BOOKMARK = new CDataBookmark();
}
\ No newline at end of file
diff --git a/src/xmlpublic/org/apache/xmlbeans/DelegateXmlObject.java b/src/main/java/org/apache/xmlbeans/DelegateXmlObject.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/DelegateXmlObject.java
rename to src/main/java/org/apache/xmlbeans/DelegateXmlObject.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/Filer.java b/src/main/java/org/apache/xmlbeans/Filer.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/Filer.java
rename to src/main/java/org/apache/xmlbeans/Filer.java
diff --git a/src/main/java/org/apache/xmlbeans/FilterXmlObject.java b/src/main/java/org/apache/xmlbeans/FilterXmlObject.java
new file mode 100644
index 0000000..b0c2cf8
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/FilterXmlObject.java
@@ -0,0 +1,389 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import java.io.*;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A FilterXmlObject delegates to some other XmlObject, which it can use as
+ * its basic source of data, possibly transforming the data along the way or
+ * providing additional functionality. The class FilterXmlObject itself
+ * simply overrides all methods of XmlObject with versions that pass all
+ * requests to the underlying XmlObject. Subclasses of FilterXmlObject may
+ * further override some of these methods and may also provide additional
+ * methods and fields.
+ *
+ * Note: it is important that FilterXmlObject has no storage (i.e., no
+ * non-transient fields), because subclasses may be serializable and
+ * adding storage would break the serialization format.
+ */
+public abstract class FilterXmlObject implements XmlObject, SimpleValue, DelegateXmlObject {
+ public SchemaType schemaType() {
+ return underlyingXmlObject().schemaType();
+ }
+
+ public boolean validate() {
+ return underlyingXmlObject().validate();
+ }
+
+ public boolean validate(XmlOptions options) {
+ return underlyingXmlObject().validate(options);
+ }
+
+ public XmlObject[] selectPath(String path) {
+ return underlyingXmlObject().selectPath(path);
+ }
+
+ public XmlObject[] selectPath(String path, XmlOptions options) {
+ return underlyingXmlObject().selectPath(path, options);
+ }
+
+ public XmlObject[] execQuery(String query) {
+ return underlyingXmlObject().execQuery(query);
+ }
+
+ public XmlObject[] execQuery(String query, XmlOptions options) {
+ return underlyingXmlObject().execQuery(query, options);
+ }
+
+ public XmlObject changeType(SchemaType newType) {
+ return underlyingXmlObject().changeType(newType);
+ }
+
+ public boolean isNil() {
+ return underlyingXmlObject().isNil();
+ }
+
+ public void setNil() {
+ underlyingXmlObject().setNil();
+ }
+
+ public boolean isImmutable() {
+ return underlyingXmlObject().isImmutable();
+ }
+
+ public XmlObject set(XmlObject srcObj) {
+ return underlyingXmlObject().set(srcObj);
+ }
+
+ public XmlObject copy() {
+ return underlyingXmlObject().copy();
+ }
+
+ public XmlObject copy(XmlOptions options) {
+ return underlyingXmlObject().copy(options);
+ }
+
+ public boolean valueEquals(XmlObject obj) {
+ return underlyingXmlObject().valueEquals(obj);
+ }
+
+ public int valueHashCode() {
+ return underlyingXmlObject().valueHashCode();
+ }
+
+ public int compareTo(Object obj) {
+ return underlyingXmlObject().compareTo(obj);
+ }
+
+ public int compareValue(XmlObject obj) {
+ return underlyingXmlObject().compareValue(obj);
+ }
+
+ public Object monitor() {
+ return underlyingXmlObject().monitor();
+ }
+
+ public XmlDocumentProperties documentProperties() {
+ return underlyingXmlObject().documentProperties();
+ }
+
+ public XmlCursor newCursor() {
+ return underlyingXmlObject().newCursor();
+ }
+
+ public XMLStreamReader newXMLStreamReader() {
+ return underlyingXmlObject().newXMLStreamReader();
+ }
+
+ public String xmlText() {
+ return underlyingXmlObject().xmlText();
+ }
+
+ public InputStream newInputStream() {
+ return underlyingXmlObject().newInputStream();
+ }
+
+ public Reader newReader() {
+ return underlyingXmlObject().newReader();
+ }
+
+ public Node newDomNode() {
+ return underlyingXmlObject().newDomNode();
+ }
+
+ public Node getDomNode() {
+ return underlyingXmlObject().getDomNode();
+ }
+
+ public void save(ContentHandler ch, LexicalHandler lh) throws SAXException {
+ underlyingXmlObject().save(ch, lh);
+ }
+
+ public void save(File file) throws IOException {
+ underlyingXmlObject().save(file);
+ }
+
+ public void save(OutputStream os) throws IOException {
+ underlyingXmlObject().save(os);
+ }
+
+ public void save(Writer w) throws IOException {
+ underlyingXmlObject().save(w);
+ }
+
+ public XMLStreamReader newXMLStreamReader(XmlOptions options) {
+ return underlyingXmlObject().newXMLStreamReader(options);
+ }
+
+ public String xmlText(XmlOptions options) {
+ return underlyingXmlObject().xmlText(options);
+ }
+
+ public InputStream newInputStream(XmlOptions options) {
+ return underlyingXmlObject().newInputStream(options);
+ }
+
+ public Reader newReader(XmlOptions options) {
+ return underlyingXmlObject().newReader(options);
+ }
+
+ public Node newDomNode(XmlOptions options) {
+ return underlyingXmlObject().newDomNode(options);
+ }
+
+ public void save(ContentHandler ch, LexicalHandler lh, XmlOptions options) throws SAXException {
+ underlyingXmlObject().save(ch, lh, options);
+ }
+
+ public void save(File file, XmlOptions options) throws IOException {
+ underlyingXmlObject().save(file, options);
+ }
+
+ public void save(OutputStream os, XmlOptions options) throws IOException {
+ underlyingXmlObject().save(os, options);
+ }
+
+ public void save(Writer w, XmlOptions options) throws IOException {
+ underlyingXmlObject().save(w, options);
+ }
+
+ public SchemaType instanceType() {
+ return ((SimpleValue) underlyingXmlObject()).instanceType();
+ }
+
+ public String getStringValue() {
+ return ((SimpleValue) underlyingXmlObject()).getStringValue();
+ }
+
+ public boolean getBooleanValue() {
+ return ((SimpleValue) underlyingXmlObject()).getBooleanValue();
+ }
+
+ public byte getByteValue() {
+ return ((SimpleValue) underlyingXmlObject()).getByteValue();
+ }
+
+ public short getShortValue() {
+ return ((SimpleValue) underlyingXmlObject()).getShortValue();
+ }
+
+ public int getIntValue() {
+ return ((SimpleValue) underlyingXmlObject()).getIntValue();
+ }
+
+ public long getLongValue() {
+ return ((SimpleValue) underlyingXmlObject()).getLongValue();
+ }
+
+ public BigInteger getBigIntegerValue() {
+ return ((SimpleValue) underlyingXmlObject()).getBigIntegerValue();
+ }
+
+ public BigDecimal getBigDecimalValue() {
+ return ((SimpleValue) underlyingXmlObject()).getBigDecimalValue();
+ }
+
+ public float getFloatValue() {
+ return ((SimpleValue) underlyingXmlObject()).getFloatValue();
+ }
+
+ public double getDoubleValue() {
+ return ((SimpleValue) underlyingXmlObject()).getDoubleValue();
+ }
+
+ public byte[] getByteArrayValue() {
+ return ((SimpleValue) underlyingXmlObject()).getByteArrayValue();
+ }
+
+ public StringEnumAbstractBase getEnumValue() {
+ return ((SimpleValue) underlyingXmlObject()).getEnumValue();
+ }
+
+ public Calendar getCalendarValue() {
+ return ((SimpleValue) underlyingXmlObject()).getCalendarValue();
+ }
+
+ public Date getDateValue() {
+ return ((SimpleValue) underlyingXmlObject()).getDateValue();
+ }
+
+ public GDate getGDateValue() {
+ return ((SimpleValue) underlyingXmlObject()).getGDateValue();
+ }
+
+ public GDuration getGDurationValue() {
+ return ((SimpleValue) underlyingXmlObject()).getGDurationValue();
+ }
+
+ public QName getQNameValue() {
+ return ((SimpleValue) underlyingXmlObject()).getQNameValue();
+ }
+
+ public List> getListValue() {
+ return ((SimpleValue) underlyingXmlObject()).getListValue();
+ }
+
+ public List extends XmlAnySimpleType> xgetListValue() {
+ return ((SimpleValue) underlyingXmlObject()).xgetListValue();
+ }
+
+ public Object getObjectValue() {
+ return ((SimpleValue) underlyingXmlObject()).getObjectValue();
+ }
+
+ public void setStringValue(String obj) {
+ ((SimpleValue) underlyingXmlObject()).setStringValue(obj);
+ }
+
+ public void setBooleanValue(boolean v) {
+ ((SimpleValue) underlyingXmlObject()).setBooleanValue(v);
+ }
+
+ public void setByteValue(byte v) {
+ ((SimpleValue) underlyingXmlObject()).setByteValue(v);
+ }
+
+ public void setShortValue(short v) {
+ ((SimpleValue) underlyingXmlObject()).setShortValue(v);
+ }
+
+ public void setIntValue(int v) {
+ ((SimpleValue) underlyingXmlObject()).setIntValue(v);
+ }
+
+ public void setLongValue(long v) {
+ ((SimpleValue) underlyingXmlObject()).setLongValue(v);
+ }
+
+ public void setBigIntegerValue(BigInteger obj) {
+ ((SimpleValue) underlyingXmlObject()).setBigIntegerValue(obj);
+ }
+
+ public void setBigDecimalValue(BigDecimal obj) {
+ ((SimpleValue) underlyingXmlObject()).setBigDecimalValue(obj);
+ }
+
+ public void setFloatValue(float v) {
+ ((SimpleValue) underlyingXmlObject()).setFloatValue(v);
+ }
+
+ public void setDoubleValue(double v) {
+ ((SimpleValue) underlyingXmlObject()).setDoubleValue(v);
+ }
+
+ public void setByteArrayValue(byte[] obj) {
+ ((SimpleValue) underlyingXmlObject()).setByteArrayValue(obj);
+ }
+
+ public void setEnumValue(StringEnumAbstractBase obj) {
+ ((SimpleValue) underlyingXmlObject()).setEnumValue(obj);
+ }
+
+ public void setCalendarValue(Calendar obj) {
+ ((SimpleValue) underlyingXmlObject()).setCalendarValue(obj);
+ }
+
+ public void setDateValue(Date obj) {
+ ((SimpleValue) underlyingXmlObject()).setDateValue(obj);
+ }
+
+ public void setGDateValue(GDate obj) {
+ ((SimpleValue) underlyingXmlObject()).setGDateValue(obj);
+ }
+
+ public void setGDurationValue(GDuration obj) {
+ ((SimpleValue) underlyingXmlObject()).setGDurationValue(obj);
+ }
+
+ public void setQNameValue(QName obj) {
+ ((SimpleValue) underlyingXmlObject()).setQNameValue(obj);
+ }
+
+ public void setListValue(List> obj) {
+ ((SimpleValue) underlyingXmlObject()).setListValue(obj);
+ }
+
+ public void setObjectValue(Object obj) {
+ ((SimpleValue) underlyingXmlObject()).setObjectValue(obj);
+ }
+
+ public XmlObject[] selectChildren(QName elementName) {
+ return underlyingXmlObject().selectChildren(elementName);
+ }
+
+ public XmlObject[] selectChildren(String elementUri, String elementLocalName) {
+ return underlyingXmlObject().selectChildren(elementUri, elementLocalName);
+ }
+
+ public XmlObject[] selectChildren(QNameSet elementNameSet) {
+ return underlyingXmlObject().selectChildren(elementNameSet);
+ }
+
+ public XmlObject selectAttribute(QName attributeName) {
+ return underlyingXmlObject().selectAttribute(attributeName);
+ }
+
+ public XmlObject selectAttribute(String attributeUri, String attributeLocalName) {
+ return underlyingXmlObject().selectAttribute(attributeUri, attributeLocalName);
+ }
+
+ public XmlObject[] selectAttributes(QNameSet attributeNameSet) {
+ return underlyingXmlObject().selectAttributes(attributeNameSet);
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/GDate.java b/src/main/java/org/apache/xmlbeans/GDate.java
new file mode 100644
index 0000000..81fb6ef
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/GDate.java
@@ -0,0 +1,1089 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * Represents an XML Schema-compatible Gregorian date.
+ *
+ * There are many date types in XML Schema, and this type
+ * represents the natural union of all those types. A GDate
+ * can hold any subset of date fields (Year, Month, Day, Time,
+ * Timezone, or some combination). Wherever the specification
+ * provides guidance, the guidelines in the
+ * XML Schema 1.0 specification
+ * (plus published errata) are followed.
+ *
+ * Instances may separately have values or no values for
+ * the year, month, day-of-month, and time-of-day. Not all
+ * operations are meaningful on all combinations.
+ */
+public final class GDate implements GDateSpecification, java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // XMLSchema spec requires support only for years 1 to 9999, but XMLBeans covers more up to the following limitations
+ // to avoid losing precision when transforming to a java.util.Date
+ static final int MAX_YEAR = 292277265; // is Long.MAX_VALUE ms in years - 1 (for the 11month, 31days, 23h, 59m, 59sec case).
+ static final int MIN_YEAR = -292275295; // is Long.MIN_VALUE ms in years + 1970 + 1
+
+ // for fast equality comparison, hashing, and serialization
+ private transient String _canonicalString;
+ private transient String _string;
+
+ private int _bits;
+ private int _CY;
+ private int _M;
+ private int _D;
+ private int _h;
+ private int _m;
+ private int _s;
+ private BigDecimal _fs;
+ private int _tzsign;
+ private int _tzh;
+ private int _tzm;
+
+
+ /* package */ static final BigDecimal _zero = BigDecimal.ZERO;
+ /* package */ static final BigDecimal _one = BigDecimal.ONE;
+
+ /**
+ * Constructs a GDate based on a lexical representation.
+ */
+ public GDate(CharSequence string) {
+ // first trim XML whitespace
+ int len = string.length();
+ int start = 0;
+ while (len > 0 && isSpace(string.charAt(len - 1))) {
+ len -= 1;
+ }
+ while (start < len && isSpace(string.charAt(start))) {
+ start += 1;
+ }
+
+ // pick optional timezone off the end
+ if (len - start >= 1 && string.charAt(len - 1) == 'Z') {
+ _bits |= HAS_TIMEZONE;
+ len -= 1;
+ } else if (len - start >= 6) {
+ timezone:
+ {
+ int tzsign;
+ int tzhour;
+ int tzminute;
+
+ if (string.charAt(len - 3) != ':') {
+ break timezone;
+ }
+
+ switch (string.charAt(len - 6)) {
+ case '-':
+ tzsign = -1;
+ break;
+ case '+':
+ tzsign = 1;
+ break;
+ default:
+ break timezone;
+ }
+
+ tzhour = twoDigit(string, len - 5);
+ tzminute = twoDigit(string, len - 2);
+ if (tzhour > 14) {
+ throw new IllegalArgumentException("time zone hour must be two digits between -14 and +14");
+ }
+ if (tzminute > 59) {
+ throw new IllegalArgumentException("time zone minute must be two digits between 00 and 59");
+ }
+ _bits |= HAS_TIMEZONE;
+ _tzsign = tzsign;
+ _tzh = tzhour;
+ _tzm = tzminute;
+ len -= 6;
+ }
+ }
+
+ // pick date fields off the beginning if it doesn't look like a time
+ if (start < len && (start + 2 >= len || string.charAt(start + 2) != ':')) {
+ scandate:
+ {
+ // parse year sign
+ boolean negyear = false;
+ if (string.charAt(start) == '-') {
+ negyear = true;
+ start += 1;
+ }
+
+ // scan year digits
+ int value = 0;
+ int digits = -start;
+ char ch;
+ boolean startsWithZero = start < len && digitVal(string.charAt(start)) == 0;
+
+ for (; ; ) {
+ ch = start < len ? string.charAt(start) : '\0';
+ if (!isDigit(ch)) {
+ break;
+ }
+
+ if (startsWithZero && start + digits >= 4) {
+ throw new IllegalArgumentException("year value starting with zero must be 4 or less digits: " + string);
+ }
+
+ value = value * 10 + digitVal(ch);
+ start += 1;
+ }
+ digits += start;
+ if (digits > 9) {
+ throw new IllegalArgumentException("year too long (up to 9 digits)");
+ } else if (digits >= 4) {
+ _bits |= HAS_YEAR;
+ _CY = negyear ? -value : value;
+ if (_CY == 0) {
+ throw new IllegalArgumentException("year must not be zero");
+ }
+ } else if (digits > 0) {
+ throw new IllegalArgumentException("year must be four digits (may pad with zeroes, e.g., 0560)");
+ }
+
+ if (_CY > MAX_YEAR) {
+ throw new IllegalArgumentException("year value not supported: too big, must be less than " + MAX_YEAR);
+ }
+
+ if (_CY < MIN_YEAR) {
+ throw new IllegalArgumentException("year values not supported: too small, must be bigger than " + MIN_YEAR);
+ }
+
+ // hyphen introduces a month
+ if (ch != '-') {
+ if (negyear && !hasYear()) {
+ throw new IllegalArgumentException(); // a single minus
+ } else {
+ break scandate;
+ }
+ }
+ start += 1;
+
+ // two-digit month
+ if (len - start >= 2) {
+ value = twoDigit(string, start);
+ if (value >= 1 && value <= 12) {
+ _bits |= HAS_MONTH;
+ _M = value;
+ start += 2;
+ }
+ }
+
+ // hyphen introduces a day
+ ch = start < len ? string.charAt(start) : '\0';
+ if (ch != '-') {
+ if (!hasMonth()) {
+ throw new IllegalArgumentException(); // minus after a year
+ } else {
+ break scandate;
+ }
+ }
+ start += 1;
+
+ // two-digit day
+ if (len - start >= 2) {
+ value = twoDigit(string, start);
+ if (value >= 1 && value <= 31) {
+ _bits |= HAS_DAY;
+ _D = value;
+ start += 2;
+ }
+ }
+
+ if (!hasDay()) {
+ // error in the original schema spec permits an extra '-' here
+ if (hasMonth() && !hasYear()) {
+ ch = start < len ? string.charAt(start) : '\0';
+ if (ch == '-') {
+ start += 1;
+ break scandate;
+ }
+ }
+ throw new IllegalArgumentException(); // minus after a month
+ }
+ }
+ }
+
+ // time
+ if (start < len) {
+ if (hasYear() || hasMonth() || hasDay()) {
+ if (string.charAt(start) != 'T') {
+ throw new IllegalArgumentException("date and time must be separated by 'T'");
+ }
+ start += 1;
+ }
+
+ if (len < start + 8 || string.charAt(start + 2) != ':' || string.charAt(start + 5) != ':') {
+ throw new IllegalArgumentException();
+ }
+
+ int h = twoDigit(string, start);
+ if (h > 24) {
+ throw new IllegalArgumentException("hour must be between 00 and 23");
+ }
+ int m = twoDigit(string, start + 3);
+ if (m >= 60) {
+ throw new IllegalArgumentException("minute must be between 00 and 59");
+ }
+ int s = twoDigit(string, start + 6);
+ if (s >= 60) {
+ throw new IllegalArgumentException("second must be between 00 and 59");
+ }
+
+ start += 8;
+
+ BigDecimal fs = _zero;
+ if (start < len) {
+ if (string.charAt(start) != '.') {
+ throw new IllegalArgumentException();
+ }
+ if (start + 1 < len) {
+ for (int i = start + 1; i < len; i++) {
+ if (!isDigit(string.charAt(i))) {
+ throw new IllegalArgumentException();
+ }
+ }
+ try {
+ fs = new BigDecimal(string.subSequence(start, len).toString());
+ } catch (Throwable e) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ _bits |= HAS_TIME;
+ _h = h;
+ _m = m;
+ _s = s;
+ _fs = fs;
+ }
+
+ if (hasTime() && _h == 24) {
+ if (_m != 0 || _s != 0 || _fs.compareTo(_zero) != 0) {
+ throw new IllegalArgumentException("if hour is 24, minutes, seconds and fraction must be 0");
+ } else { // normalize to next day if it has date or at least has day
+ if (hasDate()) {
+ GDateBuilder gdb = new GDateBuilder(_CY, _M, _D, _h, _m, _s, _fs, _tzsign, _tzh, _tzm);
+ gdb.normalize24h();
+
+ _D = gdb.getDay();
+ _M = gdb.getMonth();
+ _CY = gdb.getYear();
+ _h = 0;
+ } else if (hasDay()) // if no date only days increment
+ {
+ _D++;
+ _h = 0;
+ }
+ }
+ }
+
+ if (!isValid()) {
+ throw new IllegalArgumentException("invalid date");
+ }
+ }
+
+ /**
+ * Constructs a GDate with the specified year, month, day,
+ * hours, minutes, seconds, and optional fractional seconds, in
+ * an unspecified timezone.
+ *
+ * Note that by not specifying the timezone the GDate
+ * becomes partially unordered with respect to times that
+ * do have a specified timezone.
+ */
+ public GDate(
+ int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fraction) {
+ _bits = HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME;
+
+ _CY = year;
+ _M = month;
+ _D = day;
+ _h = hour;
+ _m = minute;
+ _s = second;
+ _fs = fraction == null ? _zero : fraction;
+
+ if (!isValid()) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Constructs an absolute GDate with the specified year,
+ * month, day, hours, minutes, seconds, and optional fractional
+ * seconds, and in the timezone specified.
+ *
+ * If you wish to have a time or date that isn't in a specified timezone,
+ * then use the constructor that does not include the timezone arguments.
+ */
+ public GDate(
+ int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fraction,
+ int tzSign,
+ int tzHour,
+ int tzMinute) {
+ _bits = HAS_TIMEZONE | HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME;
+
+ _CY = year;
+ _M = month;
+ _D = day;
+ _h = hour;
+ _m = minute;
+ _s = second;
+ _fs = fraction == null ? _zero : fraction;
+ _tzsign = tzSign;
+ _tzh = tzHour;
+ _tzm = tzMinute;
+
+ if (!isValid()) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Constructs a GDate based on a java.util.Date.
+ *
+ * The current offset of the default timezone is used as the timezone.
+ *
+ * For example, if eastern daylight time is in effect at the given
+ * date, the timezone on the east coast of the united states
+ * translates to GMT-05:00 (EST) + 1:00 (DT offset) == GMT-04:00.
+ */
+ public GDate(Date date) {
+ // requires some date math, so ctor lives on GDateBuilder
+ this(new GDateBuilder(date));
+ }
+
+ /**
+ * Constructs a GDate based on a java.util.Calendar.
+ *
+ * If the calendar does not have some fields set, the same absence
+ * of information is reflected in the GDate. Note that
+ * java.util.GregorianCalendar fills in all fields as soon as any
+ * are fetched, so constructing a GDate with the same calendar object
+ * twice may result in a different GDate because of a changed calendar.
+ * Note that org.apache.xmlbeans.XmlCalendar is stable if you re-get a set field,
+ * so it does not have the same problem.
+ */
+ public GDate(Calendar calendar) {
+ // we must scrape the "isSet" information out before accessing anything
+ boolean isSetYear = calendar.isSet(Calendar.YEAR);
+ boolean isSetEra = calendar.isSet(Calendar.ERA);
+ boolean isSetMonth = calendar.isSet(Calendar.MONTH);
+ boolean isSetDay = calendar.isSet(Calendar.DAY_OF_MONTH);
+ boolean isSetHourOfDay = calendar.isSet(Calendar.HOUR_OF_DAY);
+ boolean isSetHour = calendar.isSet(Calendar.HOUR);
+ boolean isSetAmPm = calendar.isSet(Calendar.AM_PM);
+ boolean isSetMinute = calendar.isSet(Calendar.MINUTE);
+ boolean isSetSecond = calendar.isSet(Calendar.SECOND);
+ boolean isSetMillis = calendar.isSet(Calendar.MILLISECOND);
+ boolean isSetZone = calendar.isSet(Calendar.ZONE_OFFSET);
+ boolean isSetDst = calendar.isSet(Calendar.DST_OFFSET);
+
+ if (isSetYear) {
+ int y = calendar.get(Calendar.YEAR);
+ if (isSetEra && calendar instanceof GregorianCalendar) {
+ if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
+ y = -y; //1 - y;
+ }
+ }
+ _bits |= HAS_YEAR;
+ _CY = y;
+ }
+ if (isSetMonth) {
+ _bits |= HAS_MONTH;
+ _M = calendar.get(Calendar.MONTH) + 1; // !!note
+ }
+ if (isSetDay) {
+ _bits |= HAS_DAY;
+ _D = calendar.get(Calendar.DAY_OF_MONTH);
+ }
+ boolean gotTime = false;
+
+ int h = 0;
+ int m = 0;
+ int s = 0;
+ BigDecimal fs = _zero;
+
+ if (isSetHourOfDay) {
+ h = calendar.get(Calendar.HOUR_OF_DAY);
+ gotTime = true;
+ } else if (isSetHour && isSetAmPm) {
+ h = calendar.get(Calendar.HOUR) + calendar.get(Calendar.AM_PM) * 12;
+ gotTime = true;
+ }
+
+ if (isSetMinute) {
+ m = calendar.get(Calendar.MINUTE);
+ gotTime = true;
+ }
+
+ if (isSetSecond) {
+ s = calendar.get(Calendar.SECOND);
+ gotTime = true;
+ }
+
+ if (isSetMillis) {
+ fs = BigDecimal.valueOf(calendar.get(Calendar.MILLISECOND), 3);
+ gotTime = true;
+ }
+
+ if (gotTime) {
+ _bits |= HAS_TIME;
+ _h = h;
+ _m = m;
+ _s = s;
+ _fs = fs;
+ }
+
+ if (isSetZone) {
+ int zoneOffsetInMilliseconds = calendar.get(Calendar.ZONE_OFFSET);
+ if (isSetDst) {
+ zoneOffsetInMilliseconds += calendar.get(Calendar.DST_OFFSET);
+ }
+
+ _bits |= HAS_TIMEZONE;
+ if (zoneOffsetInMilliseconds == 0) {
+ _tzsign = 0;
+ _tzh = 0;
+ _tzm = 0;
+ TimeZone zone = calendar.getTimeZone();
+ String id = zone.getID();
+ if (id != null && id.length() > 3) {
+ switch (id.charAt(3)) {
+ case '+':
+ _tzsign = 1;
+ break; // GMT+00:00
+ case '-':
+ _tzsign = -1;
+ break; // GMT-00:00
+ }
+ }
+ } else {
+ _tzsign = (zoneOffsetInMilliseconds < 0 ? -1 : +1);
+ zoneOffsetInMilliseconds = zoneOffsetInMilliseconds * _tzsign;
+ _tzh = zoneOffsetInMilliseconds / 3600000;
+ _tzm = (zoneOffsetInMilliseconds - _tzh * 3600000) / 60000;
+ }
+ }
+ }
+
+ /**
+ * Constructs a GDate based on another GDateSpecification.
+ */
+ public GDate(GDateSpecification gdate) {
+ if (gdate.hasTimeZone()) {
+ _bits |= HAS_TIMEZONE;
+ _tzsign = gdate.getTimeZoneSign();
+ _tzh = gdate.getTimeZoneHour();
+ _tzm = gdate.getTimeZoneMinute();
+ }
+
+ if (gdate.hasTime()) {
+ _bits |= HAS_TIME;
+ _h = gdate.getHour();
+ _m = gdate.getMinute();
+ _s = gdate.getSecond();
+ _fs = gdate.getFraction();
+ }
+
+ if (gdate.hasDay()) {
+ _bits |= HAS_DAY;
+ _D = gdate.getDay();
+ }
+
+ if (gdate.hasMonth()) {
+ _bits |= HAS_MONTH;
+ _M = gdate.getMonth();
+ }
+
+ if (gdate.hasYear()) {
+ _bits |= HAS_YEAR;
+ _CY = gdate.getYear();
+ }
+ }
+
+ /* package */
+ static boolean isDigit(char ch) {
+ return ((char) (ch - '0') <= '9' - '0'); // char is unsigned
+ }
+
+ /* package */
+ static boolean isSpace(char ch) {
+ switch (ch) {
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /* package */
+ static int digitVal(char ch) {
+ return (ch - '0');
+ }
+
+ private static int twoDigit(CharSequence str, int index) {
+ char ch1 = str.charAt(index);
+ char ch2 = str.charAt(index + 1);
+ if (!isDigit(ch1) || !isDigit(ch2)) {
+ return 100; // not two digits
+ }
+ return digitVal(ch1) * 10 + digitVal(ch2);
+ }
+
+ /**
+ * Returns true: all GDate instances are immutable.
+ */
+ public final boolean isImmutable() {
+ return true;
+ }
+
+ /**
+ * Returns a combination of flags indicating the information
+ * contained by this GDate. The five flags are
+ * HAS_TIMEZONE, HAS_YEAR, HAS_MONTH, HAS_DAY, and HAS_TIME.
+ */
+ public int getFlags() {
+ return _bits;
+ }
+
+ /**
+ * True if this date/time specification specifies a timezone.
+ */
+ public final boolean hasTimeZone() {
+ return ((_bits & HAS_TIMEZONE) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a year.
+ */
+ public final boolean hasYear() {
+ return ((_bits & HAS_YEAR) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a month-of-year.
+ */
+ public final boolean hasMonth() {
+ return ((_bits & HAS_MONTH) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a day-of-month.
+ */
+ public final boolean hasDay() {
+ return ((_bits & HAS_DAY) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a time-of-day.
+ */
+ public final boolean hasTime() {
+ return ((_bits & HAS_TIME) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a full date (year, month, day)
+ */
+ public final boolean hasDate() {
+ return ((_bits & (HAS_DAY | HAS_MONTH | HAS_YEAR)) == (HAS_DAY | HAS_MONTH | HAS_YEAR));
+ }
+
+ /**
+ * Gets the year. Should be a four-digit year specification.
+ */
+ public final int getYear() {
+ return _CY;
+ }
+
+ /**
+ * Gets the month-of-year. January is 1.
+ */
+ public final int getMonth() {
+ return _M;
+ }
+
+ /**
+ * Gets the day-of-month. The first day of each month is 1.
+ */
+ public final int getDay() {
+ return _D;
+ }
+
+ /**
+ * Gets the hour-of-day. Midnight is 0, and 11PM is 23.
+ */
+ public final int getHour() {
+ return _h;
+ }
+
+ /**
+ * Gets the minute-of-hour. Range from 0 to 59.
+ */
+ public final int getMinute() {
+ return _m;
+ }
+
+ /**
+ * Gets the second-of-minute. Range from 0 to 59.
+ */
+ public final int getSecond() {
+ return _s;
+ }
+
+ /**
+ * Gets the fraction-of-second. Range from 0 (inclusive) to 1 (exclusive).
+ */
+ public final BigDecimal getFraction() {
+ return _fs;
+ }
+
+ /**
+ * Gets the time zone sign. For time zones east of GMT,
+ * this is positive; for time zones west, this is negative.
+ */
+ public final int getTimeZoneSign() {
+ return _tzsign;
+ }
+
+ /**
+ * Gets the time zone hour.
+ *
+ * This is always positive: for the sign, look at
+ * getTimeZoneSign().
+ */
+ public final int getTimeZoneHour() {
+ return _tzh;
+ }
+
+ /**
+ * Gets the time zone minutes.
+ *
+ * This is always positive: for the sign, look at
+ * getTimeZoneSign().
+ */
+ public final int getTimeZoneMinute() {
+ return _tzm;
+ }
+
+ /**
+ * Gets the rounded millisecond value. Range from 0 to 999
+ */
+ public int getMillisecond() {
+ if (_fs == null) {
+ return 0;
+ }
+ return _fs.setScale(3, RoundingMode.DOWN).unscaledValue().intValue();
+ }
+
+ /**
+ * The canonical string representation. Specific moments or
+ * times-of-day in a specified timezone are normalized to
+ * UTC time to produce a canonical string form for them.
+ * Other recurring time specifications keep their timezone
+ * information.
+ */
+ public String canonicalString() {
+ ensureCanonicalString();
+ return _canonicalString;
+ }
+
+ /**
+ * True if this GDate corresponds to a valid gregorian date value
+ * in XML schema.
+ */
+ public boolean isValid() {
+ return GDateBuilder.isValidGDate(this);
+ }
+
+ /**
+ * Returns the Julian date corresponding to this Gregorian date.
+ * The Julian date (JD) is a continuous count of days from
+ * 1 January 4713 BC.
+ */
+ public int getJulianDate() {
+ return GDateBuilder.julianDateForGDate(this);
+ }
+
+ /**
+ * Retrieves the value of the current time as an {@link XmlCalendar}.
+ *
+ * {@link XmlCalendar} is a subclass of {@link java.util.GregorianCalendar}
+ * which is slightly customized to match XML schema date rules.
+ *
+ * The returned {@link XmlCalendar} has only those time and date fields
+ * set that are reflected in the GDate object. Because of the way the
+ * {@link java.util.Calendar} contract works, any information in the isSet() vanishes
+ * as soon as you view any unset field using get() methods.
+ * This means that if it is important to understand which date fields
+ * are set, you must call isSet() first before get().
+ */
+ public XmlCalendar getCalendar() {
+ return new XmlCalendar(this);
+ }
+
+
+ /**
+ * Retrieves the value of the current time as a java.util.Date
+ * instance.
+ */
+ public Date getDate() {
+ return GDateBuilder.dateForGDate(this);
+ }
+
+ /**
+ * Comparison to another GDate.
+ *
+ *
Returns -1 if this < date. (less-than)
+ *
Returns 0 if this == date. (equal)
+ *
Returns 1 if this > date. (greater-than)
+ *
Returns 2 if this <> date. (incomparable)
+ *
+ * Two instances are incomparable if they have different amounts
+ * of information.
+ */
+ public int compareToGDate(GDateSpecification datespec) {
+ return GDateBuilder.compareGDate(this, datespec);
+ }
+
+ /**
+ * Returns the builtin type code for the shape of the information
+ * contained in this instance, or 0 if the
+ * instance doesn't contain information corresponding to a
+ * Schema type.
+ *
+ * Value will be equal to
+ * {@link SchemaType#BTC_NOT_BUILTIN},
+ * {@link SchemaType#BTC_G_YEAR},
+ * {@link SchemaType#BTC_G_YEAR_MONTH},
+ * {@link SchemaType#BTC_G_MONTH},
+ * {@link SchemaType#BTC_G_MONTH_DAY},
+ * {@link SchemaType#BTC_G_DAY},
+ * {@link SchemaType#BTC_DATE},
+ * {@link SchemaType#BTC_DATE_TIME}, or
+ * {@link SchemaType#BTC_TIME}.
+ */
+ public int getBuiltinTypeCode() {
+ return GDateBuilder.btcForFlags(_bits);
+ }
+
+ /**
+ * Adds a duration to this GDate, and returns a new GDate.
+ */
+ public GDate add(GDurationSpecification duration) {
+ GDateBuilder builder = new GDateBuilder(this);
+ builder.addGDuration(duration);
+ return builder.toGDate();
+ }
+
+ /**
+ * Adds a duration to this GDate, and returns a new GDate.
+ */
+ public GDate subtract(GDurationSpecification duration) {
+ GDateBuilder builder = new GDateBuilder(this);
+ builder.subtractGDuration(duration);
+ return builder.toGDate();
+ }
+
+ /**
+ * GDate is an immutable class, and equality is computed based
+ * on its canonical value.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof GDate)) {
+ return false;
+ }
+
+ ensureCanonicalString();
+ return _canonicalString.equals(((GDate) obj).canonicalString());
+ }
+
+ /**
+ * Returns a hash code for this GDate.
+ */
+ public int hashCode() {
+ ensureCanonicalString();
+ return _canonicalString.hashCode();
+ }
+
+ /**
+ * The canonical string representation. Specific moments or
+ * times-of-day in a specified timezone are normalized to
+ * UTC time to produce a canonical string form for them.
+ * Other recurring time specifications keep their timezone
+ * information.
+ */
+ private void ensureCanonicalString() {
+ if (_canonicalString != null) {
+ return;
+ }
+
+ boolean needNormalize =
+ (hasTimeZone() && getTimeZoneSign() != 0 && hasTime() &&
+ ((hasDay() == hasMonth() && hasDay() == hasYear())));
+
+ if (!needNormalize && getFraction() != null && getFraction().scale() > 0) {
+ BigInteger bi = getFraction().unscaledValue();
+ needNormalize = (bi.mod(GDateBuilder.TEN).signum() == 0);
+ }
+
+ if (!needNormalize) {
+ _canonicalString = toString();
+ } else {
+ GDateBuilder gdb = new GDateBuilder(this);
+ gdb.normalize();
+ _canonicalString = gdb.toString();
+ }
+ }
+
+ /**
+ * The natural string representation. This represents the information
+ * that is available, including timezone. For types that correspond
+ * to defined schema types (schemaBuiltinTypeCode() > 0),
+ * this provides the natural lexical representation.
+ *
+ * When both time and timezone are specified, this string is not
+ * the canonical representation unless the timezone is UTC (Z)
+ * (since the same moment in time can be expressed in different
+ * timezones). To get a canonical string, use the canonicalString()
+ * method.
+ */
+ public String toString() {
+ if (_string == null) {
+ _string = formatGDate(this);
+ }
+ return _string;
+ }
+
+ private final static char[] _tensDigit =
+ {
+ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
+ '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
+ '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
+ '3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
+ '4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
+ '5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
+ '6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
+ '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
+ '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
+ '9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
+ };
+ private final static char[] _onesDigit =
+ {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ };
+
+ private static int _padTwoAppend(char[] b, int i, int n) {
+ assert (n >= 0 && n < 100);
+ b[i] = _tensDigit[n];
+ b[i + 1] = _onesDigit[n];
+ return i + 2;
+ }
+
+ private static int _padFourAppend(char[] b, int n) {
+ int i = 0;
+ if (n < 0) {
+ b[i++] = '-';
+ n = -n;
+ }
+ if (n >= 10000) {
+ String s = Integer.toString(n);
+ s.getChars(0, s.length(), b, i);
+ return i + s.length();
+ }
+ int q = n / 100;
+ int r = n - q * 100;
+ b[i] = _tensDigit[q];
+ b[i + 1] = _onesDigit[q];
+ b[i + 2] = _tensDigit[r];
+ b[i + 3] = _onesDigit[r];
+ return i + 4;
+ }
+
+ private static final TimeZone GMTZONE = TimeZone.getTimeZone("GMT");
+ private static final TimeZone[] MINUSZONE =
+ {
+ TimeZone.getTimeZone("GMT-00:00"),
+ TimeZone.getTimeZone("GMT-01:00"),
+ TimeZone.getTimeZone("GMT-02:00"),
+ TimeZone.getTimeZone("GMT-03:00"),
+ TimeZone.getTimeZone("GMT-04:00"),
+ TimeZone.getTimeZone("GMT-05:00"),
+ TimeZone.getTimeZone("GMT-06:00"),
+ TimeZone.getTimeZone("GMT-07:00"),
+ TimeZone.getTimeZone("GMT-08:00"),
+ TimeZone.getTimeZone("GMT-09:00"),
+ TimeZone.getTimeZone("GMT-10:00"),
+ TimeZone.getTimeZone("GMT-11:00"),
+ TimeZone.getTimeZone("GMT-12:00"),
+ TimeZone.getTimeZone("GMT-13:00"),
+ TimeZone.getTimeZone("GMT-14:00"),
+ };
+ private static final TimeZone[] PLUSZONE =
+ {
+ TimeZone.getTimeZone("GMT+00:00"),
+ TimeZone.getTimeZone("GMT+01:00"),
+ TimeZone.getTimeZone("GMT+02:00"),
+ TimeZone.getTimeZone("GMT+03:00"),
+ TimeZone.getTimeZone("GMT+04:00"),
+ TimeZone.getTimeZone("GMT+05:00"),
+ TimeZone.getTimeZone("GMT+06:00"),
+ TimeZone.getTimeZone("GMT+07:00"),
+ TimeZone.getTimeZone("GMT+08:00"),
+ TimeZone.getTimeZone("GMT+09:00"),
+ TimeZone.getTimeZone("GMT+10:00"),
+ TimeZone.getTimeZone("GMT+11:00"),
+ TimeZone.getTimeZone("GMT+12:00"),
+ TimeZone.getTimeZone("GMT+13:00"),
+ TimeZone.getTimeZone("GMT+14:00"),
+ };
+
+ /* package */
+ static TimeZone timeZoneForGDate(GDateSpecification date) {
+ // use a cached timezone if integral; otherwise make a new one.
+ if (!date.hasTimeZone()) {
+ return TimeZone.getDefault();
+ }
+ if (date.getTimeZoneSign() == 0) {
+ return GMTZONE;
+ }
+ if (date.getTimeZoneMinute() == 0 && date.getTimeZoneHour() <= 14 && date.getTimeZoneHour() >= 0) {
+ return date.getTimeZoneSign() < 0 ? MINUSZONE[date.getTimeZoneHour()] : PLUSZONE[date.getTimeZoneHour()];
+ }
+
+ char[] zb = new char[9];
+ zb[0] = 'G';
+ zb[1] = 'M';
+ zb[2] = 'T';
+ zb[3] = (date.getTimeZoneSign() < 0) ? '-' : '+';
+ GDate._padTwoAppend(zb, 4, date.getTimeZoneHour());
+ zb[6] = ':';
+ GDate._padTwoAppend(zb, 7, date.getTimeZoneMinute());
+ return TimeZone.getTimeZone(new String(zb));
+ }
+
+ /* package */
+ static String formatGDate(GDateSpecification spec) {
+ // We've used a char[] rather than a StringBuffer for a 4x speedup
+ // -YY(10)YY-MM-DDTHH:MM:SS.FFFFFF+ZH:ZM
+ // 1 + 10 + 3+ 3+ 3+ 3+ 3+1 + s + 3+ 3 = 33 + s
+ BigDecimal fs = spec.getFraction();
+ char[] message = new char[33 + (fs == null ? 0 : fs.scale())];
+ int i = 0;
+
+ if (spec.hasYear() || spec.hasMonth() || spec.hasDay()) {
+ dmy:
+ {
+ if (spec.hasYear()) {
+ i = _padFourAppend(message, spec.getYear());
+ } else {
+ message[i++] = '-';
+ }
+
+ if (!(spec.hasMonth() || spec.hasDay())) {
+ break dmy;
+ }
+
+ message[i++] = '-';
+ if (spec.hasMonth()) {
+ i = _padTwoAppend(message, i, spec.getMonth());
+ }
+
+ if (!spec.hasDay()) {
+ break dmy;
+ }
+
+ message[i++] = '-';
+ i = _padTwoAppend(message, i, spec.getDay());
+ }
+ if (spec.hasTime()) {
+ message[i++] = 'T';
+ }
+ }
+
+ if (spec.hasTime()) {
+ i = _padTwoAppend(message, i, spec.getHour());
+ message[i++] = ':';
+ i = _padTwoAppend(message, i, spec.getMinute());
+ message[i++] = ':';
+ i = _padTwoAppend(message, i, spec.getSecond());
+ if (fs != null && !_zero.equals(fs)) // (optimization ~3%)
+ {
+ String frac = fs.toString();
+ int point = frac.indexOf('.');
+ if (point >= 0) {
+ frac.getChars(point, frac.length(), message, i);
+ i += frac.length() - point;
+ }
+ }
+ }
+
+ if (spec.hasTimeZone()) {
+ if (spec.getTimeZoneSign() == 0) {
+ message[i++] = 'Z';
+ } else {
+ message[i++] = spec.getTimeZoneSign() > 0 ? '+' : '-';
+ i = _padTwoAppend(message, i, spec.getTimeZoneHour());
+ message[i++] = ':';
+ i = _padTwoAppend(message, i, spec.getTimeZoneMinute());
+ }
+ }
+
+ // it would be nice to use (0, i, message) ctor instead
+ return new String(message, 0, i);
+ }
+
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/GDateBuilder.java b/src/main/java/org/apache/xmlbeans/GDateBuilder.java
new file mode 100644
index 0000000..4388b75
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/GDateBuilder.java
@@ -0,0 +1,1527 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * Used to build {@link GDate GDates}.
+ *
+ * Like GDate, a GDateBuilder represents an Gregorian Date, Time,
+ * and Timezone, or subset of information (Year, Month, Day,
+ * Time, Timezone, or some combination). Wherever it provides
+ * guidance, the XML Schema 1.0 specification (plus published
+ * errata) is followed.
+ *
+ * Instances may separately set or clear the year, month,
+ * day-of-month, and time-of-day. Not all operations are
+ * meaningful on all combinations. In particular, timezone
+ * normalization is only possible if there is a time, or
+ * a time together with a full date.
+ */
+public final class GDateBuilder implements GDateSpecification, java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private int _bits;
+ private int _CY;
+ private int _M;
+ private int _D;
+ private int _h;
+ private int _m;
+ private int _s;
+ private BigDecimal _fs;
+ private int _tzsign;
+ private int _tzh;
+ private int _tzm;
+
+ /**
+ * Constructs a GDateBuilder specifying no date or time
+ */
+ public GDateBuilder() {
+ }
+
+ /**
+ * Builds another GDateBuilder with the same value
+ * as this one.
+ */
+ public Object clone() {
+ return new GDateBuilder(this);
+ }
+
+ /**
+ * Builds a GDate from this GDateBuilder.
+ */
+ public GDate toGDate() {
+ return new GDate(this);
+ }
+
+ /**
+ * Construts a GDateBuilder by copying another GDateSpecificaiton.
+ */
+ public GDateBuilder(GDateSpecification gdate) {
+ if (gdate.hasTimeZone()) {
+ setTimeZone(gdate.getTimeZoneSign(), gdate.getTimeZoneHour(), gdate.getTimeZoneMinute());
+ }
+
+ if (gdate.hasTime()) {
+ setTime(gdate.getHour(), gdate.getMinute(), gdate.getSecond(), gdate.getFraction());
+ }
+
+ if (gdate.hasDay()) {
+ setDay(gdate.getDay());
+ }
+
+ if (gdate.hasMonth()) {
+ setMonth(gdate.getMonth());
+ }
+
+ if (gdate.hasYear()) {
+ setYear(gdate.getYear());
+ }
+ }
+
+ // Forms:
+
+ // Date part:
+ // Year: (-?\d{4,})
+ // YearMonth: (-?\d{4,})-(\d{2})
+ // Date: (-?\d{4,})-(\d{2})-(\d{2})
+ // Month: --(\d{2})(--)? //errata R-48
+ // MonthDay: --(\d{2})-(\d{2})
+ // Day: ---(\d{2})
+
+ // Time part:
+ // Time: (\d{2}):(\d{2}):(\d{2})(.\d*)?
+
+ // Timezone part:
+ // TZ: (Z)|([+-]\d{2}):(\d{2})
+
+ /**
+ * Constructs a GDateBuilder from a lexical
+ * representation. The lexical space contains the
+ * union of the lexical spaces of all the schema
+ * date/time types (except for duration).
+ */
+ public GDateBuilder(CharSequence string) {
+ this(new GDate(string));
+ }
+
+
+ public GDateBuilder(Calendar calendar) {
+ this(new GDate(calendar));
+ }
+
+ /**
+ * Constructs a GDateBuilder with the specified year, month, day,
+ * hours, minutes, seconds, and optional fractional seconds, in
+ * an unspecified timezone.
+ *
+ * Note that by not specifying the timezone the GDateBuilder
+ * becomes partially unordered with respect to timesthat do have a
+ * specified timezone.
+ *
+ * @param year The year
+ * @param month The month, from 1-12
+ * @param day The day of month, from 1-31
+ * @param hour The hour of day, from 0-23
+ * @param minute The minute of hour, from 0-59
+ * @param second The second of minute, from 0-59
+ * @param fraction The fraction of second, 0.0 to 0.999... (may be null)
+ */
+ public GDateBuilder(
+ int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fraction) {
+ _bits = HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME;
+
+ if (year == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ _CY = (year > 0 ? year : year + 1);
+ _M = month;
+ _D = day;
+ _h = hour;
+ _m = minute;
+ _s = second;
+ _fs = fraction == null ? GDate._zero : fraction;
+
+ if (!isValid()) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Constructs an absolute GDateBuilder with the specified year,
+ * month, day, hours, minutes, seconds, and optional fractional
+ * seconds, and in the timezone specified.
+ *
+ * Note that you can reexpress the GDateBuilder in any timezone using
+ * normalizeToTimeZone(). The normalize() method normalizes to UTC.
+ *
+ * If you wish to have a time or date that isn't in a specified timezone,
+ * then use the constructor that does not include the timezone arguments.
+ *
+ * @param year the year
+ * @param month the month, from 1-12
+ * @param day the day of month, from 1-31
+ * @param hour the hour of day, from 0-23
+ * @param minute the minute of hour, from 0-59
+ * @param second the second of minute, from 0-59
+ * @param fraction the fraction of second, 0.0 to 0.999... (may be null)
+ * @param tzSign the timezone offset sign, either +1, 0, or -1
+ * @param tzHour the timezone offset hour
+ * @param tzMinute the timezone offset minute
+ */
+ public GDateBuilder(
+ int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fraction,
+ int tzSign,
+ int tzHour,
+ int tzMinute) {
+ _bits = HAS_TIMEZONE | HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME;
+
+ if (year == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ _CY = (year > 0 ? year : year + 1);
+ _M = month;
+ _D = day;
+ _h = hour;
+ _m = minute;
+ _s = second;
+ _fs = fraction == null ? GDate._zero : fraction;
+ _tzsign = tzSign;
+ _tzh = tzHour;
+ _tzm = tzMinute;
+
+ if (!isValid()) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * Constructs a GDateBuilder based on a java.util.Date.
+ *
+ * The current offset of the default timezone is used as the timezone.
+ *
+ * For example, if eastern daylight time is in effect at the given
+ * date, the timezone on the east coast of the united states
+ * translates to GMT-05:00 (EST) + 1:00 (DT offset) == GMT-04:00.
+ *
+ * @param date the date object to copy
+ */
+ public GDateBuilder(Date date) {
+ setDate(date);
+ }
+
+ /**
+ * True if the instance is immutable.
+ */
+ public boolean isImmutable() {
+ return false;
+ }
+
+ /**
+ * Returns a combination of flags indicating the information
+ * contained by this GDate. The five flags are
+ * HAS_TIMEZONE, HAS_YEAR, HAS_MONTH, HAS_DAY, and HAS_TIME.
+ */
+ public int getFlags() {
+ return _bits;
+ }
+
+ /**
+ * True if this date/time specification specifies a timezone.
+ */
+ public final boolean hasTimeZone() {
+ return ((_bits & HAS_TIMEZONE) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a year.
+ */
+ public final boolean hasYear() {
+ return ((_bits & HAS_YEAR) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a month-of-year.
+ */
+ public final boolean hasMonth() {
+ return ((_bits & HAS_MONTH) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a day-of-month.
+ */
+ public final boolean hasDay() {
+ return ((_bits & HAS_DAY) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a time-of-day.
+ */
+ public final boolean hasTime() {
+ return ((_bits & HAS_TIME) != 0);
+ }
+
+ /**
+ * True if this date/time specification specifies a full date (year, month, day)
+ */
+ public final boolean hasDate() {
+ return ((_bits & (HAS_DAY | HAS_MONTH | HAS_YEAR)) == (HAS_DAY | HAS_MONTH | HAS_YEAR));
+ }
+
+ /**
+ * Gets the year. Should be a four-digit year specification.
+ */
+ public final int getYear() {
+ return (_CY > 0 ? _CY : _CY - 1);
+ }
+
+ /**
+ * Gets the month-of-year. January is 1.
+ */
+ public final int getMonth() {
+ return _M;
+ }
+
+ /**
+ * Gets the day-of-month. The first day of each month is 1.
+ */
+ public final int getDay() {
+ return _D;
+ }
+
+ /**
+ * Gets the hour-of-day. Midnight is 0, and 11PM is 23.
+ */
+ public final int getHour() {
+ return _h;
+ }
+
+ /**
+ * Gets the minute-of-hour. Range from 0 to 59.
+ */
+ public final int getMinute() {
+ return _m;
+ }
+
+ /**
+ * Gets the second-of-minute. Range from 0 to 59.
+ */
+ public final int getSecond() {
+ return _s;
+ }
+
+
+ /**
+ * Gets the fraction-of-second. Range from 0 (inclusive) to 1 (exclusive).
+ */
+ public final BigDecimal getFraction() {
+ return _fs;
+ }
+
+
+ /**
+ * Gets the rounded millisecond value. Range from 0 to 999
+ */
+ public final int getMillisecond() {
+ if (_fs == null || GDate._zero.equals(_fs)) {
+ return 0;
+ }
+ return _fs.setScale(3, RoundingMode.HALF_UP).unscaledValue().intValue();
+ }
+
+ /**
+ * Gets the time zone sign. For time zones east of GMT,
+ * this is positive; for time zones west, this is negative.
+ */
+ public final int getTimeZoneSign() {
+ return _tzsign;
+ }
+
+ /**
+ * Gets the time zone hour.
+ * This is always positive: for the sign, look at
+ * getTimeZoneSign().
+ */
+ public final int getTimeZoneHour() {
+ return _tzh;
+ }
+
+ /**
+ * Gets the time zone minutes.
+ * This is always positive: for the sign, look at
+ * getTimeZoneSign().
+ */
+ public final int getTimeZoneMinute() {
+ return _tzm;
+ }
+
+
+ /**
+ * Sets the year. Should be a four-digit year specification.
+ *
+ * @param year the year
+ */
+ public void setYear(int year) {
+ if (year < GDate.MIN_YEAR || year > GDate.MAX_YEAR) {
+ throw new IllegalArgumentException("year out of range");
+ }
+ if (year == 0) {
+ throw new IllegalArgumentException("year cannot be 0");
+ }
+ _bits |= HAS_YEAR;
+ _CY = (year > 0 ? year : year + 1);
+ }
+
+ /**
+ * Sets the month-of-year. January is 1.
+ *
+ * @param month the month, from 1-12
+ */
+ public void setMonth(int month) {
+ if (month < 1 || month > 12) {
+ throw new IllegalArgumentException("month out of range");
+ }
+ _bits |= HAS_MONTH;
+ _M = month;
+ }
+
+ /**
+ * Sets the day-of-month. The first day of each month is 1.
+ *
+ * @param day the day of month, from 1-31
+ */
+ public void setDay(int day) {
+ if (day < 1 || day > 31) {
+ throw new IllegalArgumentException("day out of range");
+ }
+ _bits |= HAS_DAY;
+ _D = day;
+ }
+
+ /**
+ * Sets the time. Hours in the day range from 0 to 23;
+ * minutes and seconds range from 0 to 59; and fractional
+ * seconds range from 0 (inclusive) to 1 (exclusive).
+ * The fraction can be null and is assumed to be zero.
+ *
+ * @param hour the hour of day, from 0-23 or 24 only if min, sec and fraction are 0
+ * @param minute the minute of hour, from 0-59
+ * @param second the second of minute, from 0-59
+ * @param fraction the fraction of second, 0.0 to 0.999... (may be null)
+ */
+ public void setTime(int hour, int minute, int second, BigDecimal fraction) {
+ if (hour < 0 || hour > 24) {
+ throw new IllegalArgumentException("hour out of range");
+ }
+ if (minute < 0 || minute > 59) {
+ throw new IllegalArgumentException("minute out of range");
+ }
+ if (second < 0 || second > 59) {
+ throw new IllegalArgumentException("second out of range");
+ }
+ if (fraction != null && (fraction.signum() < 0 || GDate._one.compareTo(fraction) <= 0)) {
+ throw new IllegalArgumentException("fraction out of range");
+ }
+ if (hour == 24 && (minute != 0 || second != 0 || (fraction != null && (GDate._zero.compareTo(fraction) != 0)))) {
+ throw new IllegalArgumentException("when hour is 24, min sec and fracton must be 0");
+ }
+
+ _bits |= HAS_TIME;
+ _h = hour;
+ _m = minute;
+ _s = second;
+ _fs = fraction == null ? GDate._zero : fraction;
+ }
+
+ /**
+ * Sets the time zone without changing the other time
+ * fields. If you with to adjust other time fields to express
+ * the same actual moment in time in a different time zone,
+ * use normalizeToTimeZone.
+ *
+ * Timezones must be between -14:00 and +14:00. Sign
+ * must be -1 or 1 (or 0 for UTC only), and the offset hours
+ * and minute arguments must be nonnegative.
+ *
+ * @param tzSign the timezone offset sign, either +1, 0, or -1
+ * @param tzHour the timezone offset hour
+ * @param tzMinute the timezone offset minute
+ */
+ public void setTimeZone(int tzSign, int tzHour, int tzMinute) {
+ if (!((tzSign == 0 && tzHour == 0 && tzMinute == 0) ||
+ ((tzSign == -1 || tzSign == 1) &&
+ (tzHour >= 0 && tzMinute >= 0) &&
+ (tzHour == 14 && tzMinute == 0 || tzHour < 14 && tzMinute < 60)))) {
+ throw new IllegalArgumentException("time zone out of range (-14:00 to +14:00). (" +
+ (tzSign < 0 ? "-" : "+") + tzHour + ":" + tzMinute + ")");
+ }
+
+ _bits |= HAS_TIMEZONE;
+ _tzsign = tzSign;
+ _tzh = tzHour;
+ _tzm = tzMinute;
+ }
+
+ /**
+ * Sets the time zone based on a number of offset minutes rather
+ * than sign/hour/minute; for example, setTimeZone(-60) is the
+ * same as setTimeZone(-1, 1, 0).
+ */
+ public void setTimeZone(int tzTotalMinutes) {
+ if (tzTotalMinutes < -14 * 60 || tzTotalMinutes > 14 * 60) {
+ throw new IllegalArgumentException("time zone out of range (-840 to 840 minutes). (" + tzTotalMinutes + ")");
+ }
+
+ int tzSign = Integer.compare(tzTotalMinutes, 0);
+ tzTotalMinutes *= tzSign;
+ int tzH = tzTotalMinutes / 60;
+ int tzM = tzTotalMinutes - tzH * 60;
+
+ setTimeZone(tzSign, tzH, tzM);
+ }
+
+ /**
+ * Clears the year. After clearing, hasYear returns false and the
+ * value of getYear is undefined.
+ */
+ public void clearYear() {
+ _bits &= ~HAS_YEAR;
+ _CY = 0;
+ }
+
+ /**
+ * Clears the month-of-year. After clearing. hasMonth returns false and
+ * the value of getMonth is undefined.
+ */
+ public void clearMonth() {
+ _bits &= ~HAS_MONTH;
+ _M = 0;
+ }
+
+ /**
+ * Clears the day-of-month. After clearing. hasDay returns false and
+ * the value of getDay is undefined.
+ */
+ public void clearDay() {
+ _bits &= ~HAS_DAY;
+ _D = 0;
+ }
+
+ /**
+ * Clears the time-of-day.
+ * After clearing. hasTime returns false and
+ * the value of getTime is undefined.
+ */
+ public void clearTime() {
+ _bits &= ~HAS_TIME;
+ _h = 0;
+ _m = 0;
+ _s = 0;
+ _fs = null;
+ }
+
+ /**
+ * Clears the timezone. After clearing. hasTimeZone returns false and
+ * the value of getTimeZoneHour and getTimeZoneMinute are undefined.
+ * Does not change the other time fields.
+ */
+ public void clearTimeZone() {
+ _bits &= ~HAS_TIMEZONE;
+ _tzsign = 0;
+ _tzh = 0;
+ _tzm = 0;
+ }
+
+ /**
+ * True if all date fields lie within their legal ranges. A GDateBuilder
+ * can be invalid, for example, if you change the month to February
+ * and the day-of-month is 31.
+ */
+ public boolean isValid() {
+ return isValidGDate(this);
+ }
+
+ /* package */
+ static boolean isValidGDate(GDateSpecification date) {
+ if (date.hasYear() && date.getYear() == 0) {
+ return false;
+ }
+
+ if (date.hasMonth() && (date.getMonth() < 1 || date.getMonth() > 12)) {
+ return false;
+ }
+
+ if (date.hasDay() &&
+ (date.getDay() < 1 || date.getDay() > 31 ||
+ date.getDay() > 28 &&
+ date.hasMonth() &&
+ (date.hasYear() ?
+ date.getDay() > _maxDayInMonthFor((date.getYear() > 0 ?
+ date.getYear() :
+ date.getYear() + 1),
+ date.getMonth()) :
+ date.getDay() > _maxDayInMonth(date.getMonth())))) {
+ return false;
+ }
+
+ if (date.hasTime() && ((date.getHour() < 0 || date.getHour() > 23 ||
+ date.getMinute() < 0 || date.getMinute() > 59 ||
+ date.getSecond() < 0 || date.getSecond() > 59 ||
+ date.getFraction().signum() < 0 || date.getFraction().compareTo(GDate._one) >= 0)) &&
+ // check for 24:00:00 valid format
+ !(date.getHour() == 24 && date.getMinute() == 0 && date.getSecond() == 0 &&
+ date.getFraction().compareTo(GDate._zero) == 0)) {
+ return false;
+ }
+
+ if (date.hasTimeZone() &&
+ (!((date.getTimeZoneSign() == 0 && date.getTimeZoneHour() == 0 && date.getTimeZoneMinute() == 0) ||
+ ((date.getTimeZoneSign() == -1 || date.getTimeZoneSign() == +1) &&
+ // NB: allow +00:00 and -00:00
+ // (date.getTimeZoneHour() == 0 && date.getTimeZoneMinute() > 0 || date.getTimeZoneHour() > 0 && date.getTimeZoneMinute() >= 0) &&
+ (date.getTimeZoneHour() >= 0 && date.getTimeZoneMinute() >= 0) &&
+ (date.getTimeZoneHour() == 14 && date.getTimeZoneMinute() == 0 || date.getTimeZoneHour() < 14 && date.getTimeZoneMinute() < 60))))) {
+ return false;
+ }
+
+ // everyting looks kosher
+ return true;
+ }
+
+
+ /**
+ * Normalizes the instance, ensuring date and time fields are within
+ * their normal ranges.
+ *
+ * If no timezone or no time is specified, or if a partial date is specified, this
+ * method does nothing, and leaves the timezone information as-is.
+ *
+ * If a time or time and date is specified, this method normalizes the timezone
+ * to UTC.
+ */
+ public void normalize() {
+ // DateTime or Time, with TimeZone: normalize to UTC.
+ // In the process all the fields will be normalized.
+ if (hasDay() == hasMonth() && hasDay() == hasYear() &&
+ hasTimeZone() && hasTime()) {
+ normalizeToTimeZone(0, 0, 0);
+ } else {
+ // No timezone, or incomplete date.
+ _normalizeTimeAndDate();
+ }
+
+ // remove trailing zeros from fractional seconds
+ if (hasTime() && _fs != null && _fs.scale() > 0) {
+ if (_fs.signum() == 0) {
+ _fs = GDate._zero;
+ } else {
+ BigInteger bi = _fs.unscaledValue();
+ String str = bi.toString();
+ int lastzero;
+ for (lastzero = str.length(); lastzero > 0; lastzero -= 1) {
+ if (str.charAt(lastzero - 1) != '0') {
+ break;
+ }
+ }
+ if (lastzero < str.length()) {
+ _fs = _fs.setScale(_fs.scale() - str.length() + lastzero, RoundingMode.UNNECESSARY);
+ }
+ }
+ }
+ }
+
+ /**
+ * Normalizes the instance when hour is 24. If day is present, hour 24 is equivalent to hour 00 next day.
+ */
+ void normalize24h() {
+ if (!hasTime() || getHour() != 24) {
+ return;
+ }
+
+ _normalizeTimeAndDate();
+ }
+
+
+ private void _normalizeTimeAndDate() {
+ long carry = 0;
+
+ if (hasTime()) {
+ carry = _normalizeTime();
+ }
+
+ if (hasDay()) {
+ _D += carry;
+ }
+
+ if (hasDate()) {
+ _normalizeDate();
+ } else if (hasMonth()) {
+ // with incomplete dates, just months can be normalized:
+ // days stay denormalized.
+ if (_M < 1 || _M > 12) {
+ int temp = _M;
+ _M = _modulo(temp, 1, 13);
+ if (hasYear()) {
+ _CY = _CY + (int) _fQuotient(temp, 1, 13);
+ }
+ }
+ }
+ }
+
+ /**
+ * If the time and timezone are known, this method changes the timezone to the
+ * specified UTC offset, altering minutes, hours, day, month, and year as
+ * necessary to ensure that the actual described moment in time is the same.
+ *
+ * It is an error to operate on instances without a time or timezone, or
+ * with a partially specified date.
+ *
+ * @param tzSign the timezone offset sign, either +1, 0, or -1
+ * @param tzHour the timezone offset hour
+ * @param tzMinute the timezone offset minute
+ */
+ public void normalizeToTimeZone(int tzSign, int tzHour, int tzMinute) {
+ if (!((tzSign == 0 && tzHour == 0 && tzMinute == 0) ||
+ ((tzSign == -1 || tzSign == 1) &&
+ (tzHour >= 0 && tzMinute >= 0) &&
+ (tzHour == 14 && tzMinute == 0 || tzHour < 14 && tzMinute < 60)))) {
+ throw new IllegalArgumentException("time zone must be between -14:00 and +14:00");
+ }
+
+ if (!hasTimeZone() || !hasTime()) {
+ throw new IllegalStateException("cannot normalize time zone without both time and timezone");
+ }
+
+ if (!(hasDay() == hasMonth() && hasDay() == hasYear())) {
+ throw new IllegalStateException("cannot do date math without a complete date");
+ }
+
+ int hshift = tzSign * tzHour - _tzsign * _tzh;
+ int mshift = tzSign * tzMinute - _tzsign * _tzm;
+
+ _tzsign = tzSign;
+ _tzh = tzHour;
+ _tzm = tzMinute;
+ addDuration(1, 0, 0, 0, hshift, mshift, 0, null);
+ }
+
+ /**
+ * Normalizes to a time zone specified by a number of offset minutes rather
+ * than sign/hour/minute; for example, normalizeToTimeZone(-60) is the
+ * same as normalizeToTimeZone(-1, 1, 0).
+ */
+ public void normalizeToTimeZone(int tzTotalMinutes) {
+ if (tzTotalMinutes < -14 * 60 || tzTotalMinutes > 14 * 60) {
+ throw new IllegalArgumentException("time zone out of range (-840 to 840 minutes). (" + tzTotalMinutes + ")");
+ }
+
+ int tzSign = Integer.compare(tzTotalMinutes, 0);
+ tzTotalMinutes *= tzSign;
+ int tzH = tzTotalMinutes / 60;
+ int tzM = tzTotalMinutes - tzH * 60;
+
+ normalizeToTimeZone(tzSign, tzH, tzM);
+ }
+
+
+ /**
+ * Adds a given duration to the date/time.
+ *
+ * @param duration the duration to add
+ */
+ public void addGDuration(GDurationSpecification duration) {
+ addDuration(duration.getSign(), duration.getYear(), duration.getMonth(), duration.getDay(),
+ duration.getHour(), duration.getMinute(), duration.getSecond(), duration.getFraction());
+ }
+
+ /**
+ * Subtracts a given duration from the date/time.
+ *
+ * @param duration the duration to subtract
+ */
+ public void subtractGDuration(GDurationSpecification duration) {
+ addDuration(-duration.getSign(), duration.getYear(), duration.getMonth(), duration.getDay(),
+ duration.getHour(), duration.getMinute(), duration.getSecond(), duration.getFraction());
+ }
+
+
+ /**
+ * Normalizes the date by carrying over to the year any months outside 1..12
+ * and carrying over to the month any days outside 1..(days-in-month).
+ */
+ private void _normalizeDate() {
+ if (_M < 1 || _M > 12 || _D < 1 || _D > _maxDayInMonthFor(_CY, _M)) {
+ // fix months first
+ int temp = _M;
+ _M = _modulo(temp, 1, 13);
+ _CY = _CY + (int) _fQuotient(temp, 1, 13);
+
+ // then pull days out
+ int extradays = _D - 1;
+ _D = 1;
+
+ // then use the julian date function to fix
+ setJulianDate(getJulianDate() + extradays);
+ }
+ }
+
+ /**
+ * Normalizes time so that fractions are 0..1(exc), seconds/minutes 0..59,
+ * and hours 0..24. Returns the number of days to carry over from normalizing
+ * away more than 24 hours.
+ */
+ private long _normalizeTime() {
+ long carry = 0;
+ long temp;
+
+ // fractions
+ if (_fs != null && (_fs.signum() < 0 || _fs.compareTo(GDate._one) >= 0)) {
+ BigDecimal bdcarry = _fs.setScale(0, RoundingMode.FLOOR);
+ _fs = _fs.subtract(bdcarry);
+ carry = bdcarry.longValue();
+ }
+
+ if (carry != 0 || _s < 0 || _s > 59 || _m < 0 || _m > 50 || _h < 0 || _h > 23) {
+ // seconds
+ temp = _s + carry;
+ carry = _fQuotient(temp, 60);
+ _s = _mod(temp, 60, carry);
+
+ // minutes
+ temp = _m + carry;
+ carry = _fQuotient(temp, 60);
+ _m = _mod(temp, 60, carry);
+
+ // hours
+ temp = _h + carry;
+ carry = _fQuotient(temp, 24);
+ _h = _mod(temp, 24, carry);
+ }
+
+ return carry;
+ }
+
+ /**
+ * Adds a given duration to the date/time.
+ *
+ * @param sign +1 to add, -1 to subtract
+ * @param year the number of years to add
+ * @param month the number of months to add
+ * @param day the number of days to add
+ * @param hour the number of hours to add
+ * @param minute the number of minutes to add
+ * @param second the number of seconds to add
+ * @param fraction the number of fractional seconds to add (may be null)
+ */
+ public void addDuration(int sign, int year, int month, int day,
+ int hour, int minute, int second, BigDecimal fraction) {
+ boolean timemath = hour != 0 || minute != 0 || second != 0 || fraction != null && fraction.signum() != 0;
+ if (timemath && !hasTime()) {
+ throw new IllegalStateException("cannot do time math without a complete time");
+ }
+ boolean datemath = hasDay() && (day != 0 || timemath);
+ if (datemath && !hasDate()) {
+ throw new IllegalStateException("cannot do date math without a complete date");
+ }
+
+ int temp;
+
+ // months + years are easy
+ if (month != 0 || year != 0) {
+ // Prepare the _D to be pegged before changing month
+ if (hasDay()) {
+ _normalizeDate();
+ }
+
+ // Add months and years
+ temp = _M + sign * month;
+ _M = _modulo(temp, 1, 13);
+ _CY = _CY + sign * year + (int) _fQuotient(temp, 1, 13);
+
+ // In new month, day may need to be pegged before proceeding
+ if (hasDay()) {
+ assert (_D >= 1);
+ temp = _maxDayInMonthFor(_CY, _M);
+ if (_D > temp) {
+ _D = temp;
+ }
+ }
+ }
+
+ long carry = 0;
+
+ if (timemath) {
+ // fractions
+ if (fraction != null && fraction.signum() != 0) {
+ if (_fs.signum() == 0 && sign == 1) {
+ _fs = fraction;
+ } else {
+ _fs = (sign == 1) ? _fs.add(fraction) : _fs.subtract(fraction);
+ }
+ }
+
+ // seconds, minutes, hours
+ _s += sign * second;
+ _m += sign * minute;
+ _h += sign * hour;
+
+ // normalize time
+ carry = _normalizeTime();
+ }
+
+ if (datemath) {
+ // days: may require renormalization
+ _D += sign * day + carry;
+ _normalizeDate();
+ }
+ }
+
+ /**
+ * Given {year,month} computes maximum
+ * number of days for given month
+ */
+ private static int _maxDayInMonthFor(int year, int month) {
+ if (month == 4 || month == 6 || month == 9 || month == 11) {
+ return 30;
+ }
+
+ if (month == 2) {
+ return (_isLeapYear(year) ? 29 : 28);
+ }
+
+ return 31;
+ }
+
+ /**
+ * Given {year,month} computes maximum
+ * number of days for given month
+ */
+ private static int _maxDayInMonth(int month) {
+ if (month == 4 || month == 6 || month == 9 || month == 11) {
+ return 30;
+ }
+
+ if (month == 2) {
+ return 29;
+ }
+
+ return 31;
+ }
+
+ /**
+ * Returns the Julian date corresponding to this Gregorian date.
+ * The Julian date (JD) is a continuous count of days from
+ * 1 January 4713 BC.
+ */
+ public final int getJulianDate() {
+ return julianDateForGDate(this);
+ }
+
+
+ /**
+ * Sets the Gregorian date based on the given Julian date.
+ * The Julian date (JD) is a continuous count of days from
+ * 1 January 4713 BC.
+ *
+ * @param julianday the julian day number
+ */
+ public void setJulianDate(int julianday) {
+ if (julianday < 0) {
+ throw new IllegalArgumentException("date before year -4713");
+ }
+
+ int temp;
+ int qepoc;
+
+ // from http://aa.usno.navy.mil/faq/docs/JD_Formula.html
+ temp = julianday + 68569;
+ qepoc = 4 * temp / 146097;
+ temp = temp - (146097 * qepoc + 3) / 4;
+ _CY = 4000 * (temp + 1) / 1461001;
+ temp = temp - 1461 * _CY / 4 + 31;
+ _M = 80 * temp / 2447;
+ _D = temp - 2447 * _M / 80;
+ temp = _M / 11;
+ _M = _M + 2 - 12 * temp;
+ _CY = 100 * (qepoc - 49) + _CY + temp;
+
+ _bits |= HAS_DAY | HAS_MONTH | HAS_YEAR;
+ }
+
+
+ /**
+ * Sets the current time and date based on a java.util.Date instance.
+ *
+ * The timezone offset used is based on the default TimeZone. (The
+ * default TimeZone is consulted to incorporate daylight savings offsets
+ * if applicable for the current date as well as the base timezone offset.)
+ *
+ * If you wish to normalize the timezone, e.g., to UTC, follow this with
+ * a call to normalizeToTimeZone.
+ *
+ * @param date the Date object to copy
+ */
+ public void setDate(Date date) {
+ // Default timezone
+ TimeZone dtz = TimeZone.getDefault();
+ int offset = dtz.getOffset(date.getTime());
+ int offsetsign = 1;
+ if (offset < 0) {
+ offsetsign = -1;
+ offset = -offset;
+ }
+ int offsetmin = offset / (1000 * 60);
+ int offsethr = offsetmin / 60;
+ offsetmin = offsetmin - offsethr * 60;
+
+ setTimeZone(offsetsign, offsethr, offsetmin);
+
+ // paranoia: tz.getOffset can return fractions of minutes, but we must round
+ int roundedoffset = offsetsign * (offsethr * 60 + offsetmin) * 60 * 1000;
+
+ // midnight
+ setTime(0, 0, 0, GDate._zero);
+
+ // Set to January 1, 1970.
+ // setJulianDate(2440588);
+ _bits |= HAS_DAY | HAS_MONTH | HAS_YEAR;
+ _CY = 1970;
+ _M = 1;
+ _D = 1;
+
+ // Add a duration representing the number of milliseconds
+ addGDuration(new GDuration(1, 0, 0, 0, 0, 0, 0,
+ BigDecimal.valueOf(date.getTime() + roundedoffset, 3)));
+
+ // special case: ss.000 -> ss
+ if (_fs.signum() == 0) {
+ _fs = GDate._zero;
+ }
+ }
+
+ /**
+ * Copies a GDateSpecification, completely replacing the current
+ * information in this GDateBuilder.
+ *
+ * @param gdate the GDateSpecification to copy
+ */
+ public void setGDate(GDateSpecification gdate) {
+ _bits = gdate.getFlags() & (HAS_TIMEZONE | HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME);
+ int year = gdate.getYear();
+ _CY = (year > 0 ? year : year + 1);
+ _M = gdate.getMonth();
+ _D = gdate.getDay();
+ _h = gdate.getHour();
+ _m = gdate.getMinute();
+ _s = gdate.getSecond();
+ _fs = gdate.getFraction();
+ _tzsign = gdate.getTimeZoneSign();
+ _tzh = gdate.getTimeZoneHour();
+ _tzm = gdate.getTimeZoneMinute();
+ }
+
+
+ /**
+ * Retrieves the value of the current time as an {@link XmlCalendar}.
+ *
+ * {@link XmlCalendar} is a subclass of {@link java.util.GregorianCalendar}
+ * which is slightly customized to match XML schema date rules.
+ *
+ * The returned {@link XmlCalendar} has only those time and date fields
+ * set that are reflected in the GDate object. Because of the way the
+ * {@link java.util.Calendar} contract works, any information in the isSet() vanishes
+ * as soon as you view any unset field using get() methods.
+ * This means that if it is important to understand which date fields
+ * are set, you must call isSet() first before get().
+ */
+ public XmlCalendar getCalendar() {
+ return new XmlCalendar(this);
+ }
+
+ /**
+ * Retrieves the value of the current time as a java.util.Date
+ * instance.
+ */
+ public Date getDate() {
+ return dateForGDate(this);
+ }
+
+ /* package */
+ static int julianDateForGDate(GDateSpecification date) {
+ if (!date.hasDate()) {
+ throw new IllegalStateException("cannot do date math without a complete date");
+ }
+
+ // from http://aa.usno.navy.mil/faq/docs/JD_Formula.html
+ int day = date.getDay();
+ int month = date.getMonth();
+ int year = date.getYear();
+ year = (year > 0 ? year : year + 1);
+ int result = day - 32075 + 1461 * (year + 4800 + (month - 14) / 12) / 4 +
+ 367 * (month - 2 - (month - 14) / 12 * 12) / 12 - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4;
+
+ if (result < 0) {
+ throw new IllegalStateException("date too far in the past (year allowed to -4713)");
+ }
+
+ return result;
+ }
+
+ /* package */
+ static Date dateForGDate(GDateSpecification date) {
+ long jDate = julianDateForGDate(date);
+ long to1970Date = jDate - 2440588;
+ long to1970Ms = 1000 * 60 * 60 * 24 * to1970Date;
+
+ to1970Ms += date.getMillisecond();
+ to1970Ms += date.getSecond() * 1000;
+ to1970Ms += date.getMinute() * 60 * 1000;
+ to1970Ms += date.getHour() * 60 * 60 * 1000;
+ if (date.hasTimeZone()) {
+ to1970Ms -= (date.getTimeZoneMinute() * date.getTimeZoneSign()) * 60 * 1000;
+ to1970Ms -= (date.getTimeZoneHour() * date.getTimeZoneSign()) * 60 * 60 * 1000;
+ } else {
+ TimeZone def = TimeZone.getDefault();
+ int offset = def.getOffset(to1970Ms);
+ to1970Ms -= offset;
+ }
+
+ return new Date(to1970Ms);
+ }
+
+ /**
+ * True for leap years.
+ */
+ private static boolean _isLeapYear(int year) {
+ // BUGBUG: Julian calendar?
+ return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
+ }
+
+ /**
+ * fQuotient(a, b) = the greatest integer less than or equal to a/b
+ */
+ private static long _fQuotient(long a, int b) {
+ if ((a < 0) == (b < 0)) {
+ return a / b;
+ }
+
+ return -((b - a - 1) / b);
+ }
+
+ /**
+ * modulo(a, b) = a - fQuotient(a,b)*b
+ */
+ private static int _mod(long a, int b, long quotient) {
+ return (int) (a - quotient * b);
+ }
+
+ /**
+ * modulo(a - low, high - low) + low
+ */
+ private static int _modulo(long temp, int low, int high) {
+ long a = temp - low;
+ int b = high - low;
+ return (_mod(a, b, _fQuotient(a, b)) + low);
+ }
+
+ /**
+ * Quotient(a - low, high - low)
+ */
+ private static long _fQuotient(long temp, int low, int high) {
+ return _fQuotient(temp - low, high - low);
+ }
+
+ /**
+ * Sets to the first possible moment that matches the given
+ * specification.
+ */
+ private void _setToFirstMoment() {
+ // 1584 was the first leap year during which the Gregorian
+ // calendar was in use: seems like the most reasonable "first"
+ // year to use in absence of a year.
+
+ if (!hasYear()) {
+ setYear(1584);
+ }
+
+ if (!hasMonth()) {
+ setMonth(1);
+ }
+
+ if (!hasDay()) {
+ setDay(1);
+ }
+
+ if (!hasTime()) {
+ setTime(0, 0, 0, GDate._zero);
+ }
+ }
+
+ /**
+ * Comparison to another GDate.
+ *
+ *
Returns -1 if this < date. (less-than)
+ *
Returns 0 if this == date. (equal)
+ *
Returns 1 if this > date. (greater-than)
+ *
Returns 2 if this <> date. (incomparable)
+ *
+ * Two instances are incomparable if they have different amounts
+ * of information.
+ *
+ * @param datespec the date to compare against
+ */
+ public final int compareToGDate(GDateSpecification datespec) {
+ return compareGDate(this, datespec);
+ }
+
+
+ /* package */
+ static int compareGDate(GDateSpecification tdate, GDateSpecification datespec) {
+ // same amount of information: looks good
+ int bitdiff = tdate.getFlags() ^ datespec.getFlags();
+
+ if ((bitdiff & (HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME | HAS_TIMEZONE)) == 0) {
+ // If the other date needs to be normalized to
+ // our timezone, make a clone and do so if possible
+ if (tdate.hasTimeZone() &&
+ (datespec.getTimeZoneHour() != tdate.getTimeZoneHour() ||
+ datespec.getTimeZoneMinute() != tdate.getTimeZoneMinute() ||
+ datespec.getTimeZoneSign() != tdate.getTimeZoneSign())) {
+ datespec = new GDateBuilder(datespec);
+
+ int flags = tdate.getFlags() & (HAS_YEAR | HAS_MONTH | HAS_DAY);
+ if (flags != 0 && flags != (HAS_YEAR | HAS_MONTH | HAS_DAY) || !tdate.hasTime()) {
+ // in these cases we'll need to fill in fields
+ ((GDateBuilder) datespec)._setToFirstMoment();
+ tdate = new GDateBuilder(tdate);
+ ((GDateBuilder) tdate)._setToFirstMoment();
+ }
+
+ ((GDateBuilder) datespec).normalizeToTimeZone(tdate.getTimeZoneSign(), tdate.getTimeZoneHour(), tdate.getTimeZoneMinute());
+ }
+
+ // compare by field
+ return fieldwiseCompare(tdate, datespec);
+ }
+
+ // different amounts of information (except timezone): not comparable
+ if ((bitdiff & (HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME)) != 0) {
+ return 2;
+ }
+
+ // The schema spec says we should try to compare with-timezone and
+ // without-timezone specifications... Well, OK, sure, if they say so.
+
+ // We don't have a timezone but the other does: reverse the call
+ if (!tdate.hasTimeZone()) {
+ int result = compareGDate(datespec, tdate);
+ return result == 2 ? 2 : -result;
+ }
+
+ // Now tdate is guaranteed to have a timezone and datespec not.
+
+ // To muck with the times, make clones
+ GDateBuilder pdate = new GDateBuilder(tdate);
+
+ // To cover the one uncovered case: if one date is 02/28 and the
+ // other date is 03/01, shift days closer by one to simulate being
+ // the last day of the month within a leap year
+ if ((tdate.getFlags() & (HAS_YEAR | HAS_MONTH | HAS_DAY)) == (HAS_MONTH | HAS_DAY)) {
+ if (tdate.getDay() == 28 && tdate.getMonth() == 2) {
+ if (datespec.getDay() == 1 && datespec.getMonth() == 3) {
+ pdate.setDay(29);
+ }
+ } else if (datespec.getDay() == 28 && datespec.getMonth() == 2) {
+ if (tdate.getDay() == 1 && tdate.getMonth() == 3) {
+ pdate.setMonth(2);
+ pdate.setDay(29);
+ }
+ }
+ }
+
+ // For timespans, compare by first instant of time
+ // possible. Therefore, fill in Midnight, January 1, 1584 (a leap year)
+ // in absence of other information.
+ pdate._setToFirstMoment();
+
+ // P < Q if P < (Q with time zone +14:00)
+ GDateBuilder qplusdate = new GDateBuilder(datespec);
+ qplusdate._setToFirstMoment();
+ qplusdate.setTimeZone(1, 14, 0);
+ qplusdate.normalizeToTimeZone(tdate.getTimeZoneSign(), tdate.getTimeZoneHour(), tdate.getTimeZoneMinute());
+ if (fieldwiseCompare(pdate, qplusdate) == -1) {
+ return -1;
+ }
+
+ // P > Q if P > (Q with time zone -14:00)
+ GDateBuilder qminusdate = qplusdate;
+ qminusdate.setGDate(datespec);
+ qminusdate._setToFirstMoment();
+ qminusdate.setTimeZone(-1, 14, 0);
+ qminusdate.normalizeToTimeZone(tdate.getTimeZoneSign(), tdate.getTimeZoneHour(), tdate.getTimeZoneMinute());
+ if (fieldwiseCompare(pdate, qminusdate) == 1) {
+ return 1;
+ }
+
+ // P <> Q otherwise
+ return 2;
+ }
+
+ /**
+ * Does a simple most-significant-digit-first comparison,
+ * ignoring any timezone or has/doesn't have issues.
+ * The data must have been digested first.
+ */
+ private static int fieldwiseCompare(GDateSpecification tdate, GDateSpecification date) {
+ if (tdate.hasYear()) {
+ int CY = date.getYear();
+ int TCY = tdate.getYear();
+ if (TCY < CY) {
+ return -1;
+ }
+ if (TCY > CY) {
+ return 1;
+ }
+ }
+ if (tdate.hasMonth()) {
+ int M = date.getMonth();
+ int TM = tdate.getMonth();
+ if (TM < M) {
+ return -1;
+ }
+ if (TM > M) {
+ return 1;
+ }
+ }
+ if (tdate.hasDay()) {
+ int D = date.getDay();
+ int TD = tdate.getDay();
+ if (TD < D) {
+ return -1;
+ }
+ if (TD > D) {
+ return 1;
+ }
+ }
+ if (tdate.hasTime()) {
+ int h = date.getHour();
+ int th = tdate.getHour();
+ if (th < h) {
+ return -1;
+ }
+ if (th > h) {
+ return 1;
+ }
+ int m = date.getMinute();
+ int tm = tdate.getMinute();
+ if (tm < m) {
+ return -1;
+ }
+ if (tm > m) {
+ return 1;
+ }
+ int s = date.getSecond();
+ int ts = tdate.getSecond();
+ if (ts < s) {
+ return -1;
+ }
+ if (ts > s) {
+ return 1;
+ }
+ BigDecimal fs = date.getFraction();
+ BigDecimal tfs = tdate.getFraction();
+ if (tfs == null && fs == null) {
+ return 0;
+ }
+ return (tfs == null ? GDate._zero : tfs).compareTo(fs == null ? GDate._zero : fs);
+ }
+
+ return 0;
+ }
+
+ /**
+ * Returns the builtin type code for the shape of the information
+ * contained in this instance, or 0 if the
+ * instance doesn't contain information corresponding to a
+ * Schema type.
+ *
+ * Value will be equal to
+ * {@link SchemaType#BTC_NOT_BUILTIN},
+ * {@link SchemaType#BTC_G_YEAR},
+ * {@link SchemaType#BTC_G_YEAR_MONTH},
+ * {@link SchemaType#BTC_G_MONTH},
+ * {@link SchemaType#BTC_G_MONTH_DAY},
+ * {@link SchemaType#BTC_G_DAY},
+ * {@link SchemaType#BTC_DATE},
+ * {@link SchemaType#BTC_DATE_TIME}, or
+ * {@link SchemaType#BTC_TIME}.
+ */
+ public final int getBuiltinTypeCode() {
+ return btcForFlags(_bits);
+ }
+
+ /* package */
+ static int btcForFlags(int flags) {
+ switch (flags & (HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME)) {
+ case HAS_YEAR:
+ return SchemaType.BTC_G_YEAR;
+ case HAS_YEAR | HAS_MONTH:
+ return SchemaType.BTC_G_YEAR_MONTH;
+ case HAS_MONTH:
+ return SchemaType.BTC_G_MONTH;
+ case HAS_MONTH | HAS_DAY:
+ return SchemaType.BTC_G_MONTH_DAY;
+ case HAS_DAY:
+ return SchemaType.BTC_G_DAY;
+ case HAS_YEAR | HAS_MONTH | HAS_DAY:
+ return SchemaType.BTC_DATE;
+ case HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME:
+ return SchemaType.BTC_DATE_TIME;
+ case HAS_TIME:
+ return SchemaType.BTC_TIME;
+ default:
+ return SchemaType.BTC_NOT_BUILTIN;
+ }
+ }
+
+ /**
+ * Clears the fields in this GDateBuilder that are not applicable
+ * for the given SchemaType date code. The code should be
+ * {@link SchemaType#BTC_G_YEAR},
+ * {@link SchemaType#BTC_G_YEAR_MONTH},
+ * {@link SchemaType#BTC_G_MONTH},
+ * {@link SchemaType#BTC_G_MONTH_DAY},
+ * {@link SchemaType#BTC_G_DAY},
+ * {@link SchemaType#BTC_DATE},
+ * {@link SchemaType#BTC_DATE_TIME}, or
+ * {@link SchemaType#BTC_TIME}.
+ *
+ * @param typeCode the type code to apply
+ */
+ public void setBuiltinTypeCode(int typeCode) {
+ switch (typeCode) {
+ case SchemaType.BTC_G_YEAR:
+ //HAS_YEAR
+ clearMonth();
+ clearDay();
+ clearTime();
+ return;
+ case SchemaType.BTC_G_YEAR_MONTH:
+ //HAS_YEAR | HAS_MONTH
+ clearDay();
+ clearTime();
+ return;
+ case SchemaType.BTC_G_MONTH:
+ //HAS_MONTH
+ clearYear();
+ clearDay();
+ clearTime();
+ return;
+ case SchemaType.BTC_G_MONTH_DAY:
+ //HAS_MONTH | HAS_DAY
+ clearYear();
+ clearTime();
+ return;
+ case SchemaType.BTC_G_DAY:
+ //HAS_DAY
+ clearYear();
+ clearMonth();
+ clearTime();
+ return;
+ case SchemaType.BTC_DATE:
+ //HAS_YEAR | HAS_MONTH | HAS_DAY
+ clearTime();
+ return;
+ case SchemaType.BTC_DATE_TIME:
+ //HAS_YEAR | HAS_MONTH | HAS_DAY | HAS_TIME
+ return;
+ case SchemaType.BTC_TIME:
+ //HAS_TIME
+ clearYear();
+ clearMonth();
+ clearDay();
+ return;
+ default:
+ throw new IllegalArgumentException("codeType must be one of SchemaType BTC_ DATE TIME related types.");
+ }
+ }
+
+
+ /* package */ static final BigInteger TEN = BigInteger.valueOf(10);
+
+ /**
+ * The canonical string representation. Specific moments or
+ * times-of-day in a specified timezone are normalized to
+ * UTC time to produce a canonical string form for them.
+ * Other recurring time specifications keep their timezone
+ * information.
+ */
+ public String canonicalString() {
+ boolean needNormalize =
+ (hasTimeZone() && getTimeZoneSign() != 0 && hasTime() &&
+ ((hasDay() == hasMonth() && hasDay() == hasYear())));
+
+ if (!needNormalize && getFraction() != null && getFraction().scale() > 0) {
+ BigInteger bi = getFraction().unscaledValue();
+ needNormalize = (bi.mod(TEN).signum() == 0);
+ }
+
+ if (!needNormalize) {
+ return toString();
+ }
+
+ GDateBuilder cdate = new GDateBuilder(this);
+ cdate.normalize();
+ return cdate.toString();
+ }
+
+ /**
+ * The natural string representation. This represents the information
+ * that is available, including timezone. For types that correspond
+ * to defined schema types (schemaBuiltinTypeCode() > 0),
+ * this provides the natural lexical representation.
+ *
+ * When both time and timezone are specified, this string is not
+ * the canonical representation unless the timezone is UTC (Z)
+ * (since the same moment in time can be expressed in different
+ * timezones). To get a canonical string, use the canonicalString()
+ * method.
+ */
+ public final String toString() {
+ return GDate.formatGDate(this);
+ }
+
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/GDateSpecification.java b/src/main/java/org/apache/xmlbeans/GDateSpecification.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/GDateSpecification.java
rename to src/main/java/org/apache/xmlbeans/GDateSpecification.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/GDuration.java b/src/main/java/org/apache/xmlbeans/GDuration.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/GDuration.java
rename to src/main/java/org/apache/xmlbeans/GDuration.java
diff --git a/src/main/java/org/apache/xmlbeans/GDurationBuilder.java b/src/main/java/org/apache/xmlbeans/GDurationBuilder.java
new file mode 100644
index 0000000..83c304f
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/GDurationBuilder.java
@@ -0,0 +1,662 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
+
+/**
+ * Used to build {@link GDuration GDurations}.
+ */
+public class GDurationBuilder implements GDurationSpecification, java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private int _sign;
+ private int _CY;
+ private int _M;
+ private int _D;
+ private int _h;
+ private int _m;
+ private int _s;
+ private BigDecimal _fs;
+
+ /**
+ * Constructs an empty GDurationBuilder representing zero seconds.
+ */
+ public GDurationBuilder() {
+ _sign = +1;
+ _fs = GDate._zero;
+ }
+
+ /**
+ * Constructs a GDuration from a lexical
+ * representation.
+ */
+ public GDurationBuilder(String s) {
+ this(new GDuration(s));
+ }
+
+ /**
+ * Constructs a GDurationBuilder with the specified sign,
+ * year, month, day, hours, minutes, seconds, and optional
+ * fractional seconds.
+ *
+ * @param sign +1 for a positive duration, -1 for a negative duration
+ * @throws java.lang.IllegalArgumentException if the sign is not 1 or -1
+ */
+ public GDurationBuilder(
+ int sign,
+ int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ BigDecimal fraction) {
+ if (sign != 1 && sign != -1) {
+ throw new IllegalArgumentException();
+ }
+ _sign = sign;
+ _CY = year;
+ _M = month;
+ _D = day;
+ _h = hour;
+ _m = minute;
+ _s = second;
+ _fs = fraction == null ? GDate._zero : fraction;
+ }
+
+ /**
+ * Constructs a GDurationBuilder from another GDurationBuilderSpecification.
+ */
+ public GDurationBuilder(GDurationSpecification gDuration) {
+ _sign = gDuration.getSign();
+ _CY = gDuration.getYear();
+ _M = gDuration.getMonth();
+ _D = gDuration.getDay();
+ _h = gDuration.getHour();
+ _m = gDuration.getMinute();
+ _s = gDuration.getSecond();
+ _fs = gDuration.getFraction();
+ }
+
+ /**
+ * Builds another GDurationBuilder with the same value
+ * as this one.
+ */
+ public Object clone() {
+ return new GDurationBuilder(this);
+ }
+
+ /**
+ * Builds a GDuration from this GDurationBuilder.
+ */
+ public GDuration toGDuration() {
+ return new GDuration(this);
+ }
+
+ /**
+ * Adds to this duration. Does a fieldwise add, with no
+ * normalization.
+ */
+ public void addGDuration(GDurationSpecification duration) {
+ int sign = _sign * duration.getSign();
+ _add(duration, sign);
+ }
+
+ /**
+ * Subtracts from this duration. Does a fieldwise subtraction,
+ * with no normalization.
+ */
+ public void subtractGDuration(GDurationSpecification duration) {
+ int sign = -_sign * duration.getSign();
+ _add(duration, sign);
+ }
+
+ private void _add(GDurationSpecification duration, int sign) {
+ _CY += sign * duration.getYear();
+ _M += sign * duration.getMonth();
+ _D += sign * duration.getDay();
+ _h += sign * duration.getHour();
+ _m += sign * duration.getMinute();
+ _s += sign * duration.getSecond();
+
+ if (duration.getFraction().signum() == 0) {
+ return;
+ }
+
+ if (_fs.signum() == 0 && sign == 1) {
+ _fs = duration.getFraction();
+ } else {
+ _fs = sign > 0 ?
+ _fs.add(duration.getFraction()) :
+ _fs.subtract(duration.getFraction());
+ }
+ }
+
+ /**
+ * Sets the sign.
+ */
+ public final void setSign(int sign) {
+ if (sign != 1 && sign != -1) {
+ throw new IllegalArgumentException();
+ }
+ _sign = sign;
+ }
+
+ /**
+ * Sets the year component.
+ */
+ public void setYear(int year) {
+ _CY = year;
+ }
+
+ /**
+ * Sets the month component.
+ */
+ public void setMonth(int month) {
+ _M = month;
+ }
+
+ /**
+ * Sets the day component.
+ */
+ public void setDay(int day) {
+ _D = day;
+ }
+
+ /**
+ * Sets the hour component.
+ */
+ public void setHour(int hour) {
+ _h = hour;
+ }
+
+ /**
+ * Sets the minute component.
+ */
+ public void setMinute(int minute) {
+ _m = minute;
+ }
+
+ /**
+ * Sets the second component.
+ */
+ public void setSecond(int second) {
+ _s = second;
+ }
+
+ /**
+ * Sets the fraction-of-second component.
+ */
+ public void setFraction(BigDecimal fraction) {
+ _fs = fraction == null ? GDate._zero : fraction;
+ }
+
+ /**
+ * All GDuration instances return true.
+ */
+ public final boolean isImmutable() {
+ return true;
+ }
+
+ /**
+ * Returns the sign of the duration: +1 is forwards
+ * and -1 is backwards in time.
+ * This value does not necessarily reflect the
+ * true direction of the duration if the duration
+ * is not normalized or not normalizable.
+ */
+ public final int getSign() {
+ return _sign;
+ }
+
+ /**
+ * Gets the year component.
+ */
+ public final int getYear() {
+ return _CY;
+ }
+
+ /**
+ * Gets the month-of-year component.
+ */
+ public final int getMonth() {
+ return _M;
+ }
+
+ /**
+ * Gets the day-of-month component.
+ */
+ public final int getDay() {
+ return _D;
+ }
+
+ /**
+ * Gets the hour-of-day component.
+ */
+ public final int getHour() {
+ return _h;
+ }
+
+ /**
+ * Gets the minute-of-hour component.
+ */
+ public final int getMinute() {
+ return _m;
+ }
+
+ /**
+ * Gets the second-of-minute component.
+ */
+ public final int getSecond() {
+ return _s;
+ }
+
+
+ /**
+ * Gets the fraction-of-second. Range from 0 (inclusive) to 1 (exclusive).
+ */
+ public BigDecimal getFraction() {
+ return _fs;
+ }
+
+ /**
+ * Returns true if all of the individual components
+ * of the duration are nonnegative.
+ */
+ public boolean isValid() {
+ return GDurationBuilder.isValidDuration(this);
+ }
+
+
+ /**
+ * Normalize a duration value. This ensures that months,
+ * hours, minutes, seconds, and fractions are positive and
+ * within the ranges 0..11, 0..23, 0..59, etc. Negative
+ * durations are indicated by a negative sign rather
+ * than negative components.
+ *
+ * Most duration specifications can be normalized to
+ * valid durations with all positive components, but
+ * not all of them can.
+ *
+ * The only situations which cannot be normalized are
+ * where the year/month and the day/hour/minute/second
+ * offsets are of opposite sign. Days cannot be carried
+ * into months since the length of a Gregorian month is
+ * variable depending on when the duration is applied.
+ * In these cases, this method normalizes the components
+ * so that "day" is the only negative component.
+ */
+ public void normalize() {
+ _normalizeImpl(true);
+ }
+
+ /**
+ * fQuotient(a, b) = the greatest integer less than or equal to a/b
+ */
+ private static long _fQuotient(long a, int b) {
+ if ((a < 0) == (b < 0)) {
+ return a / b;
+ }
+
+ return -((b - a - 1) / b);
+ }
+
+ /**
+ * modulo(a, b) = a - fQuotient(a,b)*b
+ */
+ private static int _mod(long a, int b, long quotient) {
+ return (int) (a - quotient * b);
+ }
+
+
+ /**
+ * Private implemenation of normalize. The flag is
+ * to facilitate this method calling itself without
+ * danger of infinite recursion.
+ */
+ private void _normalizeImpl(boolean adjustSign) {
+ long temp;
+
+ // months to years
+ if (_M < 0 || _M > 11) {
+ temp = _M;
+ long ycarry = _fQuotient(temp, 12);
+ _M = _mod(temp, 12, ycarry);
+ _CY += ycarry;
+ }
+
+ long carry = 0;
+
+ // fractions to seconds
+ if (_fs != null && (_fs.signum() < 0 || _fs.compareTo(GDate._one) >= 0)) {
+ BigDecimal bdcarry = _fs.setScale(0, RoundingMode.FLOOR);
+ _fs = _fs.subtract(bdcarry);
+ carry = bdcarry.intValue();
+ }
+
+ if (carry != 0 || _s < 0 || _s > 59 || _m < 0 || _m > 50 || _h < 0 || _h > 23) {
+ // seconds
+ temp = _s + carry;
+ carry = _fQuotient(temp, 60);
+ _s = _mod(temp, 60, carry);
+
+ // minutes
+ temp = _m + carry;
+ carry = _fQuotient(temp, 60);
+ _m = _mod(temp, 60, carry);
+
+ // hours
+ temp = _h + carry;
+ carry = _fQuotient(temp, 24);
+ _h = _mod(temp, 24, carry);
+ _D += carry;
+ }
+
+ if (_CY == 0 && _M == 0 && _D == 0 && _h == 0 && _m == 0 && _s == 0 && (_fs == null || _fs.signum() == 0)) {
+ _sign = 1;
+ }
+
+ if (adjustSign && (_D < 0 || _CY < 0)) {
+ int sign = (_D <= 0 && (_CY < 0 || _CY == 0 && _M == 0)) ? -_sign : _getTotalSignSlowly();
+ if (sign == 2) {
+ sign = (_CY < 0) ? -_sign : _sign;
+ }
+ if (sign == 0) {
+ sign = 1;
+ }
+ if (sign != _sign) {
+ _sign = sign;
+ _CY = -_CY;
+ _M = -_M;
+ _D = -_D;
+ _h = -_h;
+ _m = -_m;
+ _s = -_s;
+ if (_fs != null) {
+ _fs = _fs.negate();
+ }
+ }
+ _normalizeImpl(false);
+ }
+ }
+
+
+ /* package */
+ static boolean isValidDuration(GDurationSpecification spec) {
+ if (!(spec.getSign() == 1 || spec.getSign() == -1)) {
+ return false;
+ }
+
+ return (spec.getYear() >= 0 && spec.getMonth() >= 0 && spec.getDay() >= 0 &&
+ spec.getHour() >= 0 && spec.getMinute() >= 0 && spec.getSecond() >= 0 &&
+ spec.getFraction().signum() >= 0);
+ }
+
+ /**
+ * Comparison to another GDuration.
+ *
+ *
Returns -1 if this < duration. (less-than)
+ *
Returns 0 if this == duration. (equal)
+ *
Returns 1 if this > duration. (greater-than)
+ *
Returns 2 if this <> duration. (incomparable)
+ *
+ * Two instances are incomparable if they have different amounts
+ * of information.
+ */
+ public final int compareToGDuration(GDurationSpecification duration) {
+ return GDurationBuilder.compareDurations(this, duration);
+ }
+
+ /**
+ * The natural string representation of the duration.
+ *
+ * Any components that are zero are omitted. Note that if the duration
+ * is invalid, i.e., it has negative components, those negative
+ * components are serialized out here. To check for validity, use
+ * the isValid() method; and to normalize most durations to a valid
+ * form use the normalize() method.
+ */
+ public String toString() {
+ return GDurationBuilder.formatDuration(this);
+ }
+
+ /* package */
+ static int compareDurations(GDurationSpecification d1, GDurationSpecification d2) {
+ // first do an all-fields check
+ if (d1.getFraction().signum() == 0 && d2.getFraction().signum() == 0) {
+ int s1 = d1.getSign();
+ int s2 = d2.getSign();
+ long month1 = s1 * ((long) d1.getYear() * 12 + d1.getMonth());
+ long month2 = s2 * ((long) d2.getYear() * 12 + d2.getMonth());
+ long sec1 = s1 * ((((long) d1.getDay() * 24 + d1.getHour()) * 60 + d1.getMinute()) * 60 + d1.getSecond());
+ long sec2 = s2 * ((((long) d2.getDay() * 24 + d2.getHour()) * 60 + d2.getMinute()) * 60 + d2.getSecond());
+ if (month1 == month2) {
+ if (sec1 == sec2) {
+ return 0;
+ }
+ return sec1 < sec2 ? -1 : 1;
+ }
+ if (month1 < month2 && sec1 - sec2 < 28 * 24 * 60 * 60) {
+ return -1;
+ }
+ if (month1 > month2 && sec2 - sec1 < 28 * 24 * 60 * 60) {
+ return 1;
+ }
+ }
+
+ // the answer isn't obvious, so then do a total-sign check
+ GDurationBuilder diff = new GDurationBuilder(d1);
+ diff.subtractGDuration(d2);
+ return diff._getTotalSignSlowly();
+ }
+
+ /**
+ * Per schema spec, comparison of durations is simply done
+ * by calculating adding the duration to these four dates and
+ * comparing the results. If the results are ambiguous, the
+ * answer is "incomparable".
+ */
+ private static final GDate[] _compDate = new GDate[]
+ {
+ new GDate(1696, 9, 1, 0, 0, 0, null, 0, 0, 0),
+ new GDate(1697, 2, 1, 0, 0, 0, null, 0, 0, 0),
+ new GDate(1903, 3, 1, 0, 0, 0, null, 0, 0, 0),
+ new GDate(1903, 7, 1, 0, 0, 0, null, 0, 0, 0)
+ };
+
+
+ /**
+ * This returns the total sign of the duration, +1
+ * if the duration moves forward in time, -1 if the
+ * duration moves backwards in time, 0 if the duration
+ * is zero-length, and 2 if the duration may be positive
+ * or negative depending on the date.
+ *
+ * (For example, one month minus 30 days is indeterminate).
+ */
+ private int _getTotalSignSlowly() {
+ int pos = 0;
+ int neg = 0;
+ int zer = 0;
+
+ GDateBuilder enddate = new GDateBuilder();
+ for (GDate gDate : _compDate) {
+ enddate.setGDate(gDate);
+ enddate.addGDuration(this);
+ switch (enddate.compareToGDate(gDate)) {
+ case -1:
+ neg++;
+ break;
+ case 0:
+ zer++;
+ break;
+ case 1:
+ pos++;
+ break;
+ }
+ }
+
+ if (pos == _compDate.length) {
+ return +1;
+ }
+ if (neg == _compDate.length) {
+ return -1;
+ }
+ if (zer == _compDate.length) {
+ return 0;
+ }
+ return 2;
+ }
+
+ /* package */
+ static String formatDuration(GDurationSpecification duration) {
+ // Sign+P: (-)?P
+ // Year: (?:(\d+)Y)?
+ // Month: (?:(\d+)M)?
+ // Day: (?:(\d+)D)?
+ // Time: (?:(T)
+ // Hours: (?:(\d+)H)?
+ // Minutes: (?:(\d+)M)?
+ // Seconds: (?:(\d+(?:\.\d*)?|(?:.\d+)S)?
+
+ StringBuilder message = new StringBuilder(30);
+
+ if (duration.getSign() < 0) {
+ message.append('-');
+ }
+
+ message.append('P');
+
+ if (duration.getYear() != 0) {
+ message.append(duration.getYear());
+ message.append('Y');
+ }
+
+ if (duration.getMonth() != 0) {
+ message.append(duration.getMonth());
+ message.append('M');
+ }
+
+ if (duration.getDay() != 0) {
+ message.append(duration.getDay());
+ message.append('D');
+ }
+
+ if (duration.getHour() != 0 || duration.getMinute() != 0 || duration.getSecond() != 0 ||
+ (duration.getFraction().signum() != 0)) {
+ message.append('T');
+ }
+
+ if (duration.getHour() != 0) {
+ message.append(duration.getHour());
+ message.append('H');
+ }
+
+ if (duration.getMinute() != 0) {
+ message.append(duration.getMinute());
+ message.append('M');
+ }
+
+ if (duration.getFraction().signum() != 0) {
+ BigDecimal s = duration.getFraction();
+ if (duration.getSecond() != 0) {
+ s = s.add(BigDecimal.valueOf(duration.getSecond()));
+ }
+ // todo when upgrade to 1.5 message.append(s.stripTrailingZeros().toPlainString());
+ message.append(stripTrailingZeros(toPlainString(s)));
+ message.append('S');
+ } else if (duration.getSecond() != 0) {
+ message.append(duration.getSecond());
+ message.append('S');
+ } else if (message.length() <= 2)
+ // Specify zero seconds if everything was 0
+ {
+ message.append("T0S");
+ }
+
+ return message.toString();
+ }
+
+ public static String toPlainString(BigDecimal bd) {
+ BigInteger intVal = bd.unscaledValue();
+ int scale = bd.scale();
+ String intValStr = intVal.toString();
+ if (scale == 0) {
+ return intValStr;
+ }
+
+ boolean isNegative = (intValStr.charAt(0) == '-');
+
+ int point = intValStr.length() - scale - (isNegative ? 1 : 0);
+
+ StringBuilder sb = new StringBuilder(intValStr.length() + 2 + (point <= 0 ? (-point + 1) : 0));
+ if (point <= 0) {
+ // prepend zeros and a decimal point.
+ if (isNegative) {
+ sb.append('-');
+ }
+ sb.append('0').append('.');
+ while (point < 0) {
+ sb.append('0');
+ point++;
+ }
+ sb.append(intValStr.substring(isNegative ? 1 : 0));
+ } else if (point < intValStr.length()) {
+ // No zeros needed
+ sb.append(intValStr);
+ sb.insert(point + (isNegative ? 1 : 0), '.');
+ } else {
+ // append zeros if not 0
+ sb.append(intValStr);
+ if (!intVal.equals(BigInteger.ZERO)) {
+ for (int i = intValStr.length(); i < point; i++) {
+ sb.append('0');
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+ public static String stripTrailingZeros(String s) {
+ boolean seenDot = false;
+ int i = s.length() - 1;
+ int zeroIndex = i;
+
+ while (i >= 0) {
+ if (s.charAt(i) != '0') {
+ break;
+ }
+ i--;
+ zeroIndex--;
+ }
+ while (i >= 0) {
+ if (s.charAt(i) == 'E') {
+ return s;
+ }
+ if (s.charAt(i) == '.') {
+ seenDot = true;
+ break;
+ }
+ i--;
+ }
+
+ return seenDot ? s.substring(0, zeroIndex + 1) : s;
+ }
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/GDurationSpecification.java b/src/main/java/org/apache/xmlbeans/GDurationSpecification.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/GDurationSpecification.java
rename to src/main/java/org/apache/xmlbeans/GDurationSpecification.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/InterfaceExtension.java b/src/main/java/org/apache/xmlbeans/InterfaceExtension.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/InterfaceExtension.java
rename to src/main/java/org/apache/xmlbeans/InterfaceExtension.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/ObjectFactory.java b/src/main/java/org/apache/xmlbeans/ObjectFactory.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/ObjectFactory.java
rename to src/main/java/org/apache/xmlbeans/ObjectFactory.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/PrePostExtension.java b/src/main/java/org/apache/xmlbeans/PrePostExtension.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/PrePostExtension.java
rename to src/main/java/org/apache/xmlbeans/PrePostExtension.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/QNameCache.java b/src/main/java/org/apache/xmlbeans/QNameCache.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/QNameCache.java
rename to src/main/java/org/apache/xmlbeans/QNameCache.java
diff --git a/src/main/java/org/apache/xmlbeans/QNameSet.java b/src/main/java/org/apache/xmlbeans/QNameSet.java
new file mode 100644
index 0000000..f58c3f4
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/QNameSet.java
@@ -0,0 +1,436 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.namespace.QName;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This interface represents a lattice of finite and infinite sets of QNames.
+ * The lattice the minimal one that is closed under union, intersection, and
+ * inverse, and contains individual QNames as well as entire namespaces.
+ * Here is a summary of the two kinds of QNameSets:
+ *
+ *
A QNameSet can cover a finite set of namespaces, additionally including a finite
+ * set of QNames outside those namespaces, and with the exception of
+ * a finite set of QNames excluded from those namespaes:
+ *
+ *
excludedQNamesInIncludedURIs == the set of excluded QNames from coveredURIs namespaces
+ *
excludedURIs == null
+ *
includedURIs == the set of covered namespace URIs
+ *
includedQNamesInExcludedURIs == set of additional QNames outside coveredURIs namespaces
+ *
+ *
+ *
A QNameSet can cover all namespaces except for a finite number of excluded ones,
+ * additionally including a finite set of QNames within the excluded namespaces,
+ * and with the exception of a finite set of QNames outside the excluded namespaces:
+ *
+ *
excludedQNamesInIncludedURIs == the set of excluded QNames outside uncoveredURIs namespaces
+ *
excludedURIs == the set of uncovered namespace URIs
+ *
includedURIs == null
+ *
includedQNamesInExcludedURIs == set of additional QNames from uncoveredURIs namespaces
+ *
+ *
+ *
+ *
+ * Notice that a finite set of QNames is a degenerate case of the first
+ * category outlined above:
+ *
+ *
A QnameSet can contain a finite number of QNames:
+ *
+ *
excludedQNamesInIncludedURIs == empty set
+ *
excludedURIs == null
+ *
includedURIs == empty set
+ *
includedQNamesInExcludedURIs == set of included QNames
+ *
+ *
+ *
+ *
+ * @see QNameSetBuilder
+ */
+public final class QNameSet implements QNameSetSpecification, java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final boolean _inverted;
+ private final Set _includedURIs;
+ private final Set _excludedQNames;
+ private final Set _includedQNames;
+
+ /**
+ * The empty QNameSet.
+ */
+ public static final QNameSet EMPTY = new QNameSet(null, Collections.emptySet(), Collections.emptySet(), Collections.emptySet());
+
+ /**
+ * The QNameSet containing all QNames.
+ */
+ public static final QNameSet ALL = new QNameSet(Collections.emptySet(), null, Collections.emptySet(), Collections.emptySet());
+
+ /**
+ * The QNameSet containing all QNames in the local (no-)namespace.
+ */
+ public static final QNameSet LOCAL = new QNameSet(null, Collections.singleton(""), Collections.emptySet(), Collections.emptySet());
+
+ /**
+ * The QNameSet containing all QNames except for those in the local (no-)namespace.
+ */
+ public static final QNameSet NONLOCAL = new QNameSet(Collections.singleton(""), null, Collections.emptySet(), Collections.emptySet());
+
+ /**
+ * Private function to minimize object creation when copying sets.
+ */
+ private static Set minSetCopy(Set original) {
+ if (original == null) {
+ return null;
+ }
+ if (original.isEmpty()) {
+ return Collections.emptySet();
+ }
+ if (original.size() == 1) {
+ return Collections.singleton(original.iterator().next());
+ }
+ return new HashSet<>(original);
+ }
+
+ /**
+ * Returns a QNameSet based on the given sets of excluded URIs,
+ * included URIs, excluded QNames in included namespaces, and included
+ * QNames in excluded namespaces.
+ *
+ * @param excludedURIs the finite set of namespace URI strings to exclude from the set, or null if this set is infinite
+ * @param includedURIs the finite set of namespace URI strings to include in the set, or null if this set is infinite
+ * @param excludedQNamesInIncludedURIs the finite set of exceptional QNames to exclude from the included namespaces
+ * @param includedQNamesInExcludedURIs the finite set of exceptional QNames to include that are in the excluded namespaces
+ * @return the constructed QNameSet
+ */
+ public static QNameSet forSets(Set excludedURIs, Set includedURIs, Set excludedQNamesInIncludedURIs, Set includedQNamesInExcludedURIs) {
+ if ((excludedURIs != null) == (includedURIs != null)) {
+ throw new IllegalArgumentException("Exactly one of excludedURIs and includedURIs must be null");
+ }
+
+ if (excludedURIs == null && includedURIs.isEmpty() && includedQNamesInExcludedURIs.isEmpty()) {
+ return EMPTY;
+ }
+ if (includedURIs == null && excludedURIs.isEmpty() && excludedQNamesInIncludedURIs.isEmpty()) {
+ return ALL;
+ }
+ if (excludedURIs == null && includedURIs.size() == 1 && includedURIs.contains("") &&
+ includedQNamesInExcludedURIs.isEmpty() && excludedQNamesInIncludedURIs.isEmpty()) {
+ return LOCAL;
+ }
+ if (includedURIs == null && excludedURIs.size() == 1 && excludedURIs.contains("") &&
+ excludedQNamesInIncludedURIs.isEmpty() && includedQNamesInExcludedURIs.isEmpty()) {
+ return NONLOCAL;
+ }
+
+ return new QNameSet(
+ minSetCopy(excludedURIs),
+ minSetCopy(includedURIs),
+ minSetCopy(excludedQNamesInIncludedURIs),
+ minSetCopy(includedQNamesInExcludedURIs));
+ }
+
+ /**
+ * Returns a QNameSet based on the given array of included QNames
+ *
+ * @param includedQNames the array of included QNames
+ */
+ public static QNameSet forArray(QName[] includedQNames) {
+ if (includedQNames == null) {
+ throw new IllegalArgumentException("includedQNames cannot be null");
+ }
+
+ return new QNameSet(null, Collections.emptySet(), Collections.emptySet(), new HashSet<>(Arrays.asList(includedQNames)));
+ }
+
+ /**
+ * Returns a QNameSet with the same contents as the given
+ * QNameSetSpecification.
+ *
+ * @return the copied QNameSet
+ */
+ public static QNameSet forSpecification(QNameSetSpecification spec) {
+ if (spec instanceof QNameSet) {
+ return (QNameSet) spec;
+ }
+ return QNameSet.forSets(spec.excludedURIs(), spec.includedURIs(), spec.excludedQNamesInIncludedURIs(), spec.includedQNamesInExcludedURIs());
+ }
+
+ /**
+ * Returns a QNameSet corresponding to the given wildcard namespace string.
+ * This is a space-separated list of URIs, plus special tokens as specified
+ * in the XML Schema specification (##any, ##other, ##targetNamespace, ##local).
+ *
+ * @return the constructed QNameSet
+ */
+ public static QNameSet forWildcardNamespaceString(String wildcard, String targetURI) {
+ return QNameSet.forSpecification(new QNameSetBuilder(wildcard, targetURI));
+ }
+
+ /**
+ * Returns a QNameSet containing only the given QName.
+ *
+ * @return the constructed QNameSet
+ */
+ public static QNameSet singleton(QName name) {
+ return new QNameSet(null, Collections.emptySet(), Collections.emptySet(), Collections.singleton(name));
+ }
+
+ /**
+ * Constructs a QNameSetBuilder whose contents are given by
+ * the four sets.
+ *
+ * This constuctor is PRIVATE because it uses the given
+ * sets directly, and it trusts its callers to set only immutable values.
+ * This constructor is is only called by the static builder methods on
+ * QNameSet: those methods are all careful assign only unchanging sets.
+ */
+ private QNameSet(Set excludedURIs, Set includedURIs, Set excludedQNamesInIncludedURIs, Set includedQNamesInExcludedURIs) {
+ if (includedURIs != null && excludedURIs == null) {
+ _inverted = false;
+ _includedURIs = includedURIs;
+ _excludedQNames = excludedQNamesInIncludedURIs;
+ _includedQNames = includedQNamesInExcludedURIs;
+ } else if (excludedURIs != null && includedURIs == null) {
+ _inverted = true;
+ _includedURIs = excludedURIs;
+ _excludedQNames = includedQNamesInExcludedURIs;
+ _includedQNames = excludedQNamesInIncludedURIs;
+ } else {
+ throw new IllegalArgumentException("Exactly one of excludedURIs and includedURIs must be null");
+ }
+ }
+
+ /**
+ * Local xml names are hased using "" as the namespace.
+ */
+ private static String nsFromName(QName xmlName) {
+ String ns = xmlName.getNamespaceURI();
+ return ns == null ? "" : ns;
+ }
+
+ /**
+ * True if this ModelTransitionSet contains the given qname.
+ */
+ public boolean contains(QName name) {
+ boolean in = _includedURIs.contains(nsFromName(name)) ?
+ !_excludedQNames.contains(name) :
+ _includedQNames.contains(name);
+ return _inverted ^ in;
+ }
+
+ /**
+ * True if this ModelTransitionSet contains all QNames.
+ */
+ public boolean isAll() {
+ return _inverted && _includedURIs.isEmpty() && _includedQNames.isEmpty();
+ }
+
+ /**
+ * True if this ModelTransitionSet contains no QNames.
+ */
+ public boolean isEmpty() {
+ return !_inverted && _includedURIs.isEmpty() && _includedQNames.isEmpty();
+ }
+
+ /**
+ * Returns a new QNameSet that is the intersection of this one and another.
+ *
+ * @param set the set to insersect with
+ * @return the intersection
+ */
+ public QNameSet intersect(QNameSetSpecification set) {
+ QNameSetBuilder result = new QNameSetBuilder(this);
+ result.restrict(set);
+ return result.toQNameSet();
+ }
+
+ /**
+ * Returns a new QNameSet that is the union of this one and another.
+ *
+ * @param set the set to union with
+ * @return the union
+ */
+ public QNameSet union(QNameSetSpecification set) {
+ QNameSetBuilder result = new QNameSetBuilder(this);
+ result.addAll(set);
+ return result.toQNameSet();
+ }
+
+ /**
+ * Returns a new QNameSet that is the inverse of this one.
+ */
+ public QNameSet inverse() {
+ if (this == EMPTY) {
+ return ALL;
+ }
+ if (this == ALL) {
+ return EMPTY;
+ }
+ if (this == LOCAL) {
+ return NONLOCAL;
+ }
+ if (this == NONLOCAL) {
+ return LOCAL;
+ }
+ return new QNameSet(includedURIs(), excludedURIs(), includedQNamesInExcludedURIs(), excludedQNamesInIncludedURIs());
+ }
+
+ /**
+ * True if the given set is a subset of this one.
+ *
+ * @param set the set to test
+ * @return true if this contains all QNames contained by the given set
+ */
+ public boolean containsAll(QNameSetSpecification set) {
+ // a.contains(b) == a.inverse.isDisjoint(b)
+ if (!_inverted && set.excludedURIs() != null) {
+ return false;
+ }
+
+ return inverse().isDisjoint(set);
+ }
+
+ /**
+ * True if the given set is disjoint from this one.
+ *
+ * @param set the set to test
+ * @return true if the set is disjoint from this set
+ */
+ public boolean isDisjoint(QNameSetSpecification set) {
+ if (_inverted && set.excludedURIs() != null) {
+ return false;
+ }
+
+ if (_inverted) {
+ return isDisjointImpl(set, this);
+ } else {
+ return isDisjointImpl(this, set);
+ }
+ }
+
+ private boolean isDisjointImpl(QNameSetSpecification set1, QNameSetSpecification set2) {
+ Set includeURIs = set1.includedURIs();
+ Set otherIncludeURIs = set2.includedURIs();
+
+ if (otherIncludeURIs != null) {
+ if (!Collections.disjoint(includeURIs, otherIncludeURIs)) {
+ return false;
+ }
+ } else {
+ if (!set2.excludedURIs().containsAll(includeURIs)) {
+ return false;
+ }
+ }
+
+ if (set1.includedQNamesInExcludedURIs().stream().anyMatch(set2::contains)) {
+ return false;
+ }
+
+ if (set2.includedQNamesInExcludedURIs().stream().anyMatch(set1::contains)) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Namespaces that are fully excluded from the set except for a finite
+ * number of individual QName exceptions. Returns null if this set is infinite.
+ *
+ * @return the set of excluded namespace URI strings
+ */
+ public Set excludedURIs() {
+ if (_inverted) {
+ return Collections.unmodifiableSet(_includedURIs);
+ }
+ return null;
+ }
+
+ /**
+ * Namespaces that are fully included in set except for a finite
+ * number of individual QName exceptions. Returns null if this set is infinite.
+ *
+ * @return the set of included namespace URI strings
+ */
+ public Set includedURIs() {
+ if (!_inverted) {
+ return _includedURIs;
+ }
+ return null;
+ }
+
+ /**
+ * The set of QNames excluded from the set even though they are within
+ * a namespace that is otherwise fully included in the set.
+ *
+ * @return the set of excluded QNames from within includedURI namespaces
+ */
+ public Set excludedQNamesInIncludedURIs() {
+ return Collections.unmodifiableSet(_inverted ? _includedQNames : _excludedQNames);
+ }
+
+ /**
+ * The set of QNames included in the set even though they are within
+ * a namespace that is otherwise fully included in the set.
+ *
+ * @return the set of included QNames from within excludedURI namespaces
+ */
+ public Set includedQNamesInExcludedURIs() {
+ return Collections.unmodifiableSet(_inverted ? _excludedQNames : _includedQNames);
+ }
+
+ private String prettyQName(QName name) {
+ if (name.getNamespaceURI() == null) {
+ return name.getLocalPart();
+ }
+ return name.getLocalPart() + "@" + name.getNamespaceURI();
+ }
+
+ /**
+ * Returns a string representation useful for debugging, subject to change.
+ */
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("QNameSet");
+ sb.append(_inverted ? "-(" : "+(");
+ for (String includedURIs : _includedURIs) {
+ sb.append("+*@");
+ sb.append(includedURIs);
+ sb.append(", ");
+ }
+ for (QName excludedQName : _excludedQNames) {
+ sb.append("-");
+ sb.append(prettyQName(excludedQName));
+ sb.append(", ");
+ }
+ for (QName includedQName : _includedQNames) {
+ sb.append("+");
+ sb.append(prettyQName(includedQName));
+ sb.append(", ");
+ }
+ int index = sb.lastIndexOf(", ");
+ if (index > 0) {
+ sb.setLength(index);
+ }
+ sb.append(')');
+ return sb.toString();
+ }
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/QNameSetBuilder.java b/src/main/java/org/apache/xmlbeans/QNameSetBuilder.java
similarity index 99%
rename from src/xmlpublic/org/apache/xmlbeans/QNameSetBuilder.java
rename to src/main/java/org/apache/xmlbeans/QNameSetBuilder.java
index 2594561..13d8e7e 100644
--- a/src/xmlpublic/org/apache/xmlbeans/QNameSetBuilder.java
+++ b/src/main/java/org/apache/xmlbeans/QNameSetBuilder.java
@@ -682,7 +682,7 @@ private String prettyQName(QName name)
*/
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("QNameSetBuilder");
sb.append(_inverted ? "-(" : "+(");
for (Iterator i = _includedURIs.iterator(); i.hasNext(); )
diff --git a/src/xmlpublic/org/apache/xmlbeans/QNameSetSpecification.java b/src/main/java/org/apache/xmlbeans/QNameSetSpecification.java
similarity index 94%
rename from src/xmlpublic/org/apache/xmlbeans/QNameSetSpecification.java
rename to src/main/java/org/apache/xmlbeans/QNameSetSpecification.java
index 49d2f10..68d0d0f 100644
--- a/src/xmlpublic/org/apache/xmlbeans/QNameSetSpecification.java
+++ b/src/main/java/org/apache/xmlbeans/QNameSetSpecification.java
@@ -16,19 +16,17 @@
package org.apache.xmlbeans;
import javax.xml.namespace.QName;
-
import java.util.Set;
/**
* Represents a lattice of finite and infinite sets of QNames.
- *
+ *
* @see QNameSet
*/
-public interface QNameSetSpecification
-{
+public interface QNameSetSpecification {
/**
* True if the set contains the given QName.
- *
+ *
* Roughly equivalent to:
* (includedURIs() == null ?
* excludedURIs().contains(namespace) :
@@ -51,9 +49,9 @@ public interface QNameSetSpecification
/**
* True if the parameter is a subset of this set.
- */
+ */
boolean containsAll(QNameSetSpecification set);
-
+
/**
* True if is disjoint from the specified set.
*/
@@ -88,7 +86,7 @@ public interface QNameSetSpecification
*
* The same set as inverse().includedURIs().
*/
- Set excludedURIs();
+ Set excludedURIs();
/**
* The finite set of namespace URIs that are almost completely included in
@@ -101,7 +99,7 @@ public interface QNameSetSpecification
*
* The same as inverse.excludedURIs().
*/
- Set includedURIs();
+ Set includedURIs();
/**
* The finite set of QNames that are excluded from the set within namespaces
@@ -113,7 +111,7 @@ public interface QNameSetSpecification
*
* The same set as inverse().includedQNames().
*/
- Set excludedQNamesInIncludedURIs();
+ Set excludedQNamesInIncludedURIs();
/**
* The finite set of QNames that are included in the set within namespaces
@@ -125,5 +123,5 @@ public interface QNameSetSpecification
*
* The same as inverse().excludedQNames().
*/
- Set includedQNamesInExcludedURIs();
+ Set includedQNamesInExcludedURIs();
}
diff --git a/src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java b/src/main/java/org/apache/xmlbeans/ResourceLoader.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/ResourceLoader.java
rename to src/main/java/org/apache/xmlbeans/ResourceLoader.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaAnnotated.java b/src/main/java/org/apache/xmlbeans/SchemaAnnotated.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaAnnotated.java
rename to src/main/java/org/apache/xmlbeans/SchemaAnnotated.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaAnnotation.java b/src/main/java/org/apache/xmlbeans/SchemaAnnotation.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaAnnotation.java
rename to src/main/java/org/apache/xmlbeans/SchemaAnnotation.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaAttributeGroup.java b/src/main/java/org/apache/xmlbeans/SchemaAttributeGroup.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaAttributeGroup.java
rename to src/main/java/org/apache/xmlbeans/SchemaAttributeGroup.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaAttributeModel.java b/src/main/java/org/apache/xmlbeans/SchemaAttributeModel.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaAttributeModel.java
rename to src/main/java/org/apache/xmlbeans/SchemaAttributeModel.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaBookmark.java b/src/main/java/org/apache/xmlbeans/SchemaBookmark.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaBookmark.java
rename to src/main/java/org/apache/xmlbeans/SchemaBookmark.java
diff --git a/src/main/java/org/apache/xmlbeans/SchemaCodePrinter.java b/src/main/java/org/apache/xmlbeans/SchemaCodePrinter.java
new file mode 100755
index 0000000..67821e7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/SchemaCodePrinter.java
@@ -0,0 +1,31 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * This class is used to provide alternate implementations of the
+ * schema Java code generation.
+ */
+
+public interface SchemaCodePrinter {
+ void printTypeImpl(Writer writer, SchemaType sType) throws IOException;
+
+ void printType(Writer writer, SchemaType sType) throws IOException;
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java b/src/main/java/org/apache/xmlbeans/SchemaComponent.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
rename to src/main/java/org/apache/xmlbeans/SchemaComponent.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaField.java b/src/main/java/org/apache/xmlbeans/SchemaField.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaField.java
rename to src/main/java/org/apache/xmlbeans/SchemaField.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java b/src/main/java/org/apache/xmlbeans/SchemaGlobalAttribute.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaGlobalAttribute.java
rename to src/main/java/org/apache/xmlbeans/SchemaGlobalAttribute.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java b/src/main/java/org/apache/xmlbeans/SchemaGlobalElement.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaGlobalElement.java
rename to src/main/java/org/apache/xmlbeans/SchemaGlobalElement.java
diff --git a/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java b/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java
new file mode 100644
index 0000000..bf3512e
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java
@@ -0,0 +1,103 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Map;
+
+/**
+ * Represents an identity constraint definition.
+ */
+public interface SchemaIdentityConstraint extends SchemaComponent, SchemaAnnotated {
+ /**
+ * Return the selector xpath as a string.
+ */
+ String getSelector();
+
+ /**
+ * Return a compiled xpath object for the selector.
+ */
+ Object getSelectorPath();
+
+ /**
+ * Return (a copy of) the xpaths for all the fields.
+ */
+ String[] getFields();
+
+ /**
+ * Return a compiled xpath object for the field.
+ */
+ Object getFieldPath(int index);
+
+ /**
+ * Return a read-only copy of the namespace map. This is the
+ * set of prefix to URI mappings that were in scope in the
+ * schema at the point at which this constraint was declared
+ */
+ Map getNSMap();
+
+ /**
+ * A xs:key constraint. See {@link #getConstraintCategory}.
+ */
+ int CC_KEY = 1;
+ /**
+ * A xs:keyRef constraint. See {@link #getConstraintCategory}.
+ */
+ int CC_KEYREF = 2;
+ /**
+ * A xs:unique constraint. See {@link #getConstraintCategory}.
+ */
+ int CC_UNIQUE = 3;
+
+ /**
+ * Return the constraint category. Either {@link #CC_KEY}, {@link #CC_KEYREF},
+ * or {@link #CC_UNIQUE}.
+ */
+ int getConstraintCategory();
+
+ /**
+ * Returns the key that a key ref refers to. Only valid for
+ * keyrefs.
+ */
+ SchemaIdentityConstraint getReferencedKey();
+
+ /**
+ * Used to allow on-demand loading of identity constraints.
+ */
+ final class Ref extends SchemaComponent.Ref {
+ public Ref(SchemaIdentityConstraint idc) {
+ super(idc);
+ }
+
+ public Ref(SchemaTypeSystem system, String handle) {
+ super(system, handle);
+ }
+
+ public final int getComponentType() {
+ return SchemaComponent.IDENTITY_CONSTRAINT;
+ }
+
+ public final SchemaIdentityConstraint get() {
+ return (SchemaIdentityConstraint) getComponent();
+ }
+ }
+
+ /**
+ * Returns user-specific information.
+ *
+ * @see SchemaBookmark
+ */
+ Object getUserData();
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttribute.java b/src/main/java/org/apache/xmlbeans/SchemaLocalAttribute.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttribute.java
rename to src/main/java/org/apache/xmlbeans/SchemaLocalAttribute.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaLocalElement.java b/src/main/java/org/apache/xmlbeans/SchemaLocalElement.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaLocalElement.java
rename to src/main/java/org/apache/xmlbeans/SchemaLocalElement.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup.java b/src/main/java/org/apache/xmlbeans/SchemaModelGroup.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup.java
rename to src/main/java/org/apache/xmlbeans/SchemaModelGroup.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaParticle.java b/src/main/java/org/apache/xmlbeans/SchemaParticle.java
similarity index 85%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaParticle.java
rename to src/main/java/org/apache/xmlbeans/SchemaParticle.java
index 22dbd21..741dea6 100644
--- a/src/xmlpublic/org/apache/xmlbeans/SchemaParticle.java
+++ b/src/main/java/org/apache/xmlbeans/SchemaParticle.java
@@ -15,9 +15,8 @@
package org.apache.xmlbeans;
-import java.math.BigInteger;
-
import javax.xml.namespace.QName;
+import java.math.BigInteger;
/**
* Represents a Schema particle definition.
@@ -33,44 +32,43 @@
* sequences, nonrepeating sequences with only one item, and so on.
* (Pointless particles
* are defined precisely in the XML Schema specification.)
- *
+ *
* @see SchemaType#getContentModel
*/
-public interface SchemaParticle
-{
+public interface SchemaParticle {
/**
* Returns the particle type ({@link #ALL}, {@link #CHOICE},
- * {@link #SEQUENCE}, {@link #ELEMENT}, or {@link #WILDCARD}).
- */
+ * {@link #SEQUENCE}, {@link #ELEMENT}, or {@link #WILDCARD}).
+ */
int getParticleType();
-
+
/**
* An xs:all group.
* See {@link #getParticleType}.
- */
- static final int ALL = 1;
+ */
+ int ALL = 1;
/**
* A xs:choice group.
* See {@link #getParticleType}.
- */
- static final int CHOICE = 2;
+ */
+ int CHOICE = 2;
/**
* A xs:sequence group.
* See {@link #getParticleType}.
- */
- static final int SEQUENCE = 3;
+ */
+ int SEQUENCE = 3;
/**
* An xs:element particle.
* This code means the particle can be coerced to {@link SchemaLocalElement}.
* See {@link #getParticleType}.
- */
- static final int ELEMENT = 4;
+ */
+ int ELEMENT = 4;
/**
* An xs:any particle,
* also known as an element wildcard.
* See {@link #getParticleType}.
- */
- static final int WILDCARD = 5;
+ */
+ int WILDCARD = 5;
/**
* Returns the minOccurs value for this particle.
@@ -90,14 +88,14 @@ public interface SchemaParticle
* convenience of a validating state machine that doesn't count
* higher than MAX_INT anyway.
*/
- public int getIntMinOccurs();
+ int getIntMinOccurs();
/**
* Returns the maxOccurs value, pegged to a 32-bit int for
* convenience of a validating state machine that doesn't count
* higher than MAX_INT anyway. Unbounded is given as MAX_INT.
*/
- public int getIntMaxOccurs();
+ int getIntMaxOccurs();
/**
@@ -151,19 +149,25 @@ public interface SchemaParticle
*/
int getWildcardProcess();
- /** Strict wildcard processing. See {@link #getWildcardProcess} */
- static final int STRICT = 1;
- /** Lax wildcard processing. See {@link #getWildcardProcess} */
- static final int LAX = 2;
- /** Skip wildcard processing. See {@link #getWildcardProcess} */
- static final int SKIP = 3;
+ /**
+ * Strict wildcard processing. See {@link #getWildcardProcess}
+ */
+ int STRICT = 1;
+ /**
+ * Lax wildcard processing. See {@link #getWildcardProcess}
+ */
+ int LAX = 2;
+ /**
+ * Skip wildcard processing. See {@link #getWildcardProcess}
+ */
+ int SKIP = 3;
/**
* For elements only: the QName for the element use.
* May be unqualified version of referenced element's name.
*/
QName getName();
-
+
/**
* For elements only: returns the type of the element.
*/
@@ -178,7 +182,7 @@ public interface SchemaParticle
* For elements only: returns the default (or fixed) text value
*/
String getDefaultText();
-
+
/**
* For elements only: returns the default (or fixed) strongly-typed value
*/
@@ -193,5 +197,5 @@ public interface SchemaParticle
* For elements only: true if is fixed value.
*/
boolean isFixed();
-
+
}
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaProperty.java b/src/main/java/org/apache/xmlbeans/SchemaProperty.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaProperty.java
rename to src/main/java/org/apache/xmlbeans/SchemaProperty.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaStringEnumEntry.java b/src/main/java/org/apache/xmlbeans/SchemaStringEnumEntry.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaStringEnumEntry.java
rename to src/main/java/org/apache/xmlbeans/SchemaStringEnumEntry.java
diff --git a/src/main/java/org/apache/xmlbeans/SchemaType.java b/src/main/java/org/apache/xmlbeans/SchemaType.java
new file mode 100644
index 0000000..8c55dc7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/SchemaType.java
@@ -0,0 +1,1111 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a schema type.
+ *
+ * SchemaType is the metadata "type" class for {@link XmlObject}, and it plays the
+ * analogous role for {@link XmlObject} that {@link java.lang.Class} plays for
+ * {@link java.lang.Object}.
+ *
+ * Every XML Bean class corresponds to a singleton SchemaType object
+ * obtainable by ClassName.type (e.g., {@link XmlNonPositiveInteger#type}), and
+ * every XML Bean instance has an actual SchemaType, obtainable by
+ * {@link XmlObject#schemaType}. The ClassName.type and schemaType() mechanisms are
+ * analogous to the ordinary Java ClassName.class and obj.getClass() mechanisms.
+ *
+ * All schema types are represented by a SchemaType, this includes all types
+ * regardless of whether they are built-in or user-defined, compiled or
+ * uncompiled, simple or complex.
+ *
+ * In addition, a compiled XML Bean type system includes special "document" schema types
+ * each representing a document containing nothing but a single element for each
+ * global element, and special "attribute" schema types each representing
+ * a fragment containing nothing but a single global attribute for global
+ * attribute.
+ *
+ * Do not confuse Schema Types with other types of Schema Components such as
+ * {@link SchemaGlobalElement Global Elements}, {@link SchemaGlobalAttribute Global Attributes},
+ * {@link SchemaModelGroup Named Model Groups}, or {@link SchemaAttributeGroup Attribute Groups}.
+ * SchemaType represents a Type component, not any of the other kinds of components.
+ * There are different kinds of metadata objects for the different Schema components.
+ *
+ * The space of SchemaTypes is divided as follows:
+ *
+ *
+ *
First, there is the universal base type and the universal
+ * subtype. These are {@link XmlObject#type}
+ * (corresponding to xs:anyType) and {@link XmlBeans#NO_TYPE},
+ * respectively. The first type is a base type of all other
+ * types. The other type indicates the absence of type information
+ * and, at least in set-theoretic terms, is a subtype of all other types.
+ *
There is another universal base type that is the base type
+ * for all simple types. This is the {@link XmlAnySimpleType#type},
+ * corresponding to xs:anySimpleType. Only XmlObject.type and
+ * XmlAnySimpleType.type return true for {@link #isURType}, and
+ * only XmlBeans.NO_TYPE returns true for {@link #isNoType}.
+ *
The two "special" kinds of types that are generated that
+ * do not formally exist in the actual Schema specification are
+ * document types and global attribute types (corresponding to
+ * documents that contain a global element, or fragments that
+ * contain a global attribute). They can be detected using
+ * {@link #isDocumentType} and {@link #isAttributeType}. Other
+ * than their anonymity (lack of a type name) and their appearance
+ * only at the root of an instance, they are otherwise just like
+ * ordinary complex types.
+ *
Simple types can be detected using {@link #isSimpleType}.
+ * Complex types are consdered to be all the types that are
+ * not simple.
+ *
Simple types are divided into three varieties: atomic types,
+ * list types, and union types. Which variety of simple type
+ * you have can be discoverd using {@link #getSimpleVariety}.
+ * It will return either {@link #ATOMIC}, {@link #LIST}, or
+ * {@link #UNION}.
+ *
An {@link #ATOMIC} simple type is always based on one of the
+ * 20 built-in primitive schema types. You can determine
+ * the underlying primitive type for an atomic simple type
+ * by calling {@link #getPrimitiveType}. An atomic type
+ * may add facet restrictions on top of the primitive type,
+ * and these facets can be explored using {@link #getFacet},
+ * {@link #getWhiteSpaceRule}, {@link #matchPatternFacet},
+ * {@link #getEnumerationValues}, and related methods.
+ *
A {@link #LIST} simple type is always based on another non-list
+ * simple type. The underlying list item type can be obtained
+ * by using {@link #getListItemType}.
+ *
A {@link #UNION} simple type is always composed out of a number of
+ * other simple types. The direct members of the union can
+ * be obtained by {@link #getUnionMemberTypes}. When unions
+ * consist of other unions, it is useful to know useful to know
+ * the "leaves of the union tree", so the
+ * set of non-union types making up the union can be obtained
+ * by {@link #getUnionConstituentTypes}. The closure of the
+ * entire "union tree" is {@link #getUnionSubTypes} (this includes
+ * the type itself). For
+ * simple unions that do not consist of other unions, all three
+ * of these sets are the same.
+ *
Complex types have nested structure. They are divided into
+ * four content types: empty content, simple content, element-only
+ * content, and mixed content. All kinds of complex types may
+ * have attributes. The content type for a complex type can
+ * be dermined using {@link #getContentType}. This will return
+ * {@link #EMPTY_CONTENT}, {@link #SIMPLE_CONTENT},
+ * {@link #ELEMENT_CONTENT}, or {@link #MIXED_CONTENT}.
+ *
If a complex type has {@link #EMPTY_CONTENT}, the content model will be null.
+ *
If a complex type has {@link #SIMPLE_CONTENT}, then it will extend the
+ * simple type that describes the content. In addition, the type
+ * may impose additional simple type facet restrictions; these can
+ * be determined in the same way they are for a simple type.
+ *
If a complex type has {@link #ELEMENT_CONTENT} or {@link #MIXED_CONTENT}, then
+ * the detailed content model can be determined by examining
+ * the particle tree (which may be null for MIXED_CONTENT).
+ * The particle tree can be obtained via {@link #getContentModel}.
+ *
When working with a complex type, most users will find it
+ * sufficient to discover the summarized shape of the content model
+ * and attribute model using {@link #getElementProperties},
+ * {@link #getAttributeProperties}, and related methods rather than
+ * examining the particle tree and attribute model directly.
+ *
+ *
+ * @see SchemaTypeLoader
+ * @see XmlObject#schemaType
+ * @see SimpleValue#instanceType
+ */
+public interface SchemaType extends SchemaComponent, SchemaAnnotated {
+ /**
+ * The name used to describe the type in the schema.
+ * Null if the type is anonymous (nested), or if it is a document type.
+ */
+ QName getName();
+
+ /**
+ * The parent schema element.
+ * Null for top-level (named) types and document types.
+ */
+ SchemaField getContainerField();
+
+ /**
+ * True if this is a document type.
+ *
+ * Document types are generated for every global element. A document
+ * type is an unnamed complex type that contains exactly one element:
+ * we define these types, because they are the types of the "documents"
+ * which contain the defined global elements, and they all turn into
+ * Java types. (Named ElementnameDocument.)
+ */
+ boolean isDocumentType();
+
+ /**
+ * True if this is a attribute type.
+ *
+ * Attribute types are generated for every global attribute. An attribute
+ * type is an unnamed complex type that contains exactly one attribute:
+ * we define these types, because they are the types of the "attribute documents"
+ * which contain the defined global attribute, and they all turn into
+ * Java types. (Named AttributenameAttribute.)
+ */
+ boolean isAttributeType();
+
+
+ /**
+ * Returns the document element name if this is a document type,
+ * or null otherwise.
+ */
+ QName getDocumentElementName();
+
+ /**
+ * Returns the attribute qname if this is a attribute type,
+ * or null otherwise.
+ */
+ QName getAttributeTypeAttributeName();
+
+ /**
+ * The outer schema type.
+ * Null for top-level (named) types.
+ */
+ SchemaType getOuterType();
+
+ /**
+ * True if this anonymous type has no corresponding Java type. True for
+ * anonymous types nested within simple type restrictions.
+ */
+ boolean isSkippedAnonymousType();
+
+ /**
+ * True if this schema type was compiled to have a corresponding
+ * Java class.
+ */
+ boolean isCompiled();
+
+ /**
+ * The fully-qualified Java type name of the class.
+ */
+ String getFullJavaName();
+
+ /**
+ * The short unqualfiied Java name for the class.
+ */
+ String getShortJavaName();
+
+ /**
+ * The fully-qualified Java type name of the implementation class.
+ */
+ String getFullJavaImplName();
+
+ /**
+ * The short unqualfiied Java name for the implementation class.
+ */
+ String getShortJavaImplName();
+
+ /**
+ * The Java class corresponding to this schema type.
+ */
+ Class extends XmlObject> getJavaClass();
+
+ /**
+ * The Java class corresponding to the enumeration type for this schema type,
+ * if applicable (or null if not an enumeration).
+ */
+ Class extends StringEnumAbstractBase> getEnumJavaClass();
+
+ /**
+ * Returns user-specific information.
+ *
+ * @see SchemaBookmark
+ */
+ Object getUserData();
+
+ /**
+ * True if the Xsd type is anonymous (i.e., not top-level).
+ */
+ boolean isAnonymousType();
+
+ /**
+ * True for any of the 40+ built-in types.
+ */
+ boolean isBuiltinType();
+
+ /**
+ * True for the anySimpleType and any restrictions/unions/lists.
+ */
+ boolean isSimpleType();
+
+ /**
+ * Returns base restriction or extension type. Unions and lists
+ * return the anySimpleType.
+ */
+ SchemaType getBaseType();
+
+ /**
+ * Returns common base type with the given type. The returned
+ * type is the most specific declared base type of both types.
+ */
+ SchemaType getCommonBaseType(SchemaType type);
+
+ /**
+ * True if the specified type derives from this type (or if
+ * it is the same type).
+ *
+ * Note that XmlObject.type (the anyType) is assignable
+ * from all type, and the XmlBeans.noType (the absence of
+ * a type) is assignable to all types.
+ */
+ boolean isAssignableFrom(SchemaType type);
+
+ /**
+ * Returns an integer for the derivation type, either
+ * {@link #DT_EXTENSION}, {@link #DT_RESTRICTION}, {@link #DT_NOT_DERIVED}.
+ */
+ int getDerivationType();
+
+ /**
+ * Not derived. True for XmlObject.type only. See {@link #getDerivationType}.
+ */
+ int DT_NOT_DERIVED = 0;
+ /**
+ * Derived by restriction. See {@link #getDerivationType}.
+ */
+ int DT_RESTRICTION = 1;
+ /**
+ * Derived by extension. See {@link #getDerivationType}.
+ */
+ int DT_EXTENSION = 2;
+
+ /**
+ * Returns an integer for builtin types that can be used
+ * for quick comparison.
+ */
+ int getBuiltinTypeCode();
+
+ /**
+ * Not a builtin type
+ */
+ int BTC_NOT_BUILTIN = 0;
+ /**
+ * xs:anyType, aka {@link XmlObject#type}
+ */
+ int BTC_ANY_TYPE = 1;
+
+ /**
+ * The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive
+ */
+ int BTC_FIRST_PRIMITIVE = 2;
+
+ /**
+ * xs:anySimpleType, aka {@link XmlAnySimpleType#type}
+ */
+ int BTC_ANY_SIMPLE = 2;
+
+ /**
+ * xs:boolean, aka {@link XmlBoolean#type}
+ */
+ int BTC_BOOLEAN = 3;
+ /**
+ * xs:base64Binary, aka {@link XmlBase64Binary#type}
+ */
+ int BTC_BASE_64_BINARY = 4;
+ /**
+ * xs:hexBinary, aka {@link XmlBase64Binary#type}
+ */
+ int BTC_HEX_BINARY = 5;
+ /**
+ * xs:anyURI, aka {@link XmlAnyURI#type}
+ */
+ int BTC_ANY_URI = 6;
+ /**
+ * xs:QName, aka {@link XmlQName#type}
+ */
+ int BTC_QNAME = 7;
+ /**
+ * xs:NOTATION, aka {@link XmlNOTATION#type}
+ */
+ int BTC_NOTATION = 8;
+ /**
+ * xs:float, aka {@link XmlFloat#type}
+ */
+ int BTC_FLOAT = 9;
+ /**
+ * xs:double, aka {@link XmlDouble#type}
+ */
+ int BTC_DOUBLE = 10;
+ /**
+ * xs:decimal, aka {@link XmlDecimal#type}
+ */
+ int BTC_DECIMAL = 11;
+ /**
+ * xs:string, aka {@link XmlString#type}
+ */
+ int BTC_STRING = 12;
+
+ /**
+ * xs:duration, aka {@link XmlDuration#type}
+ */
+ int BTC_DURATION = 13;
+ /**
+ * xs:dateTime, aka {@link XmlDateTime#type}
+ */
+ int BTC_DATE_TIME = 14;
+ /**
+ * xs:time, aka {@link XmlTime#type}
+ */
+ int BTC_TIME = 15;
+ /**
+ * xs:date, aka {@link XmlDate#type}
+ */
+ int BTC_DATE = 16;
+ /**
+ * xs:gYearMonth, aka {@link XmlGYearMonth#type}
+ */
+ int BTC_G_YEAR_MONTH = 17;
+ /**
+ * xs:gYear, aka {@link XmlGYear#type}
+ */
+ int BTC_G_YEAR = 18;
+ /**
+ * xs:gMonthDay, aka {@link XmlGMonthDay#type}
+ */
+ int BTC_G_MONTH_DAY = 19;
+ /**
+ * xs:gDay, aka {@link XmlGDay#type}
+ */
+ int BTC_G_DAY = 20;
+ /**
+ * xs:gMonth, aka {@link XmlGMonth#type}
+ */
+ int BTC_G_MONTH = 21;
+
+ /**
+ * The primitive types have codes between BTC_FIRST_PRIMITIVE and BTC_LAST_PRIMITIVE inclusive
+ */
+ int BTC_LAST_PRIMITIVE = 21;
+
+ // derived numerics
+ /**
+ * xs:integer, aka {@link XmlInteger#type}
+ */
+ int BTC_INTEGER = 22;
+ /**
+ * xs:long, aka {@link XmlLong#type}
+ */
+ int BTC_LONG = 23;
+ /**
+ * xs:int, aka {@link XmlInt#type}
+ */
+ int BTC_INT = 24;
+ /**
+ * xs:short, aka {@link XmlShort#type}
+ */
+ int BTC_SHORT = 25;
+ /**
+ * xs:byte, aka {@link XmlByte#type}
+ */
+ int BTC_BYTE = 26;
+ /**
+ * xs:nonPositiveInteger, aka {@link XmlNonPositiveInteger#type}
+ */
+ int BTC_NON_POSITIVE_INTEGER = 27;
+ /**
+ * xs:NegativeInteger, aka {@link XmlNegativeInteger#type}
+ */
+ int BTC_NEGATIVE_INTEGER = 28;
+ /**
+ * xs:nonNegativeInteger, aka {@link XmlNonNegativeInteger#type}
+ */
+ int BTC_NON_NEGATIVE_INTEGER = 29;
+ /**
+ * xs:positiveInteger, aka {@link XmlPositiveInteger#type}
+ */
+ int BTC_POSITIVE_INTEGER = 30;
+ /**
+ * xs:unsignedLong, aka {@link XmlUnsignedLong#type}
+ */
+ int BTC_UNSIGNED_LONG = 31;
+ /**
+ * xs:unsignedInt, aka {@link XmlUnsignedInt#type}
+ */
+ int BTC_UNSIGNED_INT = 32;
+ /**
+ * xs:unsignedShort, aka {@link XmlUnsignedShort#type}
+ */
+ int BTC_UNSIGNED_SHORT = 33;
+ /**
+ * xs:unsignedByte, aka {@link XmlUnsignedByte#type}
+ */
+ int BTC_UNSIGNED_BYTE = 34;
+
+ // derived strings
+ /**
+ * xs:normalizedString, aka {@link XmlNormalizedString#type}
+ */
+ int BTC_NORMALIZED_STRING = 35;
+ /**
+ * xs:token, aka {@link XmlToken#type}
+ */
+ int BTC_TOKEN = 36;
+ /**
+ * xs:Name, aka {@link XmlName#type}
+ */
+ int BTC_NAME = 37;
+ /**
+ * xs:NCName, aka {@link XmlNCName#type}
+ */
+ int BTC_NCNAME = 38;
+ /**
+ * xs:language, aka {@link XmlLanguage#type}
+ */
+ int BTC_LANGUAGE = 39;
+ /**
+ * xs:ID, aka {@link XmlID#type}
+ */
+ int BTC_ID = 40;
+ /**
+ * xs:IDREF, aka {@link XmlIDREF#type}
+ */
+ int BTC_IDREF = 41;
+ /**
+ * xs:IDREFS, aka {@link XmlIDREFS#type}
+ */
+ int BTC_IDREFS = 42;
+ /**
+ * xs:ENTITY, aka {@link XmlENTITY#type}
+ */
+ int BTC_ENTITY = 43;
+ /**
+ * xs:ENTITIES, aka {@link XmlENTITIES#type}
+ */
+ int BTC_ENTITIES = 44;
+ /**
+ * xs:NMTOKEN, aka {@link XmlNMTOKEN#type}
+ */
+ int BTC_NMTOKEN = 45;
+ /**
+ * xs:NMTOKENS, aka {@link XmlNMTOKENS#type}
+ */
+ int BTC_NMTOKENS = 46;
+
+ int BTC_LAST_BUILTIN = 46;
+
+ /**
+ * True for anyType and anySimpleType.
+ */
+ boolean isURType();
+
+ /**
+ * True for the type object that represents a the absence of a determined type.
+ * XML Objects whose type isNoType() are never valid.
+ */
+ boolean isNoType();
+
+ /**
+ * Returns the SchemaTypeLoader in which this type was defined.
+ * Complex types are defined and used in exactly one schema type
+ * system, but simple types are defined in one type system and can
+ * be used in any number of type systems. The most common case is
+ * the builtin types, which are defined in the builtin type system
+ * and used elsewhere.
+ */
+ SchemaTypeSystem getTypeSystem();
+
+ /**
+ * True if this type cannot be used directly in instances
+ */
+ boolean isAbstract();
+
+ /**
+ * True if other types cannot extend this type (only for complex types)
+ */
+ boolean finalExtension();
+
+ /**
+ * True if other types cannot restrict this type
+ */
+ boolean finalRestriction();
+
+ /**
+ * True if list derivation of this type is prohibited (only for simple types)
+ */
+ boolean finalList();
+
+ /**
+ * True if union derivation of this type is prohibited (only for simple types)
+ */
+ boolean finalUnion();
+
+ /**
+ * True if extensions of this type cannot be substituted for this type
+ */
+ boolean blockExtension();
+
+ /**
+ * True if restrictions of this type cannot be substituted for this type
+ */
+ boolean blockRestriction();
+
+ /**
+ * Returns {@link #EMPTY_CONTENT}, {@link #SIMPLE_CONTENT}, {@link #ELEMENT_CONTENT}, or
+ * {@link #MIXED_CONTENT} for complex types. For noncomplex types, returns
+ * {@link #NOT_COMPLEX_TYPE}.
+ */
+ int getContentType();
+
+ /**
+ * Not a complex type. See {@link #getContentType()}.
+ */
+ int NOT_COMPLEX_TYPE = 0;
+ /**
+ * Empty content. See {@link #getContentType()}.
+ */
+ int EMPTY_CONTENT = 1;
+ /**
+ * Simple content. See {@link #getContentType()}.
+ */
+ int SIMPLE_CONTENT = 2;
+ /**
+ * Element-only content. See {@link #getContentType()}.
+ */
+ int ELEMENT_CONTENT = 3;
+ /**
+ * Mixed content. See {@link #getContentType()}.
+ */
+ int MIXED_CONTENT = 4;
+
+
+ /**
+ * For complex types with simple content returns the base type for this
+ * type's content. In most cases, this is the same as the base type, but
+ * it can also be an anonymous type.
+ */
+ SchemaType getContentBasedOnType();
+
+ /**
+ * Returns a {@link SchemaTypeElementSequencer} object, which can then
+ * be used to validate complex content inside this element. This is useful
+ * for example for trying out different names and see which one would be
+ * valid as a child of this element.
+ */
+ SchemaTypeElementSequencer getElementSequencer();
+
+ /**
+ * The array of inner (anonymous) types defined
+ * within this type.
+ */
+ SchemaType[] getAnonymousTypes();
+
+ /**
+ * Returns a SchemaProperty corresponding to an element within this
+ * complex type by looking up the element name.
+ */
+ SchemaProperty getElementProperty(QName eltName);
+
+ /**
+ * Returns all the SchemaProperties corresponding to elements.
+ */
+ SchemaProperty[] getElementProperties();
+
+ /**
+ * Returns a SchemaProperty corresponding to an attribute within this
+ * complex type by looking up the attribute name.
+ */
+ SchemaProperty getAttributeProperty(QName attrName);
+
+ /**
+ * Returns all the SchemaProperties corresponding to attributes.
+ */
+ SchemaProperty[] getAttributeProperties();
+
+ /**
+ * Returns all the SchemaProperties within this complex type,
+ * elements followed by attributes.
+ */
+ SchemaProperty[] getProperties();
+
+ /**
+ * Returns the SchemaProperties defined by this complex type,
+ * exclusive of the base type (if any).
+ */
+ SchemaProperty[] getDerivedProperties();
+
+ /**
+ * Returns the attribute model for this complex type (with simple or complex content).
+ */
+ SchemaAttributeModel getAttributeModel();
+
+ /**
+ * True if this type permits wildcard attributes. See the attribute model for
+ * more information about which wildcards are allowed.
+ */
+ boolean hasAttributeWildcards();
+
+ /**
+ * Returns the complex content model for this complex type (with complex content).
+ */
+ SchemaParticle getContentModel();
+
+ /**
+ * True if this type permits element wildcards. See the content model for
+ * more information about which wildcards are allowed, and where.
+ */
+ boolean hasElementWildcards();
+
+ /**
+ * For document types, true if the given name can be substituted for the
+ * document element name.
+ */
+ boolean isValidSubstitution(QName name);
+
+ /**
+ * True if the complex content model for this complex type is an "all" group.
+ */
+ boolean hasAllContent();
+
+ /**
+ * True if particles have same defaults, nillability, etc, that are
+ * invariant when order changes. Computed only for Javaized types.
+ */
+ boolean isOrderSensitive();
+
+ /**
+ * Returns the type of a child element based on the element name and
+ * an xsi:type attribute (and the type system within which names are
+ * resolved).
+ */
+ SchemaType getElementType(QName eltName, QName xsiType, SchemaTypeLoader wildcardTypeLoader);
+
+ /**
+ * Returns the type of an attribute based on the attribute name and
+ * the type system within which (wildcard) names are resolved.
+ */
+ SchemaType getAttributeType(QName eltName, SchemaTypeLoader wildcardTypeLoader);
+
+ /* *********************************************************** */
+ /* SIMPLE TYPE MODEL BELOW */
+ /* *********************************************************** */
+
+ /**
+ * xs:length facet
+ */
+ int FACET_LENGTH = 0;
+ /**
+ * xs:minLength facet
+ */
+ int FACET_MIN_LENGTH = 1;
+ /**
+ * xs:maxLength facet
+ */
+ int FACET_MAX_LENGTH = 2;
+ /**
+ * xs:minExclusive facet
+ */
+ int FACET_MIN_EXCLUSIVE = 3;
+ /**
+ * xs:minInclusive facet
+ */
+ int FACET_MIN_INCLUSIVE = 4;
+ /**
+ * xs:maxInclusive facet
+ */
+ int FACET_MAX_INCLUSIVE = 5;
+ /**
+ * xs:maxExclusive facet
+ */
+ int FACET_MAX_EXCLUSIVE = 6;
+ /**
+ * xs:totalDigits facet
+ */
+ int FACET_TOTAL_DIGITS = 7;
+ /**
+ * xs:fractionDigits facet
+ */
+ int FACET_FRACTION_DIGITS = 8;
+
+ int LAST_BASIC_FACET = 8;
+
+ /**
+ * xs:whiteSpace facet - use {@link #getWhiteSpaceRule} instead
+ */
+ int FACET_WHITE_SPACE = 9;
+ /**
+ * xs:pattern facet - use {@link #matchPatternFacet} instead
+ */
+ int FACET_PATTERN = 10;
+ /**
+ * xs:enumeration facet - use {@link #getEnumerationValues} instead
+ */
+ int FACET_ENUMERATION = 11;
+
+ /**
+ * The last ordinary facet code
+ */
+ int LAST_FACET = 11;
+
+ /**
+ * @see #ordered
+ */
+ int PROPERTY_ORDERED = 12;
+ /**
+ * @see #isBounded
+ */
+ int PROPERTY_BOUNDED = 13;
+ /**
+ * @see #isFinite
+ */
+ int PROPERTY_CARDINALITY = 14;
+ /**
+ * @see #isNumeric
+ */
+ int PROPERTY_NUMERIC = 15;
+
+ /**
+ * The last property code
+ */
+ int LAST_PROPERTY = 15;
+
+
+ /**
+ * Returns the value of the given facet, or null if
+ * none is set.
+ */
+ XmlAnySimpleType getFacet(int facetCode);
+
+ /**
+ * True if the given facet is fixed.
+ */
+ boolean isFacetFixed(int facetCode);
+
+ /**
+ * True if ordered. Returns either {@link #UNORDERED},
+ * {@link #PARTIAL_ORDER}, or {@link #TOTAL_ORDER}.
+ */
+ int ordered();
+
+ /**
+ * Unordered. See {@link #ordered}.
+ */
+ int UNORDERED = 0;
+ /**
+ * Partially ordered. See {@link #ordered}.
+ */
+ int PARTIAL_ORDER = 1;
+ /**
+ * Totally ordered. See {@link #ordered}.
+ */
+ int TOTAL_ORDER = 2;
+
+ /**
+ * True if bounded.
+ */
+ boolean isBounded();
+
+ /**
+ * True if finite.
+ */
+ boolean isFinite();
+
+ /**
+ * True if numeric.
+ */
+ boolean isNumeric();
+
+ /**
+ * True if there are regex pattern facents
+ */
+ boolean hasPatternFacet();
+
+ /**
+ * True
+ */
+ String[] getPatterns();
+
+ /**
+ * True if the given string matches the pattern facets.
+ * Always true if there are no pattern facets.
+ */
+ boolean matchPatternFacet(String s);
+
+ /**
+ * Returns the array of valid objects from the
+ * enumeration facet, null if no enumeration defined.
+ */
+ XmlAnySimpleType[] getEnumerationValues();
+
+ /**
+ * True if this is a string enum where an integer
+ * is assigned to each enumerated value.
+ */
+ boolean hasStringEnumValues();
+
+ /**
+ * If this is a string enumeration, returns the most basic base schema
+ * type that this enuemration is based on. Otherwise returns null.
+ */
+ SchemaType getBaseEnumType();
+
+ /**
+ * Returns the array of SchemaStringEnumEntries for this type: this
+ * array includes information about the java constant names used for
+ * each string enum entry.
+ */
+ SchemaStringEnumEntry[] getStringEnumEntries();
+
+ /**
+ * Returns the string enum entry corresponding to the given enumerated
+ * string, or null if there is no match or this type is not
+ * a string enumeration.
+ */
+ SchemaStringEnumEntry enumEntryForString(String s);
+
+ /**
+ * Returns the string enum value corresponding to the given enumerated
+ * string, or null if there is no match or this type is not
+ * a string enumeration.
+ */
+ StringEnumAbstractBase enumForString(String s);
+
+ /**
+ * Returns the string enum value corresponding to the given enumerated
+ * string, or null if there is no match or this type is not
+ * a string enumeration.
+ */
+ StringEnumAbstractBase enumForInt(int i);
+
+ /**
+ * True for any of the 20 primitive types (plus anySimpleType)
+ */
+ boolean isPrimitiveType();
+
+ /**
+ * Returns whether the simple type is ATOMIC, UNION, or LIST.
+ * Returns {@link #NOT_SIMPLE}, {@link #ATOMIC}, {@link #UNION},
+ * or {@link #LIST}.
+ */
+ int getSimpleVariety();
+
+ /**
+ * Not a simple type or simple content. See {@link #getSimpleVariety}.
+ */
+ int NOT_SIMPLE = 0;
+ /**
+ * Atomic type. See {@link #getSimpleVariety}
+ */
+ int ATOMIC = 1;
+ /**
+ * Union type. See {@link #getSimpleVariety}
+ */
+ int UNION = 2;
+ /**
+ * Simple list type. See {@link #getSimpleVariety}
+ */
+ int LIST = 3;
+
+
+ /**
+ * For atomic types only: get the primitive type underlying this one.
+ *
+ * Returns null if this is not an atomic type.
+ */
+ SchemaType getPrimitiveType();
+
+ /**
+ * For atomic numeric restrictions of decimal only: the
+ * numeric size category. Takes into account min and max
+ * restrictions as well as totalDigits and fractionDigits
+ * facets.
+ *
+ * Returns either {@link #NOT_DECIMAL},
+ * {@link #SIZE_BYTE}, {@link #SIZE_SHORT}, {@link #SIZE_INT},
+ * {@link #SIZE_LONG}, {@link #SIZE_BIG_INTEGER}, or
+ * {@link #SIZE_BIG_DECIMAL}.
+ */
+ int getDecimalSize();
+
+ /**
+ * Not a decimal restriction. See {@link #getDecimalSize}.
+ */
+ int NOT_DECIMAL = 0;
+ /**
+ * Fits in a byte. See {@link #getDecimalSize}.
+ */
+ int SIZE_BYTE = 8;
+ /**
+ * Fits in a short. See {@link #getDecimalSize}.
+ */
+ int SIZE_SHORT = 16;
+ /**
+ * Fits in an int. See {@link #getDecimalSize}.
+ */
+ int SIZE_INT = 32;
+ /**
+ * Fits in a long. See {@link #getDecimalSize}.
+ */
+ int SIZE_LONG = 64;
+ /**
+ * Fits in a {@link java.math.BigInteger}. See {@link #getDecimalSize}.
+ */
+ int SIZE_BIG_INTEGER = 1000000; // "millions"
+ /**
+ * Fits in a {@link java.math.BigDecimal}. See {@link #getDecimalSize}.
+ */
+ int SIZE_BIG_DECIMAL = 1000001; // "even more"
+
+ /**
+ * For union types only: get the shallow member types. This
+ * returns the declared member types of the union, so, for
+ * example if the type contains another union, the nested
+ * members of that union are NOT returned here.
+ *
+ * Returns null if this type is not a union.
+ */
+ SchemaType[] getUnionMemberTypes();
+
+ /**
+ * For union types only: gets the full tree of member types.
+ * This computes the closure of the set returned by
+ * getUnionMemberTypes(), so, for example, it returns
+ * all the types nested within unions of unions as well
+ * as the top-level members; the set also includes the
+ * type itself. If you are seeking only the basic
+ * non-union consituents, use getUnionConstituentTypes.
+ *
+ * Returns null if this type is not a union.
+ */
+ SchemaType[] getUnionSubTypes();
+
+ /**
+ * For union types only: get the constituent member types. This
+ * returns only non-union types, so, for example, for unions of
+ * unions, this returns the flattened list of individual member
+ * types within the innermost unions.
+ *
+ * Returns null if this type is not a union.
+ */
+ SchemaType[] getUnionConstituentTypes();
+
+ /**
+ * For union types only: get the most specific common base
+ * type of the constituent member types. May return a UR type.
+ *
+ * Returns null if this type is not a union.
+ */
+ SchemaType getUnionCommonBaseType();
+
+ /**
+ * For anonymous types defined inside a union only: gets
+ * the integer indicating the declaration order of this
+ * type within the outer union type, or zero if this is
+ * not applicable. The first anonymous union member within
+ * a union type is numbered "1". Used to differentiate
+ * between different anonymous types.
+ */
+ int getAnonymousUnionMemberOrdinal();
+
+ /**
+ * For list types only: get the item type. This is the atomic
+ * or union type that is the type of every entry in the list.
+ *
+ * Returns null if this type is not a list.
+ */
+ SchemaType getListItemType();
+
+ /**
+ * For nonunion simple types: get the whitespace rule. This is
+ * either {@link #WS_PRESERVE}, {@link #WS_REPLACE}, or
+ * {@link #WS_COLLAPSE}. Returns {@link #WS_UNSPECIFIED}
+ * for unions and complex types.
+ */
+ int getWhiteSpaceRule();
+
+ /**
+ * Whitespace rule unspecified. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_UNSPECIFIED = 0;
+ /**
+ * Whitespace preserved. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_PRESERVE = 1;
+ /**
+ * Whitespace replaced by ordinary space. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_REPLACE = 2;
+ /**
+ * Whitespace collapsed and trimmed. See {@link #getWhiteSpaceRule}.
+ */
+ int WS_COLLAPSE = 3;
+
+ /**
+ * Creates an immutable simple type value that does not reside in a tree.
+ */
+ XmlAnySimpleType newValue(Object v);
+
+
+ /**
+ * Used to allow on-demand loading of types.
+ */
+ final class Ref extends SchemaComponent.Ref {
+ public Ref(SchemaType type) {
+ super(type);
+ }
+
+ public Ref(SchemaTypeSystem system, String handle) {
+ super(system, handle);
+ }
+
+ public final int getComponentType() {
+ return SchemaComponent.TYPE;
+ }
+
+ public final SchemaType get() {
+ return (SchemaType) getComponent();
+ }
+ }
+
+ /**
+ * Retruns a SchemaType.Ref pointing to this schema type itself.
+ */
+ Ref getRef();
+
+ /**
+ * Returns a QNameSet of elements that may exist in wildcard
+ * buchets and are not explicitly defined in this schema type.
+ * Note: In this example:
+ *
+ *
+ *
+ *
+ *
+ *
+ * the returned QNameSet will not contain the qname of 'someElement'.
+ *
+ * @return the constructed QNameSet
+ */
+ QNameSet qnameSetForWildcardElements();
+
+ /**
+ * Returns a QNameSet of attributes that may exist in wildcard
+ * buchets and are not explicitly defined in this schema type.
+ * Note: In this example:
+ *
+ * ...
+ *
+ *
+ *
+ * the returned QNameSet will not contain the qname of 'someAttribute'.
+ *
+ * @return the constructed QNameSet
+ */
+ QNameSet qnameSetForWildcardAttributes();
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaTypeElementSequencer.java b/src/main/java/org/apache/xmlbeans/SchemaTypeElementSequencer.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaTypeElementSequencer.java
rename to src/main/java/org/apache/xmlbeans/SchemaTypeElementSequencer.java
diff --git a/src/main/java/org/apache/xmlbeans/SchemaTypeLoader.java b/src/main/java/org/apache/xmlbeans/SchemaTypeLoader.java
new file mode 100644
index 0000000..6928658
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/SchemaTypeLoader.java
@@ -0,0 +1,223 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+
+/**
+ * Represents a searchable set of XML Schema component definitions.
+ *
+ * SchemaTypeLoader is somewhat analogous to {@link java.lang.ClassLoader},
+ * because it is responsible for finding {@link SchemaComponent} definitions
+ * by name, yet it is not responsible for being able to enumerate all the
+ * component definitons available. (If you wish to enumerate component
+ * definitions, see {@link SchemaTypeSystem}.) There are some ways in which
+ * SchemaTypeSystems are dissimilar from ClassLoaders, however.
+ * Since XML Schema has a number of instance-oriented typing mechanisms
+ * (such as wildcards) that do not exist in Java, a SchemaTypeLoader is
+ * not associated with a type; instead, a SchemaTypeLoader is associated
+ * with each XML instance.
+ *
+ * Every XML instance is loaded within the context of a SchemaTypeLoader;
+ * the SchemaTypeLoader for an instance is used to resolve all type definitions
+ * within the instance and for applying type-sensitive methods such as
+ * {@link XmlObject#validate}.
+ *
+ * Normally the SchemaTypeLoader being used for all instances is the
+ * context type loader (that is, the SchemaTypeLoader returned from
+ * {@link XmlBeans#getContextTypeLoader()}). The context type loader
+ * consults the thread's context ClassLoader (see {@link Thread#getContextClassLoader()})
+ * to find schema type defintions that are available on the classpath.
+ * The net result is that you can use schema types simply by putting
+ * their compiled schema JARs on your classpath.
+ * If you wish to load instances using a different SchemaTypeLoader, then you must
+ * call {@link #parse} methods on the SchemaTypeLoader instance explicitly
+ * rather than using the normal convenient Factory methods.
+ *
+ * A SchemaTypeLoader can be obtained by dynamically loading XSD files
+ * using {@link XmlBeans#loadXsd}, or by assembling other SchemaTypeLoaders
+ * or SchemaTypeSystems on a path using {@link XmlBeans#typeLoaderUnion}.
+ *
+ * @see XmlBeans#loadXsd
+ * @see XmlBeans#getContextTypeLoader
+ * @see XmlBeans#typeLoaderUnion
+ * @see SchemaTypeSystem
+ */
+public interface SchemaTypeLoader {
+ /**
+ * Returns the type with the given name, or null if none.
+ */
+ SchemaType findType(QName name);
+
+ /**
+ * Returns the document type rooted at the given element name, or null if none.
+ */
+ SchemaType findDocumentType(QName name);
+
+ /**
+ * Returns the attribute type containing the given attribute name, or null if none.
+ */
+ SchemaType findAttributeType(QName name);
+
+ /**
+ * Returns the global element defintion with the given name, or null if none.
+ */
+ SchemaGlobalElement findElement(QName name);
+
+ /**
+ * Returns the global attribute defintion with the given name, or null if none.
+ */
+ SchemaGlobalAttribute findAttribute(QName name);
+
+ /**
+ * Returns the model group defintion with the given name, or null if none.
+ */
+ SchemaModelGroup findModelGroup(QName name);
+
+ /**
+ * Returns the attribute group defintion with the given name, or null if none.
+ */
+ SchemaAttributeGroup findAttributeGroup(QName name);
+
+ /**
+ * True if the typeloader contains any definitions in the given namespace.
+ */
+ boolean isNamespaceDefined(String namespace);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaType.Ref findTypeRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaType.Ref findDocumentTypeRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaType.Ref findAttributeTypeRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaGlobalElement.Ref findElementRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaGlobalAttribute.Ref findAttributeRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaModelGroup.Ref findModelGroupRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaAttributeGroup.Ref findAttributeGroupRef(QName name);
+
+ /**
+ * Used for on-demand loading.
+ */
+ SchemaIdentityConstraint.Ref findIdentityConstraintRef(QName name);
+
+ /**
+ * Finds a type for a given signature string
+ */
+ SchemaType typeForSignature(String signature);
+
+ /**
+ * Finds a type for a given fully-qualified XML Bean classname
+ */
+ SchemaType typeForClassname(String classname);
+
+ /**
+ * Loads original XSD source as a stream. See {@link SchemaType#getSourceName}.
+ */
+ InputStream getSourceAsStream(String sourceName);
+
+ /**
+ * Compiles an XPath
+ */
+ String compilePath(String pathExpr, XmlOptions options) throws XmlException;
+
+ /**
+ * Compiles an XQuery
+ */
+ String compileQuery(String queryExpr, XmlOptions options) throws XmlException;
+
+ /**
+ * Creates an instance of the given type.
+ */
+ XmlObject newInstance(SchemaType type, XmlOptions options);
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(String xmlText, SchemaType type, XmlOptions options) throws XmlException;
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException;
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException;
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(InputStream jiois, SchemaType type, XmlOptions options) throws XmlException, IOException;
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(XMLStreamReader xsr, SchemaType type, XmlOptions options) throws XmlException;
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(Reader jior, SchemaType type, XmlOptions options) throws XmlException, IOException;
+
+ /**
+ * Parses an instance of the given type.
+ */
+ XmlObject parse(Node node, SchemaType type, XmlOptions options) throws XmlException;
+
+ /**
+ * Returns an XmlSaxHandler that can parse an instance of the given type.
+ */
+ XmlSaxHandler newXmlSaxHandler(SchemaType type, XmlOptions options);
+
+ /**
+ * Returns a DOMImplementation.
+ */
+ DOMImplementation newDomImplementation(XmlOptions options);
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaTypeLoaderException.java b/src/main/java/org/apache/xmlbeans/SchemaTypeLoaderException.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaTypeLoaderException.java
rename to src/main/java/org/apache/xmlbeans/SchemaTypeLoaderException.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem.java b/src/main/java/org/apache/xmlbeans/SchemaTypeSystem.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem.java
rename to src/main/java/org/apache/xmlbeans/SchemaTypeSystem.java
diff --git a/src/main/java/org/apache/xmlbeans/SimpleValue.java b/src/main/java/org/apache/xmlbeans/SimpleValue.java
new file mode 100644
index 0000000..9e6d5dd
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/SimpleValue.java
@@ -0,0 +1,246 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.namespace.QName;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * All XmlObject implementations can be coerced to SimpleValue.
+ * For any given schema type, only a subset of the conversion
+ * methods will work. Others will throw an exception.
+ *
+ * SimpleValue is useful for declaring variables which can hold
+ * more than one similar schema type that may not happen to
+ * have a common XML base type, for example, two list types,
+ * or two unrelated integer restrictions that happen to fit
+ * into an int.
+ */
+public interface SimpleValue extends XmlObject {
+ /**
+ * The same as getSchemaType unless this is a union instance
+ * or nil value.
+ *
+ * For unions, this returns the non-union consituent type of
+ * this instance. This type may change if setters are called
+ * that cause the instance to change to another constituent
+ * type of the union.
+ *
+ * For nil values, this returns null.
+ */
+ SchemaType instanceType();
+
+ /**
+ * Returns the value as a {@link String}.
+ */
+ String getStringValue();
+
+ /**
+ * Returns the value as a boolean.
+ */
+ boolean getBooleanValue();
+
+ /**
+ * Returns the value as a byte.
+ */
+ byte getByteValue();
+
+ /**
+ * Returns the value as a short.
+ */
+ short getShortValue();
+
+ /**
+ * Returns the value as an int.
+ */
+ int getIntValue();
+
+ /**
+ * Returns the value as a long.
+ */
+ long getLongValue();
+
+ /**
+ * Returns the value as a {@link BigInteger}.
+ */
+ BigInteger getBigIntegerValue();
+
+ /**
+ * Returns the value as a {@link BigDecimal}.
+ */
+ BigDecimal getBigDecimalValue();
+
+ /**
+ * Returns the value as a float.
+ */
+ float getFloatValue();
+
+ /**
+ * Returns the value as a double.
+ */
+ double getDoubleValue();
+
+ /**
+ * Returns the value as a byte array.
+ */
+ byte[] getByteArrayValue();
+
+ /**
+ * Returns the value as a {@link StringEnumAbstractBase}.
+ */
+ StringEnumAbstractBase getEnumValue();
+
+ /**
+ * Returns the value as a {@link Calendar}.
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Returns the value as a {@link Date}.
+ */
+ Date getDateValue();
+
+ /**
+ * Returns the value as a {@link GDate}.
+ */
+ GDate getGDateValue();
+
+ /**
+ * Returns the value as a {@link GDuration}.
+ */
+ GDuration getGDurationValue();
+
+ /**
+ * Returns the value as a {@link QName}.
+ */
+ QName getQNameValue();
+
+ /**
+ * Returns the value as a {@link List} of friendly Java objects (String, Integer, Byte, Short, Long, BigInteger, Decimal, Float, Double, byte[], Calendar, GDuration).
+ */
+ List> getListValue();
+
+ /**
+ * Returns the value as a {@link List} of XmlAnySimpleType objects.
+ */
+ List extends XmlAnySimpleType> xgetListValue();
+
+ /**
+ * Returns a union value as a its natural friendly Java object (String, Integer, Byte, Short, Long, BigInteger, Decimal, Float, Double, byte[], Calendar, GDuration).
+ */
+ Object getObjectValue();
+
+ // following are simple type value setters
+
+ /**
+ * Sets the value as a {@link String}.
+ */
+ void setStringValue(String obj);
+
+ /**
+ * Sets the value as a boolean.
+ */
+ void setBooleanValue(boolean v);
+
+ /**
+ * Sets the value as a byte.
+ */
+ void setByteValue(byte v);
+
+ /**
+ * Sets the value as a short.
+ */
+ void setShortValue(short v);
+
+ /**
+ * Sets the value as an int.
+ */
+ void setIntValue(int v);
+
+ /**
+ * Sets the value as a long.
+ */
+ void setLongValue(long v);
+
+ /**
+ * Sets the value as a {@link BigInteger}.
+ */
+ void setBigIntegerValue(BigInteger obj);
+
+ /**
+ * Sets the value as a {@link BigDecimal}.
+ */
+ void setBigDecimalValue(BigDecimal obj);
+
+ /**
+ * Sets the value as a float.
+ */
+ void setFloatValue(float v);
+
+ /**
+ * Sets the value as a double.
+ */
+ void setDoubleValue(double v);
+
+ /**
+ * Sets the value as a byte array.
+ */
+ void setByteArrayValue(byte[] obj);
+
+ /**
+ * Sets the value as a {@link StringEnumAbstractBase}.
+ */
+ void setEnumValue(StringEnumAbstractBase obj);
+
+ /**
+ * Sets the value as a {@link Calendar}.
+ */
+ void setCalendarValue(Calendar obj);
+
+ /**
+ * Sets the value as a {@link Date}.
+ */
+ void setDateValue(Date obj);
+
+ /**
+ * Sets the value as a {@link GDate}.
+ */
+ void setGDateValue(GDate obj);
+
+ /**
+ * Sets the value as a {@link GDuration}.
+ */
+ void setGDurationValue(GDuration obj);
+
+ /**
+ * Sets the value as a {@link QName}.
+ */
+ void setQNameValue(QName obj);
+
+ /**
+ * Sets the value as a {@link List}.
+ */
+ void setListValue(List> obj);
+
+ /**
+ * Sets the value as an arbitrary {@link Object}.
+ */
+ void setObjectValue(Object obj);
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/StringEnumAbstractBase.java b/src/main/java/org/apache/xmlbeans/StringEnumAbstractBase.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/StringEnumAbstractBase.java
rename to src/main/java/org/apache/xmlbeans/StringEnumAbstractBase.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/SystemProperties.java b/src/main/java/org/apache/xmlbeans/SystemProperties.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/SystemProperties.java
rename to src/main/java/org/apache/xmlbeans/SystemProperties.java
diff --git a/src/main/java/org/apache/xmlbeans/ThreadLocalUtil.java b/src/main/java/org/apache/xmlbeans/ThreadLocalUtil.java
new file mode 100644
index 0000000..614cade
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/ThreadLocalUtil.java
@@ -0,0 +1,46 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import org.apache.xmlbeans.impl.common.SystemCache;
+import org.apache.xmlbeans.impl.schema.StscState;
+import org.apache.xmlbeans.impl.store.CharUtil;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.values.NamespaceContext;
+
+public class ThreadLocalUtil {
+
+ /**
+ * Clear {@link ThreadLocal}s of the current thread.
+ *
+ * This can be used to clean out a thread before "returning"
+ * it to a thread-pool or a Web-Container like Tomcat.
+ */
+ public static void clearAllThreadLocals() {
+ // clear thread locals in all classes which may hold some
+ XmlBeans.clearThreadLocals();
+ XmlFactoryHook.ThreadContext.clearThreadLocals();
+ StscState.clearThreadLocals();
+ CharUtil.clearThreadLocals();
+ Locale.clearThreadLocals();
+ NamespaceContext.clearThreadLocals();
+
+ // SystemCache is not a singleton, but also creates ThreadLocals,
+ // so we get the current instance and clean it out as well
+ SystemCache systemCache = SystemCache.get();
+ systemCache.clearThreadLocals();
+ }
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/UserType.java b/src/main/java/org/apache/xmlbeans/UserType.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/UserType.java
rename to src/main/java/org/apache/xmlbeans/UserType.java
diff --git a/src/main/java/org/apache/xmlbeans/XmlAnySimpleType.java b/src/main/java/org/apache/xmlbeans/XmlAnySimpleType.java
new file mode 100644
index 0000000..b4d8a01
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlAnySimpleType.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:anySimpleType type.
+ *
+ * All simple types are convertible to {@link String}.
+ */
+public interface XmlAnySimpleType extends XmlObject {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_anySimpleType");
+
+ /**
+ * Returns the value as a {@link String}
+ **/
+ String getStringValue();
+
+ /**
+ * Sets the value as a {@link String}
+ **/
+ void setStringValue(String s);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlAnySimpleType}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlAnySimpleType}
+ */
+ public static XmlAnySimpleType newInstance() {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlAnySimpleType}
+ */
+ public static XmlAnySimpleType newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlAnySimpleType} value
+ */
+ public static XmlAnySimpleType newValue(Object obj) {
+ return type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a String. For example: "<xml-fragment>anything</xml-fragment>".
+ */
+ public static XmlAnySimpleType parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a String. For example: "<xml-fragment>anything</xml-fragment>".
+ */
+ public static XmlAnySimpleType parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a File.
+ */
+ public static XmlAnySimpleType parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a File.
+ */
+ public static XmlAnySimpleType parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a URL.
+ */
+ public static XmlAnySimpleType parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a URL.
+ */
+ public static XmlAnySimpleType parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from an InputStream.
+ */
+ public static XmlAnySimpleType parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from an InputStream.
+ */
+ public static XmlAnySimpleType parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a Reader.
+ */
+ public static XmlAnySimpleType parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a Reader.
+ */
+ public static XmlAnySimpleType parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a DOM Node.
+ */
+ public static XmlAnySimpleType parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from a DOM Node.
+ */
+ public static XmlAnySimpleType parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from an XMLStreamReader.
+ */
+ public static XmlAnySimpleType parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnySimpleType} fragment from an XMLStreamReader.
+ */
+ public static XmlAnySimpleType parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnySimpleType) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlAnyURI.java b/src/main/java/org/apache/xmlbeans/XmlAnyURI.java
new file mode 100644
index 0000000..8fbe686
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlAnyURI.java
@@ -0,0 +1,159 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:anyURI type.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlAnyURI extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_anyURI");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlAnyURI}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlAnyURI}
+ */
+ public static XmlAnyURI newInstance() {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlAnyURI}
+ */
+ public static XmlAnyURI newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlAnyURI} value
+ */
+ public static XmlAnyURI newValue(Object obj) {
+ return (XmlAnyURI) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a String. For example: "<xml-fragment>http://www.w3.org/</xml-fragment>".
+ */
+ public static XmlAnyURI parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a String. For example: "<xml-fragment>http://www.w3.org/</xml-fragment>".
+ */
+ public static XmlAnyURI parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a File.
+ */
+ public static XmlAnyURI parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a File.
+ */
+ public static XmlAnyURI parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a URL.
+ */
+ public static XmlAnyURI parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a URL.
+ */
+ public static XmlAnyURI parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from an InputStream.
+ */
+ public static XmlAnyURI parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from an InputStream.
+ */
+ public static XmlAnyURI parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a Reader.
+ */
+ public static XmlAnyURI parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a Reader.
+ */
+ public static XmlAnyURI parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a DOM Node.
+ */
+ public static XmlAnyURI parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from a DOM Node.
+ */
+ public static XmlAnyURI parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from an XMLStreamReader.
+ */
+ public static XmlAnyURI parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlAnyURI} fragment from an XMLStreamReader.
+ */
+ public static XmlAnyURI parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlAnyURI) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlBase64Binary.java b/src/main/java/org/apache/xmlbeans/XmlBase64Binary.java
new file mode 100644
index 0000000..52f4f29
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlBase64Binary.java
@@ -0,0 +1,170 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:base64Binary type.
+ *
+ * Convertible to a byte array.
+ */
+public interface XmlBase64Binary extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_base64Binary");
+
+ /**
+ * Returns this value as a byte array.
+ **/
+ byte[] getByteArrayValue();
+
+ /**
+ * Sets this value as a byte array.
+ */
+ void setByteArrayValue(byte[] ba);
+
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlBase64Binary}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlBase64Binary}
+ */
+ public static XmlBase64Binary newInstance() {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlBase64Binary}
+ */
+ public static XmlBase64Binary newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlBase64Binary} value
+ */
+ public static XmlBase64Binary newValue(Object obj) {
+ return (XmlBase64Binary) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a String. For example: "<xml-fragment>VGhpcyBzdHJp</xml-fragment>".
+ */
+ public static XmlBase64Binary parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a String. For example: "<xml-fragment>VGhpcyBzdHJp</xml-fragment>".
+ */
+ public static XmlBase64Binary parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a File.
+ */
+ public static XmlBase64Binary parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a File.
+ */
+ public static XmlBase64Binary parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a URL.
+ */
+ public static XmlBase64Binary parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a URL.
+ */
+ public static XmlBase64Binary parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from an InputStream.
+ */
+ public static XmlBase64Binary parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from an InputStream.
+ */
+ public static XmlBase64Binary parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a Reader.
+ */
+ public static XmlBase64Binary parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a Reader.
+ */
+ public static XmlBase64Binary parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a DOM Node.
+ */
+ public static XmlBase64Binary parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from a DOM Node.
+ */
+ public static XmlBase64Binary parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from an XMLStreamReader.
+ */
+ public static XmlBase64Binary parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBase64Binary} fragment from an XMLStreamReader.
+ */
+ public static XmlBase64Binary parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlBase64Binary) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlBeans.java b/src/main/java/org/apache/xmlbeans/XmlBeans.java
new file mode 100644
index 0000000..5c131a2
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlBeans.java
@@ -0,0 +1,521 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
+import org.apache.xmlbeans.impl.schema.PathResourceLoader;
+import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
+import org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.lang.ref.SoftReference;
+import java.lang.reflect.Field;
+
+/**
+ * Provides an assortment of utilities
+ * for managing XML Bean types, type systems, QNames, paths,
+ * and queries.
+ */
+public final class XmlBeans {
+ private static final String HOLDER_CLASS_NAME = "TypeSystemHolder";
+ private static final String TYPE_SYSTEM_FIELD = "typeSystem";
+
+ private static String XMLBEANS_TITLE = "org.apache.xmlbeans";
+ private static String XMLBEANS_VERSION = "4.0.0";
+ private static String XMLBEANS_VENDOR = "Apache Software Foundation";
+
+ static {
+ Package pkg = XmlBeans.class.getPackage();
+ if (pkg != null && pkg.getImplementationVersion() != null) {
+ XMLBEANS_TITLE = pkg.getImplementationTitle();
+ XMLBEANS_VERSION = pkg.getImplementationVersion();
+ XMLBEANS_VENDOR = pkg.getImplementationVendor();
+ }
+ }
+
+ /**
+ * Returns the XmlBeans Package title, "org.apache.xmlbeans",
+ * the value of
+ * {@link Package#getImplementationTitle() XmlBeans.class.getPackage().getImplementationTitle()}.
+ */
+ public static final String getTitle() {
+ return XMLBEANS_TITLE;
+ }
+
+ /**
+ * Returns the XmlBeans vendor, "Apache Software Foundation",
+ * the value of
+ * {@link Package#getImplementationVendor() XmlBeans.class.getPackage().getImplementationVendor()}.
+ */
+ public static final String getVendor() {
+ return XMLBEANS_VENDOR;
+ }
+
+ /**
+ * Returns the XmlBeans version,
+ * the value of
+ * {@link Package#getImplementationVersion() XmlBeans.class.getPackage().getImplementationVersion()}.
+ */
+ public static final String getVersion() {
+ return XMLBEANS_VERSION;
+ }
+
+ /**
+ * Thread local QName cache for general use
+ */
+ private static final ThreadLocal _threadLocalLoaderQNameCache =
+ new ThreadLocal() {
+ protected Object initialValue() {
+ return new SoftReference(new QNameCache(32));
+ }
+ };
+
+ public static void clearThreadLocals() {
+ // clear thread local here
+ _threadLocalLoaderQNameCache.remove();
+ }
+
+ /**
+ * Returns a thread local QNameCache
+ */
+ public static QNameCache getQNameCache() {
+ SoftReference softRef = (SoftReference) _threadLocalLoaderQNameCache.get();
+ QNameCache qnameCache = (QNameCache) (softRef).get();
+ if (qnameCache == null) {
+ qnameCache = new QNameCache(32);
+ _threadLocalLoaderQNameCache.set(new SoftReference(qnameCache));
+ }
+ return qnameCache;
+ }
+
+ /**
+ * Obtains a name from the thread local QNameCache
+ */
+ public static QName getQName(String localPart) {
+ return getQNameCache().getName("", localPart);
+ }
+
+ /**
+ * Obtains a name from the thread local QNameCache
+ */
+
+ public static QName getQName(String namespaceUri, String localPart) {
+ return getQNameCache().getName(namespaceUri, localPart);
+ }
+
+ private static RuntimeException causedException(RuntimeException e, Throwable cause) {
+ e.initCause(cause);
+
+ return e;
+ }
+
+ /**
+ * Compiles an XPath, returning a String equal to that which was passed,
+ * but whose identity is that of one which has been precompiled and cached.
+ */
+ public static String compilePath(String pathExpr) throws XmlException {
+ return compilePath(pathExpr, null);
+ }
+
+ /**
+ * Compiles an XPath, returning a String equal to that which was passed,
+ * but whose identity is that of one which has been precompiled and cached;
+ * takes an option for specifying text that indicates the name of context node.
+ * The default is "this", as in "$this".
+ *
+ * @param options Options for the path. For example, you can call
+ * the {@link XmlOptions#setXqueryCurrentNodeVar(String) XmlOptions.setXqueryCurrentNodeVar(String)}
+ * method to specify a particular name for the expression
+ * variable that indicates the context node.
+ */
+ public static String compilePath(String pathExpr, XmlOptions options)
+ throws XmlException {
+ return getContextTypeLoader().compilePath(pathExpr, options);
+ }
+
+ /**
+ * Compiles an XQuery, returning a String equal to that which was passed,
+ * but whose identity is that of one which has been precompiled and cached.
+ */
+ public static String compileQuery(String queryExpr) throws XmlException {
+ return compileQuery(queryExpr, null);
+ }
+
+ /**
+ * Compiles an XQuery, returning a String equal to that which was passed,
+ * but whose identity is that of one which has been precompiled and cached;
+ * takes an option for specifying text that indicates the context node.
+ *
+ * @param options Options for the query. For example, you can call
+ * the {@link XmlOptions#setXqueryCurrentNodeVar(String) XmlOptions.setXqueryCurrentNodeVar(String)}
+ * method to specify a particular name for the expression
+ * variable that indicates the context node and the
+ * {@link XmlOptions#setXqueryVariables(java.util.Map) XmlOptions.setXqueryVariables(Map)}
+ * method to map external variable names to values.
+ */
+ public static String compileQuery(String queryExpr, XmlOptions options)
+ throws XmlException {
+ return getContextTypeLoader().compileQuery(queryExpr, options);
+ }
+
+ /**
+ * Gets the SchemaTypeLoader based on the current thread's context
+ * ClassLoader. This is the SchemaTypeLoader that is used to assign
+ * schema types to XML documents by default. The SchemaTypeLoader is
+ * also consulted to resolve wildcards and xsi:type attributes.
+ *
+ * The "parse" methods of XmlBeans all delegate to the
+ * "parseInstance" methods of the context type loader.
+ */
+ public static SchemaTypeLoader getContextTypeLoader() {
+ return SchemaTypeLoaderImpl.getContextTypeLoader();
+ }
+
+ /**
+ * Returns the builtin type system. This SchemaTypeSystem contains
+ * only the 46 builtin types defined by the XML Schema specification.
+ */
+ public static SchemaTypeSystem getBuiltinTypeSystem() {
+ return BuiltinSchemaTypeSystem.get();
+ }
+
+ /**
+ * Creates an XmlCursor for a DOM node which is implemented by XmlBwans
+ */
+ public static XmlCursor nodeToCursor(Node n) {
+ return Locale.nodeToCursor(n);
+ }
+
+ /**
+ * Creates an XmlObject for a DOM node which is implemented by XmlBwans
+ */
+ public static XmlObject nodeToXmlObject(Node n) {
+ return Locale.nodeToXmlObject(n);
+ }
+
+ /**
+ * Creates an XmlObject for a DOM node which is implemented by XmlBwans
+ */
+ public static XMLStreamReader nodeToXmlStreamReader(Node n) {
+ return Locale.nodeToXmlStream(n);
+ }
+
+ /**
+ * Returns the XmlObject for a DOM node which is implemented by XmlBwans
+ */
+ public static Node streamToNode(XMLStreamReader xs) {
+ return Locale.streamToNode(xs);
+ }
+
+ /**
+ * Returns the SchemaTypeSystem that results from compiling the XML
+ * schema definitions passed.
+ *
+ * Just like compileXsd, but uses the context type loader for
+ * linking, and returns a unioned typeloader that is suitable for
+ * creating instances.
+ */
+ public static SchemaTypeLoader loadXsd(XmlObject[] schemas) throws XmlException {
+ return loadXsd(schemas, null);
+ }
+
+ /**
+ *
Returns the SchemaTypeSystem that results from compiling the XML
+ * schema definitions passed in schemas.
+ *
+ *
This is just like compileXsd, but uses the context type loader for
+ * linking, and returns a unioned typeloader that is suitable for
+ * creating instances.
+ *
+ *
Use the options parameter to specify one or both of the following:
+ *
+ *
+ *
A collection instance that should be used as an error listener during
+ * compilation, as described in {@link XmlOptions#setErrorListener}.
+ *
Whether validation should not be done when building the SchemaTypeSystem,
+ * as described in {@link XmlOptions#setCompileNoValidation}.
+ *
+ *
+ * @param schemas The schema definitions from which to build the schema type system.
+ * @param options Options specifying an error listener and/or validation behavior.
+ */
+ public static SchemaTypeLoader loadXsd(XmlObject[] schemas, XmlOptions options) throws XmlException {
+ SchemaTypeSystem sts = SchemaTypeSystemCompiler.compile(null, null, schemas, null, getContextTypeLoader(), null, options);
+ return (sts == null) ? null : typeLoaderUnion(sts, getContextTypeLoader());
+ }
+
+
+ /**
+ *
Returns the SchemaTypeSystem that results from compiling the XML
+ * schema definitions passed.
+ *
+ *
The XmlObjects passed in should be w3c <schema> elements whose type
+ * is org.w3c.x2001.xmlSchema.Schema. (That is, schema elements in
+ * the XML namespace http://www.w3c.org/2001/XMLSchema.) Also
+ * org.w3c.x2001.xmlSchema.SchemaDocument is permitted.
+ *
+ *
The optional second argument is a SchemaTypeLoader which will be
+ * consulted for already-compiled schema types which may be linked
+ * while processing the given schemas.
+ *
+ *
The SchemaTypeSystem that is returned should be combined
+ * (via {@link #typeLoaderUnion}) with the typepath typeloader in order
+ * to create a typeloader that can be used for creating and validating
+ * instances.
+ *
+ *
Use the options parameter to specify the following:
+ *
+ *
+ *
A collection instance that should be used as an error listener during
+ * compilation, as described in {@link XmlOptions#setErrorListener}.
+ *
Whether validation should not be done when building the SchemaTypeSystem,
+ * as described in {@link XmlOptions#setCompileNoValidation}.
+ *
+ *
+ * @param schemas The schema definitions from which to build the schema type system.
+ * @param typepath The path to already-compiled schema types for linking while processing.
+ * @param options Options specifying an error listener and/or validation behavior.
+ */
+ public static SchemaTypeSystem compileXsd(XmlObject[] schemas, SchemaTypeLoader typepath, XmlOptions options) throws XmlException {
+ return compileXmlBeans(null, null, schemas, null, typepath, null, options);
+ }
+
+ /**
+ *
Returns the SchemaTypeSystem that results from augumenting the
+ * SchemaTypeSystem passed in by incrementally adding the given XML
+ * schema definitions.
+ *
+ *
These could be new definitions (if the Schema document is not recorded into
+ * the existing SchemaTypeSystem), modifications to the already existing
+ * definitions (if the Schema document is already recorded in the existing
+ * SchemaTypeSystem), or deletions (if the Schema document is already recorded
+ * in the existing SchemaTypeSystem and the new definitions are empty).
+ * The identity of documents is established using
+ * {@link XmlDocumentProperties#getSourceName}, so if the caller choses to
+ * construct the Schema definitions using other methods than parsing an
+ * XML document, they should make sure that the names returned by that
+ * method are consistent with the caller's intent (add/modify).
+ *
+ *
The XmlObjects passed in should be w3c <schema> elements whose type
+ * is org.w3c.x2001.xmlSchema.Schema. (That is, schema elements in
+ * the XML namespace http://www.w3c.org/2001/XMLSchema.) Also
+ * org.w3c.x2001.xmlSchema.SchemaDocument is permitted.
+ *
+ *
The optional second argument is a SchemaTypeLoader which will be
+ * consulted for already-compiled schema types which may be linked
+ * while processing the given schemas.
+ *
+ *
The SchemaTypeSystem that is returned should be combined
+ * (via {@link #typeLoaderUnion}) with the typepath typeloader in order
+ * to create a typeloader that can be used for creating and validating
+ * instances.
+ *
+ *
Use the options parameter to specify the following:
+ *
+ *
+ *
A collection instance that should be used as an error listener during
+ * compilation, as described in {@link XmlOptions#setErrorListener}.
+ *
Whether validation should not be done when building the SchemaTypeSystem,
+ * as described in {@link XmlOptions#setCompileNoValidation}.
+ *
+ *
+ * @param schemas The schema definitions from which to build the schema type system.
+ * @param typepath The path to already-compiled schema types for linking while processing.
+ * @param options Options specifying an error listener and/or validation behavior.
+ */
+ public static SchemaTypeSystem compileXsd(SchemaTypeSystem system, XmlObject[] schemas, SchemaTypeLoader typepath, XmlOptions options) throws XmlException {
+ return compileXmlBeans(null, system, schemas, null, typepath, null, options);
+ }
+
+ /**
+ *
Returns the SchemaTypeSystem that results from augumenting the
+ * SchemaTypeSystem passed in by incrementally adding the given XML
+ * schema definitions.
+ *
+ *
These could be new definitions (if the Schema document is not recorded into
+ * the existing SchemaTypeSystem), modifications to the already existing
+ * definitions (if the Schema document is already recorded in the existing
+ * SchemaTypeSystem), or deletions (if the Schema document is already recorded
+ * in the existing SchemaTypeSystem and the new definitions are empty).
+ * The identity of documents is established using
+ * {@link XmlDocumentProperties#getSourceName}, so if the caller choses to
+ * construct the Schema definitions using other methods than parsing an
+ * XML document, they should make sure that the names returned by that
+ * method are consistent with the caller's intent (add/modify).
+ *
+ *
The XmlObjects passed in should be w3c <schema> elements whose type
+ * is org.w3c.x2001.xmlSchema.Schema. (That is, schema elements in
+ * the XML namespace http://www.w3c.org/2001/XMLSchema.) Also
+ * org.w3c.x2001.xmlSchema.SchemaDocument is permitted.
+ *
+ *
The optional name argument is used to name the compiled schema type system.
+ * A randomly generated name will be used if the name is null.
+ *
+ *
The optional {@link BindingConfig} argument is used to control the shape
+ * of the generated code. A BindingConfig isn't used if Filer
+ * is null.
+ *
+ *
The optional SchemaTypeLoader argument will be
+ * consulted for already-compiled schema types which may be linked
+ * while processing the given schemas. If not specified, the context
+ * typeloader (as returned by {@link #getContextTypeLoader}) will be used.
+ *
+ *
The optional {@link Filer} argument is used to create new binary or source
+ * files which are the product of the compilation. If the Filer is null, the
+ * schema binaries (.xsb) files and source files won't be generated.
+ *
+ *
The SchemaTypeSystem that is returned should be combined
+ * (via {@link #typeLoaderUnion}) with the typepath typeloader in order
+ * to create a typeloader that can be used for creating and validating
+ * instances.
+ *
+ *
Use the options parameter to specify the following:
+ *
+ *
+ *
A collection instance that should be used as an error listener during
+ * compilation, as described in {@link XmlOptions#setErrorListener}.
+ *
Whether validation should not be done when building the SchemaTypeSystem,
+ * as described in {@link XmlOptions#setCompileNoValidation}.
+ *
+ *
+ * @param name The type system name or null to use a randomly generated name.
+ * @param system A pre-existing SchemaTypeSystem used in incremental compilation.
+ * @param schemas The schema definitions from which to build the schema type system.
+ * @param config The configuration controls the code generation shape.
+ * @param typepath The path to already-compiled schema types for linking while processing.
+ * @param filer The Filer instance used to create binary binding files and source text files.
+ * @param options Options specifying an error listener and/or validation behavior.
+ */
+ public static SchemaTypeSystem compileXmlBeans(String name, SchemaTypeSystem system, XmlObject[] schemas, BindingConfig config, SchemaTypeLoader typepath, Filer filer, XmlOptions options) throws XmlException {
+ return SchemaTypeSystemCompiler.compile(name, system, schemas, config, typepath != null ? typepath : getContextTypeLoader(), filer, options);
+ }
+
+
+ /**
+ * Returns the union of a list of typeLoaders. The returned
+ * SchemaTypeLoader searches the given list of SchemaTypeLoaders
+ * in order from first to last.
+ */
+ public static SchemaTypeLoader typeLoaderUnion(SchemaTypeLoader... typeLoaders) {
+ return (typeLoaders.length == 1) ? typeLoaders[0] : SchemaTypeLoaderImpl.build(typeLoaders, null, null);
+ }
+
+ /**
+ * Returns a SchemaTypeLoader that searches for compiled schema types
+ * in the given ClassLoader.
+ */
+ public static SchemaTypeLoader typeLoaderForClassLoader(ClassLoader loader) {
+ return SchemaTypeLoaderImpl.build(null, null, loader);
+ }
+
+ /**
+ * Returns a SchemaTypeLoader that searches for compiled schema types
+ * in the given ResourceLoader.
+ *
+ * @see XmlBeans#resourceLoaderForPath(File[])
+ */
+ public static SchemaTypeLoader typeLoaderForResource(ResourceLoader resourceLoader) {
+ return SchemaTypeLoaderImpl.build(null, resourceLoader, null);
+ }
+
+ /**
+ * Returns the SchemaTypeSystem of the given name (as returned by
+ * {@link SchemaTypeSystem#getName}) for the given ClassLoader.
+ *
+ * Note: you will almost always need typeLoaderForClassLoader()
+ * instead (see {@link XmlBeans#typeLoaderForClassLoader}).
+ */
+ public static SchemaTypeSystem typeSystemForClassLoader(ClassLoader loader, String stsName) {
+ try {
+ ClassLoader cl = loader == null ? Thread.currentThread().getContextClassLoader() : loader;
+ Class clazz = cl.loadClass(stsName + "." + HOLDER_CLASS_NAME);
+ SchemaTypeSystem sts = (SchemaTypeSystem)
+ (clazz.getDeclaredField(TYPE_SYSTEM_FIELD).get(null));
+ if (sts == null) {
+ throw new RuntimeException("SchemaTypeSystem is null for field " +
+ TYPE_SYSTEM_FIELD + " on class with name " + stsName +
+ "." + HOLDER_CLASS_NAME +
+ ". Please verify the version of xmlbeans.jar is correct.");
+ }
+ return sts;
+ } catch (ClassNotFoundException e) {
+ throw causedException(new RuntimeException("Cannot load SchemaTypeSystem. " +
+ "Unable to load class with name " + stsName + "." + HOLDER_CLASS_NAME +
+ ". Make sure the generated binary files are on the classpath."), e);
+ } catch (NoSuchFieldException e) {
+ throw causedException(new RuntimeException("Cannot find field " +
+ TYPE_SYSTEM_FIELD + " on class " + stsName + "." + HOLDER_CLASS_NAME +
+ ". Please verify the version of xmlbeans.jar is correct."), e);
+ } catch (IllegalAccessException e) {
+ throw causedException(new RuntimeException("Field " +
+ TYPE_SYSTEM_FIELD + " on class " + stsName + "." + HOLDER_CLASS_NAME +
+ "is not accessible. Please verify the version of xmlbeans.jar is correct."), e);
+ }
+ }
+
+ /**
+ * Returns a new ResourceLoader for a search path where each component of
+ * the path is either a directory or a compiled xmlbeans jar.
+ */
+ public static ResourceLoader resourceLoaderForPath(File[] path) {
+ return new PathResourceLoader(path);
+ }
+
+ /**
+ * Returns the SchemaType from a corresponding XmlObject subclass,
+ * or null if none.
+ */
+ public static SchemaType typeForClass(Class c) {
+ if (c == null || !XmlObject.class.isAssignableFrom(c)) {
+ return null;
+ }
+
+ try {
+ Field typeField = c.getField("type");
+
+ if (typeField == null) {
+ return null;
+ }
+
+ return (SchemaType) typeField.get(null);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static SchemaType getNoType() {
+ return org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem.getNoType();
+ }
+
+ /**
+ * The SchemaType object given to an XmlObject instance when
+ * no type can be determined.
+ *
+ * The NO_TYPE is the universal derived type. That is, it is
+ * derived from all other schema types, and no instances of the
+ * NO_TYPE are valid. (It is not to be confused with the anyType,
+ * which is the universal base type from which all other types
+ * can be derived, and of which all instances are valid.)
+ */
+ public static final SchemaType NO_TYPE = getNoType();
+
+ private XmlBeans() {
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlBoolean.java b/src/main/java/org/apache/xmlbeans/XmlBoolean.java
new file mode 100644
index 0000000..9d84b6f
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlBoolean.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:boolean type.
+ *
+ * Naturally, convertible to Java boolean.
+ */
+public interface XmlBoolean extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_boolean");
+
+ /**
+ * Returns this value as a boolean
+ */
+ boolean getBooleanValue();
+
+ /**
+ * Sets this value as a boolean
+ */
+ void setBooleanValue(boolean v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlBoolean}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlBoolean}
+ */
+ public static XmlBoolean newInstance() {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlBoolean}
+ */
+ public static XmlBoolean newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlBoolean} value
+ */
+ public static XmlBoolean newValue(Object obj) {
+ return (XmlBoolean) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a String. For example: "<xml-fragment>true</xml-fragment>".
+ */
+ public static XmlBoolean parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a String. For example: "<xml-fragment>true</xml-fragment>".
+ */
+ public static XmlBoolean parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a File.
+ */
+ public static XmlBoolean parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a File.
+ */
+ public static XmlBoolean parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a URL.
+ */
+ public static XmlBoolean parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a URL.
+ */
+ public static XmlBoolean parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from an InputStream.
+ */
+ public static XmlBoolean parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from an InputStream.
+ */
+ public static XmlBoolean parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a Reader.
+ */
+ public static XmlBoolean parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a Reader.
+ */
+ public static XmlBoolean parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a DOM Node.
+ */
+ public static XmlBoolean parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from a DOM Node.
+ */
+ public static XmlBoolean parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from an XMLStreamReader.
+ */
+ public static XmlBoolean parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlBoolean} fragment from an XMLStreamReader.
+ */
+ public static XmlBoolean parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlBoolean) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlByte.java b/src/main/java/org/apache/xmlbeans/XmlByte.java
new file mode 100644
index 0000000..05093e6
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlByte.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:byte type.
+ *
+ * Naturally, convertible to Java byte.
+ */
+public interface XmlByte extends XmlShort {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_byte");
+
+ /**
+ * Returns this value as a byte
+ */
+ byte getByteValue();
+
+ /**
+ * Sets this value as a byte
+ */
+ void setByteValue(byte s);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlByte}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlByte}
+ */
+ static XmlByte newInstance() {
+ return (XmlByte) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlByte}
+ */
+ static XmlByte newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlByte) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlByte} value
+ */
+ static XmlByte newValue(Object obj) {
+ return (XmlByte) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a String. For example: "<xml-fragment>123</xml-fragment>".
+ */
+ static XmlByte parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a String. For example: "<xml-fragment>123</xml-fragment>".
+ */
+ static XmlByte parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a File.
+ */
+ static XmlByte parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a File.
+ */
+ static XmlByte parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a URL.
+ */
+ static XmlByte parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a URL.
+ */
+ static XmlByte parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from an InputStream.
+ */
+ static XmlByte parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from an InputStream.
+ */
+ static XmlByte parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a Reader.
+ */
+ static XmlByte parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a Reader.
+ */
+ static XmlByte parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a DOM Node.
+ */
+ static XmlByte parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from a DOM Node.
+ */
+ static XmlByte parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from an XMLStreamReader.
+ */
+ static XmlByte parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlByte} fragment from an XMLStreamReader.
+ */
+ static XmlByte parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlByte) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlCalendar.java b/src/main/java/org/apache/xmlbeans/XmlCalendar.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/XmlCalendar.java
rename to src/main/java/org/apache/xmlbeans/XmlCalendar.java
diff --git a/src/main/java/org/apache/xmlbeans/XmlCursor.java b/src/main/java/org/apache/xmlbeans/XmlCursor.java
new file mode 100644
index 0000000..cb49624
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlCursor.java
@@ -0,0 +1,1918 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.namespace.QName;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Represents a position between two logical tokens in an XML document.
+ *
+ * The tokens themselves are not exposed as objects, but their type and properties
+ * are discoverable through methods on the cursor. In particular, the general
+ * category of token is represented by a {@link XmlCursor.TokenType TokenType}.
+ *
+ * You use an XmlCursor instance to navigate through and manipulate an XML
+ * instance document.
+ * Once you obtain an XML document, you can create a cursor to represent
+ * a specific place in the XML. Because you can use a cursor with or
+ * without a schema corresponding to the XML, cursors are an ideal
+ * way to handle XML without a schema. You can create a new cursor by
+ * calling the {@link XmlTokenSource#newCursor() newCursor} method
+ * exposed by an object representing
+ * the XML, whether it was parsed into a strong type compiled from
+ * schema or an {@link XmlObject XmlObject} (as in the no-schema case).
+ *
+ * With an XmlCursor, you can also:
+ *
+ *
+ *
Execute XQuery and XPath expressions against the XML with the
+ * execQuery and selectPath methods.
+ *
+ *
Edit and reshape the document by inserting, moving, copying, and removing
+ * XML.
+ *
+ *
Insert bookmarks that "stick" to the XML at the cursor's
+ * position even if the cursor or XML moves.
+ *
+ *
Get and set values for containers (elements and whole documents),
+ * attributes, processing instructions, and comments.
+ *
+ *
+ * A cursor moves through XML by moving past tokens. A
+ * token represents a category of XML markup, such as the start of an element,
+ * its end, an attribute, comment, and so on. XmlCursor methods such as
+ * toNextToken, toNextSibling, toParent, and so on move the cursor
+ * among tokens. Each token's category is of a particular type, represented
+ * by one of the nine types defined by the {@link XmlCursor.TokenType TokenType} class.
+ *
+ * When you get a new cursor for a whole instance document, the cursor is
+ * intially located before the STARTDOC token. This token, which has no analogy
+ * in the XML specification, is present in this logical model of XML
+ * so that you may distinguish between the document as a whole
+ * and the content of the document. Terminating the document is an ENDDOC
+ * token. This token is also not part of the XML specification. A cursor
+ * located immediately before this token is at the very end of the document.
+ * It is not possible to position the cursor after the ENDDOC token.
+ * Thus, the STARTDOC and ENDDOC tokens are effectively "bookends" for the content of
+ * the document.
+ *
+ * For example, for the following XML, if you were the navigate a cursor
+ * through the XML document using toNextToken(), the list of token types that
+ * follows represents the token sequence you would encounter.
+ * STARTDOC
+ * START (sample)
+ * ATTR (x='y')
+ * TEXT ("\n ")
+ * START (value)
+ * TEXT ("foo")
+ * END (value)
+ * TEXT ("\n")
+ * END (sample)
+ * ENDDOC
+ *
+ * When there are no more tokens available, hasNextToken() returns
+ * false and toNextToken() returns the special token type NONE and does not move
+ * the cursor.
+ *
+ *
+ * The {@link #currentTokenType() currentTokenType()} method
+ * will return the type of the token that is immediately after the cursor.
+ * You can also use a number of convenience methods that test for a particular
+ * token type. These include the methods isStart(),
+ * isStartdoc(), isText(), isAttr(), and so on. Each returns a boolean
+ * value indicating whether the token that follows the cursor is the type
+ * in question.
+ *
+ *
+ * A few other methods determine whether the token is of a kind that may include
+ * multiple token types. The isAnyAttr() method, for example, returns true if
+ * the token immediately following the cursor is any kind of attribute,
+ * including those of the ATTR token type and xmlns attributes.
+ *
+ *
+ * Legitimate sequences of tokens for an XML document are described
+ * by the following Backus-Naur Form (BNF):
+ *
+ *
+ * Note that a legitimate sequence is STARTDOC ENDDOC, the result of
+ * creating a brand new instance of an empty document. Also note that
+ * attributes may only follow container tokens (STARTDOC or START)
+ */
+public interface XmlCursor extends XmlTokenSource {
+ /**
+ * An enumeration that identifies the type of an XML token.
+ */
+ public static final class TokenType {
+ public String toString() {
+ return _name;
+ }
+
+ /**
+ * Returns one of the INT_ values defined in this class.
+ */
+ public int intValue() {
+ return _value;
+ }
+
+ /**
+ * No token. See {@link #intValue}.
+ */
+ public static final int INT_NONE = 0;
+ /**
+ * The start-document token. See {@link #intValue}.
+ */
+ public static final int INT_STARTDOC = 1;
+ /**
+ * The end-document token. See {@link #intValue}.
+ */
+ public static final int INT_ENDDOC = 2;
+ /**
+ * The start-element token. See {@link #intValue}.
+ */
+ public static final int INT_START = 3;
+ /**
+ * The end-element token. See {@link #intValue}.
+ */
+ public static final int INT_END = 4;
+ /**
+ * The text token. See {@link #intValue}.
+ */
+ public static final int INT_TEXT = 5;
+ /**
+ * The attribute token. See {@link #intValue}.
+ */
+ public static final int INT_ATTR = 6;
+ /**
+ * The namespace declaration token. See {@link #intValue}.
+ */
+ public static final int INT_NAMESPACE = 7;
+ /**
+ * The comment token. See {@link #intValue}.
+ */
+ public static final int INT_COMMENT = 8;
+ /**
+ * The processing instruction token. See {@link #intValue}.
+ */
+ public static final int INT_PROCINST = 9;
+
+ /**
+ * True if no token.
+ */
+ public boolean isNone() {
+ return this == NONE;
+ }
+
+ /**
+ * True if is start-document token.
+ */
+ public boolean isStartdoc() {
+ return this == STARTDOC;
+ }
+
+ /**
+ * True if is end-document token.
+ */
+ public boolean isEnddoc() {
+ return this == ENDDOC;
+ }
+
+ /**
+ * True if is start-element token.
+ */
+ public boolean isStart() {
+ return this == START;
+ }
+
+ /**
+ * True if is end-element token.
+ */
+ public boolean isEnd() {
+ return this == END;
+ }
+
+ /**
+ * True if is text token.
+ */
+ public boolean isText() {
+ return this == TEXT;
+ }
+
+ /**
+ * True if is attribute token.
+ */
+ public boolean isAttr() {
+ return this == ATTR;
+ }
+
+ /**
+ * True if is namespace declaration token.
+ */
+ public boolean isNamespace() {
+ return this == NAMESPACE;
+ }
+
+ /**
+ * True if is comment token.
+ */
+ public boolean isComment() {
+ return this == COMMENT;
+ }
+
+ /**
+ * True if is processing instruction token.
+ */
+ public boolean isProcinst() {
+ return this == PROCINST;
+ }
+
+ /**
+ * True if is start-document or start-element token
+ */
+ public boolean isContainer() {
+ return this == STARTDOC || this == START;
+ }
+
+ /**
+ * True if is end-document or end-element token
+ */
+ public boolean isFinish() {
+ return this == ENDDOC || this == END;
+ }
+
+ /**
+ * True if is attribute or namespace declaration token
+ */
+ public boolean isAnyAttr() {
+ return this == NAMESPACE || this == ATTR;
+ }
+
+ /**
+ * The singleton no-token type
+ */
+ public static final TokenType NONE = new TokenType("NONE", INT_NONE);
+ /**
+ * The singleton start-document token type
+ */
+ public static final TokenType STARTDOC = new TokenType("STARTDOC", INT_STARTDOC);
+ /**
+ * The singleton start-document token type
+ */
+ public static final TokenType ENDDOC = new TokenType("ENDDOC", INT_ENDDOC);
+ /**
+ * The singleton start-element token type
+ */
+ public static final TokenType START = new TokenType("START", INT_START);
+ /**
+ * The singleton end-element token type
+ */
+ public static final TokenType END = new TokenType("END", INT_END);
+ /**
+ * The singleton text token type
+ */
+ public static final TokenType TEXT = new TokenType("TEXT", INT_TEXT);
+ /**
+ * The singleton attribute token type
+ */
+ public static final TokenType ATTR = new TokenType("ATTR", INT_ATTR);
+ /**
+ * The singleton namespace declaration token type
+ */
+ public static final TokenType NAMESPACE = new TokenType("NAMESPACE", INT_NAMESPACE);
+ /**
+ * The singleton comment token type
+ */
+ public static final TokenType COMMENT = new TokenType("COMMENT", INT_COMMENT);
+ /**
+ * The singleton processing instruction token type
+ */
+ public static final TokenType PROCINST = new TokenType("PROCINST", INT_PROCINST);
+
+ private TokenType(String name, int value) {
+ _name = name;
+ _value = value;
+ }
+
+ private String _name;
+ private int _value;
+ }
+
+ /**
+ * Deallocates resources needed to manage the cursor, rendering this cursor
+ * inoperable. Because cursors are managed by a mechanism which stores the
+ * XML, simply letting a cursor go out of scope and having the garbage collector
+ * attempt to reclaim it may not produce desirable performance.
+ *
+ * So, explicitly disposing a cursor allows the underlying implementation
+ * to release its responsibility of maintaining its position.
+ *
+ * After a cursor has been disposed, it may not be used again. It can
+ * throw IllegalStateException or NullPointerException if used after
+ * disposal.
+ */
+
+ void dispose();
+
+ /**
+ * Moves this cursor to the same position as the moveTo cursor. if the
+ * moveTo cursor is in a different document from this cursor, this cursor
+ * will not be moved, and false returned.
+ *
+ * @param moveTo The cursor at the location to which this cursor
+ * should be moved.
+ * @return true if the cursor moved; otherwise, false.
+ */
+
+ boolean toCursor(XmlCursor moveTo);
+
+ /**
+ * Saves the current location of this cursor on an internal stack of saved
+ * positions (independent of selection). This location may be restored
+ * later by calling the pop() method.
+ */
+
+ void push();
+
+ /**
+ * Restores the cursor location most recently saved with the push() method.
+ *
+ * @return true if there was a location to restore; otherwise, false.
+ */
+
+ boolean pop();
+
+ /**
+ * Executes the specified XPath expression against the XML that this
+ * cursor is in. The cursor's position does not change. To navigate to the
+ * selections, use {@link #hasNextSelection} and {@link #toNextSelection} (similar to
+ * {@link java.util.Iterator}).
+ *
+ * The root referred to by the expression should be given as
+ * a dot. The following is an example path expression:
+ *
+ * Note that this method does not support top-level XPath functions.
+ *
+ * @param path The path expression to execute.
+ * @throws XmlRuntimeException If the query expression is invalid.
+ */
+ void selectPath(String path);
+
+ /**
+ * Executes the specified XPath expression against the XML that this
+ * cursor is in. The cursor's position does not change. To navigate to the
+ * selections, use hasNextSelection and toNextSelection (similar to
+ * java.util.Iterator).
+ *
+ * The root referred to by the expression should be given as
+ * a dot. The following is an example path expression:
+ *
+ * Note that this method does not support top-level XPath functions.
+ *
+ * @param path The path expression to execute.
+ * @param options Options for the query. For example, you can call
+ * the {@link XmlOptions#setXqueryCurrentNodeVar(String) XmlOptions.setXqueryCurrentNodeVar(String)}
+ * method to specify a particular name for the query expression
+ * variable that indicates the context node.
+ * @throws XmlRuntimeException If the query expression is invalid.
+ */
+ void selectPath(String path, XmlOptions options);
+
+ /**
+ * Returns whether or not there is a next selection.
+ *
+ * @return true if there is a next selection; otherwise, false.
+ */
+
+ boolean hasNextSelection();
+
+ /**
+ * Moves this cursor to the next location in the selection,
+ * if any. See the {@link #selectPath} and {@link #addToSelection} methods.
+ *
+ * @return true if the cursor moved; otherwise, false.
+ */
+
+ boolean toNextSelection();
+
+ /**
+ * Moves this cursor to the specified location in the selection.
+ * If i is less than zero or greater than or equal to the selection
+ * count, this method returns false.
+ *
+ * See also the selectPath() and addToSelection() methods.
+ *
+ * @param i The index of the desired location.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toSelection(int i);
+
+ /**
+ * Returns the count of the current selection. See also the selectPath()
+ * and addToSelection() methods.
+ *
+ * You may experience better performance if you use the iteration
+ * model using the toNextSelection method, rather than
+ * the indexing model using the getSelectionCount and
+ * toSelection methods.
+ *
+ * @return A number indicating the size of the current selection.
+ */
+
+ int getSelectionCount();
+
+
+ /**
+ * Appends the current location of the cursor to the selection.
+ * See also the selectPath() method. You can use this as an
+ * alternative to calling the selectPath method when you want
+ * to define your own selection.
+ */
+
+ void addToSelection();
+
+ /**
+ * Clears this cursor's selection, but does not modify the document.
+ */
+ void clearSelections();
+
+ /**
+ * Moves this cursor to the same position as the bookmark. If the
+ * bookmark is in a different document from this cursor or if the
+ * bookmark is orphaned, this cursor
+ * will not be moved, and false will be returned.
+ *
+ * @param bookmark The bookmark at the location to which this
+ * cursor should be moved.
+ * @return true if the cursor moved; otherwise, false.
+ */
+
+ boolean toBookmark(XmlBookmark bookmark);
+
+ /**
+ * Moves this cursor to the location after its current position
+ * where a bookmark with the given key exists. Returns false if no
+ * such bookmark exists.
+ *
+ * @param key The key held by the next bookmark at the location to
+ * which this cursor should be moved.
+ * @return The next corresponding bookmark, if it exists; null if there
+ * is no next bookmark with the specified key.
+ */
+
+ XmlBookmark toNextBookmark(Object key);
+
+ /**
+ * Moves this cursor to the location before its current position
+ * where a bookmark with the given key exists. Returns false if no
+ * such bookmark exists.
+ *
+ * @param key The key held by the previous bookmark at the location to
+ * which this cursor should be moved.
+ * @return The previous corresponding bookmark, if it exists; null if
+ * there is no previous bookmark with the specified key.
+ */
+
+ XmlBookmark toPrevBookmark(Object key);
+
+ /**
+ * Returns the name of the current token. Names may be associated with
+ * START, ATTR, NAMESPACE or PROCINST. Returns null if there is no
+ * name associated with the current token. For START and ATTR, the
+ * name returned identifies the name of the element or attribute.
+ * For NAMESPACE, the local part of the name is the prefix, while
+ * the URI is the namespace defined. For PROCINST, the local part
+ * is the target and the uri is "".
+ *
+ * In the following example, xmlObject represents
+ * an XML instance whose root element is not preceded by any other XML.
+ * This code prints the root element name (here, the local name, or
+ * name without URI).
+ *
+ *
+ * @return The name of the XML at this cursor's location; null if there
+ * is no name.
+ */
+
+ QName getName();
+
+ /**
+ * Sets the name of the current token. This token can be START, NAMESPACE,
+ * ATTR or PROCINST.
+ *
+ * @param name The new name for the current token.
+ */
+
+ void setName(QName name);
+
+ /**
+ * Returns the namespace URI indicated by the given prefix. The current
+ * context must be at a START or STARTDOC. Namespace prefix mappings
+ * are queried for the mappings defined at the current container first,
+ * then parents are queried. The prefix can be "" or null to indicate
+ * a search for the default namespace. To conform with the
+ * XML spec, the default namespace will return the no-namespace ("")
+ * if it is not mapped.
+ *
+ * Note that this queries the current state of the document. When the
+ * document is persisted, the saving mechanism may synthesize namespaces
+ * (ns1, ns2, and so on) for the purposes of persistence. These namepaces are
+ * only present in the serialized form, and are not reflected back into
+ * the document being saved.
+ *
+ * @param prefix The namespace prefix for the requested namespace.
+ * @return The URI for corresponding to the specified prefix if it
+ * exists; otherwise, null.
+ */
+ String namespaceForPrefix(String prefix);
+
+ /**
+ * Returns a prefix that can be used to indicate a namespace URI. The
+ * current context must be at a START or STARTDOC. If there is an
+ * existing prefix that indicates the URI in the current context, that
+ * prefix may be returned. Otherwise, a new prefix for the URI will be
+ * defined by adding an xmlns attribute to the current container or a
+ * parent container.
+ *
+ * Note that this queries the current state of the document. When the
+ * document is persisted, the saving mechanism may synthesize namespaces
+ * (ns1, ns2, and so on) for the purposes of persistence. These namepaces are
+ * only present in the serialized form, and are not reflected back into
+ * the document being saved.
+ *
+ * @param namespaceURI The namespace URI corresponding to the requested
+ * prefix.
+ * @return The prefix corresponding to the specified URI if it exists;
+ * otherwise, a newly generated prefix.
+ */
+ String prefixForNamespace(String namespaceURI);
+
+ /**
+ * Adds to the specified map, all the namespaces in scope at the container
+ * where this cursor is positioned. This method is useful for
+ * container tokens only.
+ *
+ * @param addToThis The Map to add the namespaces to.
+ */
+
+ void getAllNamespaces(Map addToThis);
+
+ /**
+ * Returns the strongly-typed XmlObject at the current START,
+ * STARTDOC, or ATTR.
+ *
+ * The strongly-typed object can be cast to the strongly-typed
+ * XBean interface corresponding to the XML Schema Type given
+ * by result.getSchemaType().
+ *
+ * If a more specific type cannot be determined, an XmlObject
+ * whose schema type is anyType will be returned.
+ *
+ * @return The strongly-typed object at the cursor's current location;
+ * null if the current location is not a START, STARTDOC, or ATTR.
+ */
+
+ XmlObject getObject();
+
+ /**
+ * Returns the type of the current token. By definition, the current
+ * token is the token immediately to the right of the cursor.
+ * If you're in the middle of text, before a character, you get TEXT.
+ * You can't dive into the text of an ATTR, COMMENT or PROCINST.
+ *
+ * As an alternative, it may be more convenient for you to use one of the
+ * methods that test for a particular token type. These include the methods
+ * isStart(), isStartdoc(), isText(), isAttr(), and so on. Each returns a boolean
+ * value indicating whether the token that follows the cursor is the type
+ * in question.
+ *
+ *
+ * @return The TokenType instance for the token at the cursor's current
+ * location.
+ */
+
+ TokenType currentTokenType();
+
+ /**
+ * True if the current token is a STARTDOC token type, meaning
+ * at the very root of the document.
+ *
+ * @return true if this token is a STARTDOC token type;
+ * otherwise, false.
+ */
+
+ boolean isStartdoc();
+
+ /**
+ * True if this token is an ENDDOC token type, meaning
+ * at the very end of the document.
+ *
+ * @return true if this token is an ENDDOC token type;
+ * otherwise, false.
+ */
+
+ boolean isEnddoc();
+
+ /**
+ * True if this token is a START token type, meaning
+ * just before an element's start.
+ *
+ * @return true if this token is a START token type;
+ * otherwise, false.
+ */
+
+ boolean isStart();
+
+ /**
+ * True if this token is an END token type, meaning
+ * just before an element's end.
+ *
+ * @return true if this token is an END token type;
+ * otherwise, false.
+ */
+
+ boolean isEnd();
+
+ /**
+ * True if the this token is a TEXT token type, meaning
+ * just before or inside text.
+ *
+ * @return true if this token is a TEXT token type;
+ * otherwise, false.
+ */
+
+ boolean isText();
+
+ /**
+ * True if this token is an ATTR token type, meaning
+ * just before an attribute.
+ *
+ * @return true if this token is an ATTR token type;
+ * otherwise, false.
+ */
+
+ boolean isAttr();
+
+ /**
+ * True if this token is a NAMESPACE token type, meaning
+ * just before a namespace declaration.
+ *
+ * @return true if this token is a NAMESPACE token type;
+ * otherwise, false.
+ */
+
+ boolean isNamespace();
+
+ /**
+ * True if this token is a COMMENT token type, meaning
+ * just before a comment.
+ *
+ * @return true if this token is a COMMENT token type;
+ * otherwise, false.
+ */
+
+ boolean isComment();
+
+ /**
+ * True if this token is a PROCINST token type, meaning
+ * just before a processing instruction.
+ *
+ * @return true if this token is a PROCINST token type;
+ * otherwise, false.
+ */
+
+ boolean isProcinst();
+
+ /**
+ * True if this token is a container token. The STARTDOC and START
+ * token types are containers. Containers, including documents and elements,
+ * have the same content model. In other words, a document and an element
+ * may have the same contents. For example, a document may contain attributes
+ * or text, without any child elements.
+ *
+ * @return true if this token is a container token; otherwise, false.
+ */
+
+ boolean isContainer();
+
+ /**
+ * True if this token is a finish token. A finish token can be an ENDDOC
+ * or END token type.
+ *
+ * @return true if this token is a finish token; otherwise, false.
+ */
+
+ boolean isFinish();
+
+ /**
+ * True if this token is any attribute. This includes an ATTR token type and
+ * the NAMESPACE token type attribute.
+ *
+ * @return true if the current cursor is at any attribute; otherwise, false.
+ */
+
+ boolean isAnyAttr();
+
+ /**
+ * Returns the type of the previous token. By definition, the previous
+ * token is the token immediately to the left of the cursor.
+ *
+ * If you're in the middle of text, after a character, you get TEXT.
+ *
+ * @return The TokenType instance for the token immediately before the
+ * token at the cursor's current location.
+ */
+
+ TokenType prevTokenType();
+
+ /**
+ * True if there is a next token. When this is false, as when the cursor is
+ * at the ENDDOC token, the toNextToken() method returns NONE and does not
+ * move the cursor.
+ *
+ * @return true if there is a next token; otherwise, false.
+ */
+
+ boolean hasNextToken();
+
+
+ /**
+ * True if there is a previous token. When this is false, toPrevToken
+ * returns NONE and does not move the cursor.
+ *
+ * @return true if there is a previous token; otherwise, false.
+ */
+
+ boolean hasPrevToken();
+
+ /**
+ * Moves the cursor to the next token. When there are no more tokens
+ * available, hasNextToken returns false and toNextToken() returns
+ * NONE and does not move the cursor. Returns the token type
+ * of the token to the right of the cursor upon a successful move.
+ *
+ * @return The token type for the next token if the cursor was moved;
+ * otherwise, NONE.
+ */
+
+ TokenType toNextToken();
+
+ /**
+ * Moves the cursor to the previous token. When there is no
+ * previous token, returns NONE, otherwise returns the token
+ * to the left of the new position of the cursor.
+ *
+ * @return The token type for the previous token if the cursor was moved;
+ * otherwise, NONE.
+ */
+
+ TokenType toPrevToken();
+
+ /**
+ * Moves the cursor to the first token in the content of the current
+ * START or STARTDOC. That is, the first token after all ATTR and NAMESPACE
+ * tokens associated with this START.
+ *
+ * If the current token is not a START or STARTDOC, the cursor is not
+ * moved and NONE is returned. If the current START or STARTDOC
+ * has no content, the cursor is moved to the END or ENDDOC token.
+ *
+ * @return The new current token type.
+ */
+
+ TokenType toFirstContentToken();
+
+
+ /**
+ * Moves the cursor to the END or ENDDOC token corresponding to the
+ * current START or STARTDOC, and returns END or ENDDOC.
+ *
+ * If the current token is not a START or STARTDOC, the cursor is not
+ * moved and NONE is returned.
+ *
+ * @return The new current token type.
+ */
+
+ TokenType toEndToken();
+
+ /**
+ * Moves the cursor forward by the specified number of characters, and
+ * stops at the next non-TEXT token. Returns the number of characters
+ * actually moved across, which is guaranteed to be less than or equal to
+ * maxCharacterCount. If there is no further text, or if
+ * there is no text at all, returns zero.
+ *
+ * Note this does not dive into attribute values, comment contents,
+ * processing instruction contents, etc., but only content text.
+ *
+ * You can pass maxCharacterCount < 0 to move over all the text to the
+ * right. This has the same effect as toNextToken, but returns the amount
+ * of text moved over.
+ *
+ * @param maxCharacterCount The maximum number of characters by which
+ * the cursor should be moved.
+ * @return The actual number of characters by which the cursor was moved;
+ * 0 if the cursor was not moved.
+ */
+
+ int toNextChar(int maxCharacterCount);
+
+ /**
+ * Moves the cursor backwards by the number of characters given. Has
+ * similar characteristics to the {@link #toNextChar(int) toNextChar} method.
+ *
+ * @param maxCharacterCount The maximum number of characters by which
+ * the cursor should be moved.
+ * @return The actual number of characters by which the cursor was moved;
+ * 0 if the cursor was not moved.
+ */
+
+ int toPrevChar(int maxCharacterCount);
+
+ /**
+ * Moves the cursor to the next sibling element, or returns
+ * false and does not move the cursor if there is no next sibling
+ * element. (By definition the position of an element is the same
+ * as the position of its START token.)
+ *
+ * If the current token is not s START, the cursor will be
+ * moved to the next START without moving out of the scope of the
+ * current element.
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toNextSibling();
+
+ /**
+ * Moves the cursor to the previous sibling element, or returns
+ * false and does not move the cursor if there is no previous sibling
+ * element. (By definition the position of an element is the same
+ * as the position of its START token.)
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toPrevSibling();
+
+ /**
+ * Moves the cursor to the parent element or STARTDOC, or returns
+ * false and does not move the cursor if there is no parent.
+ *
+ * Works if you're in attributes or content. Returns false only if at
+ * STARTDOC. Note that the parent of an END token is the corresponding
+ * START token.
+ *
+ * @return true if the cursor was moved; false if the cursor is at the STARTDOC
+ * token.
+ */
+
+ boolean toParent();
+
+ /**
+ * Moves the cursor to the first child element, or returns false and
+ * does not move the cursor if there are no element children.
+ *
+ * If the cursor is not currently in an element, it moves into the
+ * first child element of the next element.
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toFirstChild();
+
+ /**
+ * Moves the cursor to the last element child, or returns false and
+ * does not move the cursor if there are no element children.
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toLastChild();
+
+ /**
+ * Moves the cursor to the first child element of the specified name in
+ * no namespace.
+ *
+ * @param name The name of the element to move the cursor to.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toChild(String name);
+
+ /**
+ * Moves the cursor to the first child element of the specified name in the
+ * specified namespace.
+ *
+ * @param namespace The namespace URI for the element to move the cursor
+ * to.
+ * @param name The name of the element to move to.
+ * @return true if the cursor was moved; otherwise, false.
+ * @throws IllegalArgumentException If the name is not a valid local name.
+ */
+
+ boolean toChild(String namespace, String name);
+
+ /**
+ * Moves the cursor to the first child element of the specified qualified name.
+ *
+ * @param name The name of the element to move the cursor to.
+ */
+
+ boolean toChild(QName name);
+
+ /**
+ * Moves the cursor to the child element specified by index.
+ *
+ * @param index The position of the element in the sequence of child
+ * elements.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toChild(int index);
+
+ /**
+ * Moves the cursor to the specified index child element of the
+ * specified name, where that element is the .
+ *
+ * @param name The name of the child element to move the cursor to.
+ * @param index The position of the element in the sequence of child
+ * elements.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toChild(QName name, int index);
+
+ /**
+ * Moves the cursor to the next sibling element of the specified name in no
+ * namespace.
+ *
+ * @param name The name of the element to move the cursor to.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toNextSibling(String name);
+
+ /**
+ * Moves the cursor to the next sibling element of the specified name
+ * in the specified namespace.
+ *
+ * @param namespace The namespace URI for the element to move the cursor
+ * to.
+ * @param name The name of the element to move the cursor to.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toNextSibling(String namespace, String name);
+
+
+ /**
+ * Moves the cursor to the next sibling element of the specified
+ * qualified name.
+ *
+ * @param name The name of the element to move the cursor to.
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toNextSibling(QName name);
+
+ /**
+ * Moves the cursor to the first attribute of this element, or
+ * returns false and does not move the cursor if there are no
+ * attributes. The order of attributes is arbitrary, but stable.
+ *
+ * If the cursor is on a STARTDOC of a document-fragment, this method will
+ * move it to the first top level attribute if one exists.
+ *
+ * xmlns attributes (namespace declarations) are not considered
+ * attributes by this function.
+ *
+ * The cursor must be on a START or STARTDOC (in the case of a
+ * document fragment with top level attributes) for this method to
+ * succeed.
+ *
+ * Example for looping through attributes:
+ *
+ * XmlCursor cursor = ... //cursor on START or STARTDOC
+ * if (cursor.toFirstAttribute())
+ * {
+ * do
+ * {
+ * // do something using attribute's name and value
+ * cursor.getName();
+ * cursor.getTextValue();
+ * }
+ * while (cursor.toNextAttribute());
+ * }
+ *
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toFirstAttribute();
+
+ /**
+ * Moves the cursor to the last attribute of this element, or
+ * returns false and does not move the cursor if there are no
+ * attributes. The order of attributes is arbitrary, but stable.
+ *
+ * xmlns attributes (namespace declarations) are not considered
+ * attributes by this function.
+ *
+ * The cursor must be on a START or STARTDOC for this method
+ * to succeed.
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toLastAttribute();
+
+ /**
+ * Moves the cursor to the next sibling attribute, or returns
+ * false and does not move the cursor if there is no next
+ * sibling attribute. The order of attributes is arbitrary, but stable.
+ *
+ * xmlns attributes (namespace declarations) are not considered
+ * attributes by this function.
+ *
+ * The cursor must be on an attribute for this method to succeed.
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ * @see #toFirstAttribute()
+ */
+
+ boolean toNextAttribute();
+
+ /**
+ * Moves the cursor to the previous sibling attribute, or returns
+ * false and does not move the cursor if there is no previous
+ * sibling attribute. The order of attributes is arbitrary, but stable.
+ *
+ * xmlns attributes (namespace declarations) are not considered
+ * attributes by this function.
+ *
+ * The cursor must be on an attribute for this method to succeed.
+ *
+ * @return true if the cursor was moved; otherwise, false.
+ */
+
+ boolean toPrevAttribute();
+
+ /**
+ * When at a START or STARTDOC, returns the attribute text for the given
+ * attribute. When not at a START or STARTDOC or the attribute does not
+ * exist, returns null.
+ *
+ * @param attrName The name of the attribute whose value is requested.
+ * @return The attribute's value if it has one; otherwise, null.
+ */
+
+ String getAttributeText(QName attrName);
+
+ /**
+ * When at a START or STARTDOC, sets the attribute text for the given
+ * attribute. When not at a START or STARTDOC returns false.
+ * If the attribute does not exist, one is created.
+ *
+ * @param attrName The name of the attribute whose value is being set.
+ * @param value The new value for the attribute.
+ * @return true if the new value was set; otherwise, false.
+ */
+
+ boolean setAttributeText(QName attrName, String value);
+
+ /**
+ * When at a START or STARTDOC, removes the attribute with the given name.
+ *
+ * @param attrName The name of the attribute that should be removed.
+ * @return true if the attribute was removed; otherwise, false.
+ */
+
+ boolean removeAttribute(QName attrName);
+
+ /**
+ * Gets the text value of the current document, element, attribute,
+ * comment, procinst or text token.
+ *
+ * When getting the text value of an element, non-text content such
+ * as comments and processing instructions are ignored and text is concatenated.
+ * For elements that have nested element children, this
+ * returns the concatenated text of all mixed content and the
+ * text of all the element children, recursing in first-to-last
+ * depthfirst order.
+ *
+ * For attributes, including namespaces, this returns the attribute value.
+ *
+ * For comments and processing instructions, this returns the text content
+ * of the comment or PI, not including the delimiting sequences <!-- -->, <? ?>.
+ * For a PI, the name of the PI is also not included.
+ *
+ * The value of an empty tag is the empty string.
+ *
+ * If the current token is END or ENDDOC, this throws an {@link java.lang.IllegalStateException}.
+ *
+ * @return The text value of the current token if the token's type is
+ * START, STARTDOC, TEXT, ATTR, COMMENT, PROCINST, or NAMESPACE; null
+ * if the type is NONE.
+ */
+
+ String getTextValue();
+
+ /**
+ * Copies the text value of the current document, element, attribute,
+ * comment, processing instruction or text token, counting right from
+ * this cursor's location up to maxCharacterCount,
+ * and copies the returned text into returnedChars.
+ *
+ * When getting the text value of an element, non-text content such
+ * as comments and processing instructions are ignored and text is concatenated.
+ * For elements that have nested element children, this
+ * returns the concatenated text of all mixed content and the
+ * text of all the element children, recursing in first-to-last
+ * depthfirst order.
+ *
+ * For attributes, including namespaces, this returns the attribute value.
+ *
+ * For comments and processing instructions, this returns the text contents
+ * of the comment or PI, not including the delimiting sequences <!-- -->, <? ?>. For
+ * a PI, the text will not include the name of the PI.
+ *
+ * If the current token is END or ENDDOC, this throws an {@link java.lang.IllegalStateException}.
+ *
+ * The value of an empty tag is the empty string.
+ *
+ * @param returnedChars A character array to hold the returned characters.
+ * @param offset The position within returnedChars to which the first of the
+ * returned characters should be copied.
+ * @param maxCharacterCount The maximum number of characters after this cursor's
+ * location to copy. A negative value specifies that all characters should be copied.
+ * @return The actual number of characters copied; 0 if no characters
+ * were copied.
+ */
+
+ int getTextValue(char[] returnedChars, int offset, int maxCharacterCount);
+
+ /**
+ * Returns the characters of the current TEXT token. If the current token
+ * is not TEXT, returns "". If in the middle of a TEXT token, returns
+ * those chars to the right of the cursor of the TEXT token.
+ *
+ * @return The requested text; an empty string if the current token type is
+ * not TEXT.
+ */
+
+ /**
+ * Sets the text value of the XML at this cursor's location if that XML's
+ * token type is START, STARTDOC, ATTR, COMMENT or PROCINST.
+ *
+ * For elements that have nested children this first removes all
+ * the content of the element and replaces it with the given text.
+ *
+ * @param text The text to use as a new value.
+ * @throws java.lang.IllegalStateException If the token type at this
+ * cursor's location is not START, STARTDOC, ATTR, COMMENT or
+ * PROCINST.
+ */
+ void setTextValue(String text);
+
+ /**
+ * Sets the text value of the XML at this cursor's location (if that XML's
+ * token type is START, STARTDOC, ATTR, COMMENT or PROCINST) to the
+ * contents of the specified character array.
+ *
+ * For elements that have nested children this first removes all
+ * the content of the element and replaces it with the given text.
+ *
+ * @param sourceChars A character array containing the XML's new value.
+ * @param offset The position within sourceChars from which the first of
+ * the source characters should be copied.
+ * @param length The maximum number of characters to set as the XML's new
+ * value.
+ * @throws java.lang.IllegalArgumentException If the token type at this
+ * cursor's location is not START, STARTDOC, ATTR, COMMENT or
+ * PROCINST.
+ */
+ void setTextValue(char[] sourceChars, int offset, int length);
+
+ /**
+ * Returns characters to the right of the cursor up to the next token.
+ */
+ String getChars();
+
+ /**
+ * Copies characters up to the specified maximum number, counting right from
+ * this cursor's location to the character at maxCharacterCount. The
+ * returned characters are added to returnedChars, with the first
+ * character copied to the offset position. The maxCharacterCount
+ * parameter should be less than or equal to the length of returnedChars
+ * minus offset. Copies a number of characters, which is
+ * either maxCharacterCount or the number of characters up to the next token,
+ * whichever is less.
+ *
+ * @param returnedChars A character array to hold the returned characters.
+ * @param offset The position within returnedChars at which the first of the
+ * returned characters should be added.
+ * @param maxCharacterCount The maximum number of characters after this cursor's
+ * location to return.
+ * @return The actual number of characters returned; 0 if no characters
+ * were returned or if the current token is not TEXT.
+ */
+
+ int getChars(char[] returnedChars, int offset, int maxCharacterCount);
+
+ /**
+ * Moves the cursor to the STARTDOC token, which is the
+ * root of the document.
+ */
+
+ void toStartDoc();
+
+ /**
+ * Moves the cursor to the ENDDOC token, which is the end
+ * of the document.
+ */
+
+ void toEndDoc();
+
+ /**
+ * Determines if the specified cursor is in the same document as
+ * this cursor.
+ *
+ * @param cursor The cursor that may be in the same document
+ * as this cursor.
+ * @return true if the specified cursor is in the same document;
+ * otherwise, false.
+ */
+
+ boolean isInSameDocument(XmlCursor cursor);
+
+ /**
+ * Returns an integer indicating whether this cursor is before,
+ * after, or at the same position as the specified cursor.
+ *
+ * a.comparePosition(b) < 0 means a is to the left of b.
+ * a.comparePosition(b) == 0 means a is at the same position as b.
+ * a.comparePosition(b) > 0 means a is to the right of b.
+ *
+ * The sort order of cursors in the document is the token order.
+ * For example, if cursor "a" is at a START token and the cursor "b"
+ * is at a token within the contents of the same element, then
+ * a.comparePosition(b) will return -1, meaning that the position
+ * of a is before b.
+ *
+ * @param cursor The cursor whose position should be compared
+ * with this cursor.
+ * @return 1 if this cursor is after the specified cursor; 0 if
+ * this cursor is at the same position as the specified cursor;
+ * -1 if this cursor is before the specified cursor.
+ * @throws java.lang.IllegalArgumentException If the specified
+ * cursor is not in the same document as this cursor.
+ */
+
+ int comparePosition(XmlCursor cursor);
+
+ /**
+ * Determines if this cursor is to the left of (or before)
+ * the specified cursor. Note that this is the same as
+ * a.comparePosition(b) < 0
+ *
+ * @param cursor The cursor whose position should be compared
+ * with this cursor.
+ * @return true if this cursor is to the left of the specified
+ * cursor; otherwise, false.
+ */
+
+ boolean isLeftOf(XmlCursor cursor);
+
+ /**
+ * Determines if this cursor is at the same position as
+ * the specified cursor. Note that this is the same as
+ * a.comparePosition(b) == 0
+ *
+ * @param cursor The cursor whose position should be compared
+ * with this cursor.
+ * @return true if this cursor is at the same position as
+ * the specified cursor; otherwise, false.
+ */
+
+ boolean isAtSamePositionAs(XmlCursor cursor);
+
+ /**
+ * Determines if this cursor is to the right of (or after)
+ * the specified cursor. Note that this is the same as
+ * a.comparePosition(b) > 0
+ *
+ * @param cursor The cursor whose position should be compared
+ * with this cursor.
+ * @return true if this cursor is to the right of the specified
+ * cursor; otherwise, false.
+ */
+
+ boolean isRightOf(XmlCursor cursor);
+
+ /**
+ * Executes the specified XQuery expression against the XML this
+ * cursor is in.
+ *
+ * The query may be a String or a compiled query. You can precompile
+ * an XQuery expression using the XmlBeans.compileQuery method.
+ *
+ * The root referred to by the expression should be given as
+ * a dot. The following is an example path expression:
+ *
+ *
+ * @param query The XQuery expression to execute.
+ * @return A cursor containing the results of the query.
+ * @throws XmlRuntimeException If the query expression is invalid.
+ */
+
+ XmlCursor execQuery(String query);
+
+ /**
+ * Executes the specified XQuery expression against the XML this
+ * cursor is in, and using the specified options.
+ *
+ * @param query The XQuery expression to execute.
+ * @param options Options for the query. For example, you can call
+ * the {@link XmlOptions#setXqueryCurrentNodeVar(String) XmlOptions.setXqueryCurrentNodeVar(String)}
+ * method to specify a particular name for the query expression
+ * variable that indicates the context node.
+ * @throws XmlRuntimeException If the query expression is invalid.
+ */
+
+ XmlCursor execQuery(String query, XmlOptions options);
+
+ /**
+ * Represents the state of a dcoument at a particular point
+ * in time. It is used to determine if a document has been changed
+ * since that point in time.
+ */
+ interface ChangeStamp {
+ /**
+ * Returns whether or not the document assoiated with this ChangeStamp
+ * has been altered since the ChangeStamp had been created.
+ */
+ public boolean hasChanged();
+ }
+
+ /**
+ * Returns the current change stamp for the document the current cursor is in.
+ * This change stamp can be queried at a later point in time to find out
+ * if the document has changed.
+ *
+ * @return The change stamp for the document the current cursor is in.
+ */
+ ChangeStamp getDocChangeStamp();
+
+ /**
+ * Subclasses of XmlBookmark can be used to annotate an XML document.
+ * This class is abstract to prevent parties from inadvertently
+ * interfering with each others' bookmarks without explicitly
+ * sharing a bookmark class.
+ */
+
+ abstract class XmlBookmark {
+ /**
+ * Constructs a strongly-referenced bookmark.
+ */
+ public XmlBookmark() {
+ this(false);
+ }
+
+ /**
+ * Constructs a bookmark.
+ *
+ * @param weak true if the document's reference to the bookmark should be a WeakReference
+ */
+ public XmlBookmark(boolean weak) {
+ _ref = weak ? new WeakReference(this) : null;
+ }
+
+ /**
+ * Call the createCursor method to create a new cursor which is
+ * positioned at the same splace as the bookmark. It is much more
+ * efficient to call toBookmark on an existing cursor than it
+ * is to create a new cursor. However, toBookmark may fail if the
+ * bookmark is in a different document than the cursor. It is
+ * under these circumstances where createCursor needs to be called
+ * on the bookmark. Subsequent navigations to bookmark
+ * positions should attempt to reuse the last cursor to
+ * improve performace.
+ *
+ * @return the new cursor
+ */
+ public final XmlCursor createCursor() {
+ return _currentMark == null ? null : _currentMark.createCursor();
+ }
+
+ /**
+ * @param c the cursor to be moved
+ * @return the given cursor moved to this bookmark
+ */
+ public final XmlCursor toBookmark(XmlCursor c) {
+ return c == null || !c.toBookmark(this) ? createCursor() : c;
+ }
+
+ /**
+ * The default key for bookmarks is the class which implements
+ * them. This way, multiple parties using bookmarks in the
+ * same instance document will not interfere with eachother.
+ * One can, however, override getKey() to use a key other than
+ * the class.
+ *
+ * @return default key for bookmarks
+ */
+ public Object getKey() {
+ return this.getClass();
+ }
+
+ /**
+ * The mark is set by the host document; it is capable of
+ * returning an XmlCursor implementation at the location of
+ * the bookmark.
+ */
+ public XmlMark _currentMark;
+
+ /**
+ * If non-null, the ref is used by the host document
+ * to maintain a reference to the bookmark. If it is a weak
+ * reference, the host document will not prevent the Bookmark
+ * from being garbage collected.
+ */
+ public final Reference _ref;
+ }
+
+ /**
+ * An abstract {@link XmlCursor} factory.
+ * Implementations of XmlCursor implement XmlMark to be able to
+ * reconstitute a cursor from a bookmark. When content moves between
+ * implementations, the XmlMark is set to the implmentation's which
+ * receives the new content.
+ */
+
+ interface XmlMark {
+ XmlCursor createCursor();
+ }
+
+ /**
+ * Sets a bookmark to the document at this cursor's location.
+ *
+ * The bookmark is attached to the token in the tree immediately
+ * after the cursor. If the tree is manipulated to move
+ * that object to a different place, the bookmark moves with it.
+ * If the tree is manipulated to delete that token from the
+ * tree, the bookmark is orphaned. Copy operations do not copy
+ * bookmarks.
+ *
+ * @param bookmark The bookmark to set.
+ */
+
+ void setBookmark(XmlBookmark bookmark);
+
+ /**
+ * Retrieves the bookmark with the specified key
+ * at this cursor's location. If there is no bookmark whose key is
+ * given by the specified key at the current position, null is returned.
+ * If the {@link XmlCursor.XmlBookmark#getKey() getKey} method is not overridden on
+ * the bookmark, then the bookmark's class is used as the key.
+ *
+ * @param key The key for the bookmark to retrieve.
+ * @return The requested bookmark; null if there is no bookmark
+ * corresponding to the specified key.
+ */
+
+ XmlBookmark getBookmark(Object key);
+
+ /**
+ * Clears the bookmark whose key is specified, if the bookmark
+ * exists at this cursor's location.
+ *
+ * @param key The for the bookmark to clear.
+ */
+
+ void clearBookmark(Object key);
+
+ /**
+ * Retrieves all the bookmarks at this location, adding them to
+ * the specified collection. Bookmarks held by weak references are
+ * added to this collection as Weak referenced objects pointing to the
+ * bookmark.
+ *
+ * @param listToFill The collection that will contain bookmarks
+ * returned by this method.
+ */
+
+ void getAllBookmarkRefs(Collection listToFill);
+
+ /**
+ * Removes the XML that is immediately after this cursor.
+ *
+ * For the TEXT, ATTR, NAMESPACE, COMMENT and PROCINST tokens, a single
+ * token is removed. For a START token, the corresponding element and all
+ * of its contents are removed. For all other tokens, this is a no-op.
+ * You cannot remove a STARTDOC.
+ *
+ * The cursors located in the XML that was removed all collapse to the
+ * same location. All bookmarks in this XML will be orphaned.
+ *
+ * @return true if anything was removed; false only if the cursor is
+ * just before END or ENDDOC token.
+ * @throws java.lang.IllegalArgumentException If the cursor is at a
+ * STARTDOC token.
+ */
+
+ boolean removeXml();
+
+ /**
+ * Moves the XML immediately after this cursor to the location
+ * specified by the toHere cursor, shifting XML at that location
+ * to the right to make room. For the TEXT, ATTR, NAMESPACE,
+ * COMMENT and PROCINST tokens, a single token is moved. For a start token, the
+ * element and all of its contents are moved. For all other tokens, this
+ * is a no-op.
+ *
+ * The bookmarks located in the XML that was moved also move to the
+ * new location; the cursors don't move with the content.
+ *
+ * @param toHere The cursor at the location to which the XML should
+ * be moved.
+ * @return true if anything was moved. This only happens when the XML to be
+ * moved contains the target of the move.
+ * @throws java.lang.IllegalArgumentException If the operation is not allowed
+ * at the cursor's location. This includes attempting to move an end token or the
+ * document as a whole. Also, moving to a location before the start document or moving
+ * an attribute to a location other than after another attribute or start token
+ * will throw.
+ */
+
+ boolean moveXml(XmlCursor toHere);
+
+ /**
+ * Copies the XML immediately after this cursor to the location
+ * specified by the toHere cursor. For the TEXT, ATTR, NAMESPACE,
+ * COMMENT and PROCINST tokens, a single token is copied. For a start token,
+ * the element and all of its contents are copied. For all other tokens, this
+ * is a no-op.
+ *
+ * The cursors and bookmarks located in the XML that was copied are also copied
+ * to the new location.
+ *
+ * @param toHere The cursor at the location to which the XML should
+ * be copied.
+ * @return true if anything was copied; false if the token supports the operation,
+ * but nothing was copied.
+ * @throws java.lang.IllegalArgumentException If the operation is not allowed
+ * at the cursor's location.
+ */
+
+ boolean copyXml(XmlCursor toHere);
+
+ /**
+ * Removes the contents of the container (STARTDOC OR START) immediately after
+ * this cursor. For all other situations, returns false. Does
+ * not remove attributes or namspaces.
+ *
+ * @return true if anything was copied; otherwise, false.
+ */
+
+ boolean removeXmlContents();
+
+ /**
+ * Moves the contents of the container (STARTDOC OR START) immediately after
+ * this cursor to the location specified by the toHere cursor.
+ * For all other situations, returns false. Does not move attributes or
+ * namespaces.
+ *
+ * @param toHere The cursor at the location to which the XML should be moved.
+ * @return true if anything was moved; otherwise, false.
+ */
+ boolean moveXmlContents(XmlCursor toHere);
+
+ /**
+ * Copies the contents of the container (STARTDOC OR START) immediately to
+ * the right of the cursor to the location specified by the toHere cursor.
+ * For all other situations, returns false. Does not copy attributes or
+ * namespaces.
+ *
+ * @param toHere The cursor at the location to which the XML should
+ * be copied.
+ * @return true if anything was copied; otherwise, false.
+ */
+ boolean copyXmlContents(XmlCursor toHere);
+
+ /**
+ * Removes characters up to the specified maximum number, counting right from
+ * this cursor's location to the character at maxCharacterCount. The
+ * space remaining from removing the characters collapses up to this cursor.
+ *
+ * @param maxCharacterCount The maximum number of characters after this cursor's
+ * location to remove.
+ * @return The actual number of characters removed.
+ * @throws java.lang.IllegalArgumentException If the operation is not allowed
+ * at the cursor's location.
+ */
+
+ int removeChars(int maxCharacterCount);
+
+ /**
+ * Moves characters immediately after this cursor to the position immediately
+ * after the specified cursor. Characters are counted to the right up to the
+ * specified maximum number. XML after the destination cursor is
+ * shifted to the right to make room. The space remaining from moving the
+ * characters collapses up to this cursor.
+ *
+ * @param maxCharacterCount The maximum number of characters after this cursor's
+ * location to move.
+ * @param toHere The cursor to which the characters should be moved.
+ * @return The actual number of characters moved.
+ * @throws java.lang.IllegalArgumentException If the operation is not allowed
+ * at the cursor's location.
+ */
+
+ int moveChars(int maxCharacterCount, XmlCursor toHere);
+
+ /**
+ * Copies characters to the position immediately after the specified cursor.
+ * Characters are counted to the right up to the specified maximum number.
+ * XML after the destination cursor is shifted to the right to make room.
+ *
+ * @param maxCharacterCount The maximum number of characters after this cursor's
+ * location to copy.
+ * @param toHere The cursor to which the characters should be copied.
+ * @return The actual number of characters copied.
+ * @throws java.lang.IllegalArgumentException If the operation is not allowed
+ * at the cursor's location.
+ */
+
+ int copyChars(int maxCharacterCount, XmlCursor toHere);
+
+ /**
+ * Inserts the specified text immediately before this cursor's location.
+ *
+ * @param text The text to insert.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertChars(String text);
+
+ /**
+ * Inserts an element immediately before this cursor's location, giving
+ * the element the specified qualified name.
+ *
+ * @param name The qualified name for the element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertElement(QName name);
+
+ /**
+ * Inserts an element immediately before this cursor's location, giving
+ * the element the specified local name.
+ *
+ * @param localName The local name for the new element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertElement(String localName);
+
+ /**
+ * Inserts a new element immediately before this cursor's location, giving the
+ * element the specified local name and associating it with specified namespace
+ *
+ * @param localName The local name for the new element.
+ * @param uri The URI for the new element's namespace.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertElement(String localName, String uri);
+
+ /**
+ * Inserts a new element around this cursor, giving the element the specified
+ * qualified name. After the element is inserted, this cursor is between its start
+ * and end. This cursor can then be used to insert additional XML into
+ * the new element.
+ *
+ * @param name The qualified name for the new element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void beginElement(QName name);
+
+ /**
+ * Inserts a new element around this cursor, giving the element the specified
+ * local name. After the element is inserted, this cursor is between its start
+ * and end. This cursor can then be used to insert additional XML into
+ * the new element.
+ *
+ * @param localName The local name for the new element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void beginElement(String localName);
+
+ /**
+ * Inserts a new element around this cursor, giving the element the specified
+ * local name and associating it with the specified namespace. After the element
+ * is inserted, this cursor is between its start and end. This cursor
+ * can then be used to insert additional XML into the new element.
+ *
+ * @param localName The local name for the new element.
+ * @param uri The URI for the new element's namespace.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void beginElement(String localName, String uri);
+
+ /**
+ * Inserts a new element immediately before this cursor's location, giving the
+ * element the specified qualified name and content.
+ *
+ * @param name The qualified name for the new element.
+ * @param text The content for the new element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertElementWithText(QName name, String text);
+
+ /**
+ * Inserts a new element immediately before this cursor's location, giving the
+ * element the specified local name and content.
+ *
+ * @param localName The local name for the new element.
+ * @param text The content for the new element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertElementWithText(String localName, String text);
+
+ /**
+ * Inserts a new element immediately before this cursor's location, giving the
+ * element the specified local name, associating it with the specified namespace,
+ * and giving it the specified content.
+ *
+ * @param localName The local name for the new element.
+ * @param uri The URI for the new element's namespace.
+ * @param text The content for the new element.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertElementWithText(String localName, String uri, String text);
+
+ /**
+ * Inserts a new attribute immediately before this cursor's location, giving it
+ * the specified local name.
+ *
+ * @param localName The local name for the new attribute.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertAttribute(String localName);
+
+ /**
+ * Inserts a new attribute immediately before this cursor's location, giving it
+ * the specified local name and associating it with the specified namespace.
+ *
+ * @param localName The local name for the new attribute.
+ * @param uri The URI for the new attribute's namespace.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertAttribute(String localName, String uri);
+
+ /**
+ * Inserts a new attribute immediately before this cursor's location, giving it
+ * the specified name.
+ *
+ * @param name The local name for the new attribute.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertAttribute(QName name);
+
+ /**
+ * Inserts a new attribute immediately before this cursor's location, giving it
+ * the specified value and name.
+ *
+ * @param Name The local name for the new attribute.
+ * @param value The value for the new attribute.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertAttributeWithValue(String Name, String value);
+
+ /**
+ * Inserts an attribute immediately before the cursor's location, giving it
+ * the specified name and value, and associating it with the specified namespace.
+ *
+ * @param name The name for the new attribute.
+ * @param uri The URI for the new attribute's namespace.
+ * @param value The value for the new attribute.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertAttributeWithValue(String name, String uri, String value);
+
+ /**
+ * Inserts an attribute immediately before the cursor's location, giving it
+ * the specified name and value.
+ *
+ * @param name The name for the new attribute.
+ * @param value The value for the new attribute.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertAttributeWithValue(QName name, String value);
+
+ /**
+ * Inserts a namespace declaration immediately before the cursor's location,
+ * giving it the specified prefix and URI.
+ *
+ * @param prefix The prefix for the namespace.
+ * @param namespace The URI for the namespace.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertNamespace(String prefix, String namespace);
+
+ /**
+ * Inserts an XML comment immediately before the cursor's location,
+ * giving it the specified content.
+ *
+ * @param text The new comment's content.
+ * @throws java.lang.IllegalArgumentException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertComment(String text);
+
+ /**
+ * Inserts an XML processing instruction immediately before the cursor's location,
+ * giving it the specified target and text.
+ *
+ * @param target The target for the processing instruction.
+ * @param text The new processing instruction's text.
+ * @throws java.lang.IllegalStateException If the insertion is not allowed
+ * at the cursor's location.
+ */
+
+ void insertProcInst(String target, String text);
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlDate.java b/src/main/java/org/apache/xmlbeans/XmlDate.java
new file mode 100644
index 0000000..4314338
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlDate.java
@@ -0,0 +1,196 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+import java.util.Date;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:date type.
+ *
+ * Convertible to {@link Calendar}, {@link Date}, and {@link GDate}.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlDate extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_date");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * Returns this value as a {@link Date}
+ */
+ Date getDateValue();
+
+ /**
+ * Sets this value as a {@link Date}
+ */
+ void setDateValue(Date d);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlDate}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlDate}
+ */
+ public static XmlDate newInstance() {
+ return (XmlDate) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlDate}
+ */
+ public static XmlDate newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlDate) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlDate} value
+ */
+ public static XmlDate newValue(Object obj) {
+ return (XmlDate) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a String. For example: "<xml-fragment>2003-06-14</xml-fragment>".
+ */
+ public static XmlDate parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a String. For example: "<xml-fragment>2003-06-14</xml-fragment>".
+ */
+ public static XmlDate parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a File.
+ */
+ public static XmlDate parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a File.
+ */
+ public static XmlDate parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a URL.
+ */
+ public static XmlDate parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a URL.
+ */
+ public static XmlDate parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from an InputStream.
+ */
+ public static XmlDate parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from an InputStream.
+ */
+ public static XmlDate parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a Reader.
+ */
+ public static XmlDate parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a Reader.
+ */
+ public static XmlDate parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a DOM Node.
+ */
+ public static XmlDate parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from a DOM Node.
+ */
+ public static XmlDate parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from an XMLStreamReader.
+ */
+ public static XmlDate parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDate} fragment from an XMLStreamReader.
+ */
+ public static XmlDate parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDate) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlDateTime.java b/src/main/java/org/apache/xmlbeans/XmlDateTime.java
new file mode 100644
index 0000000..8b58428
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlDateTime.java
@@ -0,0 +1,201 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+import java.util.Date;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:dateTime type.
+ *
+ * Convertible to {@link Calendar}, {@link Date}, and {@link GDate}.
+ *
+ *
+ * The XmlDateTime class only encapsulates a schema DateTime value, if you need to perform operations
+ * on dates, see the GDate class
+ *
+ * @see XmlCalendar
+ * @see GDate
+ * @see GDuration
+ */
+public interface XmlDateTime extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_dateTime");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * Returns this value as a {@link Date}
+ */
+ Date getDateValue();
+
+ /**
+ * Sets this value as a {@link Date}
+ */
+ void setDateValue(Date d);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlDateTime}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlDateTime}
+ */
+ public static XmlDateTime newInstance() {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlDateTime}
+ */
+ public static XmlDateTime newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlDateTime} value
+ */
+ public static XmlDateTime newValue(Object obj) {
+ return (XmlDateTime) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a String. For example: "<xml-fragment>2003-06-14T12:00:00</xml-fragment>".
+ */
+ public static XmlDateTime parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a String. For example: "<xml-fragment>2003-06-14T12:00:00</xml-fragment>".
+ */
+ public static XmlDateTime parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a File.
+ */
+ public static XmlDateTime parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a File.
+ */
+ public static XmlDateTime parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a URL.
+ */
+ public static XmlDateTime parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a URL.
+ */
+ public static XmlDateTime parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from an InputStream.
+ */
+ public static XmlDateTime parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from an InputStream.
+ */
+ public static XmlDateTime parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a Reader.
+ */
+ public static XmlDateTime parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a Reader.
+ */
+ public static XmlDateTime parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a DOM Node.
+ */
+ public static XmlDateTime parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from a DOM Node.
+ */
+ public static XmlDateTime parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from an XMLStreamReader.
+ */
+ public static XmlDateTime parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDateTime} fragment from an XMLStreamReader.
+ */
+ public static XmlDateTime parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDateTime) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlDecimal.java b/src/main/java/org/apache/xmlbeans/XmlDecimal.java
new file mode 100644
index 0000000..21d38d7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlDecimal.java
@@ -0,0 +1,171 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.math.BigDecimal;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:decimal type.
+ *
+ * Convertible to {@link BigDecimal}.
+ */
+public interface XmlDecimal extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_decimal");
+
+ /**
+ * Returns this value as a {@link BigDecimal}
+ */
+ BigDecimal getBigDecimalValue();
+
+ /**
+ * Sets this value as a {@link BigDecimal}
+ */
+ void setBigDecimalValue(BigDecimal bd);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlDecimal}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlDecimal}
+ */
+ public static XmlDecimal newInstance() {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlDecimal}
+ */
+ public static XmlDecimal newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlDecimal} value
+ */
+ public static XmlDecimal newValue(Object obj) {
+ return (XmlDecimal) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a String. For example: "<xml-fragment>1234.56789</xml-fragment>".
+ */
+ public static XmlDecimal parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a String. For example: "<xml-fragment>1234.56789</xml-fragment>".
+ */
+ public static XmlDecimal parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a File.
+ */
+ public static XmlDecimal parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a File.
+ */
+ public static XmlDecimal parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a URL.
+ */
+ public static XmlDecimal parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a URL.
+ */
+ public static XmlDecimal parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from an InputStream.
+ */
+ public static XmlDecimal parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from an InputStream.
+ */
+ public static XmlDecimal parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a Reader.
+ */
+ public static XmlDecimal parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a Reader.
+ */
+ public static XmlDecimal parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a DOM Node.
+ */
+ public static XmlDecimal parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from a DOM Node.
+ */
+ public static XmlDecimal parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from an XMLStreamReader.
+ */
+ public static XmlDecimal parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDecimal} fragment from an XMLStreamReader.
+ */
+ public static XmlDecimal parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDecimal) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java b/src/main/java/org/apache/xmlbeans/XmlDocumentProperties.java
similarity index 97%
rename from src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java
rename to src/main/java/org/apache/xmlbeans/XmlDocumentProperties.java
index f61fad5..7de0aba 100644
--- a/src/xmlpublic/org/apache/xmlbeans/XmlDocumentProperties.java
+++ b/src/main/java/org/apache/xmlbeans/XmlDocumentProperties.java
@@ -79,7 +79,10 @@ public abstract class XmlDocumentProperties
/**
* Returns the standalone property
*/
- public boolean getStandalone ( ) { return get( STANDALONE ) != null; }
+ public boolean getStandalone ( ) {
+ Object flag = get( STANDALONE );
+ return flag != null && flag.toString().equalsIgnoreCase("true");
+ }
/**
* Sets the DOCTYPE name use in the <!DOCTYPE> declaration.
diff --git a/src/main/java/org/apache/xmlbeans/XmlDouble.java b/src/main/java/org/apache/xmlbeans/XmlDouble.java
new file mode 100644
index 0000000..4d17298
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlDouble.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:double type.
+ *
+ * Naturally, convertible to a Java double.
+ */
+public interface XmlDouble extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_double");
+
+ /**
+ * Returns this value as a double
+ */
+ double getDoubleValue();
+
+ /**
+ * Sets this value as a double
+ */
+ void setDoubleValue(double v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlDouble}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlDouble}
+ */
+ public static XmlDouble newInstance() {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlDouble}
+ */
+ public static XmlDouble newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlDouble} value
+ */
+ public static XmlDouble newValue(Object obj) {
+ return (XmlDouble) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a String. For example: "<xml-fragment>123.34e+57</xml-fragment>".
+ */
+ public static XmlDouble parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a String. For example: "<xml-fragment>123.34e+57</xml-fragment>".
+ */
+ public static XmlDouble parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a File.
+ */
+ public static XmlDouble parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a File.
+ */
+ public static XmlDouble parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a URL.
+ */
+ public static XmlDouble parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a URL.
+ */
+ public static XmlDouble parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from an InputStream.
+ */
+ public static XmlDouble parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from an InputStream.
+ */
+ public static XmlDouble parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a Reader.
+ */
+ public static XmlDouble parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a Reader.
+ */
+ public static XmlDouble parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a DOM Node.
+ */
+ public static XmlDouble parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from a DOM Node.
+ */
+ public static XmlDouble parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from an XMLStreamReader.
+ */
+ public static XmlDouble parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDouble} fragment from an XMLStreamReader.
+ */
+ public static XmlDouble parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDouble) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlDuration.java b/src/main/java/org/apache/xmlbeans/XmlDuration.java
new file mode 100644
index 0000000..02241df
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlDuration.java
@@ -0,0 +1,171 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:duration type.
+ *
+ * Convertible to a {@link GDuration}.
+ *
+ * @see GDuration
+ */
+public interface XmlDuration extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_duration");
+
+ /**
+ * Returns this value as a {@link GDuration}
+ */
+ GDuration getGDurationValue();
+
+ /**
+ * Sets this value as a {@link GDuration}
+ */
+ void setGDurationValue(GDuration gd);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlDuration}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlDuration}
+ */
+ public static XmlDuration newInstance() {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlDuration}
+ */
+ public static XmlDuration newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlDuration} value
+ */
+ public static XmlDuration newValue(Object obj) {
+ return (XmlDuration) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a String. For example: "<xml-fragment>P1Y2MT2H</xml-fragment>".
+ */
+ public static XmlDuration parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a String. For example: "<xml-fragment>P1Y2MT2H</xml-fragment>".
+ */
+ public static XmlDuration parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a File.
+ */
+ public static XmlDuration parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a File.
+ */
+ public static XmlDuration parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a URL.
+ */
+ public static XmlDuration parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a URL.
+ */
+ public static XmlDuration parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from an InputStream.
+ */
+ public static XmlDuration parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from an InputStream.
+ */
+ public static XmlDuration parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a Reader.
+ */
+ public static XmlDuration parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a Reader.
+ */
+ public static XmlDuration parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a DOM Node.
+ */
+ public static XmlDuration parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from a DOM Node.
+ */
+ public static XmlDuration parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from an XMLStreamReader.
+ */
+ public static XmlDuration parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlDuration} fragment from an XMLStreamReader.
+ */
+ public static XmlDuration parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlDuration) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlENTITIES.java b/src/main/java/org/apache/xmlbeans/XmlENTITIES.java
new file mode 100644
index 0000000..4f037bc
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlENTITIES.java
@@ -0,0 +1,178 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.List;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:ENTITIES type,
+ * a list type.
+ *
+ * A list type.
+ */
+public interface XmlENTITIES extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_ENTITIES");
+
+ /**
+ * Returns the value as a {@link List} of {@link String} values
+ */
+ List getListValue();
+
+ /**
+ * Returns the value as a {@link List} of {@link XmlENTITY} values
+ **/
+ List xgetListValue();
+
+ /**
+ * Sets the value as a {@link List}
+ */
+ void setListValue(List> l);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlENTITIES}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlENTITIES}
+ */
+ public static XmlENTITIES newInstance() {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlENTITIES}
+ */
+ public static XmlENTITIES newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlENTITIES} value
+ */
+ public static XmlENTITIES newValue(Object obj) {
+ return (XmlENTITIES) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a String.
+ */
+ public static XmlENTITIES parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a String.
+ */
+ public static XmlENTITIES parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a File.
+ */
+ public static XmlENTITIES parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a File.
+ */
+ public static XmlENTITIES parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a URL.
+ */
+ public static XmlENTITIES parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a URL.
+ */
+ public static XmlENTITIES parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from an InputStream.
+ */
+ public static XmlENTITIES parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from an InputStream.
+ */
+ public static XmlENTITIES parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a Reader.
+ */
+ public static XmlENTITIES parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a Reader.
+ */
+ public static XmlENTITIES parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a DOM Node.
+ */
+ public static XmlENTITIES parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from a DOM Node.
+ */
+ public static XmlENTITIES parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from an XMLStreamReader.
+ */
+ public static XmlENTITIES parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITIES} fragment from an XMLStreamReader.
+ */
+ public static XmlENTITIES parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITIES) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlENTITY.java b/src/main/java/org/apache/xmlbeans/XmlENTITY.java
new file mode 100644
index 0000000..955812e
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlENTITY.java
@@ -0,0 +1,159 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:ENTITY type.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlENTITY extends XmlNCName {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_ENTITY");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlENTITY}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlENTITY}
+ */
+ public static XmlENTITY newInstance() {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlENTITY}
+ */
+ public static XmlENTITY newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlENTITY} value
+ */
+ public static XmlENTITY newValue(Object obj) {
+ return (XmlENTITY) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a String.
+ */
+ public static XmlENTITY parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a String.
+ */
+ public static XmlENTITY parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a File.
+ */
+ public static XmlENTITY parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a File.
+ */
+ public static XmlENTITY parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a URL.
+ */
+ public static XmlENTITY parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a URL.
+ */
+ public static XmlENTITY parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from an InputStream.
+ */
+ public static XmlENTITY parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from an InputStream.
+ */
+ public static XmlENTITY parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a Reader.
+ */
+ public static XmlENTITY parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a Reader.
+ */
+ public static XmlENTITY parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a DOM Node.
+ */
+ public static XmlENTITY parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from a DOM Node.
+ */
+ public static XmlENTITY parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from an XMLStreamReader.
+ */
+ public static XmlENTITY parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlENTITY} fragment from an XMLStreamReader.
+ */
+ public static XmlENTITY parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlENTITY) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlError.java b/src/main/java/org/apache/xmlbeans/XmlError.java
new file mode 100644
index 0000000..5ae34a3
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlError.java
@@ -0,0 +1,633 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.stream.Location;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+/**
+ * Represents a message at a specific XML location.
+ *
+ * The message can be an error, warning, or simple information, and
+ * it may optionally be associated with a specific location in
+ * an XML document. The class includes methods for extracting
+ * the location as a line number, XmlCursor, or XmlObject, as
+ * well as for obtaining and message and severity of the
+ * error.
+ *
+ * @see XmlOptions#setErrorListener
+ * @see XmlException
+ */
+public class XmlError implements java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private static final ResourceBundle _bundle = PropertyResourceBundle.getBundle("org.apache.xmlbeans.message", Locale.ROOT);
+
+ private final String _message;
+ private final String _code;
+ private final String _source;
+ private final int _severity;
+ private final int _line;
+ private final int _column;
+ private int _offset = -1;
+
+ private transient XmlCursor _cursor;
+
+ /**
+ * Copy constructor.
+ *
+ * @param src The original XmlError to copy.
+ */
+ public XmlError(XmlError src) {
+ _message = src.getMessage();
+ _code = src.getErrorCode();
+ _severity = src.getSeverity();
+ _source = src.getSourceName();
+ _line = src.getLine();
+ _column = src.getColumn();
+ _offset = src.getOffset();
+ _cursor = src.getCursorLocation();
+ }
+
+ /**
+ * The static factory methods should be used instead of
+ * this constructor.
+ */
+ private XmlError(String message, String code, int severity,
+ String source, int line, int column, int offset, XmlCursor cursor) {
+ _message = message;
+ _code = code;
+ _severity = severity;
+ _source = source;
+ _line = line;
+ _column = column;
+ _offset = offset;
+ _cursor = cursor;
+ }
+
+ private XmlError(String code, Object[] args, int severity,
+ String source, int line, int column, int offset, XmlCursor cursor) {
+ this(XmlError.formattedMessage(code, args), code, severity, source, line, column, offset, cursor);
+ }
+
+ /**
+ * The static factory methods should be used instead of
+ * this constructor.
+ */
+ protected XmlError(String message, String code, int severity, XmlCursor cursor) {
+ String source = null;
+ int line = -1;
+ int column = -1;
+ int offset = -1;
+
+ if (cursor != null) {
+ // Hunt down the line/column/offset
+ source = cursor.documentProperties().getSourceName();
+
+ XmlCursor c = cursor.newCursor();
+
+ XmlLineNumber ln =
+ (XmlLineNumber) c.getBookmark(XmlLineNumber.class);
+
+ if (ln == null) {
+ ln = (XmlLineNumber) c.toPrevBookmark(XmlLineNumber.class);
+ }
+
+ if (ln != null) {
+ line = ln.getLine();
+ column = ln.getColumn();
+ offset = ln.getOffset();
+ }
+
+ c.dispose();
+ }
+
+ _message = message;
+ _code = code;
+ _severity = severity;
+ _source = source;
+ _line = line;
+ _column = column;
+ _offset = offset;
+ _cursor = cursor;
+ }
+
+ protected XmlError(String code, Object[] args, int severity, XmlCursor cursor) {
+ this(XmlError.formattedMessage(code, args), code, severity, cursor);
+ }
+
+ /**
+ * The static factory methods should be used instead of
+ * this constructor.
+ */
+ protected XmlError(String message, String code, int severity, Location loc) {
+ String source = null;
+ int line = -1;
+ int column = -1;
+
+ if (loc != null) {
+ line = loc.getLineNumber();
+ column = loc.getColumnNumber();
+ source = loc.getPublicId();
+ if (source == null) {
+ source = loc.getSystemId();
+ }
+ }
+
+ _message = message;
+ _code = code;
+ _severity = severity;
+ _source = source;
+ _line = line;
+ _column = column;
+ }
+
+ protected XmlError(String code, Object[] args, int severity, Location loc) {
+ this(XmlError.formattedMessage(code, args), code, severity, loc);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with no location and {@link #SEVERITY_ERROR}.
+ *
+ * @param message the error message
+ */
+ public static XmlError forMessage(String message) {
+ return forMessage(message, SEVERITY_ERROR);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with no location and the given severity.
+ *
+ * @param message the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ */
+ public static XmlError forMessage(String message, int severity) {
+ return forSource(message, severity, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with no location and the given severity.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ */
+ public static XmlError forMessage(String code, Object[] args) {
+ return forSource(code, args, SEVERITY_ERROR, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with no location and the given severity.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ */
+ public static XmlError forMessage(String code, Object[] args, int severity) {
+ return forSource(code, args, severity, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located in the given file and {@link #SEVERITY_ERROR}.
+ *
+ * @param message the error message
+ * @param sourceName the URL or other name for the file
+ */
+ public static XmlError forSource(String message, String sourceName) {
+ return forLocation(message, SEVERITY_ERROR, sourceName, -1, -1, -1);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located in the given file.
+ *
+ * @param message the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param sourceName the URL or other name for the file
+ */
+ public static XmlError forSource(String message, int severity, String sourceName) {
+ return forLocation(message, severity, sourceName, -1, -1, -1);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located in the given file.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param sourceName the URL or other name for the file
+ */
+ public static XmlError forSource(String code, Object[] args, int severity, String sourceName) {
+ return forLocation(code, args, severity, sourceName, -1, -1, -1);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located at a specific point in the given file and {@link #SEVERITY_ERROR}.
+ *
+ * @param message the error message
+ * @param sourceName the URL or other name for the file
+ * @param location the location from an xml stream
+ */
+ public static XmlError forLocation(String message, String sourceName, Location location) {
+ return new XmlError(message, (String) null, SEVERITY_ERROR, sourceName,
+ location.getLineNumber(), location.getColumnNumber(), -1, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located at a specific point in the given file and {@link #SEVERITY_ERROR}.
+ *
+ * @param message the error message
+ * @param sourceName the URL or other name for the file
+ * @param line the 1-based line number, or -1 if not known
+ * @param column the 1-based column number, or -1 if not known
+ * @param offset the 0-base file character offset, or -1 if not known
+ */
+ public static XmlError forLocation(String message, String sourceName, int line, int column, int offset) {
+ return new XmlError(message, (String) null, SEVERITY_ERROR, sourceName, line, column, offset, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at a specific point in the given file.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param sourceName the URL or other name for the file
+ * @param line the 1-based line number, or -1 if not known
+ * @param column the 1-based column number, or -1 if not known
+ * @param offset the 0-base file character offset, or -1 if not known
+ */
+ public static XmlError forLocation(String code, Object[] args, int severity, String sourceName, int line, int column, int offset) {
+ return new XmlError(code, args, severity, sourceName, line, column, offset, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at a specific point in the given file.
+ *
+ * @param message the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param sourceName the URL or other name for the file
+ * @param line the 1-based line number, or -1 if not known
+ * @param column the 1-based column number, or -1 if not known
+ * @param offset the 0-base file character offset, or -1 if not known
+ */
+ public static XmlError forLocation(String message, int severity, String sourceName, int line, int column, int offset) {
+ return new XmlError(message, (String) null, severity, sourceName, line, column, offset, null);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at the given physcial location and XmlCursor.
+ *
+ * @param message the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param sourceName the URL or other name for the file
+ * @param line the 1-based line number, or -1 if not known
+ * @param column the 1-based column number, or -1 if not known
+ * @param offset the 0-base file character offset, or -1 if not known
+ * @param cursor the XmlCursor representing the location of the error
+ */
+ public static XmlError forLocationAndCursor(String message, int severity, String sourceName, int line, int column, int offset, XmlCursor cursor) {
+ return new XmlError(message, (String) null, severity, sourceName, line, column, offset, cursor);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located at the XmlObject, with {@link #SEVERITY_ERROR}.
+ *
+ * @param message the error message
+ * @param xobj the XmlObject representing the location of the error
+ */
+ public static XmlError forObject(String message, XmlObject xobj) {
+ return forObject(message, SEVERITY_ERROR, xobj);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located at the XmlObject, with {@link #SEVERITY_ERROR}.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param xobj the XmlObject representing the location of the error
+ */
+ public static XmlError forObject(String code, Object[] args, XmlObject xobj) {
+ return forObject(code, args, SEVERITY_ERROR, xobj);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at the XmlObject.
+ *
+ * @param message the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param xobj the XmlObject representing the location of the error
+ */
+ public static XmlError forObject(String message, int severity, XmlObject xobj) {
+ if (xobj == null) {
+ return forMessage(message, severity);
+ }
+
+ XmlCursor cur = xobj.newCursor();
+ return forCursor(message, severity, cur);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at the XmlObject.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param xobj the XmlObject representing the location of the error
+ */
+ public static XmlError forObject(String code, Object[] args, int severity, XmlObject xobj) {
+ if (xobj == null) {
+ return forMessage(code, args, severity);
+ }
+
+ XmlCursor cur = xobj.newCursor();
+ return forCursor(code, args, severity, cur);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located at the XmlCursor, with {@link #SEVERITY_ERROR}.
+ *
+ * @param message the error message
+ * @param cursor the XmlCursor representing the location of the error
+ */
+ public static XmlError forCursor(String message, XmlCursor cursor) {
+ return forCursor(message, SEVERITY_ERROR, cursor);
+ }
+
+ /**
+ * Returns an XmlError for the given message, located at the XmlCursor, with {@link #SEVERITY_ERROR}.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param cursor the XmlCursor representing the location of the error
+ */
+ public static XmlError forCursor(String code, Object[] args, XmlCursor cursor) {
+ return forCursor(code, args, SEVERITY_ERROR, cursor);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at the XmlCursor.
+ *
+ * @param message the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param cursor the XmlCursor representing the location of the error
+ */
+ public static XmlError forCursor(String message, int severity, XmlCursor cursor) {
+ return new XmlError(message, (String) null, severity, cursor);
+ }
+
+ /**
+ * Returns an XmlError for the given message, with the given severity, located at the XmlCursor.
+ *
+ * @param code the error code
+ * @param args the arguments to use in formatting the error message
+ * @param severity the severity ({@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+ * @param cursor the XmlCursor representing the location of the error
+ */
+ public static XmlError forCursor(String code, Object[] args, int severity, XmlCursor cursor) {
+ return new XmlError(code, args, severity, cursor);
+ }
+
+ /**
+ * Tries to produce a nicely formatted filename from the given string.
+ */
+ protected static String formattedFileName(String rawString, URI base) {
+ if (rawString == null) {
+ return null;
+ }
+
+ URI uri;
+
+ try {
+ // if it looks like an absolute URI, treat it as such
+ uri = new URI(rawString);
+
+ // otherwise, treat it like a filename
+ if (!uri.isAbsolute()) {
+ uri = null;
+ }
+ } catch (URISyntaxException e) {
+ uri = null;
+ }
+
+ // looks like a filename; convert it to uri for relativization
+ if (uri == null) {
+ uri = new File(rawString).toURI();
+ }
+
+ if (base != null) {
+ uri = base.relativize(uri);
+ }
+
+ // filenames get their file: stripped off and their /'s turned into \'s (MSDOS)
+ if (uri.isAbsolute() ? uri.getScheme().compareToIgnoreCase("file") == 0 :
+ base != null && base.isAbsolute() && base.getScheme().compareToIgnoreCase("file") == 0) {
+ try {
+ return (new File(uri)).toString();
+ } catch (Exception ignored) {
+ }
+ }
+
+ return uri.toString();
+ }
+
+ /**
+ * Tries to format a message using the error code.
+ */
+ public static String formattedMessage(String code, Object[] args) {
+ if (code == null) {
+ return null;
+ }
+
+ try {
+ return new MessageFormat(_bundle.getString(code), Locale.ROOT).format(args);
+ } catch (MissingResourceException | IllegalArgumentException e) {
+ String bnd = (e instanceof MissingResourceException) ? "message.missing.resource" : "message.pattern.invalid";
+ return new MessageFormat(_bundle.getString(bnd), Locale.ROOT).format(e.getMessage());
+ }
+ }
+
+ /**
+ * An error. See {@link #getSeverity}.
+ */
+ public static final int SEVERITY_ERROR = 0;
+ /**
+ * A warning. See {@link #getSeverity}.
+ */
+ public static final int SEVERITY_WARNING = 1;
+ /**
+ * An informational message. See {@link #getSeverity}.
+ */
+ public static final int SEVERITY_INFO = 2;
+
+ /**
+ * Returns the severity. Either {@link #SEVERITY_ERROR}, {@link #SEVERITY_WARNING}, or {@link #SEVERITY_INFO}.
+ */
+ public int getSeverity() {
+ return _severity;
+ }
+
+ /**
+ * Returns the error message without location information.
+ */
+ public String getMessage() {
+ return _message;
+ }
+
+ /**
+ * Returns the error code or null. See {@link XmlErrorCodes}.
+ */
+ public String getErrorCode() {
+ return _code;
+ }
+
+ /**
+ * Returns the URL (or other name) of the file with the error, if available.
+ */
+ public String getSourceName() {
+ return _source;
+ }
+
+ /**
+ * Returns the line number of the error, if available, -1 if not.
+ */
+ public int getLine() {
+ return _line;
+ }
+
+ /**
+ * Returns the column number of the error, if available, -1 if not.
+ */
+ public int getColumn() {
+ return _column;
+ }
+
+ /**
+ * Returns the file character offset of the error, if available, -1 if not.
+ */
+ public int getOffset() {
+ return _offset;
+ }
+
+ /**
+ * Returns a location object of the given type. XmlCursor.class and
+ * XmlObject.class can be passed, for example. Null if not available.
+ */
+ public Object getLocation(Object type) {
+ if (type == XmlCursor.class) {
+ return _cursor;
+ }
+ if (type == XmlObject.class && _cursor != null) {
+ return _cursor.getObject();
+ }
+ return null;
+ }
+
+ /**
+ * Returns a location of the error as an {@link XmlCursor}, null if
+ * not available.
+ */
+ public XmlCursor getCursorLocation() {
+ return (XmlCursor) getLocation(XmlCursor.class);
+ }
+
+ /**
+ * Returns a location of the error as an {@link XmlObject}, null if
+ * not available.
+ */
+ public XmlObject getObjectLocation() {
+ return (XmlObject) getLocation(XmlObject.class);
+ }
+
+ /**
+ * Produces a standard string for the error message, complete with
+ * filename and location offsets if available.
+ */
+ public String toString() {
+ return toString(null);
+ }
+
+ /**
+ * Produces a standard string with the error message. If a non-null
+ * URI is supplied, source names are relativized against the given
+ * URI.
+ */
+ public String toString(URI base) {
+ // modified to carefully match the IDE's
+ // workshop.workspace.ant.AntLogger regex
+ // which also matches javac (davidbau)
+
+ StringBuilder sb = new StringBuilder();
+
+ String source = formattedFileName(getSourceName(), base);
+
+ if (source != null) {
+ sb.append(source);
+ int line = getLine();
+ if (line < 0) {
+ line = 0;
+ }
+
+ sb.append(':');
+ sb.append(line);
+ sb.append(':');
+ if (getColumn() > 0) {
+ sb.append(getColumn());
+ sb.append(':');
+ }
+ sb.append(" ");
+ }
+
+ switch (getSeverity()) {
+ case SEVERITY_ERROR:
+ sb.append("error: ");
+ break;
+ case SEVERITY_WARNING:
+ sb.append("warning: ");
+ break;
+ case SEVERITY_INFO:
+ break;
+ }
+
+ if (getErrorCode() != null) {
+ sb.append(getErrorCode()).append(": ");
+ }
+
+ String msg = getMessage();
+
+ sb.append(msg == null ? "" : msg);
+
+ return sb.toString();
+ }
+
+ public static String severityAsString(int severity) {
+ switch (severity) {
+ case SEVERITY_ERROR:
+ return ("error");
+ case SEVERITY_WARNING:
+ return ("warning");
+ case SEVERITY_INFO:
+ return "info";
+ default:
+ throw new IllegalArgumentException("unknown severity");
+ }
+ }
+}
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java b/src/main/java/org/apache/xmlbeans/XmlErrorCodes.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/XmlErrorCodes.java
rename to src/main/java/org/apache/xmlbeans/XmlErrorCodes.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlException.java b/src/main/java/org/apache/xmlbeans/XmlException.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/XmlException.java
rename to src/main/java/org/apache/xmlbeans/XmlException.java
diff --git a/src/main/java/org/apache/xmlbeans/XmlFactoryHook.java b/src/main/java/org/apache/xmlbeans/XmlFactoryHook.java
new file mode 100644
index 0000000..5c28509
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlFactoryHook.java
@@ -0,0 +1,131 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Node;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.lang.ref.SoftReference;
+
+/**
+ * A hook for the XML Bean Factory mechanism.
+ * Provided for advanced users who wish to provide their own
+ * implementation of the Factory.parse methods. This is used, for example,
+ * to defer reading XML streams until needed.
+ *
+ * To use the hook, call XmlFactoryHook.ThreadContext.setHook(), passing
+ * your own XmlFactoryHook implementation. Then every call to a Factory
+ * method will be delgated to your hook.
+ *
+ *
+ * MyHook hook = new MyHook();
+ * XmlFactoryHook.ThreadContext.setHook(hook);
+ * // this results in a call to hook.parse(...)
+ * XmlObject.Factory.parse(new File("test.xml"));
+ *
+ *
+ * If the hook needs to turn around and invoke the built-in parsers, then
+ * it should do so by calling the appropriate method on the passed
+ * SchemaTypeLoader. Since SchemaTypeLoader.parse() methods delegate
+ * to the registered hook, a hook that wishes to actually invoke the
+ * default parser without having itself called back again should
+ * unregister itself before calling loader.parse(), and then re-register
+ * itself again after the call.
+ *
+ */
+public interface XmlFactoryHook {
+ /**
+ * Hooks Factory.newInstance calls
+ */
+ XmlObject newInstance(SchemaTypeLoader loader, SchemaType type, XmlOptions options);
+
+ /**
+ * Hooks Factory.parse calls
+ */
+ XmlObject parse(SchemaTypeLoader loader, String xmlText, SchemaType type, XmlOptions options) throws XmlException;
+
+ /**
+ * Hooks Factory.parse calls
+ */
+ XmlObject parse(SchemaTypeLoader loader, InputStream jiois, SchemaType type, XmlOptions options) throws XmlException, IOException;
+
+ /**
+ * Hooks Factory.parse calls
+ */
+ XmlObject parse(SchemaTypeLoader loader, XMLStreamReader xsr, SchemaType type, XmlOptions options) throws XmlException;
+
+ /**
+ * Hooks Factory.parse calls
+ */
+ XmlObject parse(SchemaTypeLoader loader, Reader jior, SchemaType type, XmlOptions options) throws XmlException, IOException;
+
+ /**
+ * Hooks Factory.parse calls
+ */
+ XmlObject parse(SchemaTypeLoader loader, Node node, SchemaType type, XmlOptions options) throws XmlException;
+
+ /**
+ * Hooks Factory.newXmlSaxHandler calls
+ */
+ XmlSaxHandler newXmlSaxHandler(SchemaTypeLoader loader, SchemaType type, XmlOptions options);
+
+ /**
+ * Hooks Factory.newDomImplementation calls
+ */
+ DOMImplementation newDomImplementation(SchemaTypeLoader loader, XmlOptions options);
+
+ /**
+ * Used to manage the XmlFactoryHook for the current thread.
+ */
+ final class ThreadContext {
+ private static final ThreadLocal> threadHook = new ThreadLocal<>();
+
+ public static void clearThreadLocals() {
+ threadHook.remove();
+ }
+
+ /**
+ * Returns the current thread's hook, or null if none.
+ */
+ public static XmlFactoryHook getHook() {
+ SoftReference softRef = threadHook.get();
+ return softRef == null ? null : softRef.get();
+ }
+
+ /**
+ * Sets the hook for the current thread.
+ */
+ public static void setHook(XmlFactoryHook hook) {
+ threadHook.set(new SoftReference<>(hook));
+ }
+
+ // provided to prevent unwanted construction
+ private ThreadContext() {
+ }
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlFloat.java b/src/main/java/org/apache/xmlbeans/XmlFloat.java
new file mode 100644
index 0000000..a100bc2
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlFloat.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:float type.
+ *
+ * Naturally, convertible to a Java float.
+ */
+public interface XmlFloat extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_float");
+
+ /**
+ * Returns this value as a float
+ */
+ float getFloatValue();
+
+ /**
+ * Sets this value as a float
+ */
+ void setFloatValue(float v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlFloat}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlFloat}
+ */
+ public static XmlFloat newInstance() {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlFloat}
+ */
+ public static XmlFloat newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlFloat} value
+ */
+ public static XmlFloat newValue(Object obj) {
+ return (XmlFloat) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a String. For example: "<xml-fragment>12.34e+5</xml-fragment>".
+ */
+ public static XmlFloat parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a String. For example: "<xml-fragment>12.34e+5</xml-fragment>".
+ */
+ public static XmlFloat parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a File.
+ */
+ public static XmlFloat parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a File.
+ */
+ public static XmlFloat parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a URL.
+ */
+ public static XmlFloat parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a URL.
+ */
+ public static XmlFloat parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from an InputStream.
+ */
+ public static XmlFloat parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from an InputStream.
+ */
+ public static XmlFloat parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a Reader.
+ */
+ public static XmlFloat parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a Reader.
+ */
+ public static XmlFloat parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a DOM Node.
+ */
+ public static XmlFloat parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from a DOM Node.
+ */
+ public static XmlFloat parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from an XMLStreamReader.
+ */
+ public static XmlFloat parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlFloat} fragment from an XMLStreamReader.
+ */
+ public static XmlFloat parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlFloat) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlGDay.java b/src/main/java/org/apache/xmlbeans/XmlGDay.java
new file mode 100644
index 0000000..09effa7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlGDay.java
@@ -0,0 +1,196 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:gDay type.
+ * A gDay specifies only a day-of-month.
+ *
+ * Convertible to {@link Calendar}, {@link GDate}, or an int.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlGDay extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_gDay");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * Returns this value as an int from 1-31
+ */
+ int getIntValue();
+
+ /**
+ * Sets this value as an int from 1-31
+ */
+ void setIntValue(int v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlGDay}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlGDay}
+ */
+ public static XmlGDay newInstance() {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlGDay}
+ */
+ public static XmlGDay newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlGDay} value
+ */
+ public static XmlGDay newValue(Object obj) {
+ return (XmlGDay) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a String. For example: "<xml-fragment>---14</xml-fragment>".
+ */
+ public static XmlGDay parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a String. For example: "<xml-fragment>---14</xml-fragment>".
+ */
+ public static XmlGDay parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a File.
+ */
+ public static XmlGDay parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a File.
+ */
+ public static XmlGDay parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a URL.
+ */
+ public static XmlGDay parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a URL.
+ */
+ public static XmlGDay parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from an InputStream.
+ */
+ public static XmlGDay parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from an InputStream.
+ */
+ public static XmlGDay parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a Reader.
+ */
+ public static XmlGDay parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a Reader.
+ */
+ public static XmlGDay parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a DOM Node.
+ */
+ public static XmlGDay parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from a DOM Node.
+ */
+ public static XmlGDay parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from an XMLStreamReader.
+ */
+ public static XmlGDay parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGDay} fragment from an XMLStreamReader.
+ */
+ public static XmlGDay parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGDay) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlGMonth.java b/src/main/java/org/apache/xmlbeans/XmlGMonth.java
new file mode 100644
index 0000000..bb44425
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlGMonth.java
@@ -0,0 +1,196 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:gMonth type.
+ * A gMonth specifies only a month-of-year.
+ *
+ * Convertible to {@link Calendar}, {@link GDate}, or an int.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlGMonth extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_gMonth");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * Returns this value as an int from 1-12
+ */
+ int getIntValue();
+
+ /**
+ * Sets this value as an int from 1-12
+ */
+ void setIntValue(int v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlGMonth}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlGMonth}
+ */
+ public static XmlGMonth newInstance() {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlGMonth}
+ */
+ public static XmlGMonth newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlGMonth} value
+ */
+ public static XmlGMonth newValue(Object obj) {
+ return (XmlGMonth) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a String. For example: "<xml-fragment>--06</xml-fragment>".
+ */
+ public static XmlGMonth parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a String. For example: "<xml-fragment>--06</xml-fragment>".
+ */
+ public static XmlGMonth parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a File.
+ */
+ public static XmlGMonth parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a File.
+ */
+ public static XmlGMonth parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a URL.
+ */
+ public static XmlGMonth parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a URL.
+ */
+ public static XmlGMonth parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from an InputStream.
+ */
+ public static XmlGMonth parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from an InputStream.
+ */
+ public static XmlGMonth parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a Reader.
+ */
+ public static XmlGMonth parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a Reader.
+ */
+ public static XmlGMonth parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a DOM Node.
+ */
+ public static XmlGMonth parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from a DOM Node.
+ */
+ public static XmlGMonth parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from an XMLStreamReader.
+ */
+ public static XmlGMonth parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonth} fragment from an XMLStreamReader.
+ */
+ public static XmlGMonth parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonth) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlGMonthDay.java b/src/main/java/org/apache/xmlbeans/XmlGMonthDay.java
new file mode 100644
index 0000000..0ceaeb3
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlGMonthDay.java
@@ -0,0 +1,186 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:gMonthDay type.
+ * A gMonthDay specifies a day of a specific month without specifying the year.
+ *
+ * Convertible to {@link Calendar} or {@link GDate}.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlGMonthDay extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_gMonthDay");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlGMonthDay}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlGMonthDay}
+ */
+ public static XmlGMonthDay newInstance() {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlGMonthDay}
+ */
+ public static XmlGMonthDay newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlGMonthDay} value
+ */
+ public static XmlGMonthDay newValue(Object obj) {
+ return (XmlGMonthDay) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a String. For example: "<xml-fragment>--06-14</xml-fragment>".
+ */
+ public static XmlGMonthDay parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a String. For example: "<xml-fragment>--06-14</xml-fragment>".
+ */
+ public static XmlGMonthDay parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a File.
+ */
+ public static XmlGMonthDay parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a File.
+ */
+ public static XmlGMonthDay parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a URL.
+ */
+ public static XmlGMonthDay parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a URL.
+ */
+ public static XmlGMonthDay parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from an InputStream.
+ */
+ public static XmlGMonthDay parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from an InputStream.
+ */
+ public static XmlGMonthDay parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a Reader.
+ */
+ public static XmlGMonthDay parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a Reader.
+ */
+ public static XmlGMonthDay parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a DOM Node.
+ */
+ public static XmlGMonthDay parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from a DOM Node.
+ */
+ public static XmlGMonthDay parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from an XMLStreamReader.
+ */
+ public static XmlGMonthDay parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGMonthDay} fragment from an XMLStreamReader.
+ */
+ public static XmlGMonthDay parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGMonthDay) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlGYear.java b/src/main/java/org/apache/xmlbeans/XmlGYear.java
new file mode 100644
index 0000000..6ae72b8
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlGYear.java
@@ -0,0 +1,196 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:gYear type.
+ * A gYear specifies a Gregorian year (AD).
+ *
+ * Convertible to {@link Calendar}, {@link GDate}, or an int.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlGYear extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_gYear");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * Returns this value as an int from 1-31
+ */
+ int getIntValue();
+
+ /**
+ * Sets this value as an int from 1-31
+ */
+ void setIntValue(int v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlGYear}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlGYear}
+ */
+ public static XmlGYear newInstance() {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlGYear}
+ */
+ public static XmlGYear newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlGYear} value
+ */
+ public static XmlGYear newValue(Object obj) {
+ return (XmlGYear) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a String. For example: "<xml-fragment>2003</xml-fragment>".
+ */
+ public static XmlGYear parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a String. For example: "<xml-fragment>2003</xml-fragment>".
+ */
+ public static XmlGYear parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a File.
+ */
+ public static XmlGYear parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a File.
+ */
+ public static XmlGYear parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a URL.
+ */
+ public static XmlGYear parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a URL.
+ */
+ public static XmlGYear parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from an InputStream.
+ */
+ public static XmlGYear parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from an InputStream.
+ */
+ public static XmlGYear parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a Reader.
+ */
+ public static XmlGYear parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a Reader.
+ */
+ public static XmlGYear parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a DOM Node.
+ */
+ public static XmlGYear parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from a DOM Node.
+ */
+ public static XmlGYear parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from an XMLStreamReader.
+ */
+ public static XmlGYear parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYear} fragment from an XMLStreamReader.
+ */
+ public static XmlGYear parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYear) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlGYearMonth.java b/src/main/java/org/apache/xmlbeans/XmlGYearMonth.java
new file mode 100644
index 0000000..8e318ce
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlGYearMonth.java
@@ -0,0 +1,186 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:gYearMonth type.
+ * A gYearMonth specifies a month in a specific year.
+ *
+ * Convertible to {@link Calendar}, {@link GDate}.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlGYearMonth extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_gYearMonth");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlGYearMonth}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlGYearMonth}
+ */
+ public static XmlGYearMonth newInstance() {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlGYearMonth}
+ */
+ public static XmlGYearMonth newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlGYearMonth} value
+ */
+ public static XmlGYearMonth newValue(Object obj) {
+ return (XmlGYearMonth) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a String. For example: "<xml-fragment>2003-06</xml-fragment>".
+ */
+ public static XmlGYearMonth parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a String. For example: "<xml-fragment>2003-06</xml-fragment>".
+ */
+ public static XmlGYearMonth parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a File.
+ */
+ public static XmlGYearMonth parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a File.
+ */
+ public static XmlGYearMonth parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a URL.
+ */
+ public static XmlGYearMonth parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a URL.
+ */
+ public static XmlGYearMonth parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from an InputStream.
+ */
+ public static XmlGYearMonth parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from an InputStream.
+ */
+ public static XmlGYearMonth parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a Reader.
+ */
+ public static XmlGYearMonth parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a Reader.
+ */
+ public static XmlGYearMonth parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a DOM Node.
+ */
+ public static XmlGYearMonth parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from a DOM Node.
+ */
+ public static XmlGYearMonth parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from an XMLStreamReader.
+ */
+ public static XmlGYearMonth parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlGYearMonth} fragment from an XMLStreamReader.
+ */
+ public static XmlGYearMonth parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlGYearMonth) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlHexBinary.java b/src/main/java/org/apache/xmlbeans/XmlHexBinary.java
new file mode 100644
index 0000000..acc9487
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlHexBinary.java
@@ -0,0 +1,170 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:hexBinary type.
+ *
+ * Convertible to a byte array.
+ */
+public interface XmlHexBinary extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_hexBinary");
+
+ /**
+ * Returns this value as a byte array.
+ **/
+ byte[] getByteArrayValue();
+
+ /**
+ * Sets this value as a byte array.
+ */
+ void setByteArrayValue(byte[] ba);
+
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlHexBinary}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlHexBinary}
+ */
+ public static XmlHexBinary newInstance() {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlHexBinary}
+ */
+ public static XmlHexBinary newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlHexBinary} value
+ */
+ public static XmlHexBinary newValue(Object obj) {
+ return (XmlHexBinary) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a String. For example: "<xml-fragment>68656c6c6f</xml-fragment>".
+ */
+ public static XmlHexBinary parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a String. For example: "<xml-fragment>68656c6c6f</xml-fragment>".
+ */
+ public static XmlHexBinary parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a File.
+ */
+ public static XmlHexBinary parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a File.
+ */
+ public static XmlHexBinary parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a URL.
+ */
+ public static XmlHexBinary parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a URL.
+ */
+ public static XmlHexBinary parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from an InputStream.
+ */
+ public static XmlHexBinary parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from an InputStream.
+ */
+ public static XmlHexBinary parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a Reader.
+ */
+ public static XmlHexBinary parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a Reader.
+ */
+ public static XmlHexBinary parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a DOM Node.
+ */
+ public static XmlHexBinary parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from a DOM Node.
+ */
+ public static XmlHexBinary parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from an XMLStreamReader.
+ */
+ public static XmlHexBinary parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlHexBinary} fragment from an XMLStreamReader.
+ */
+ public static XmlHexBinary parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlHexBinary) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlID.java b/src/main/java/org/apache/xmlbeans/XmlID.java
new file mode 100644
index 0000000..ef56e1c
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlID.java
@@ -0,0 +1,162 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:ID type.
+ *
+ * When validated, IDs must be unique within a document. An element
+ * may not have more than one attribute whose type is ID.
+ *
+ * Convertible to a {@link String}.
+ */
+public interface XmlID extends XmlNCName {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_ID");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlID}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlID}
+ */
+ public static XmlID newInstance() {
+ return (XmlID) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlID}
+ */
+ public static XmlID newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlID) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlID} value
+ */
+ public static XmlID newValue(Object obj) {
+ return (XmlID) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a String. For example: "<xml-fragment>n1</xml-fragment>".
+ */
+ public static XmlID parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a String. For example: "<xml-fragment>n1</xml-fragment>".
+ */
+ public static XmlID parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a File.
+ */
+ public static XmlID parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a File.
+ */
+ public static XmlID parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a URL.
+ */
+ public static XmlID parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a URL.
+ */
+ public static XmlID parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from an InputStream.
+ */
+ public static XmlID parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from an InputStream.
+ */
+ public static XmlID parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a Reader.
+ */
+ public static XmlID parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a Reader.
+ */
+ public static XmlID parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a DOM Node.
+ */
+ public static XmlID parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from a DOM Node.
+ */
+ public static XmlID parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from an XMLStreamReader.
+ */
+ public static XmlID parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlID} fragment from an XMLStreamReader.
+ */
+ public static XmlID parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlID) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlIDREF.java b/src/main/java/org/apache/xmlbeans/XmlIDREF.java
new file mode 100644
index 0000000..5d5f99f
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlIDREF.java
@@ -0,0 +1,163 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:IDREF type.
+ *
+ * When validated, IDREF values must match an ID value that is present within
+ * the document. This rule is only verified when a whole document is validated
+ * at once.
+ *
+ * Convertible to a {@link String}.
+ */
+public interface XmlIDREF extends XmlNCName {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_IDREF");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlIDREF}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlIDREF}
+ */
+ public static XmlIDREF newInstance() {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlIDREF}
+ */
+ public static XmlIDREF newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlIDREF} value
+ */
+ public static XmlIDREF newValue(Object obj) {
+ return (XmlIDREF) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a String.
+ */
+ public static XmlIDREF parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a String.
+ */
+ public static XmlIDREF parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a File.
+ */
+ public static XmlIDREF parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a File.
+ */
+ public static XmlIDREF parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a URL.
+ */
+ public static XmlIDREF parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a URL.
+ */
+ public static XmlIDREF parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from an InputStream.
+ */
+ public static XmlIDREF parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from an InputStream.
+ */
+ public static XmlIDREF parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a Reader.
+ */
+ public static XmlIDREF parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a Reader.
+ */
+ public static XmlIDREF parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a DOM Node.
+ */
+ public static XmlIDREF parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from a DOM Node.
+ */
+ public static XmlIDREF parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from an XMLStreamReader.
+ */
+ public static XmlIDREF parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREF} fragment from an XMLStreamReader.
+ */
+ public static XmlIDREF parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREF) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlIDREFS.java b/src/main/java/org/apache/xmlbeans/XmlIDREFS.java
new file mode 100644
index 0000000..71592bd
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlIDREFS.java
@@ -0,0 +1,182 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.List;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:IDREFS type,
+ * a list type.
+ *
+ * When validated, IDREF values must match an ID value that is present within
+ * the document. This rule is only verified when a whole document is validated
+ * at once.
+ *
+ * Convertible to a {@link List}.
+ */
+public interface XmlIDREFS extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_IDREFS");
+
+ /**
+ * Returns the value as a {@link List} of {@link String} values
+ */
+ List getListValue();
+
+ /**
+ * Returns the value as a {@link List} of {@link XmlIDREF} values
+ */
+ List xgetListValue();
+
+ /**
+ * Sets the value as a {@link List}
+ */
+ void setListValue(List> l);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlIDREFS}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlIDREFS}
+ */
+ public static XmlIDREFS newInstance() {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlIDREFS}
+ */
+ public static XmlIDREFS newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlIDREFS} value
+ */
+ public static XmlIDREFS newValue(Object obj) {
+ return (XmlIDREFS) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a String.
+ */
+ public static XmlIDREFS parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a String.
+ */
+ public static XmlIDREFS parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a File.
+ */
+ public static XmlIDREFS parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a File.
+ */
+ public static XmlIDREFS parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a URL.
+ */
+ public static XmlIDREFS parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a URL.
+ */
+ public static XmlIDREFS parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from an InputStream.
+ */
+ public static XmlIDREFS parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from an InputStream.
+ */
+ public static XmlIDREFS parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a Reader.
+ */
+ public static XmlIDREFS parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a Reader.
+ */
+ public static XmlIDREFS parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a DOM Node.
+ */
+ public static XmlIDREFS parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from a DOM Node.
+ */
+ public static XmlIDREFS parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from an XMLStreamReader.
+ */
+ public static XmlIDREFS parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlIDREFS} fragment from an XMLStreamReader.
+ */
+ public static XmlIDREFS parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlIDREFS) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlInt.java b/src/main/java/org/apache/xmlbeans/XmlInt.java
new file mode 100644
index 0000000..0052fe7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlInt.java
@@ -0,0 +1,170 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:int type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Naturally, convertible to a Java int.
+ */
+public interface XmlInt extends XmlLong {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_int");
+
+ /**
+ * Returns this value as an int
+ */
+ int getIntValue();
+
+ /**
+ * Sets this value as an int
+ */
+ void setIntValue(int v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlInt}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlInt}
+ */
+ public static XmlInt newInstance() {
+ return (XmlInt) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlInt}
+ */
+ public static XmlInt newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlInt) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlInt} value
+ */
+ public static XmlInt newValue(Object obj) {
+ return (XmlInt) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a String. For example: "<xml-fragment>1234567</xml-fragment>".
+ */
+ public static XmlInt parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a String. For example: "<xml-fragment>1234567</xml-fragment>".
+ */
+ public static XmlInt parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a File.
+ */
+ public static XmlInt parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a File.
+ */
+ public static XmlInt parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a URL.
+ */
+ public static XmlInt parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a URL.
+ */
+ public static XmlInt parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from an InputStream.
+ */
+ public static XmlInt parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from an InputStream.
+ */
+ public static XmlInt parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a Reader.
+ */
+ public static XmlInt parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a Reader.
+ */
+ public static XmlInt parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a DOM Node.
+ */
+ public static XmlInt parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from a DOM Node.
+ */
+ public static XmlInt parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from an XMLStreamReader.
+ */
+ public static XmlInt parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInt} fragment from an XMLStreamReader.
+ */
+ public static XmlInt parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlInt) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlInteger.java b/src/main/java/org/apache/xmlbeans/XmlInteger.java
new file mode 100644
index 0000000..93fed93
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlInteger.java
@@ -0,0 +1,176 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.math.BigInteger;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:integer type.
+ * One of the derived types based on xs:decimal.
+ *
+ * This type should not be confused with xs:int
+ * or Java {@link Integer}. This type represents an arbitrary-precision integer with
+ * any number of digits, while a Java int or an xs:int is a 32-bit finite-precision integer.
+ *
+ * Convertible to a Java {@link BigInteger}.
+ */
+public interface XmlInteger extends XmlDecimal {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_integer");
+
+ /**
+ * Returns this value as a {@link BigInteger}
+ */
+ BigInteger getBigIntegerValue();
+
+ /**
+ * Sets this value as a {@link BigInteger}
+ */
+ void setBigIntegerValue(BigInteger bi);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlInteger}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlInteger}
+ */
+ public static XmlInteger newInstance() {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlInteger}
+ */
+ public static XmlInteger newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlInteger} value
+ */
+ public static XmlInteger newValue(Object obj) {
+ return (XmlInteger) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a String. For example: "<xml-fragment>1234567890</xml-fragment>".
+ */
+ public static XmlInteger parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a String. For example: "<xml-fragment>1234567890</xml-fragment>".
+ */
+ public static XmlInteger parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a File.
+ */
+ public static XmlInteger parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a File.
+ */
+ public static XmlInteger parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a URL.
+ */
+ public static XmlInteger parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a URL.
+ */
+ public static XmlInteger parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from an InputStream.
+ */
+ public static XmlInteger parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from an InputStream.
+ */
+ public static XmlInteger parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a Reader.
+ */
+ public static XmlInteger parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a Reader.
+ */
+ public static XmlInteger parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a DOM Node.
+ */
+ public static XmlInteger parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from a DOM Node.
+ */
+ public static XmlInteger parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlInteger parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlInteger parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlLanguage.java b/src/main/java/org/apache/xmlbeans/XmlLanguage.java
new file mode 100644
index 0000000..b936311
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlLanguage.java
@@ -0,0 +1,161 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:language type.
+ *
+ * This type is intended to represent an standard ISO language code string.
+ *
+ * Convertible to a Java {@link String}.
+ */
+public interface XmlLanguage extends XmlToken {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_language");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlLanguage}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlLanguage}
+ */
+ public static XmlLanguage newInstance() {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlLanguage}
+ */
+ public static XmlLanguage newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlLanguage} value
+ */
+ public static XmlLanguage newValue(Object obj) {
+ return (XmlLanguage) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a String. For example: "<xml-fragment>en-us</xml-fragment>".
+ */
+ public static XmlLanguage parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a String. For example: "<xml-fragment>en-us</xml-fragment>".
+ */
+ public static XmlLanguage parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a File.
+ */
+ public static XmlLanguage parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a File.
+ */
+ public static XmlLanguage parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a URL.
+ */
+ public static XmlLanguage parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a URL.
+ */
+ public static XmlLanguage parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from an InputStream.
+ */
+ public static XmlLanguage parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from an InputStream.
+ */
+ public static XmlLanguage parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a Reader.
+ */
+ public static XmlLanguage parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a Reader.
+ */
+ public static XmlLanguage parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a DOM Node.
+ */
+ public static XmlLanguage parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from a DOM Node.
+ */
+ public static XmlLanguage parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from an XMLStreamReader.
+ */
+ public static XmlLanguage parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLanguage} fragment from an XMLStreamReader.
+ */
+ public static XmlLanguage parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlLanguage) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlLineNumber.java b/src/main/java/org/apache/xmlbeans/XmlLineNumber.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/XmlLineNumber.java
rename to src/main/java/org/apache/xmlbeans/XmlLineNumber.java
diff --git a/src/main/java/org/apache/xmlbeans/XmlLong.java b/src/main/java/org/apache/xmlbeans/XmlLong.java
new file mode 100644
index 0000000..0a9bce8
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlLong.java
@@ -0,0 +1,170 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:long type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Naturally, convertible to a Java long.
+ */
+public interface XmlLong extends XmlInteger {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_long");
+
+ /**
+ * Returns this value as a long
+ */
+ long getLongValue();
+
+ /**
+ * Sets this value as a long
+ */
+ void setLongValue(long v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlLong}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlLong}
+ */
+ public static XmlLong newInstance() {
+ return (XmlLong) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlLong}
+ */
+ public static XmlLong newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlLong) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlLong} value
+ */
+ public static XmlLong newValue(Object obj) {
+ return (XmlLong) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a String. For example: "<xml-fragment>123456789</xml-fragment>".
+ */
+ public static XmlLong parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a String. For example: "<xml-fragment>123456789</xml-fragment>".
+ */
+ public static XmlLong parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a File.
+ */
+ public static XmlLong parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a File.
+ */
+ public static XmlLong parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a URL.
+ */
+ public static XmlLong parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a URL.
+ */
+ public static XmlLong parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from an InputStream.
+ */
+ public static XmlLong parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from an InputStream.
+ */
+ public static XmlLong parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a Reader.
+ */
+ public static XmlLong parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a Reader.
+ */
+ public static XmlLong parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a DOM Node.
+ */
+ public static XmlLong parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from a DOM Node.
+ */
+ public static XmlLong parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from an XMLStreamReader.
+ */
+ public static XmlLong parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlLong} fragment from an XMLStreamReader.
+ */
+ public static XmlLong parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlLong) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNCName.java b/src/main/java/org/apache/xmlbeans/XmlNCName.java
new file mode 100644
index 0000000..4f52fca
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNCName.java
@@ -0,0 +1,165 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:Name type.
+ * One of the derived types based on xs:string.
+ *
+ * This kind of string is the same as the non-colonized strings that are used
+ * for XML localnames and prefixes, "my-href.2". It is just a physical
+ * string, however, and it should NOT be confused with {@link XmlQName},
+ * which is a logical combination of localname and namespace URI.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlNCName extends XmlName {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_NCName");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNCName}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNCName}
+ */
+ public static XmlNCName newInstance() {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNCName}
+ */
+ public static XmlNCName newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNCName} value
+ */
+ public static XmlNCName newValue(Object obj) {
+ return (XmlNCName) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a String. For example: "<xml-fragment>My-Name</xml-fragment>".
+ */
+ public static XmlNCName parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a String. For example: "<xml-fragment>My-Name</xml-fragment>".
+ */
+ public static XmlNCName parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a File.
+ */
+ public static XmlNCName parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a File.
+ */
+ public static XmlNCName parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a URL.
+ */
+ public static XmlNCName parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a URL.
+ */
+ public static XmlNCName parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from an InputStream.
+ */
+ public static XmlNCName parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from an InputStream.
+ */
+ public static XmlNCName parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a Reader.
+ */
+ public static XmlNCName parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a Reader.
+ */
+ public static XmlNCName parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a DOM Node.
+ */
+ public static XmlNCName parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from a DOM Node.
+ */
+ public static XmlNCName parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from an XMLStreamReader.
+ */
+ public static XmlNCName parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNCName} fragment from an XMLStreamReader.
+ */
+ public static XmlNCName parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNCName) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNMTOKEN.java b/src/main/java/org/apache/xmlbeans/XmlNMTOKEN.java
new file mode 100644
index 0000000..dfccff4
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNMTOKEN.java
@@ -0,0 +1,164 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:NMTOKEN type.
+ * One of the derived types based on xs:string.
+ *
+ * An NMTOKEN is XML's closest concept to an "identifier"; for example,
+ * it does not permit spaces and only limited punctuation. So NMTOKEN is
+ * commonly used to describe a single token or enumerated string value.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlNMTOKEN extends XmlToken {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_NMTOKEN");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNMTOKEN}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNMTOKEN}
+ */
+ public static XmlNMTOKEN newInstance() {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNMTOKEN}
+ */
+ public static XmlNMTOKEN newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNMTOKEN} value
+ */
+ public static XmlNMTOKEN newValue(Object obj) {
+ return (XmlNMTOKEN) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a String. For example: "<xml-fragment>sample-1.2</xml-fragment>".
+ */
+ public static XmlNMTOKEN parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a String. For example: "<xml-fragment>sample-1.2</xml-fragment>".
+ */
+ public static XmlNMTOKEN parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a File.
+ */
+ public static XmlNMTOKEN parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a File.
+ */
+ public static XmlNMTOKEN parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a URL.
+ */
+ public static XmlNMTOKEN parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a URL.
+ */
+ public static XmlNMTOKEN parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from an InputStream.
+ */
+ public static XmlNMTOKEN parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from an InputStream.
+ */
+ public static XmlNMTOKEN parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a Reader.
+ */
+ public static XmlNMTOKEN parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a Reader.
+ */
+ public static XmlNMTOKEN parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a DOM Node.
+ */
+ public static XmlNMTOKEN parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from a DOM Node.
+ */
+ public static XmlNMTOKEN parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from an XMLStreamReader.
+ */
+ public static XmlNMTOKEN parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKEN} fragment from an XMLStreamReader.
+ */
+ public static XmlNMTOKEN parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKEN) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNMTOKENS.java b/src/main/java/org/apache/xmlbeans/XmlNMTOKENS.java
new file mode 100644
index 0000000..9cf6fbb
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNMTOKENS.java
@@ -0,0 +1,178 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.List;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:NMTOKENS type,
+ * a list type.
+ *
+ * Convertible to {@link List}.
+ */
+public interface XmlNMTOKENS extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_NMTOKENS");
+
+ /**
+ * Returns the value as a {@link List} of {@link String} values
+ */
+ List getListValue();
+
+ /**
+ * Returns the value as a {@link List} of {@link XmlNMTOKEN} values
+ */
+ List xgetListValue();
+
+ /**
+ * Sets the value as a {@link List}
+ */
+ void setListValue(List> l);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNMTOKENS}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNMTOKENS}
+ */
+ public static XmlNMTOKENS newInstance() {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNMTOKENS}
+ */
+ public static XmlNMTOKENS newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNMTOKENS} value
+ */
+ public static XmlNMTOKENS newValue(Object obj) {
+ return (XmlNMTOKENS) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a String. For example: "<xml-fragment>sample-1.1 sample-1.2 sample-1.3</xml-fragment>".
+ */
+ public static XmlNMTOKENS parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a String. For example: "<xml-fragment>sample-1.1 sample-1.2 sample-1.3</xml-fragment>".
+ */
+ public static XmlNMTOKENS parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a File.
+ */
+ public static XmlNMTOKENS parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a File.
+ */
+ public static XmlNMTOKENS parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a URL.
+ */
+ public static XmlNMTOKENS parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a URL.
+ */
+ public static XmlNMTOKENS parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from an InputStream.
+ */
+ public static XmlNMTOKENS parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from an InputStream.
+ */
+ public static XmlNMTOKENS parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a Reader.
+ */
+ public static XmlNMTOKENS parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a Reader.
+ */
+ public static XmlNMTOKENS parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a DOM Node.
+ */
+ public static XmlNMTOKENS parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from a DOM Node.
+ */
+ public static XmlNMTOKENS parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from an XMLStreamReader.
+ */
+ public static XmlNMTOKENS parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNMTOKENS} fragment from an XMLStreamReader.
+ */
+ public static XmlNMTOKENS parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNMTOKENS) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNOTATION.java b/src/main/java/org/apache/xmlbeans/XmlNOTATION.java
new file mode 100644
index 0000000..6b56eaa
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNOTATION.java
@@ -0,0 +1,163 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:NOTATION type.
+ *
+ * NOTATIONs are a mechanism in XML Schema that is provided
+ * for partial backward compatibility with NOTATIONs in DTDs. XML Schema
+ * users should almost never have any reason to use this data type.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlNOTATION extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_NOTATION");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNOTATION}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNOTATION}
+ */
+ public static XmlNOTATION newInstance() {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNOTATION}
+ */
+ public static XmlNOTATION newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNOTATION} value
+ */
+ public static XmlNOTATION newValue(Object obj) {
+ return (XmlNOTATION) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a String.
+ */
+ public static XmlNOTATION parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a String.
+ */
+ public static XmlNOTATION parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a File.
+ */
+ public static XmlNOTATION parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a File.
+ */
+ public static XmlNOTATION parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a URL.
+ */
+ public static XmlNOTATION parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a URL.
+ */
+ public static XmlNOTATION parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from an InputStream.
+ */
+ public static XmlNOTATION parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from an InputStream.
+ */
+ public static XmlNOTATION parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a Reader.
+ */
+ public static XmlNOTATION parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a Reader.
+ */
+ public static XmlNOTATION parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a DOM Node.
+ */
+ public static XmlNOTATION parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from a DOM Node.
+ */
+ public static XmlNOTATION parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from an XMLStreamReader.
+ */
+ public static XmlNOTATION parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNOTATION} fragment from an XMLStreamReader.
+ */
+ public static XmlNOTATION parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNOTATION) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlName.java b/src/main/java/org/apache/xmlbeans/XmlName.java
new file mode 100644
index 0000000..1bd945d
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlName.java
@@ -0,0 +1,165 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:Name type.
+ * One of the derived types based on xs:string.
+ *
+ * This kind of string is the same as the lexical representation used for XML 1.0
+ * element and attribute names, e.g., "pre:a-b.cdef". It is just a physical
+ * string, however, and it should NOT be confused with {@link XmlQName},
+ * which is a logical combination of localname and namespace URI.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlName extends XmlToken {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_Name");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlName}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlName}
+ */
+ public static XmlName newInstance() {
+ return (XmlName) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlName}
+ */
+ public static XmlName newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlName) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlName} value
+ */
+ public static XmlName newValue(Object obj) {
+ return (XmlName) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a String. For example: "<xml-fragment>My:Name</xml-fragment>".
+ */
+ public static XmlName parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a String. For example: "<xml-fragment>My:Name</xml-fragment>".
+ */
+ public static XmlName parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a File.
+ */
+ public static XmlName parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a File.
+ */
+ public static XmlName parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a URL.
+ */
+ public static XmlName parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a URL.
+ */
+ public static XmlName parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from an InputStream.
+ */
+ public static XmlName parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from an InputStream.
+ */
+ public static XmlName parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a Reader.
+ */
+ public static XmlName parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a Reader.
+ */
+ public static XmlName parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a DOM Node.
+ */
+ public static XmlName parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from a DOM Node.
+ */
+ public static XmlName parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from an XMLStreamReader.
+ */
+ public static XmlName parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlName} fragment from an XMLStreamReader.
+ */
+ public static XmlName parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlName) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNegativeInteger.java b/src/main/java/org/apache/xmlbeans/XmlNegativeInteger.java
new file mode 100644
index 0000000..ee7aa7c
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNegativeInteger.java
@@ -0,0 +1,162 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:negativeInteger type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be negative when validating.
+ *
+ * Convertible to {@link java.math.BigInteger}.
+ */
+public interface XmlNegativeInteger extends XmlNonPositiveInteger {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_negativeInteger");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNegativeInteger}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNegativeInteger}
+ */
+ public static XmlNegativeInteger newInstance() {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNegativeInteger}
+ */
+ public static XmlNegativeInteger newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNegativeInteger} value
+ */
+ public static XmlNegativeInteger newValue(Object obj) {
+ return (XmlNegativeInteger) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a String. For example: "<xml-fragment>-1234567890</xml-fragment>".
+ */
+ public static XmlNegativeInteger parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a String. For example: "<xml-fragment>-1234567890</xml-fragment>".
+ */
+ public static XmlNegativeInteger parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a File.
+ */
+ public static XmlNegativeInteger parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a File.
+ */
+ public static XmlNegativeInteger parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a URL.
+ */
+ public static XmlNegativeInteger parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a URL.
+ */
+ public static XmlNegativeInteger parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from an InputStream.
+ */
+ public static XmlNegativeInteger parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from an InputStream.
+ */
+ public static XmlNegativeInteger parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a Reader.
+ */
+ public static XmlNegativeInteger parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a Reader.
+ */
+ public static XmlNegativeInteger parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a DOM Node.
+ */
+ public static XmlNegativeInteger parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from a DOM Node.
+ */
+ public static XmlNegativeInteger parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlNegativeInteger parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNegativeInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlNegativeInteger parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNegativeInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNonNegativeInteger.java b/src/main/java/org/apache/xmlbeans/XmlNonNegativeInteger.java
new file mode 100644
index 0000000..0179f4e
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNonNegativeInteger.java
@@ -0,0 +1,162 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:nonNegativeInteger type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be zero or positive when validating.
+ *
+ * Convertible to {@link java.math.BigInteger}.
+ */
+public interface XmlNonNegativeInteger extends XmlInteger {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_nonNegativeInteger");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNonNegativeInteger}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNonNegativeInteger}
+ */
+ public static XmlNonNegativeInteger newInstance() {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNonNegativeInteger}
+ */
+ public static XmlNonNegativeInteger newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNonNegativeInteger} value
+ */
+ public static XmlNonNegativeInteger newValue(Object obj) {
+ return (XmlNonNegativeInteger) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a String. For example: "<xml-fragment>1234567890</xml-fragment>".
+ */
+ public static XmlNonNegativeInteger parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a String. For example: "<xml-fragment>1234567890</xml-fragment>".
+ */
+ public static XmlNonNegativeInteger parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a File.
+ */
+ public static XmlNonNegativeInteger parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a File.
+ */
+ public static XmlNonNegativeInteger parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a URL.
+ */
+ public static XmlNonNegativeInteger parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a URL.
+ */
+ public static XmlNonNegativeInteger parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from an InputStream.
+ */
+ public static XmlNonNegativeInteger parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from an InputStream.
+ */
+ public static XmlNonNegativeInteger parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a Reader.
+ */
+ public static XmlNonNegativeInteger parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a Reader.
+ */
+ public static XmlNonNegativeInteger parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a DOM Node.
+ */
+ public static XmlNonNegativeInteger parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from a DOM Node.
+ */
+ public static XmlNonNegativeInteger parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlNonNegativeInteger parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonNegativeInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlNonNegativeInteger parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonNegativeInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNonPositiveInteger.java b/src/main/java/org/apache/xmlbeans/XmlNonPositiveInteger.java
new file mode 100644
index 0000000..6333e88
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNonPositiveInteger.java
@@ -0,0 +1,162 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:nonPositiveInteger type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be zero or negative when validating.
+ *
+ * Convertible to {@link java.math.BigInteger}.
+ */
+public interface XmlNonPositiveInteger extends XmlInteger {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_nonPositiveInteger");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNonPositiveInteger}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNonPositiveInteger}
+ */
+ public static XmlNonPositiveInteger newInstance() {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNonPositiveInteger}
+ */
+ public static XmlNonPositiveInteger newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNonPositiveInteger} value
+ */
+ public static XmlNonPositiveInteger newValue(Object obj) {
+ return (XmlNonPositiveInteger) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a String. For example: "<xml-fragment>-1234567890</xml-fragment>".
+ */
+ public static XmlNonPositiveInteger parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a String. For example: "<xml-fragment>-1234567890</xml-fragment>".
+ */
+ public static XmlNonPositiveInteger parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a File.
+ */
+ public static XmlNonPositiveInteger parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a File.
+ */
+ public static XmlNonPositiveInteger parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a URL.
+ */
+ public static XmlNonPositiveInteger parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a URL.
+ */
+ public static XmlNonPositiveInteger parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from an InputStream.
+ */
+ public static XmlNonPositiveInteger parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from an InputStream.
+ */
+ public static XmlNonPositiveInteger parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a Reader.
+ */
+ public static XmlNonPositiveInteger parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a Reader.
+ */
+ public static XmlNonPositiveInteger parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a DOM Node.
+ */
+ public static XmlNonPositiveInteger parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from a DOM Node.
+ */
+ public static XmlNonPositiveInteger parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlNonPositiveInteger parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNonPositiveInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlNonPositiveInteger parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNonPositiveInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlNormalizedString.java b/src/main/java/org/apache/xmlbeans/XmlNormalizedString.java
new file mode 100644
index 0000000..98fe1c5
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlNormalizedString.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:normalizedString type.
+ * One of the derived types based on xs:string.
+ *
+ * An normalizedString simply is a string where all the carriage return,
+ * linefeed, and tab characters have been normalized (switched to) ordinary
+ * space characters. Use normalizedString for long strings to make them
+ * insensitive to line breaking. If you wish to often be insensitive to
+ * runs of whitespace (as is often the case), use
+ * xs:token
+ * (aka {@link XmlToken}) instead.
+ *
+ * Convertible to {@link String}. When obtaining the stringValue, the
+ * whitespace-normalized value is returned.
+ */
+public interface XmlNormalizedString extends XmlString {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_normalizedString");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlNormalizedString}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlNormalizedString}
+ */
+ public static XmlNormalizedString newInstance() {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlNormalizedString}
+ */
+ public static XmlNormalizedString newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlNormalizedString} value
+ */
+ public static XmlNormalizedString newValue(Object obj) {
+ return (XmlNormalizedString) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a String. For example: "<xml-fragment> string to normalize </xml-fragment>".
+ */
+ public static XmlNormalizedString parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a String. For example: "<xml-fragment> string to normalize </xml-fragment>".
+ */
+ public static XmlNormalizedString parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a File.
+ */
+ public static XmlNormalizedString parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a File.
+ */
+ public static XmlNormalizedString parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a URL.
+ */
+ public static XmlNormalizedString parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a URL.
+ */
+ public static XmlNormalizedString parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from an InputStream.
+ */
+ public static XmlNormalizedString parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from an InputStream.
+ */
+ public static XmlNormalizedString parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a Reader.
+ */
+ public static XmlNormalizedString parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a Reader.
+ */
+ public static XmlNormalizedString parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a DOM Node.
+ */
+ public static XmlNormalizedString parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from a DOM Node.
+ */
+ public static XmlNormalizedString parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from an XMLStreamReader.
+ */
+ public static XmlNormalizedString parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlNormalizedString} fragment from an XMLStreamReader.
+ */
+ public static XmlNormalizedString parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlNormalizedString) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlObject.java b/src/main/java/org/apache/xmlbeans/XmlObject.java
similarity index 79%
rename from src/xmlpublic/org/apache/xmlbeans/XmlObject.java
rename to src/main/java/org/apache/xmlbeans/XmlObject.java
index 3a29b59..d99f151 100644
--- a/src/xmlpublic/org/apache/xmlbeans/XmlObject.java
+++ b/src/main/java/org/apache/xmlbeans/XmlObject.java
@@ -15,19 +15,15 @@
package org.apache.xmlbeans;
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
-import org.apache.xmlbeans.xml.stream.XMLStreamException;
-
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.namespace.QName;
-
-import org.w3c.dom.Node;
import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Node;
-import java.io.InputStream;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
import java.io.File;
-import java.io.Reader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
/**
* Corresponds to the XML Schema
@@ -59,7 +55,7 @@
*
It is also simple to copy an XmlObject instance to or from a standard
* DOM tree or SAX stream. Use {@link XmlObject.Factory#parse(Node)},
* for example, to load from DOM; use {@link XmlObject.Factory#newXmlSaxHandler}
- * to load from SAX; use {@link #newDomNode()} to save to DOM; and use
+ * to load from SAX; use {@link #newDomNode()} to save to DOM; and use
* {@link #save(org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler)}
* to save to SAX.
*
Use {@link #validate} to validate the subtree of XML under this
@@ -69,7 +65,7 @@
*
Use {@link #newCursor} to access the full XML infoset, for example,
* if you need to determine interleaved element order or manipulate
* annotations, comments, or mixed content. You can get an element name with
- * a cursor by calling {@link XmlCursor#getName() cursor.getName()} when the
+ * a cursor by calling {@link XmlCursor#getName() cursor.getName()} when the
* cursor is positioned at an element's START token. See {@link XmlCursor}.
*
Use {@link #selectPath} to find other XmlObjects in the subtree underneath
* this XmlObject using relative XPaths. (In selectPath, "." indicates
@@ -131,12 +127,13 @@
* If you need to implement XmlObject yourself, you should subclass
* FilterXmlObject in order to delegate to another underlying XmlObject
* implementation. This technique will allow you to use your code unchanged
- * with future versions of XMLBeans that add additional methods on XmlObject.
- */
-public interface XmlObject extends XmlTokenSource
-{
- /** The constant {@link SchemaType} object representing this schema type. */
- public static final SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_anyType");
+ * with future versions of XMLBeans that add additional methods on XmlObject.
+ */
+public interface XmlObject extends XmlTokenSource {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_anyType");
/**
* @return The schema type for this instance. This is a permanent,
@@ -161,16 +158,16 @@ public interface XmlObject extends XmlTokenSource
* use the {@link XmlOptions#setErrorListener} method. With that method,
* you can specify an object in which to store messages related to validation.
* The following is a simple example.
- *
+ *
*
* // Create an XmlOptions instance and set the error listener.
* XmlOptions validateOptions = new XmlOptions();
* ArrayList errorList = new ArrayList();
* validateOptions.setErrorListener(errorList);
- *
+ *
* // Validate the XML.
* boolean isValid = newEmp.validate(validateOptions);
- *
+ *
* // If the XML isn't valid, loop through the listener's contents,
* // printing contained messages.
* if (!isValid)
@@ -178,18 +175,17 @@ public interface XmlObject extends XmlTokenSource
* for (int i = 0; i < errorList.size(); i++)
* {
* XmlError error = (XmlError)errorList.get(i);
- *
+ *
* System.out.println("\n");
* System.out.println("Message: " + error.getMessage() + "\n");
- * System.out.println("Location of invalid XML: " +
+ * System.out.println("Location of invalid XML: " +
* error.getCursorLocation().xmlText() + "\n");
* }
* }
*
*
* @param options An object that implements the {@link java.util.Collection
- * Collection} interface.
- *
+ * Collection} interface.
* @return true if the contents of this object are valid
* accoring to schemaType().
*/
@@ -198,19 +194,19 @@ public interface XmlObject extends XmlTokenSource
/**
* Selects a path. Path can be a string or precompiled path String.
*
- *
+ *
* The path must be a relative path, where "." represents the
* element or attribute containg this XmlObject, and it must select
* only other elements or attributes. If a non-element or non-attribute
* is selected, an unchecked exception is thrown.
*
- *
+ *
* The array that is returned contains all the selected
* XmlObjects, within the same document, listed in document
* order. The actual array type of the result is inferred
* from the closest common base type of selected results.
*
- *
+ *
* Here is an example of usage. Suppose we have a global
* element definition for "owner" whose type is "person":
*
@@ -222,7 +218,7 @@ public interface XmlObject extends XmlTokenSource
* </complexType>
* </schema>
*
- *
+ *
* and suppose "owner" tags can be scattered throughout the
* document. Then we can write the following code to find
* them all:
@@ -237,7 +233,7 @@ public interface XmlObject extends XmlTokenSource
* "declare namespace s='http://www.openuri.org/sample' " +
* ".//s:owner");
*
- *
+ *
* Notice the way in which namespace declarations are done in XPath 2.0.
* Since XPath can only navigate within an XML document - it cannot
* construct new XML - the resulting XmlObjects all reside in
@@ -246,19 +242,18 @@ public interface XmlObject extends XmlTokenSource
* @param path the xpath
* @return an array of all selected XmlObjects
*/
- XmlObject[] selectPath ( String path );
+ XmlObject[] selectPath(String path);
/**
* Selects a path, applying options.
*
- * @param path the xpath
+ * @param path the xpath
* @param options the options used to execute the xpath
* @return an array of all selected XmlObjects
- *
* @see #selectPath(String)
*/
- XmlObject[] selectPath ( String path, XmlOptions options );
-
+ XmlObject[] selectPath(String path, XmlOptions options);
+
/**
* Executes a query. Query can be a string or precompiled query String.
@@ -273,16 +268,15 @@ public interface XmlObject extends XmlTokenSource
*
* @param query The XQuery expression
* @return an array of all selected XmlObjects
- *
* @see #selectPath(String)
*/
- XmlObject[] execQuery ( String query );
+ XmlObject[] execQuery(String query);
/**
* Executes a query with options.
- *
+ *
* Use the options parameter to specify the following:
- *
+ *
*
*
To specify this
Use this method
*
@@ -315,7 +309,7 @@ public interface XmlObject extends XmlTokenSource
*
{@link XmlOptions#setLoadAdditionalNamespaces}
*
*
- *
To trim the underlying XML text buffer immediately after constructing
+ *
To trim the underlying XML text buffer immediately after constructing
* a document, resulting in a smaller memory footprint.
*
{@link XmlOptions#setLoadTrimTextBuffer}
*
@@ -323,17 +317,15 @@ public interface XmlObject extends XmlTokenSource
*
Whether value facets should be checked as they are set.
*
{@link XmlOptions#setValidateOnSet}
*
- *
- *
- * @param query The XQuery expression.
- * @param options Options as described.
+ *
*
+ * @param query The XQuery expression.
+ * @param options Options as described.
* @return an array of all selected XmlObjects
- *
* @see #execQuery(String)
*/
- XmlObject[] execQuery ( String query, XmlOptions options );
-
+ XmlObject[] execQuery(String query, XmlOptions options);
+
/**
* Changes the schema type associated with this data and
@@ -354,7 +346,7 @@ public interface XmlObject extends XmlTokenSource
* any other XmlObject instances in the subtree are permanently
* invalidated and should not be used. (They will return
* XmlValueDisconnectedException if you try to use them.)
- *
+ *
* If a type change is done on the interior of an Xml
* tree, then xsi:type attributes are updated as needed.
*
@@ -385,9 +377,8 @@ public interface XmlObject extends XmlTokenSource
*
* @param newName the new name
* @param newType the new type
- *
* @return an XmlObject instance whose schemaType is the
- * new type and container name is the new name
+ * new type and container name is the new name
*/
XmlObject substitute(QName newName, SchemaType newType);
@@ -447,11 +438,12 @@ public interface XmlObject extends XmlTokenSource
* the XML document underneath the current object. Note that
* any parts of the XML document above or outside this XmlObject are
* not copied.
- *
+ *
* Note: The result object will be in the same synchronization domain as the source,
* and additional synchronization is required for concurent access.
* To use a different synchronization domain use setCopyUseNewSynchronizationDomain
* option with copy(XmlOptions) method.
+ *
* @see #copy(XmlOptions)
* @see org.apache.xmlbeans.XmlOptions#setCopyUseNewSynchronizationDomain(boolean)
*/
@@ -463,11 +455,12 @@ public interface XmlObject extends XmlTokenSource
* the XML document underneath the current object. Note that
* any parts of the XML document above or outside this XmlObject are
* not copied.
- *
+ *
* Note: The result object will be in the same synchronization domain as the source,
* and additional synchronization is required for concurent access.
* To use a different synchronization domain use setCopyUseNewSynchronizationDomain
* option when creating the original XmlObject.
+ *
* @see org.apache.xmlbeans.XmlOptions#setCopyUseNewSynchronizationDomain(boolean)
*/
XmlObject copy(XmlOptions options);
@@ -524,20 +517,29 @@ public interface XmlObject extends XmlTokenSource
*/
int compareValue(XmlObject obj);
- /** LESS_THAN is -1. See {@link #compareValue}. */
+ /**
+ * LESS_THAN is -1. See {@link #compareValue}.
+ */
static final int LESS_THAN = -1;
- /** EQUAL is 0. See {@link #compareValue}. */
+ /**
+ * EQUAL is 0. See {@link #compareValue}.
+ */
static final int EQUAL = 0;
- /** GREATER_THAN is 1. See {@link #compareValue}. */
+ /**
+ * GREATER_THAN is 1. See {@link #compareValue}.
+ */
static final int GREATER_THAN = 1;
- /** NOT_EQUAL is 2. See {@link #compareValue}. */
+ /**
+ * NOT_EQUAL is 2. See {@link #compareValue}.
+ */
static final int NOT_EQUAL = 2;
/**
* Selects the contents of the children elements with the given name.
+ *
* @param elementName The name of the elements to be selected.
* @return Returns the contents of the selected elements.
*/
@@ -545,7 +547,8 @@ public interface XmlObject extends XmlTokenSource
/**
* Selects the contents of the children elements with the given name.
- * @param elementUri The URI of the elements to be selected.
+ *
+ * @param elementUri The URI of the elements to be selected.
* @param elementLocalName The local name of the elements to be selected.
* @return Returns the contents of the selected elements.
*/
@@ -553,6 +556,7 @@ public interface XmlObject extends XmlTokenSource
/**
* Selects the contents of the children elements that are contained in the elementNameSet.
+ *
* @param elementNameSet Set of element names to be selected.
* @return Returns the contents of the selected elements.
* @see SchemaType#qnameSetForWildcardElements()
@@ -562,6 +566,7 @@ public interface XmlObject extends XmlTokenSource
/**
* Selects the content of the attribute with the given name.
+ *
* @param attributeName The name of the attribute to be selected.
* @return Returns the contents of the selected attribute.
*/
@@ -569,7 +574,8 @@ public interface XmlObject extends XmlTokenSource
/**
* Selects the content of the attribute with the given name.
- * @param attributeUri The URI of the attribute to be selected.
+ *
+ * @param attributeUri The URI of the attribute to be selected.
* @param attributeLocalName The local name of the attribute to be selected.
* @return Returns the content of the selected attribute.
*/
@@ -577,6 +583,7 @@ public interface XmlObject extends XmlTokenSource
/**
* Selects the contents of the attributes that are contained in the elementNameSet.
+ *
* @param attributeNameSet Set of attribute names to be selected.
* @return Returns the contents of the selected attributes.
* @see SchemaType#qnameSetForWildcardAttributes()
@@ -591,21 +598,21 @@ public interface XmlObject extends XmlTokenSource
* returned by a factory will have the inferred type. Otherwise
* the Factory will returned an untyped document.
*/
- public static final class Factory
- {
+ final class Factory {
/**
* Creates a new, completely empty instance.
- */
- public static XmlObject newInstance ( ) {
- return XmlBeans.getContextTypeLoader().newInstance( null, null ); }
-
+ */
+ public static XmlObject newInstance() {
+ return XmlBeans.getContextTypeLoader().newInstance(null, null);
+ }
+
/**
*
Creates a new, completely empty instance, specifying options
* for the root element's document type and/or whether to validate
* value facets as they are set.
- *
+ *
* Use the options parameter to specify the following:
Trim the underlying XML text buffer immediately after parsing
+ *
Trim the underlying XML text buffer immediately after parsing
* a document, resulting in a smaller memory footprint.
*
{@link XmlOptions#setLoadTrimTextBuffer}
*
- *
- */
- public static XmlObject parse ( InputStream is, XmlOptions options ) throws XmlException, IOException {
- return XmlBeans.getContextTypeLoader().parse( is, null, options ); }
-
+ *
+ */
+ public static XmlObject parse(InputStream is, XmlOptions options) throws XmlException, IOException {
+ return XmlBeans.getContextTypeLoader().parse(is, null, options);
+ }
+
/**
* Parses the given {@link XMLStreamReader} as XML.
- */
- public static XmlObject parse ( XMLStreamReader xsr, XmlOptions options ) throws XmlException {
- return XmlBeans.getContextTypeLoader().parse( xsr, null, options ); }
-
+ */
+ public static XmlObject parse(XMLStreamReader xsr, XmlOptions options) throws XmlException {
+ return XmlBeans.getContextTypeLoader().parse(xsr, null, options);
+ }
+
/**
* Parses the given {@link Reader} as XML.
- */
- public static XmlObject parse ( Reader r ) throws XmlException, IOException {
- return XmlBeans.getContextTypeLoader().parse( r, null, null ); }
-
+ */
+ public static XmlObject parse(Reader r) throws XmlException, IOException {
+ return XmlBeans.getContextTypeLoader().parse(r, null, null);
+ }
+
/**
* Parses the given {@link Reader} as XML.
- */
- public static XmlObject parse ( Reader r, XmlOptions options ) throws XmlException, IOException {
- return XmlBeans.getContextTypeLoader().parse( r, null, options ); }
-
- /**
- * Converts the given DOM {@link Node} into an XmlObject.
- */
- public static XmlObject parse ( Node node ) throws XmlException {
- return XmlBeans.getContextTypeLoader().parse( node, null, null ); }
-
+ */
+ public static XmlObject parse(Reader r, XmlOptions options) throws XmlException, IOException {
+ return XmlBeans.getContextTypeLoader().parse(r, null, options);
+ }
+
/**
* Converts the given DOM {@link Node} into an XmlObject.
- */
- public static XmlObject parse ( Node node, XmlOptions options ) throws XmlException {
- return XmlBeans.getContextTypeLoader().parse( node, null, options ); }
-
- /**
- * Loads the given {@link XMLInputStream} into an XmlObject.
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
*/
- public static XmlObject parse ( XMLInputStream xis ) throws XmlException, XMLStreamException {
- return XmlBeans.getContextTypeLoader().parse( xis, null, null ); }
-
+ public static XmlObject parse(Node node) throws XmlException {
+ return XmlBeans.getContextTypeLoader().parse(node, null, null);
+ }
+
/**
- * Loads the given {@link XMLInputStream} into an XmlObject.
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
+ * Converts the given DOM {@link Node} into an XmlObject.
*/
- public static XmlObject parse ( XMLInputStream xis, XmlOptions options ) throws XmlException, XMLStreamException {
- return XmlBeans.getContextTypeLoader().parse( xis, null, options ); }
+ public static XmlObject parse(Node node, XmlOptions options) throws XmlException {
+ return XmlBeans.getContextTypeLoader().parse(node, null, options);
+ }
/**
* Returns an {@link XmlSaxHandler} that can load an XmlObject from SAX events.
- */
- public static XmlSaxHandler newXmlSaxHandler ( ) {
- return XmlBeans.getContextTypeLoader().newXmlSaxHandler( null, null ); }
-
+ */
+ public static XmlSaxHandler newXmlSaxHandler() {
+ return XmlBeans.getContextTypeLoader().newXmlSaxHandler(null, null);
+ }
+
/**
* Returns an {@link XmlSaxHandler} that can load an XmlObject from SAX events.
- */
- public static XmlSaxHandler newXmlSaxHandler ( XmlOptions options ) {
- return XmlBeans.getContextTypeLoader().newXmlSaxHandler( null, options ); }
-
+ */
+ public static XmlSaxHandler newXmlSaxHandler(XmlOptions options) {
+ return XmlBeans.getContextTypeLoader().newXmlSaxHandler(null, options);
+ }
+
/**
* Creates a new DOMImplementation object
- */
- public static DOMImplementation newDomImplementation ( ) {
- return XmlBeans.getContextTypeLoader().newDomImplementation( null ); }
-
- /**
- * Creates a new DOMImplementation object, taking options
- */
- public static DOMImplementation newDomImplementation ( XmlOptions options ) {
- return XmlBeans.getContextTypeLoader().newDomImplementation( options ); }
-
- /**
- * Returns a new validating {@link XMLInputStream} that throws exceptions when the input is not valid.
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
*/
- public static XMLInputStream newValidatingXMLInputStream ( XMLInputStream xis ) throws XmlException, XMLStreamException {
- return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, null, null ); }
-
+ public static DOMImplementation newDomImplementation() {
+ return XmlBeans.getContextTypeLoader().newDomImplementation(null);
+ }
+
/**
- * Returns a new validating {@link XMLInputStream} that throws exceptions
- * when the input is not valid, specifying options
- * for the root element's document type and/or the collection object to use
- * as an error listener while validating.
- *
- *
Use the options parameter to specify the following:
- *
- *
- *
A collection instance that should be used as an error listener during
- * compilation, as described in {@link XmlOptions#setErrorListener}.
- *
The document type for the root element, as described in
- * {@link XmlOptions#setDocumentType(SchemaType)}.
- *
- *
- * @param xis The basis for the new XMLInputStream.
- * @param options Options specifying root document type and/or an error listener.
- * @return A new validating XMLInputStream.
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
+ * Creates a new DOMImplementation object, taking options
*/
- public static XMLInputStream newValidatingXMLInputStream ( XMLInputStream xis, XmlOptions options ) throws XmlException, XMLStreamException {
- return XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, null, options ); }
-
+ public static DOMImplementation newDomImplementation(XmlOptions options) {
+ return XmlBeans.getContextTypeLoader().newDomImplementation(options);
+ }
+
/**
* Instances cannot be created.
- */
- private Factory() { }
+ */
+ private Factory() {
+ }
}
}
diff --git a/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java b/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java
new file mode 100644
index 0000000..76ecdc7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java
@@ -0,0 +1,134 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Corresponds to the Saver and XmlOptions.
+ *
+ * This class is used to set up a map containing characters to be escaped.
+ * Characters can be escaped as hex, decimal or as a predefined entity (this
+ * latter option applies only to the 5 characters defined as predefined entities
+ * in the XML Spec).
+ *
+ *
+ * For example:
+ *
+ * XmlOptionCharEscapeMap escapes = new XmlOptionCharEscapeMap();
+ * escapes.addMapping('A', XmlOptionCharEscapeMap.HEXADECIMAL);
+ * escapes.addMapping('B', XmlOptionCharEscapeMap.DECIMAL);
+ * escapes.addMapping('>', XmlOptionCharEscapeMap.PREDEF_ENTITY);
+ *
+ * XmlOptions opts = new XmlOptions();
+ * opts.setSaveSubstituteCharacters(escapes);
+ * System.out.println(myXml.xmlText(opts));
+ *
+ * will result in:
+ * A being printed as A
+ * B being printed as B
+ * > being printed as >
+ *
+ *
+ */
+public class XmlOptionCharEscapeMap {
+ public static final int PREDEF_ENTITY = 0;
+ public static final int DECIMAL = 1;
+ public static final int HEXADECIMAL = 2;
+
+ // map of Character to String which will represent it in the output document
+ private final Map _charMap;
+
+ // internal HashMap just for predefined entities
+ private static final Map _predefEntities = new HashMap<>();
+
+ static {
+ _predefEntities.put('<', "<");
+ _predefEntities.put('>', ">");
+ _predefEntities.put('&', "&");
+ _predefEntities.put('\'', "'");
+ _predefEntities.put('"', """);
+ }
+
+ /**
+ * Construct a new XmlOptionCharEncoder.
+ */
+ public XmlOptionCharEscapeMap() {
+ _charMap = new HashMap<>();
+ }
+
+ /**
+ * @return whether a character encoding exists for this character
+ */
+ public boolean containsChar(char ch) {
+ return _charMap.containsKey(ch);
+ }
+
+ /**
+ * set up this character to be escaped in output documents
+ * according to the given mode
+ */
+ public void addMapping(char ch, int mode) throws XmlException {
+ Character theChar = ch;
+ switch (mode) {
+ case PREDEF_ENTITY:
+ String replString = _predefEntities.get(theChar);
+ if (replString == null) {
+ throw new XmlException("XmlOptionCharEscapeMap.addMapping(): " +
+ "the PREDEF_ENTITY mode can only be used for the following " +
+ "characters: <, >, &, \" and '");
+ }
+ _charMap.put(theChar, replString);
+ break;
+
+ case DECIMAL:
+ _charMap.put(theChar, "" + (int) ch + ";");
+ break;
+
+ case HEXADECIMAL:
+ String hexCharPoint = Integer.toHexString(ch);
+ _charMap.put(theChar, "" + hexCharPoint + ";");
+ break;
+
+ default:
+ throw new XmlException("XmlOptionCharEscapeMap.addMapping(): " +
+ "mode must be PREDEF_ENTITY, DECIMAL or HEXADECIMAL");
+ }
+ }
+
+ /**
+ * set up this contiguous set of characters to be escaped in
+ * output documents according to the given mode
+ */
+ public void addMappings(char ch1, char ch2, int mode) throws XmlException {
+ if (ch1 > ch2) {
+ throw new XmlException("XmlOptionCharEscapeMap.addMappings(): " +
+ "ch1 must be <= ch2");
+ }
+
+ for (char c = ch1; c <= ch2; c++) {
+ addMapping(c, mode);
+ }
+ }
+
+ /**
+ * returns the escaped String for the character
+ */
+ public String getEscapedString(char ch) {
+ return _charMap.get(ch);
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlOptions.java b/src/main/java/org/apache/xmlbeans/XmlOptions.java
new file mode 100644
index 0000000..ff6b2e5
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlOptions.java
@@ -0,0 +1,1440 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import org.apache.xmlbeans.impl.store.Saaj;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.XMLReader;
+
+import javax.xml.namespace.QName;
+import java.net.URI;
+import java.util.*;
+
+/**
+ * Used to supply options for loading, saving, and compiling, and validating.
+ *
+ * There are two styles for using XmlOptions: multiline setup, and single-line use.
+ * Here are two examples. First, multiline style:
+ *
+ */
+public class XmlOptions implements java.io.Serializable {
+ //
+ // Complete set of XmlOption's
+ //
+
+ // TODO - Add selectPath option to track the seletion (default is to clean selections fast).
+ public enum XmlOptionsKeys {
+ SAVE_NAMESPACES_FIRST,
+ SAVE_SYNTHETIC_DOCUMENT_ELEMENT,
+ SAVE_PRETTY_PRINT,
+ SAVE_PRETTY_PRINT_INDENT,
+ SAVE_PRETTY_PRINT_OFFSET,
+ SAVE_AGGRESSIVE_NAMESPACES,
+ SAVE_USE_DEFAULT_NAMESPACE,
+ SAVE_IMPLICIT_NAMESPACES,
+ SAVE_SUGGESTED_PREFIXES,
+ SAVE_FILTER_PROCINST,
+ SAVE_USE_OPEN_FRAGMENT,
+ SAVE_OUTER,
+ SAVE_INNER,
+ SAVE_NO_XML_DECL,
+ SAVE_SUBSTITUTE_CHARACTERS,
+ SAVE_OPTIMIZE_FOR_SPEED,
+ SAVE_CDATA_LENGTH_THRESHOLD,
+ SAVE_CDATA_ENTITY_COUNT_THRESHOLD,
+ SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES,
+ LOAD_REPLACE_DOCUMENT_ELEMENT,
+ LOAD_STRIP_WHITESPACE,
+ LOAD_STRIP_COMMENTS,
+ LOAD_STRIP_PROCINSTS,
+ LOAD_LINE_NUMBERS,
+ LOAD_LINE_NUMBERS_END_ELEMENT,
+ LOAD_SAVE_CDATA_BOOKMARKS,
+ LOAD_SUBSTITUTE_NAMESPACES,
+ LOAD_TRIM_TEXT_BUFFER,
+ LOAD_ADDITIONAL_NAMESPACES,
+ LOAD_MESSAGE_DIGEST,
+ LOAD_USE_DEFAULT_RESOLVER,
+ LOAD_USE_XMLREADER,
+ XQUERY_CURRENT_NODE_VAR,
+ XQUERY_VARIABLE_MAP,
+ CHARACTER_ENCODING,
+ ERROR_LISTENER,
+ DOCUMENT_TYPE,
+ DOCUMENT_SOURCE_NAME,
+ COMPILE_SUBSTITUTE_NAMES,
+ COMPILE_NO_VALIDATION,
+ COMPILE_NO_UPA_RULE,
+ COMPILE_NO_PVR_RULE,
+ COMPILE_NO_ANNOTATIONS,
+ COMPILE_DOWNLOAD_URLS,
+ COMPILE_MDEF_NAMESPACES,
+ COMPILE_PARTIAL_TYPESYSTEM,
+ VALIDATE_ON_SET,
+ VALIDATE_TREAT_LAX_AS_SKIP,
+ VALIDATE_STRICT,
+ VALIDATE_TEXT_ONLY,
+ UNSYNCHRONIZED,
+ ENTITY_RESOLVER,
+ BASE_URI,
+ SCHEMA_CODE_PRINTER,
+ GENERATE_JAVA_VERSION,
+ USE_SAME_LOCALE,
+ COPY_USE_NEW_SYNC_DOMAIN,
+ LOAD_ENTITY_BYTES_LIMIT,
+ ENTITY_EXPANSION_LIMIT,
+ LOAD_DTD_GRAMMAR,
+ LOAD_EXTERNAL_DTD,
+ SAAJ_IMPL,
+ LOAD_USE_LOCALE_CHAR_UTIL,
+ XPATH_USE_SAXON,
+ XPATH_USE_XMLBEANS,
+ ATTTRIBUTE_VALIDATION_COMPAT_MODE
+ }
+
+
+ public static final int DEFAULT_ENTITY_EXPANSION_LIMIT = 2048;
+
+ private static final XmlOptions EMPTY_OPTIONS;
+
+ static {
+ EMPTY_OPTIONS = new XmlOptions();
+ EMPTY_OPTIONS._map = Collections.unmodifiableMap(EMPTY_OPTIONS._map);
+ }
+
+
+ private static final long serialVersionUID = 1L;
+
+ private Map _map = new HashMap<>();
+
+
+ /**
+ * Construct a new blank XmlOptions.
+ */
+ public XmlOptions() {
+ }
+
+ /**
+ * Construct a new XmlOptions, copying the options.
+ */
+ public XmlOptions(XmlOptions other) {
+ if (other != null) {
+ _map.putAll(other._map);
+ }
+ }
+
+ //
+ // Handy-dandy helper methods for setting some options
+ //
+
+ /**
+ * This option will cause the saver to save namespace attributes first.
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveNamespacesFirst() {
+ return setSaveNamespacesFirst(true);
+ }
+
+ public XmlOptions setSaveNamespacesFirst(boolean b) {
+ return set(XmlOptionsKeys.SAVE_NAMESPACES_FIRST, b);
+ }
+
+ public boolean isSaveNamespacesFirst() {
+ return hasOption(XmlOptionsKeys.SAVE_NAMESPACES_FIRST);
+ }
+
+
+ /**
+ * This option will cause the saver to reformat white space for easier reading.
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSavePrettyPrint() {
+ return setSavePrettyPrint(true);
+ }
+
+ public XmlOptions setSavePrettyPrint(boolean b) {
+ return set(XmlOptionsKeys.SAVE_PRETTY_PRINT, b);
+ }
+
+ public boolean isSavePrettyPrint() {
+ return hasOption(XmlOptionsKeys.SAVE_PRETTY_PRINT);
+ }
+
+
+ /**
+ * When used with setSavePrettyPrint this sets the indent
+ * amount to use.
+ *
+ * @param indent the indent amount to use
+ * @see #setSavePrettyPrint
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSavePrettyPrintIndent(int indent) {
+ return set(XmlOptionsKeys.SAVE_PRETTY_PRINT_INDENT, indent);
+ }
+
+ public Integer getSavePrettyPrintIndent() {
+ return (Integer) get(XmlOptionsKeys.SAVE_PRETTY_PRINT_INDENT);
+ }
+
+ /**
+ * When used with setSavePrettyPrint this sets the offset
+ * amount to use.
+ *
+ * @param offset the offset amount to use
+ * @see #setSavePrettyPrint
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSavePrettyPrintOffset(int offset) {
+ return set(XmlOptionsKeys.SAVE_PRETTY_PRINT_OFFSET, offset);
+ }
+
+ public Integer getSavePrettyPrintOffset() {
+ return (Integer) get(XmlOptionsKeys.SAVE_PRETTY_PRINT_OFFSET);
+ }
+
+ /**
+ * When writing a document, this sets the character
+ * encoding to use.
+ *
+ * @param encoding the character encoding
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ */
+ public XmlOptions setCharacterEncoding(String encoding) {
+ return set(XmlOptionsKeys.CHARACTER_ENCODING, encoding);
+ }
+
+ public String getCharacterEncoding() {
+ return (String) get(XmlOptionsKeys.CHARACTER_ENCODING);
+ }
+
+ /**
+ * When parsing a document, this sets the type of the root
+ * element. If this is set, the parser will not try to guess
+ * the type based on the document's QName.
+ *
+ * @param type The root element's document type.
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setDocumentType(SchemaType type) {
+ return set(XmlOptionsKeys.DOCUMENT_TYPE, type);
+ }
+
+ public SchemaType getDocumentType() {
+ return (SchemaType) get(XmlOptionsKeys.DOCUMENT_TYPE);
+ }
+
+
+ /**
+ *
Sets a collection object for collecting {@link XmlError} objects
+ * during parsing, validation, and compilation. When set, the collection
+ * will contain all the errors after the operation takes place. Notice that
+ * the errors will only have line numbers if the document was
+ * loaded with line numbers enabled.
+ *
+ *
The following simple example illustrates using an error listener
+ * during validation.
+ *
+ *
+ * // Create an XmlOptions instance and set the error listener.
+ * XmlOptions validateOptions = new XmlOptions();
+ * ArrayList errorList = new ArrayList();
+ * validateOptions.setErrorListener(errorList);
+ *
+ * // Validate the XML.
+ * boolean isValid = newEmp.validate(validateOptions);
+ *
+ * // If the XML isn't valid, loop through the listener's contents,
+ * // printing contained messages.
+ * if (!isValid)
+ * {
+ * for (int i = 0; i < errorList.size(); i++)
+ * {
+ * XmlError error = (XmlError)errorList.get(i);
+ *
+ * System.out.println("\n");
+ * System.out.println("Message: " + error.getMessage() + "\n");
+ * System.out.println("Location of invalid XML: " +
+ * error.getCursorLocation().xmlText() + "\n");
+ * }
+ * }
+ *
+ *
+ * @param c A collection that will be filled with {@link XmlError} objects
+ * via {@link Collection#add}
+ * @see XmlError
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ * @see XmlObject#validate(XmlOptions)
+ * @see XmlBeans#compileXsd
+ * @see XmlOptions#setLoadLineNumbers
+ */
+ public XmlOptions setErrorListener(Collection c) {
+ return set(XmlOptionsKeys.ERROR_LISTENER, c);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection getErrorListener() {
+ return (Collection) get(XmlOptionsKeys.ERROR_LISTENER);
+ }
+
+ /**
+ * Causes the saver to reduce the number of namespace prefix declarations.
+ * The saver will do this by passing over the document twice, first to
+ * collect the set of needed namespace declarations, and then second
+ * to actually save the document with the declarations collected
+ * at the root.
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveAggressiveNamespaces() {
+ return setSaveAggressiveNamespaces(true);
+ }
+
+ public XmlOptions setSaveAggressiveNamespaces(boolean b) {
+ return set(XmlOptionsKeys.SAVE_AGGRESSIVE_NAMESPACES, b);
+ }
+
+ public boolean isSaveAggressiveNamespaces() {
+ return hasOption(XmlOptionsKeys.SAVE_AGGRESSIVE_NAMESPACES);
+ }
+
+
+ /**
+ * This option causes the saver to wrap the current fragment in
+ * an element with the given name.
+ *
+ * @param name the name to use for the top level element
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveSyntheticDocumentElement(QName name) {
+ return set(XmlOptionsKeys.SAVE_SYNTHETIC_DOCUMENT_ELEMENT, name);
+ }
+
+ public QName getSaveSyntheticDocumentElement() {
+ return (QName) get(XmlOptionsKeys.SAVE_SYNTHETIC_DOCUMENT_ELEMENT);
+ }
+
+
+ /**
+ * If this option is set, the saver will try to use the default
+ * namespace for the most commonly used URI. If it is not set
+ * the saver will always created named prefixes.
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setUseDefaultNamespace() {
+ return setUseDefaultNamespace(true);
+ }
+
+ public XmlOptions setUseDefaultNamespace(boolean b) {
+ return set(XmlOptionsKeys.SAVE_USE_DEFAULT_NAMESPACE, b);
+ }
+
+ public boolean isUseDefaultNamespace() {
+ return hasOption(XmlOptionsKeys.SAVE_USE_DEFAULT_NAMESPACE);
+ }
+
+ /**
+ * If namespaces have already been declared outside the scope of the
+ * fragment being saved, this allows those mappings to be passed
+ * down to the saver, so the prefixes are not re-declared.
+ *
+ * @param implicitNamespaces a map of prefixes to uris that can be
+ * used by the saver without being declared
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveImplicitNamespaces(Map implicitNamespaces) {
+ return set(XmlOptionsKeys.SAVE_IMPLICIT_NAMESPACES, implicitNamespaces);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map getSaveImplicitNamespaces() {
+ return (Map) get(XmlOptionsKeys.SAVE_IMPLICIT_NAMESPACES);
+ }
+
+ /**
+ * A map of hints to pass to the saver for which prefixes to use
+ * for which namespace URI.
+ *
+ * @param suggestedPrefixes a map from URIs to prefixes
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveSuggestedPrefixes(Map suggestedPrefixes) {
+ return set(XmlOptionsKeys.SAVE_SUGGESTED_PREFIXES, suggestedPrefixes);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map getSaveSuggestedPrefixes() {
+ return (Map) get(XmlOptionsKeys.SAVE_SUGGESTED_PREFIXES);
+ }
+
+ /**
+ * This option causes the saver to filter a Processing Instruction
+ * with the given target
+ *
+ * @param filterProcinst the name of a Processing Instruction to filter
+ * on save
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveFilterProcinst(String filterProcinst) {
+ return set(XmlOptionsKeys.SAVE_FILTER_PROCINST, filterProcinst);
+ }
+
+ public String getSaveFilterProcinst() {
+ return (String) get(XmlOptionsKeys.SAVE_FILTER_PROCINST);
+ }
+
+ /**
+ * This option causes the saver to replace characters with other values in
+ * the output stream. It is intended to be used for escaping non-standard
+ * characters during output.
+ *
+ * @param characterReplacementMap is an XmlOptionCharEscapeMap containing
+ * the characters to be escaped.
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ * @see XmlOptionCharEscapeMap
+ */
+ public XmlOptions setSaveSubstituteCharacters(
+ XmlOptionCharEscapeMap characterReplacementMap) {
+ return set(XmlOptionsKeys.SAVE_SUBSTITUTE_CHARACTERS, characterReplacementMap);
+ }
+
+ public XmlOptionCharEscapeMap getSaveSubstituteCharacters() {
+ return (XmlOptionCharEscapeMap) get(XmlOptionsKeys.SAVE_SUBSTITUTE_CHARACTERS);
+ }
+
+ /**
+ * When saving a fragment, this option changes the qname of the synthesized
+ * root element. Normally <xml-fragment> is used.
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveUseOpenFrag() {
+ return setSaveUseOpenFrag(true);
+ }
+
+ public XmlOptions setSaveUseOpenFrag(boolean b) {
+ return set(XmlOptionsKeys.SAVE_USE_OPEN_FRAGMENT, b);
+ }
+
+ public boolean isSaveUseOpenFrag() {
+ return hasOption(XmlOptionsKeys.SAVE_USE_OPEN_FRAGMENT);
+ }
+
+ /**
+ * This option controls whether saving begins on the element or its contents
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveOuter() {
+ return setSaveOuter(true);
+ }
+
+ public XmlOptions setSaveOuter(boolean b) {
+ return set(XmlOptionsKeys.SAVE_OUTER, b);
+ }
+
+ public boolean isSaveOuter() {
+ return hasOption(XmlOptionsKeys.SAVE_OUTER);
+ }
+
+ /**
+ * This option controls whether saving begins on the element or its contents
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveInner() {
+ return setSaveInner(true);
+ }
+
+ public XmlOptions setSaveInner(boolean b) {
+ return set(XmlOptionsKeys.SAVE_INNER, b);
+ }
+
+ public boolean isSaveInner() {
+ return hasOption(XmlOptionsKeys.SAVE_INNER);
+ }
+
+ /**
+ * This option controls whether saving saves out the XML
+ * declaration (
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveNoXmlDecl() {
+ return setSaveNoXmlDecl(true);
+ }
+
+ public XmlOptions setSaveNoXmlDecl(boolean b) {
+ return set(XmlOptionsKeys.SAVE_NO_XML_DECL, b);
+ }
+
+ public boolean isSaveNoXmlDecl() {
+ return hasOption(XmlOptionsKeys.SAVE_NO_XML_DECL);
+ }
+
+
+ /**
+ * This option controls when saving will use CDATA blocks.
+ * CDATA will be used if the folowing condition is true:
+ * textLength > cdataLengthThreshold && entityCount > cdataEntityCountThreshold
+ * The default value of cdataLengthThreshold is 32.
+ *
+ * Use the folowing values for these cases:
+ *
+ *
Scenario
cdataLengthThreshold
cdataEntityCountThreshold
+ *
Every text is CDATA
0
-1
+ *
Only text that has an entity is CDATA
0
0
+ *
Only text longer than x chars is CDATA
x
-1
+ *
Only text that has y entitazable chars is CDATA
0
y
+ *
Only text longer than x chars and has y entitazable chars is CDATA
x
y
+ *
+ *
+ * @see XmlOptions#setSaveCDataEntityCountThreshold(int)
+ */
+ public XmlOptions setSaveCDataLengthThreshold(int cdataLengthThreshold) {
+ return set(XmlOptionsKeys.SAVE_CDATA_LENGTH_THRESHOLD, cdataLengthThreshold);
+ }
+
+ public Integer getSaveCDataLengthThreshold() {
+ return (Integer) get(XmlOptionsKeys.SAVE_CDATA_LENGTH_THRESHOLD);
+ }
+
+
+ /**
+ * This option controls when saving will use CDATA blocks.
+ * CDATA will be used if the folowing condition is true:
+ * textLength > cdataLengthThreshold && entityCount > cdataEntityCountThreshold
+ * The default value of cdataEntityCountThreshold is 5.
+ *
+ * @see XmlOptions#setSaveCDataLengthThreshold(int)
+ */
+ public XmlOptions setSaveCDataEntityCountThreshold(int cdataEntityCountThreshold) {
+ return set(XmlOptionsKeys.SAVE_CDATA_ENTITY_COUNT_THRESHOLD, cdataEntityCountThreshold);
+ }
+
+ public Integer getSaveCDataEntityCountThreshold() {
+ return (Integer) get(XmlOptionsKeys.SAVE_CDATA_ENTITY_COUNT_THRESHOLD);
+ }
+
+ /**
+ *
Use this option when parsing and saving XML documents.
+ *
+ *
For parsing this option will annotate the text fields in the store with CDataBookmark.
+ *
+ *
For saving this option will save the text fields annotated with CDataBookmark as
+ * CDATA XML text.
+ * Note: The SaveCDataEntityCountThreshold and SaveCDataLengthThreshold options and
+ * their default values still apply.
+ *
+ *
Note: Due to the store representation, a CDATA will not be recognized
+ * if it is imediately after non CDATA text and all text following it will
+ * be considered CDATA.
+ * Example:
+ *
+ * <a><![CDATA[cdata text]]></a> - is considered as: <a><![CDATA[cdata text]]></a>
+ * <b><![CDATA[cdata text]]> regular text</b> - is considered as: <b><![CDATA[cdata text regular text]]></b>
+ * <c>text <![CDATA[cdata text]]></c> - is considered as: <c>text cdata text</c>
+ *
+ *
+ * @see CDataBookmark
+ * @see CDataBookmark#CDATA_BOOKMARK
+ */
+ public XmlOptions setUseCDataBookmarks() {
+ return set(XmlOptionsKeys.LOAD_SAVE_CDATA_BOOKMARKS);
+ }
+
+ public boolean isUseCDataBookmarks() {
+ return hasOption(XmlOptionsKeys.LOAD_SAVE_CDATA_BOOKMARKS);
+ }
+
+ /**
+ * This option controls whether namespace declarations are included as attributes in the
+ * startElement event. By default, up to and including XMLBeans 2.3.0 they were included, in
+ * subsequent versions, they are no longer included.
+ */
+ public XmlOptions setSaveSaxNoNSDeclsInAttributes() {
+ return setSaveSaxNoNSDeclsInAttributes(true);
+ }
+
+ public XmlOptions setSaveSaxNoNSDeclsInAttributes(boolean b) {
+ return set(XmlOptionsKeys.SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES, b);
+ }
+
+ public boolean isSaveSaxNoNSDeclsInAttributes() {
+ return hasOption(XmlOptionsKeys.SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES);
+ }
+
+
+ /**
+ * If this option is set, the document element is replaced with the
+ * given QName when parsing. If null is supplied, the document element
+ * is removed.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadReplaceDocumentElement(QName replacement) {
+ return set(XmlOptionsKeys.LOAD_REPLACE_DOCUMENT_ELEMENT, replacement);
+ }
+
+ public QName getLoadReplaceDocumentElement() {
+ return (QName) get(XmlOptionsKeys.LOAD_REPLACE_DOCUMENT_ELEMENT);
+ }
+
+ /**
+ * If this option is set, all insignificant whitespace is stripped
+ * when parsing a document. Can be used to save memory on large
+ * documents when you know there is no mixed content.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadStripWhitespace() {
+ return setLoadStripWhitespace(true);
+ }
+
+ public XmlOptions setLoadStripWhitespace(boolean b) {
+ return set(XmlOptionsKeys.LOAD_STRIP_WHITESPACE, b);
+ }
+
+ public boolean isSetLoadStripWhitespace() {
+ return hasOption(XmlOptionsKeys.LOAD_STRIP_WHITESPACE);
+ }
+
+ /**
+ * If this option is set, all comments are stripped when parsing
+ * a document.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadStripComments() {
+ return setLoadStripComments(true);
+ }
+
+ public XmlOptions setLoadStripComments(boolean b) {
+ return set(XmlOptionsKeys.LOAD_STRIP_COMMENTS, b);
+ }
+
+ public boolean isLoadStripComments() {
+ return hasOption(XmlOptionsKeys.LOAD_STRIP_COMMENTS);
+ }
+
+ /**
+ * If this option is set, all processing instructions
+ * are stripped when parsing a document.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadStripProcinsts() {
+ return setLoadStripProcinsts(true);
+ }
+
+ public XmlOptions setLoadStripProcinsts(boolean b) {
+ return set(XmlOptionsKeys.LOAD_STRIP_PROCINSTS, b);
+ }
+
+ public boolean isLoadStripProcinsts() {
+ return hasOption(XmlOptionsKeys.LOAD_STRIP_PROCINSTS);
+ }
+
+ /**
+ * If this option is set, line number annotations are placed
+ * in the store when parsing a document. This is particularly
+ * useful when you want {@link XmlError} objects to contain
+ * line numbers.
+ * Note: This adds line numbers info only for start tags.
+ * For line number info on end tags use:
+ * {@link XmlOptions#setLoadLineNumbersEndElement()}
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ * @see XmlError
+ */
+ public XmlOptions setLoadLineNumbers() {
+ return setLoadLineNumbers(true);
+ }
+
+ public XmlOptions setLoadLineNumbers(boolean b) {
+ return set(XmlOptionsKeys.LOAD_LINE_NUMBERS, b);
+ }
+
+ public boolean isLoadLineNumbers() {
+ return hasOption(XmlOptionsKeys.LOAD_LINE_NUMBERS);
+ }
+
+
+ /**
+ * If this option is set, line number annotations are placed
+ * in the store when parsing a document. This is particularly
+ * useful when you want {@link XmlError} objects to contain
+ * line numbers. Use the option to load line numbers at the end of an element.
+ */
+ public XmlOptions setLoadLineNumbersEndElement() {
+ return setLoadLineNumbersEndElement(true);
+ }
+
+ public XmlOptions setLoadLineNumbersEndElement(boolean b) {
+ setLoadLineNumbers(true);
+ return set(XmlOptionsKeys.LOAD_LINE_NUMBERS_END_ELEMENT, b);
+ }
+
+ public boolean isLoadLineNumbersEndElement() {
+ return hasOption(XmlOptionsKeys.LOAD_LINE_NUMBERS_END_ELEMENT);
+ }
+
+ /**
+ * This option sets a map of namespace uri substitutions that happen
+ * when parsing a document.
+ *
+ * This is particularly useful if you
+ * have documents that use no namespace, but you wish to avoid
+ * the name collision problems that occur when you introduce
+ * schema definitions without a target namespace.
+ *
+ * By mapping the empty string "" (the absence of a URI) to a specific
+ * namespace, you can force the parser to behave as if a no-namespace
+ * document were actually in the specified namespace. This allows you
+ * to type the instance according to a schema in a nonempty namespace,
+ * and therefore avoid the problematic practice of using schema
+ * definitions without a target namespace.
+ *
+ * @param substNamespaces a map of document URIs to replacement URIs
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadSubstituteNamespaces(Map substNamespaces) {
+ return set(XmlOptionsKeys.LOAD_SUBSTITUTE_NAMESPACES, substNamespaces);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map getLoadSubstituteNamespaces() {
+ return (Map) get(XmlOptionsKeys.LOAD_SUBSTITUTE_NAMESPACES);
+ }
+
+ /**
+ * If this option is set, the underlying xml text buffer is trimmed
+ * immediately after parsing a document resulting in a smaller memory
+ * footprint. Use this option if you are loading a large number
+ * of unchanging documents that will stay in memory for some time.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadTrimTextBuffer() {
+ return setLoadTrimTextBuffer(true);
+ }
+
+ public XmlOptions setLoadTrimTextBuffer(boolean b) {
+ return set(XmlOptionsKeys.LOAD_TRIM_TEXT_BUFFER, b);
+ }
+
+ public boolean isLoadTrimTextBuffer() {
+ return hasOption(XmlOptionsKeys.LOAD_TRIM_TEXT_BUFFER);
+ }
+
+ /**
+ * Set additional namespace mappings to be added when parsing
+ * a document.
+ *
+ * @param nses additional namespace mappings
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadAdditionalNamespaces(Map nses) {
+ return set(XmlOptionsKeys.LOAD_ADDITIONAL_NAMESPACES, nses);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map getLoadAdditionalNamespaces() {
+ return (Map) get(XmlOptionsKeys.LOAD_ADDITIONAL_NAMESPACES);
+ }
+
+ /**
+ * If this option is set when loading from an InputStream or File, then
+ * the loader will compute a 160-bit SHA-1 message digest of the XML
+ * file while loading it and make it available via
+ * XmlObject.documentProperties().getMessageDigest();
+ *
+ * The schema compiler uses message digests to detect and eliminate
+ * duplicate imported xsd files.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadMessageDigest() {
+ return setLoadMessageDigest(true);
+ }
+
+ public XmlOptions setLoadMessageDigest(boolean b) {
+ return set(XmlOptionsKeys.LOAD_MESSAGE_DIGEST, b);
+ }
+
+ public boolean isLoadMessageDigest() {
+ return hasOption(XmlOptionsKeys.LOAD_MESSAGE_DIGEST);
+ }
+
+ /**
+ * By default, XmlBeans does not resolve entities when parsing xml
+ * documents (unless an explicit entity resolver is specified).
+ * Use this option to turn on entity resolving by default.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadUseDefaultResolver() {
+ return setLoadUseDefaultResolver(true);
+ }
+
+ public XmlOptions setLoadUseDefaultResolver(boolean b) {
+ return set(XmlOptionsKeys.LOAD_USE_DEFAULT_RESOLVER, b);
+ }
+
+ public boolean isLoadUseDefaultResolver() {
+ return hasOption(XmlOptionsKeys.LOAD_USE_DEFAULT_RESOLVER);
+ }
+
+
+ /**
+ * By default, XmlBeans creates a JAXP parser,
+ * other parsers can be used by providing an XMLReader.
+ * For using the default JDK's SAX parser use:
+ * xmlOptions.setLoadUseXMLReader( SAXParserFactory.newInstance().newSAXParser().getXMLReader() );
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setLoadUseXMLReader(XMLReader xmlReader) {
+ return set(XmlOptionsKeys.LOAD_USE_XMLREADER, xmlReader);
+ }
+
+ public XMLReader getLoadUseXMLReader() {
+ return (XMLReader) get(XmlOptionsKeys.LOAD_USE_XMLREADER);
+ }
+
+ /**
+ * Sets the name of the variable that represents
+ * the current node in a query expression.
+ *
+ * @param varName The new variable name to use for the query.
+ * @see XmlObject#execQuery
+ * @see XmlCursor#execQuery
+ */
+ public XmlOptions setXqueryCurrentNodeVar(String varName) {
+ return set(XmlOptionsKeys.XQUERY_CURRENT_NODE_VAR, varName);
+ }
+
+ public String getXqueryCurrentNodeVar() {
+ return (String) get(XmlOptionsKeys.XQUERY_CURRENT_NODE_VAR);
+ }
+
+ /**
+ * Map the names and values of external variables in an xquery
+ * expression. The keys of the map are the variable names
+ * in the query without the '$' prefix. The values of the map
+ * are objects and can be any of the primitive wrapper classes,
+ * String, XmlObject, or XmlCursor. The mapping only applies to
+ * xquery and has no effect on xpath expressions.
+ *
+ * @param varMap a map from Strings to variable instances.
+ * @see XmlObject#execQuery
+ * @see XmlCursor#execQuery
+ */
+ public XmlOptions setXqueryVariables(Map varMap) {
+ return set(XmlOptionsKeys.XQUERY_VARIABLE_MAP, varMap);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map getXqueryVariables() {
+ return (Map) get(XmlOptionsKeys.XQUERY_VARIABLE_MAP);
+ }
+
+ /**
+ * This option sets the document source name into the xml store
+ * when parsing a document. If a document is parsed from a
+ * File or URI, it is automatically set to the URI of the
+ * source; otherwise, for example, when parsing a String,
+ * you can use this option to specify the source name yourself.
+ *
+ * @see XmlObject.Factory#parse(java.lang.String, XmlOptions)
+ */
+ public XmlOptions setDocumentSourceName(String documentSourceName) {
+ return set(XmlOptionsKeys.DOCUMENT_SOURCE_NAME, documentSourceName);
+ }
+
+ public String getDocumentSourceName() {
+ return (String) get(XmlOptionsKeys.DOCUMENT_SOURCE_NAME);
+ }
+
+ /**
+ * This option allows for QName substitution during schema compilation.
+ *
+ * @param nameMap a map from QNames to substitute QNames.
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileSubstituteNames(Map nameMap) {
+ return set(XmlOptionsKeys.COMPILE_SUBSTITUTE_NAMES, nameMap);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map getCompileSubstituteNames() {
+ return (Map) get(XmlOptionsKeys.COMPILE_SUBSTITUTE_NAMES);
+ }
+
+ /**
+ * If this option is set, validation is not done on the Schema XmlBeans
+ * when building a SchemaTypeSystem
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileNoValidation() {
+ return set(XmlOptionsKeys.COMPILE_NO_VALIDATION);
+ }
+
+ public boolean isCompileNoValidation() {
+ return hasOption(XmlOptionsKeys.COMPILE_NO_VALIDATION);
+ }
+
+ /**
+ * If this option is set, the unique particle attribution rule is not
+ * enforced when building a SchemaTypeSystem. See
+ * Appendix H of the XML Schema specification
+ * for information on the UPA rule.
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileNoUpaRule() {
+ return setCompileNoUpaRule(true);
+ }
+
+ public XmlOptions setCompileNoUpaRule(boolean b) {
+ return set(XmlOptionsKeys.COMPILE_NO_UPA_RULE, b);
+ }
+
+ public boolean isCompileNoUpaRule() {
+ return hasOption(XmlOptionsKeys.COMPILE_NO_UPA_RULE);
+ }
+
+ /**
+ * If this option is set, the particle valid (restriciton) rule is not
+ * enforced when building a SchemaTypeSystem. See
+ * Section 3.9.6 of the XML Schema specification
+ * for information on the PVR rule.
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileNoPvrRule() {
+ return setCompileNoPvrRule(true);
+ }
+
+ public XmlOptions setCompileNoPvrRule(boolean b) {
+ return set(XmlOptionsKeys.COMPILE_NO_PVR_RULE, b);
+ }
+
+ public boolean isCompileNoPvrRule() {
+ return hasOption(XmlOptionsKeys.COMPILE_NO_PVR_RULE);
+ }
+
+ /**
+ * if this option is set, the schema compiler will skip annotations when
+ * processing Schema components.
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileNoAnnotations() {
+ return setCompileNoAnnotations(true);
+ }
+
+ public XmlOptions setCompileNoAnnotations(boolean b) {
+ return set(XmlOptionsKeys.COMPILE_NO_ANNOTATIONS, b);
+ }
+
+ public boolean isCompileNoAnnotations() {
+ return hasOption(XmlOptionsKeys.COMPILE_NO_ANNOTATIONS);
+ }
+
+ /**
+ * If this option is set, then the schema compiler will try to download
+ * schemas that appear in imports and includes from network based URLs.
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileDownloadUrls() {
+ return setCompileDownloadUrls(true);
+ }
+
+ public XmlOptions setCompileDownloadUrls(boolean b) {
+ return set(XmlOptionsKeys.COMPILE_DOWNLOAD_URLS, b);
+ }
+
+ public boolean isCompileDownloadUrls() {
+ return hasOption(XmlOptionsKeys.COMPILE_DOWNLOAD_URLS);
+ }
+
+ /**
+ * If this option is set, then the schema compiler will permit and
+ * ignore multiple definitions of the same component (element, attribute,
+ * type, etc) names in the given namespaces. If multiple definitions
+ * with the same name appear, the definitions that happen to be processed
+ * last will be ignored.
+ *
+ * @param mdefNamespaces a set of namespace URIs as Strings
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setCompileMdefNamespaces(Set mdefNamespaces) {
+ return set(XmlOptionsKeys.COMPILE_MDEF_NAMESPACES, mdefNamespaces);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set getCompileMdefNamespaces() {
+ return (Set) get(XmlOptionsKeys.COMPILE_MDEF_NAMESPACES);
+ }
+
+ public XmlOptions setCompilePartialTypesystem() {
+ return setCompilePartialTypesystem(true);
+ }
+
+ public XmlOptions setCompilePartialTypesystem(boolean compilePartialTypesystem) {
+ return set(XmlOptionsKeys.COMPILE_PARTIAL_TYPESYSTEM, compilePartialTypesystem);
+ }
+
+ public boolean isCompilePartialTypesystem() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.COMPILE_PARTIAL_TYPESYSTEM);
+ return flag != null && flag;
+ }
+
+ /**
+ * If this option is set when an instance is created, then value
+ * facets will be checked on each call to a setter or getter
+ * method on instances of XmlObject within the instance document.
+ * If the facets are not satisfied, then an unchecked exception is
+ * thrown immediately. This option is useful for finding code that
+ * is introducing invalid values in an XML document, but it
+ * slows performance.
+ *
+ * @see XmlObject.Factory#parse(java.io.File, XmlOptions)
+ */
+ public XmlOptions setValidateOnSet() {
+ return setValidateOnSet(true);
+ }
+
+ public XmlOptions setValidateOnSet(boolean b) {
+ return set(XmlOptionsKeys.VALIDATE_ON_SET, b);
+ }
+
+ public boolean isValidateOnSet() {
+ return hasOption(XmlOptionsKeys.VALIDATE_ON_SET);
+ }
+
+ /**
+ * Instructs the validator to skip elements matching an
+ * particle with contentModel="lax". This is useful because,
+ * in certain situations, XmlBeans will find types on the
+ * classpath that the document author did not anticipate.
+ */
+ public XmlOptions setValidateTreatLaxAsSkip() {
+ return setValidateTreatLaxAsSkip(true);
+ }
+
+ public XmlOptions setValidateTreatLaxAsSkip(boolean b) {
+ return set(XmlOptionsKeys.VALIDATE_TREAT_LAX_AS_SKIP, b);
+ }
+
+ public boolean isValidateTreatLaxAsSkip() {
+ return hasOption(XmlOptionsKeys.VALIDATE_TREAT_LAX_AS_SKIP);
+ }
+
+ /**
+ * Performs additional validation checks that are disabled by
+ * default for better compatibility.
+ */
+ public XmlOptions setValidateStrict() {
+ return setValidateStrict(true);
+ }
+
+ public XmlOptions setValidateStrict(boolean b) {
+ return set(XmlOptionsKeys.VALIDATE_STRICT, b);
+ }
+
+ public boolean isValidateStrict() {
+ return hasOption(XmlOptionsKeys.VALIDATE_STRICT);
+ }
+
+ public XmlOptions setValidateTextOnly() {
+ return setValidateTextOnly(true);
+ }
+
+ public XmlOptions setValidateTextOnly(boolean b) {
+ return set(XmlOptionsKeys.VALIDATE_TEXT_ONLY, b);
+ }
+
+ public boolean isValidateTextOnly() {
+ return hasOption(XmlOptionsKeys.VALIDATE_TEXT_ONLY);
+ }
+
+
+ /**
+ * This option controls whether or not operations on XmlBeans are
+ * thread safe. When not on, all XmlBean operations will be syncronized.
+ * This provides for multiple thread the ability to access a single
+ * XmlBeans simultainously, but has a perf impact. If set, then
+ * only one thread may access an XmlBean.
+ */
+ public XmlOptions setUnsynchronized() {
+ return setUnsynchronized(true);
+ }
+
+ public XmlOptions setUnsynchronized(boolean b) {
+ return set(XmlOptionsKeys.UNSYNCHRONIZED, b);
+ }
+
+ public boolean isUnsynchronized() {
+ return hasOption(XmlOptionsKeys.UNSYNCHRONIZED);
+ }
+
+ /**
+ * If this option is set when compiling a schema, then the given
+ * EntityResolver will be consulted in order to resolve any
+ * URIs while downloading imported schemas.
+ *
+ * EntityResolvers are currently only used by compileXsd; they
+ * are not consulted by other functions, for example, parse.
+ * This will likely change in the future.
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setEntityResolver(EntityResolver resolver) {
+ return set(XmlOptionsKeys.ENTITY_RESOLVER, resolver);
+ }
+
+ public EntityResolver getEntityResolver() {
+ return (EntityResolver) get(XmlOptionsKeys.ENTITY_RESOLVER);
+ }
+
+ /**
+ * If this option is set when compiling a schema, then the given
+ * URI will be considered as base URI when deciding the directory
+ * structure for saving the sources inside the generated JAR file.
+ *
+ * @param baseURI the URI to be considered as "base"
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setBaseURI(URI baseURI) {
+ return set(XmlOptionsKeys.BASE_URI, baseURI);
+ }
+
+ public URI getBaseURI() {
+ return (URI) get(XmlOptionsKeys.BASE_URI);
+ }
+
+ /**
+ * If this option is set when compiling a schema, then the given
+ * SchemaTypeCodePrinter.Printer will be used to generate the
+ * Java code.
+ *
+ * @see XmlBeans#compileXsd
+ */
+ public XmlOptions setSchemaCodePrinter(SchemaCodePrinter printer) {
+ return set(XmlOptionsKeys.SCHEMA_CODE_PRINTER, printer);
+ }
+
+ public SchemaCodePrinter getSchemaCodePrinter() {
+ return (SchemaCodePrinter) get(XmlOptionsKeys.SCHEMA_CODE_PRINTER);
+ }
+
+ /**
+ * If this option is set to true, the return of XmlObject.copy() method will
+ * return an object in it's own synchronization domain, otherwise both objects
+ * will share the same synchronization domain, requiring explicit synchronization
+ * when concurent accessing the two objects.
+ *
+ * @param useNewSyncDomain A flag representing the usage of new domain
+ * @see XmlObject#copy()
+ */
+ public XmlOptions setCopyUseNewSynchronizationDomain(boolean useNewSyncDomain) {
+ return set(XmlOptionsKeys.COPY_USE_NEW_SYNC_DOMAIN, useNewSyncDomain);
+ }
+
+ public boolean isCopyUseNewSynchronizationDomain() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.COPY_USE_NEW_SYNC_DOMAIN);
+ return flag != null && flag;
+ }
+
+ public XmlOptions setUseSameLocale(Object localeOrXmlTokenSource) {
+ return set(XmlOptionsKeys.USE_SAME_LOCALE, localeOrXmlTokenSource);
+ }
+
+ public Object getUseSameLocale() {
+ return get(XmlOptionsKeys.USE_SAME_LOCALE);
+ }
+
+
+ /**
+ * Sets the maximum number of bytes allowed when an Entity is expanded during parsing.
+ * The default value is 10240 bytes.
+ *
+ * @param entityBytesLimit the maximum number of bytes allowed when an Entity is expanded during parsing
+ * @return this
+ */
+ public XmlOptions setLoadEntityBytesLimit(int entityBytesLimit) {
+ return set(XmlOptionsKeys.LOAD_ENTITY_BYTES_LIMIT, entityBytesLimit);
+ }
+
+ public Integer getLoadEntityBytesLimit() {
+ return (Integer) get(XmlOptionsKeys.LOAD_ENTITY_BYTES_LIMIT);
+ }
+
+
+ /**
+ * Sets the maximum number of entity expansions allowed during parsing.
+ * The default value is 2048.
+ *
+ * @param entityExpansionLimit the maximum number of entity expansions allowed during parsing
+ * @return this
+ */
+ public XmlOptions setEntityExpansionLimit(int entityExpansionLimit) {
+ return set(XmlOptionsKeys.ENTITY_EXPANSION_LIMIT, entityExpansionLimit);
+ }
+
+ public int getEntityExpansionLimit() {
+ Integer limit = (Integer) get(XmlOptionsKeys.ENTITY_EXPANSION_LIMIT);
+ return limit == null ? DEFAULT_ENTITY_EXPANSION_LIMIT : limit;
+ }
+
+ /**
+ * Controls whether DTD grammar is loaded during parsing.
+ * The default value is false.
+ *
+ * @param loadDTDGrammar {@code true}, if DTD grammar is loaded during parsing
+ * @return this
+ */
+ public XmlOptions setLoadDTDGrammar(boolean loadDTDGrammar) {
+ return set(XmlOptionsKeys.LOAD_DTD_GRAMMAR, loadDTDGrammar);
+ }
+
+ public boolean isLoadDTDGrammar() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.LOAD_DTD_GRAMMAR);
+ return flag != null && flag;
+ }
+
+ /**
+ * Controls whether external DTDs are loaded during parsing.
+ * The default value is false.
+ *
+ * @param loadExternalDTD {@code true}, if external DTDs are loaded during parsing
+ * @return this
+ */
+ public XmlOptions setLoadExternalDTD(boolean loadExternalDTD) {
+ return set(XmlOptionsKeys.LOAD_EXTERNAL_DTD, loadExternalDTD);
+ }
+
+ public boolean isLoadExternalDTD() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.LOAD_EXTERNAL_DTD);
+ return flag != null && flag;
+ }
+
+ public XmlOptions setSaveOptimizeForSpeed(boolean saveOptimizeForSpeed) {
+ return set(XmlOptionsKeys.SAVE_OPTIMIZE_FOR_SPEED, saveOptimizeForSpeed);
+ }
+
+ public boolean isSaveOptimizeForSpeed() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.SAVE_OPTIMIZE_FOR_SPEED);
+ return flag != null && flag;
+ }
+
+ // Use in XmlOptions to enable SAAJ support in store
+ public XmlOptions setSaaj(Saaj saaj) {
+ return set(XmlOptionsKeys.SAAJ_IMPL, saaj);
+ }
+
+ public Saaj getSaaj() {
+ return (Saaj) get(XmlOptionsKeys.SAAJ_IMPL);
+ }
+
+ public XmlOptions setLoadUseLocaleCharUtil(boolean useCharUtil) {
+ return set(XmlOptionsKeys.LOAD_USE_LOCALE_CHAR_UTIL, useCharUtil);
+ }
+
+ public boolean isLoadUseLocaleCharUtil() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.LOAD_USE_LOCALE_CHAR_UTIL);
+ return flag != null && flag;
+ }
+
+ public XmlOptions setXPathUseSaxon() {
+ return setXPathUseSaxon(true);
+ }
+
+ public XmlOptions setXPathUseSaxon(boolean xpathUseSaxon) {
+ return set(XmlOptionsKeys.XPATH_USE_SAXON, xpathUseSaxon);
+ }
+
+ public boolean isXPathUseSaxon() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.XPATH_USE_SAXON);
+ return flag != null && flag;
+ }
+
+ public XmlOptions setXPathUseXmlBeans() {
+ return setXPathUseSaxon(true);
+ }
+
+ public XmlOptions setXPathUseXmlBeans(boolean xpathUseXmlBeans) {
+ return set(XmlOptionsKeys.XPATH_USE_XMLBEANS, xpathUseXmlBeans);
+ }
+
+ public boolean isXPathUseXmlBeans() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.XPATH_USE_XMLBEANS);
+ return flag != null && flag;
+ }
+
+ public XmlOptions setAttributeValidationCompatMode(boolean attributeValidationCompatMode) {
+ return set(XmlOptionsKeys.ATTTRIBUTE_VALIDATION_COMPAT_MODE, attributeValidationCompatMode);
+ }
+
+ public boolean isAttributeValidationCompatMode() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.ATTTRIBUTE_VALIDATION_COMPAT_MODE);
+ return flag != null && flag;
+ }
+
+ /**
+ * If passed null, returns an empty options object. Otherwise, returns its argument.
+ */
+ public static XmlOptions maskNull(XmlOptions o) {
+ return (o == null) ? EMPTY_OPTIONS : o;
+ }
+
+
+ private XmlOptions set(XmlOptionsKeys option) {
+ return set(option, true);
+ }
+
+ private XmlOptions set(XmlOptionsKeys option, Object value) {
+ _map.put(option, value);
+ return this;
+ }
+
+ private XmlOptions set(XmlOptionsKeys option, int value) {
+ return set(option, (Integer)value);
+ }
+
+ private XmlOptions set(XmlOptionsKeys option, boolean value) {
+ if (value) {
+ set(option, Boolean.TRUE);
+ } else {
+ remove(option);
+ }
+ return this;
+ }
+
+ /**
+ * Used to test a generic option
+ */
+ public boolean hasOption(XmlOptionsKeys option) {
+ return _map.containsKey(option);
+ }
+
+ /**
+ * Used to get a generic option
+ */
+ public Object get(XmlOptionsKeys option) {
+ return _map.get(option);
+ }
+
+ public void remove(XmlOptionsKeys option) {
+ _map.remove(option);
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlOptionsBean.java b/src/main/java/org/apache/xmlbeans/XmlOptionsBean.java
new file mode 100644
index 0000000..7ab1a51
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlOptionsBean.java
@@ -0,0 +1,39 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Same as {@link XmlOptions} but adhering to JavaBean conventions
+ *
+ * @deprecated use XmlOptions instead
+ */
+@Deprecated
+public class XmlOptionsBean extends XmlOptions {
+ /**
+ * Construct a new blank XmlOptions.
+ */
+ public XmlOptionsBean() {
+ }
+
+ /**
+ * Construct a new XmlOptions, copying the options.
+ *
+ * @param other the source XmlOptions object
+ */
+ public XmlOptionsBean(XmlOptions other) {
+ super(other);
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlPositiveInteger.java b/src/main/java/org/apache/xmlbeans/XmlPositiveInteger.java
new file mode 100644
index 0000000..cfa2679
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlPositiveInteger.java
@@ -0,0 +1,162 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:positiveInteger type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be positive when validating.
+ *
+ * Convertible to {@link java.math.BigInteger}.
+ */
+public interface XmlPositiveInteger extends XmlNonNegativeInteger {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_positiveInteger");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlPositiveInteger}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlPositiveInteger}
+ */
+ public static XmlPositiveInteger newInstance() {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlPositiveInteger}
+ */
+ public static XmlPositiveInteger newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlPositiveInteger} value
+ */
+ public static XmlPositiveInteger newValue(Object obj) {
+ return (XmlPositiveInteger) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a String. For example: "<xml-fragment>1234567890</xml-fragment>".
+ */
+ public static XmlPositiveInteger parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a String. For example: "<xml-fragment>1234567890</xml-fragment>".
+ */
+ public static XmlPositiveInteger parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a File.
+ */
+ public static XmlPositiveInteger parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a File.
+ */
+ public static XmlPositiveInteger parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a URL.
+ */
+ public static XmlPositiveInteger parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a URL.
+ */
+ public static XmlPositiveInteger parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from an InputStream.
+ */
+ public static XmlPositiveInteger parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from an InputStream.
+ */
+ public static XmlPositiveInteger parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a Reader.
+ */
+ public static XmlPositiveInteger parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a Reader.
+ */
+ public static XmlPositiveInteger parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a DOM Node.
+ */
+ public static XmlPositiveInteger parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from a DOM Node.
+ */
+ public static XmlPositiveInteger parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlPositiveInteger parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlPositiveInteger} fragment from an XMLStreamReader.
+ */
+ public static XmlPositiveInteger parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlPositiveInteger) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlQName.java b/src/main/java/org/apache/xmlbeans/XmlQName.java
new file mode 100644
index 0000000..7c648c5
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlQName.java
@@ -0,0 +1,179 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:QName type.
+ *
+ * A QName is the logical combination of an XML namespace URI and a localName.
+ * Although in an XML instance document, a QName appears as "prefix:localName",
+ * the logical value of a QName does NOT contain any information about the
+ * prefix, only the namespace URI to which the prefix maps. For example,
+ * two QNames "a:hello" and "b:hello" are perfectly equivalent if "a:" in
+ * the first instance maps to the same URI as "b:" in the second instance.
+ *
+ * Convertible to {@link javax.xml.namespace.QName}.
+ */
+public interface XmlQName extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_QName");
+
+ /**
+ * Returns this value as a {@link QName}
+ */
+ QName getQNameValue();
+
+ /**
+ * Sets this value as a {@link QName}
+ */
+ void setQNameValue(QName name);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlQName}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlQName}
+ */
+ public static XmlQName newInstance() {
+ return (XmlQName) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlQName}
+ */
+ public static XmlQName newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlQName) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlQName} value
+ */
+ public static XmlQName newValue(Object obj) {
+ return (XmlQName) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a String. For example: "<xml-fragment xmlns:x="http://openuri.org/">x:sample</xml-fragment>".
+ */
+ public static XmlQName parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a String. For example: "<xml-fragment xmlns:x="http://openuri.org/">x:sample</xml-fragment>".
+ */
+ public static XmlQName parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a File.
+ */
+ public static XmlQName parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a File.
+ */
+ public static XmlQName parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a URL.
+ */
+ public static XmlQName parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a URL.
+ */
+ public static XmlQName parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from an InputStream.
+ */
+ public static XmlQName parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from an InputStream.
+ */
+ public static XmlQName parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a Reader.
+ */
+ public static XmlQName parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a Reader.
+ */
+ public static XmlQName parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a DOM Node.
+ */
+ public static XmlQName parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from a DOM Node.
+ */
+ public static XmlQName parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from an XMLStreamReader.
+ */
+ public static XmlQName parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlQName} fragment from an XMLStreamReader.
+ */
+ public static XmlQName parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlQName) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlRuntimeException.java b/src/main/java/org/apache/xmlbeans/XmlRuntimeException.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/XmlRuntimeException.java
rename to src/main/java/org/apache/xmlbeans/XmlRuntimeException.java
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlSaxHandler.java b/src/main/java/org/apache/xmlbeans/XmlSaxHandler.java
similarity index 100%
rename from src/xmlpublic/org/apache/xmlbeans/XmlSaxHandler.java
rename to src/main/java/org/apache/xmlbeans/XmlSaxHandler.java
diff --git a/src/main/java/org/apache/xmlbeans/XmlShort.java b/src/main/java/org/apache/xmlbeans/XmlShort.java
new file mode 100644
index 0000000..45b362d
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlShort.java
@@ -0,0 +1,170 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:short type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Naturally, convertible to a Java short.
+ */
+public interface XmlShort extends XmlInt {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_short");
+
+ /**
+ * Returns this value as a short
+ */
+ short getShortValue();
+
+ /**
+ * Sets this value as a short
+ */
+ void setShortValue(short s);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlShort}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlShort}
+ */
+ public static XmlShort newInstance() {
+ return (XmlShort) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlShort}
+ */
+ public static XmlShort newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlShort) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlShort} value
+ */
+ public static XmlShort newValue(Object obj) {
+ return (XmlShort) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a String. For example: "<xml-fragment>12345</xml-fragment>".
+ */
+ public static XmlShort parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a String. For example: "<xml-fragment>12345</xml-fragment>".
+ */
+ public static XmlShort parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a File.
+ */
+ public static XmlShort parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a File.
+ */
+ public static XmlShort parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a URL.
+ */
+ public static XmlShort parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a URL.
+ */
+ public static XmlShort parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from an InputStream.
+ */
+ public static XmlShort parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from an InputStream.
+ */
+ public static XmlShort parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a Reader.
+ */
+ public static XmlShort parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a Reader.
+ */
+ public static XmlShort parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a DOM Node.
+ */
+ public static XmlShort parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from a DOM Node.
+ */
+ public static XmlShort parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from an XMLStreamReader.
+ */
+ public static XmlShort parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlShort} fragment from an XMLStreamReader.
+ */
+ public static XmlShort parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlShort) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlSimpleList.java b/src/main/java/org/apache/xmlbeans/XmlSimpleList.java
new file mode 100644
index 0000000..5ad4222
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlSimpleList.java
@@ -0,0 +1,321 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.*;
+
+/**
+ * The immutable {@link List} returned for XML simple list values.
+ *
+ * XmlSimpleList implements an equals() and hashCode() that compare list
+ * contents, so two XmlSimpleLists are the same if they have the same
+ * values in the same order.
+ */
+public class XmlSimpleList implements List, java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final List underlying;
+
+ /**
+ * Constructs an immutable XmlSimpleList that wraps (does not copy)
+ * the given {@link List}. All non-mutating methods delegate to
+ * the underlying List instance.
+ */
+ public XmlSimpleList(List list) {
+ this.underlying = list;
+ }
+
+ /**
+ * Returns the number of elements in this list.
+ */
+ public int size() {
+ return underlying.size();
+ }
+
+ /**
+ * True if the list is empty.
+ */
+ public boolean isEmpty() {
+ return underlying.isEmpty();
+ }
+
+ /**
+ * True if the list is contains an object equal to o.
+ */
+ public boolean contains(Object o) {
+ return underlying.contains(o);
+ }
+
+ /**
+ * True if the list is contains all the objects in the given collection.
+ */
+ public boolean containsAll(Collection coll) {
+ return underlying.containsAll(coll);
+ }
+
+ /**
+ * Copies the collection to an array.
+ */
+ public Object[] toArray() {
+ return underlying.toArray(new Object[0]);
+ }
+
+ /**
+ * Copies the collection to an array of a specified type.
+ */
+ @SuppressWarnings("SuspiciousToArrayCall")
+ public X[] toArray(X[] a) {
+ return underlying.toArray(a);
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public boolean add(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public boolean addAll(Collection coll) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public boolean removeAll(Collection coll) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public boolean retainAll(Collection coll) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the object at the specified position in this list.
+ */
+ public T get(int index) {
+ return underlying.get(index);
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public T set(int index, T element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public void add(int index, Object element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public T remove(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns index of the first occurance of an object equal to o.
+ */
+ public int indexOf(Object o) {
+ return underlying.indexOf(o);
+ }
+
+ /**
+ * Returns index of the last occurance of an object equal to o.
+ */
+ public int lastIndexOf(Object o) {
+ return underlying.lastIndexOf(o);
+ }
+
+ /**
+ * Unsupported because this list is immutable.
+ */
+ public boolean addAll(int index, Collection c) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
+ */
+ public List subList(int from, int to) {
+ return new XmlSimpleList<>(underlying.subList(from, to));
+ }
+
+ /**
+ * Returns an iterator over the elements in this list in proper sequence.
+ */
+ public Iterator iterator() {
+ return new Iterator() {
+ final Iterator i = underlying.iterator();
+
+ public boolean hasNext() {
+ return i.hasNext();
+ }
+
+ public T next() {
+ return i.next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ /**
+ * Returns a list iterator of the elements in this list in proper sequence.
+ */
+ public ListIterator listIterator() {
+ return listIterator(0);
+ }
+
+ /**
+ * Returns a list iterator of the elements in this list in proper sequence, starting at the specified position in this list.
+ */
+ public ListIterator listIterator(final int index) {
+ return new ListIterator() {
+ final ListIterator i = underlying.listIterator(index);
+
+ public boolean hasNext() {
+ return i.hasNext();
+ }
+
+ public T next() {
+ return i.next();
+ }
+
+ public boolean hasPrevious() {
+ return i.hasPrevious();
+ }
+
+ public T previous() {
+ return i.previous();
+ }
+
+ public int nextIndex() {
+ return i.nextIndex();
+ }
+
+ public int previousIndex() {
+ return i.previousIndex();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void set(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ private String stringValue(Object o) {
+ if (o instanceof SimpleValue) {
+ return ((SimpleValue) o).getStringValue();
+ }
+ return o.toString();
+ }
+
+ /**
+ * Returns a space-separated list of the string representations of all
+ * the items in the list. For most lists, this is a valid xml lexical
+ * value for the list. (The notable exception is a list of QNames.)
+ */
+ public String toString() {
+ int size = underlying.size();
+ if (size == 0) {
+ return "";
+ }
+ String first = stringValue(underlying.get(0));
+ if (size == 1) {
+ return first;
+ }
+ StringBuilder result = new StringBuilder(first);
+ for (int i = 1; i < size; i++) {
+ result.append(' ');
+ result.append(stringValue(underlying.get(i)));
+ }
+ return result.toString();
+ }
+
+ /**
+ * Two XmlSimpleLists are equal if all their items are equal.
+ * (They must have the same number of items, and the items must be in
+ * the same order.)
+ */
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof XmlSimpleList)) {
+ return false;
+ }
+ final XmlSimpleList> xmlSimpleList = (XmlSimpleList>) o;
+ List> underlying2 = xmlSimpleList.underlying;
+ int size = underlying.size();
+ if (size != underlying2.size()) {
+ return false;
+ }
+ for (int i = 0; i < size; i++) {
+ if (!Objects.equals(underlying.get(i), underlying2.get(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Combines the hash codes of all the list items.
+ */
+ public int hashCode() {
+ int hash = 0;
+ for (Object item : underlying) {
+ hash *= 19;
+ hash += item.hashCode();
+ }
+ return hash;
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/XmlString.java b/src/main/java/org/apache/xmlbeans/XmlString.java
new file mode 100644
index 0000000..b05a72e
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlString.java
@@ -0,0 +1,169 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:string type.
+ *
+ * A basic string in XML schema is not whitespace normalized. If you
+ * want your string type to be insensitive to variations in runs of
+ * whitespace, consider using
+ * xs:token
+ * (aka {@link XmlToken}) instead.
+ * To forbid whitespace and permit just alphanumeric and other
+ * common identifier characters consider
+ * xs:NMTOKEN
+ * (aka {@link XmlNMTOKEN}) instead.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlString extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_string");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlString}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlString}
+ */
+ public static XmlString newInstance() {
+ return (XmlString) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlString}
+ */
+ public static XmlString newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlString) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlString} value
+ */
+ public static XmlString newValue(Object obj) {
+ return (XmlString) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a String. For example: "<xml-fragment> arbitrary string </xml-fragment>".
+ */
+ public static XmlString parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a String. For example: "<xml-fragment> arbitrary string </xml-fragment>".
+ */
+ public static XmlString parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a File.
+ */
+ public static XmlString parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a File.
+ */
+ public static XmlString parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a URL.
+ */
+ public static XmlString parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a URL.
+ */
+ public static XmlString parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from an InputStream.
+ */
+ public static XmlString parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from an InputStream.
+ */
+ public static XmlString parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a Reader.
+ */
+ public static XmlString parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a Reader.
+ */
+ public static XmlString parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a DOM Node.
+ */
+ public static XmlString parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from a DOM Node.
+ */
+ public static XmlString parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from an XMLStreamReader.
+ */
+ public static XmlString parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlString} fragment from an XMLStreamReader.
+ */
+ public static XmlString parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlString) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlTime.java b/src/main/java/org/apache/xmlbeans/XmlTime.java
new file mode 100644
index 0000000..c3a1aeb
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlTime.java
@@ -0,0 +1,186 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.util.Calendar;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:time type.
+ * A gDay specifies only a day-of-month.
+ *
+ * Convertible to {@link Calendar} or {@link GDate}.
+ *
+ * @see XmlCalendar
+ * @see GDate
+ */
+public interface XmlTime extends XmlAnySimpleType {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_time");
+
+ /**
+ * Returns this value as a {@link Calendar}
+ */
+ Calendar getCalendarValue();
+
+ /**
+ * Sets this value as a {@link Calendar}
+ */
+ void setCalendarValue(Calendar c);
+
+ /**
+ * Returns this value as a {@link GDate}
+ */
+ GDate getGDateValue();
+
+ /**
+ * Sets this value as a {@link GDateSpecification}
+ */
+ void setGDateValue(GDate gd);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlTime}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlTime}
+ */
+ public static XmlTime newInstance() {
+ return (XmlTime) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlTime}
+ */
+ public static XmlTime newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlTime) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlTime} value
+ */
+ public static XmlTime newValue(Object obj) {
+ return (XmlTime) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a String. For example: "<xml-fragment>12:00:00</xml-fragment>".
+ */
+ public static XmlTime parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a String. For example: "<xml-fragment>12:00:00</xml-fragment>".
+ */
+ public static XmlTime parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a File.
+ */
+ public static XmlTime parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a File.
+ */
+ public static XmlTime parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a URL.
+ */
+ public static XmlTime parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a URL.
+ */
+ public static XmlTime parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from an InputStream.
+ */
+ public static XmlTime parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from an InputStream.
+ */
+ public static XmlTime parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a Reader.
+ */
+ public static XmlTime parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a Reader.
+ */
+ public static XmlTime parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a DOM Node.
+ */
+ public static XmlTime parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from a DOM Node.
+ */
+ public static XmlTime parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from an XMLStreamReader.
+ */
+ public static XmlTime parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlTime} fragment from an XMLStreamReader.
+ */
+ public static XmlTime parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlTime) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlToken.java b/src/main/java/org/apache/xmlbeans/XmlToken.java
new file mode 100644
index 0000000..f209dd1
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlToken.java
@@ -0,0 +1,173 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:token type.
+ * One of the derived types based on xs:string.
+ *
+ * A token is XML's best representation for a "whitespace insensitive string."
+ * All carriage returns, linefeeds, and tabs are converted to ordinary space
+ * characters (as with xs:normalizedString),
+ * and furthermore, all contiguous runs of space are collapsed to single spaces,
+ * and leading and trailing spaces are trimmed.
+ *
+ * If you want " high priority "
+ * to be equivalent to "high priority", you should consider
+ * using xs:token or a subtype of xs:token.
+ *
+ * When the {@link #getStringValue()} is obtained from an XmlToken, the normalized,
+ * trimmed, whitespace collapsed value is returned.
+ *
+ * Convertible to {@link String}.
+ */
+public interface XmlToken extends XmlNormalizedString {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_token");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlToken}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlToken}
+ */
+ public static XmlToken newInstance() {
+ return (XmlToken) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlToken}
+ */
+ public static XmlToken newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlToken) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlToken} value
+ */
+ public static XmlToken newValue(Object obj) {
+ return (XmlToken) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a String. For example: "<xml-fragment>string to collapse</xml-fragment>".
+ */
+ public static XmlToken parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a String. For example: "<xml-fragment>string to collapse</xml-fragment>".
+ */
+ public static XmlToken parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a File.
+ */
+ public static XmlToken parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a File.
+ */
+ public static XmlToken parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a URL.
+ */
+ public static XmlToken parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a URL.
+ */
+ public static XmlToken parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from an InputStream.
+ */
+ public static XmlToken parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from an InputStream.
+ */
+ public static XmlToken parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a Reader.
+ */
+ public static XmlToken parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a Reader.
+ */
+ public static XmlToken parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a DOM Node.
+ */
+ public static XmlToken parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from a DOM Node.
+ */
+ public static XmlToken parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from an XMLStreamReader.
+ */
+ public static XmlToken parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlToken} fragment from an XMLStreamReader.
+ */
+ public static XmlToken parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlToken) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlTokenSource.java b/src/main/java/org/apache/xmlbeans/XmlTokenSource.java
similarity index 85%
rename from src/xmlpublic/org/apache/xmlbeans/XmlTokenSource.java
rename to src/main/java/org/apache/xmlbeans/XmlTokenSource.java
index 2c57fd1..8082863 100644
--- a/src/xmlpublic/org/apache/xmlbeans/XmlTokenSource.java
+++ b/src/main/java/org/apache/xmlbeans/XmlTokenSource.java
@@ -15,22 +15,13 @@
package org.apache.xmlbeans;
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.stream.XMLStreamReader;
-
import org.w3c.dom.Node;
-
import org.xml.sax.ContentHandler;
-import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.*;
/**
* Represents a holder of XML that can return an {@link XmlCursor}
@@ -39,12 +30,11 @@
* Both {@link XmlObject}
* (and thus all XML Beans) and {@link XmlCursor} are
* XmlTokenSource implementations.
- *
+ *
* @see XmlObject
* @see XmlCursor
- */
-public interface XmlTokenSource
-{
+ */
+public interface XmlTokenSource {
/**
* Returns the synchronization object for the document. If concurrent
* multithreaded access to a document is required, the access should should
@@ -52,7 +42,7 @@ public interface XmlTokenSource
* monitor per XML document tree.
*/
Object monitor();
-
+
/**
* Returns the XmlDocumentProperties object for the document this token
* source is associated with.
@@ -61,46 +51,29 @@ public interface XmlTokenSource
/**
* Returns a new XML cursor.
- *
+ *
* A cursor provides random access to all the tokens in the XML
* data, plus the ability to extract strongly-typed XmlObjects
* for the data. If the data is not read-only, the XML cursor
* also allows modifications to the data.
- *
+ *
* Using a cursor for the first time typically forces the XML
* document into memory.
*/
XmlCursor newCursor();
- /**
- * Returns a new XmlInputStream.
- *
- * The stream starts at the current begin-tag or begin-document
- * position and ends at the matching end-tag or end-document.
- *
- * This is a fail-fast stream, so if the underlying data is changed
- * while the stream is being read, the stream throws a
- * ConcurrentModificationException.
- *
- * Throws an IllegalStateException if the XmlTokenSource is not
- * positioned at begin-tag or begin-document (e.g., if it is at
- * an attribute).
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
- */
- XMLInputStream newXMLInputStream();
-
/**
* Returns a new XMLStreamReader.
- *
+ *
* The stream starts at the current begin-tag or begin-document
* position and ends at the matching end-tag or end-document.
- *
+ *
* This is a fail-fast stream, so if the underlying data is changed
* while the stream is being read, the stream throws a
* ConcurrentModificationException.
*/
XMLStreamReader newXMLStreamReader();
-
+
/**
* Returns standard XML text.
*
@@ -113,8 +86,8 @@ public interface XmlTokenSource
* positioned at begin-tag or begin-document (e.g., if it is at
* an attribute).
*
- * Note that this method does not produce XML with the XML declaration,
- * including the encoding information. To save the XML declaration with
+ * Note that this method does not produce XML with the XML declaration,
+ * including the encoding information. To save the XML declaration with
* the XML, see {@link #save(OutputStream)} or {@link #save(OutputStream, XmlOptions)}.
*/
String xmlText();
@@ -122,16 +95,16 @@ public interface XmlTokenSource
/**
* Returns a new stream containing standard XML text, encoded
* according to the given encoding.
- *
+ *
* The byte stream contains contents starting at the current
* begin-tag or begin-document and ending at the matching
* end-tag or end-document. The specified encoding is used
* and also emitted in a PI at the beginning of the stream.
- *
+ *
* This is a fail-fast stream, so if the underlying data is changed
* while the stream is being read, the stream throws a
* ConcurrentModificationException.
- *
+ *
* Throws an IllegalStateException if the XmlTokenSource is not
* positioned at begin-tag or begin-document (e.g., if it is at
* an attribute).
@@ -140,22 +113,22 @@ public interface XmlTokenSource
/**
* Returns a new character reader containing XML text.
- *
+ *
* The contents of the reader represents the document contents
* starting at the current begin-tag or begin-document and ending at
* the matching end-tag or end-document. No encoding annotation
* will be made in the text itself.
- *
+ *
* This is a fail-fast reader, so if the underlying data is changed
* while the reader is being read, the reader throws a
* ConcurrentModificationException.
- *
+ *
* Throws an IllegalStateException if the XmlTokenSource is not
* positioned at begin-tag or begin-document (e.g., if it is at
* an attribute).
*/
Reader newReader();
-
+
/**
* Returns a W3C DOM Node containing the XML
* represented by this source. This is a copy of the XML, it is
@@ -177,38 +150,48 @@ public interface XmlTokenSource
/**
* Writes the XML represented by this source to the given SAX content and
* lexical handlers.
- * Note that this method does not save the XML declaration, including the encoding information.
- * To save the XML declaration with the XML, see {@link #save(OutputStream)},
+ * Note that this method does not save the XML declaration, including the encoding information.
+ * To save the XML declaration with the XML, see {@link #save(OutputStream)},
* {@link #save(OutputStream, XmlOptions)}, {@link #save(File)} or {@link #save(File, XmlOptions)}.
*/
- void save ( ContentHandler ch, LexicalHandler lh ) throws SAXException;
-
+ void save(ContentHandler ch, LexicalHandler lh) throws SAXException;
+
/**
* Writes the XML represented by this source to the given File.
* This method will save the XML declaration, including encoding information,
* with the XML.
*/
- void save ( File file ) throws IOException;
-
+ void save(File file) throws IOException;
+
/**
* Writes the XML represented by this source to the given output stream.
* This method will save the XML declaration, including encoding information,
* with the XML.
*/
- void save ( OutputStream os ) throws IOException;
+ void save(OutputStream os) throws IOException;
/**
* Writes the XML represented by this source to the given output.
- * Note that this method does not save the XML declaration, including the encoding information.
- * To save the XML declaration with the XML, see {@link #save(OutputStream)},
+ * Note that this method does not save the XML declaration, including the encoding information.
+ * To save the XML declaration with the XML, see {@link #save(OutputStream)},
* {@link #save(OutputStream, XmlOptions)}, {@link #save(File)} or {@link #save(File, XmlOptions)}.
*/
- void save ( Writer w ) throws IOException;
+ void save(Writer w) throws IOException;
/**
- *
Just like newXMLInputStream() but with any of a number of options. Use the
- * options parameter to specify the following:
- *
+ * Returns a new XMLStreamReader.
+ *
+ * The stream starts at the current begin-tag or begin-document
+ * position and ends at the matching end-tag or end-document.
+ *
+ * This is a fail-fast stream, so if the underlying data is changed
+ * while the stream is being read, the stream throws a
+ * ConcurrentModificationException.
+ *
+ * Throws an IllegalStateException if the XmlTokenSource is not
+ * positioned at begin-tag or begin-document (e.g., if it is at
+ * an attribute).
+ *
*
*
To specify this
Use this method
*
@@ -219,8 +202,8 @@ public interface XmlTokenSource
*
*
Prefix-to-namespace mappings that should be assumed
* when saving this XML. This is useful when the resulting
- * XML will be part of a larger XML document, ensuring that this
- * inner document will take advantage of namespaces defined in
+ * XML will be part of a larger XML document, ensuring that this
+ * inner document will take advantage of namespaces defined in
* the outer document.
*
{@link XmlOptions#setSaveImplicitNamespaces}
*
@@ -235,12 +218,12 @@ public interface XmlTokenSource
*
{@link XmlOptions#setSaveNamespacesFirst}
*
*
- *
The XML should be pretty printed when saved. Note that this
+ *
The XML should be pretty printed when saved. Note that this
* should only be used for debugging.
*
{@link XmlOptions#setSavePrettyPrint}
*
*
- *
The number of spaces to use when indenting for pretty printing.
+ *
The number of spaces to use when indenting for pretty printing.
* The default is 2.
*
{@link XmlOptions#setSavePrettyPrintIndent}
*
@@ -250,14 +233,14 @@ public interface XmlTokenSource
*
{@link XmlOptions#setSavePrettyPrintOffset}
*
*
- *
To minimize the number of namespace attributes generated for the
+ *
To minimize the number of namespace attributes generated for the
* saved XML. Note that this can reduce performance significantly.
- *
{@link XmlOptions#setSaveAggresiveNamespaces}
+ *
{@link XmlOptions#setSaveAggressiveNamespaces}
*
*
*
To reduce the size of the saved document
- * by allowing the use of the default namespace. Note that this can
- * potentially change the semantic meaning of the XML if unprefixed QNames are
+ * by allowing the use of the default namespace. Note that this can
+ * potentially change the semantic meaning of the XML if unprefixed QNames are
* present as the value of an attribute or element.
*
{@link XmlOptions#setUseDefaultNamespace}
*
@@ -266,8 +249,8 @@ public interface XmlTokenSource
*
{@link XmlOptions#setSaveFilterProcinst}
*
*
- *
Change the QName of the synthesized root element when saving. This
- * replaces "xml-fragment" with "fragment" in the namespace
+ *
Change the QName of the synthesized root element when saving. This
+ * replaces "xml-fragment" with "fragment" in the namespace
* http://www.openuri.org/fragment
*
{@link XmlOptions#setSaveUseOpenFrag}
*
@@ -285,87 +268,80 @@ public interface XmlTokenSource
*
- *
- * @see XmlOptions
- *
- * @param options Any of the described options.
- * @return A new validating XMLInputStream.
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
- */
- XMLInputStream newXMLInputStream(XmlOptions options);
-
- /**
- * Just like newXMLInputStream() but with options.
- * Options map may be null.
+ *
+ * @param options Any of the described options. Options map may be null.
+ * @return A new validating XMLStreamReader.
* @see XmlOptions
*/
XMLStreamReader newXMLStreamReader(XmlOptions options);
-
+
/**
* Just like xmlText() but with options.
* Options map may be null.
*
- * Note that this method does not produce XML with the XML declaration,
- * including the encoding information. To save the XML declaration with
+ * Note that this method does not produce XML with the XML declaration,
+ * including the encoding information. To save the XML declaration with
* the XML, see {@link #save(OutputStream)} or {@link #save(OutputStream, XmlOptions)}.
*
* @see XmlOptions
*/
String xmlText(XmlOptions options);
-
+
/**
- *
* Just like newInputStream(String encoding) but with options.
* Options map may be null.
+ *
* @see XmlOptions
*/
InputStream newInputStream(XmlOptions options);
-
+
/**
* Just like newReader() but with options.
* Options map may be null.
+ *
* @see XmlOptions
*/
Reader newReader(XmlOptions options);
-
+
/**
* Just like newDomNode() but with options.
* Options map may be null.
+ *
* @see XmlOptions
*/
Node newDomNode(XmlOptions options);
-
+
/**
* Writes the XML represented by this source to the given SAX content and
* lexical handlers.
- * Note that this method does not save the XML declaration, including the encoding information.
- * To save the XML declaration with the XML, see {@link #save(OutputStream)},
+ * Note that this method does not save the XML declaration, including the encoding information.
+ * To save the XML declaration with the XML, see {@link #save(OutputStream)},
* {@link #save(OutputStream, XmlOptions)}, {@link #save(File)} or {@link #save(File, XmlOptions)}.
*/
- void save ( ContentHandler ch, LexicalHandler lh, XmlOptions options ) throws SAXException;
-
+ void save(ContentHandler ch, LexicalHandler lh, XmlOptions options) throws SAXException;
+
/**
* Writes the XML represented by this source to the given File.
* This method will save the XML declaration, including encoding information,
* with the XML.
*/
- void save ( File file, XmlOptions options ) throws IOException;
-
+ void save(File file, XmlOptions options) throws IOException;
+
/**
* Writes the XML represented by this source to the given output stream.
* This method will save the XML declaration, including encoding information,
* with the XML.
*/
- void save ( OutputStream os, XmlOptions options ) throws IOException;
+ void save(OutputStream os, XmlOptions options) throws IOException;
/**
* Writes the XML represented by this source to the given output.
- * Note that this method does not save the XML declaration, including the encoding information.
- * To save the XML declaration with the XML, see {@link #save(OutputStream)},
+ * Note that this method does not save the XML declaration, including the encoding information.
+ * To save the XML declaration with the XML, see {@link #save(OutputStream)},
* {@link #save(OutputStream, XmlOptions)}, {@link #save(File)} or {@link #save(File, XmlOptions)}.
*/
- void save ( Writer w, XmlOptions options ) throws IOException;
+ void save(Writer w, XmlOptions options) throws IOException;
/**
* Prints to stdout the state of the document in which this token source is positioned.
@@ -374,5 +350,5 @@ public interface XmlTokenSource
* XML text which only approximates the actual state of the document.
*/
- void dump ( );
+ void dump();
}
diff --git a/src/main/java/org/apache/xmlbeans/XmlUnsignedByte.java b/src/main/java/org/apache/xmlbeans/XmlUnsignedByte.java
new file mode 100644
index 0000000..32f3e67
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlUnsignedByte.java
@@ -0,0 +1,173 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:unsignedByte type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be in the range 0..255 when validating.
+ *
+ * As suggested by JAXB, convertible to Java short.
+ */
+public interface XmlUnsignedByte extends XmlUnsignedShort {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_unsignedByte");
+
+ /**
+ * Returns this value as a short
+ */
+ short getShortValue();
+
+ /**
+ * Sets this value as a short
+ */
+ void setShortValue(short s);
+
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlUnsignedByte}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlUnsignedByte}
+ */
+ public static XmlUnsignedByte newInstance() {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlUnsignedByte}
+ */
+ public static XmlUnsignedByte newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlUnsignedByte} value
+ */
+ public static XmlUnsignedByte newValue(Object obj) {
+ return (XmlUnsignedByte) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a String. For example: "<xml-fragment>123</xml-fragment>".
+ */
+ public static XmlUnsignedByte parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a String. For example: "<xml-fragment>123</xml-fragment>".
+ */
+ public static XmlUnsignedByte parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a File.
+ */
+ public static XmlUnsignedByte parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a File.
+ */
+ public static XmlUnsignedByte parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a URL.
+ */
+ public static XmlUnsignedByte parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a URL.
+ */
+ public static XmlUnsignedByte parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from an InputStream.
+ */
+ public static XmlUnsignedByte parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from an InputStream.
+ */
+ public static XmlUnsignedByte parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a Reader.
+ */
+ public static XmlUnsignedByte parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a Reader.
+ */
+ public static XmlUnsignedByte parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a DOM Node.
+ */
+ public static XmlUnsignedByte parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from a DOM Node.
+ */
+ public static XmlUnsignedByte parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedByte parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedByte} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedByte parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedByte) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlUnsignedInt.java b/src/main/java/org/apache/xmlbeans/XmlUnsignedInt.java
new file mode 100644
index 0000000..d1869e0
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlUnsignedInt.java
@@ -0,0 +1,172 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:unsignedInt type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be in the range 0..4294967295 when validating.
+ *
+ * Convertible to Java long.
+ */
+public interface XmlUnsignedInt extends XmlUnsignedLong {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_unsignedInt");
+
+ /**
+ * Returns this value as a long
+ */
+ long getLongValue();
+
+ /**
+ * Sets this value as a long
+ */
+ void setLongValue(long v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlUnsignedInt}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlUnsignedInt}
+ */
+ public static XmlUnsignedInt newInstance() {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlUnsignedInt}
+ */
+ public static XmlUnsignedInt newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlUnsignedInt} value
+ */
+ public static XmlUnsignedInt newValue(Object obj) {
+ return (XmlUnsignedInt) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a String. For example: "<xml-fragment>1234567</xml-fragment>".
+ */
+ public static XmlUnsignedInt parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a String. For example: "<xml-fragment>1234567</xml-fragment>".
+ */
+ public static XmlUnsignedInt parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a File.
+ */
+ public static XmlUnsignedInt parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a File.
+ */
+ public static XmlUnsignedInt parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a URL.
+ */
+ public static XmlUnsignedInt parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a URL.
+ */
+ public static XmlUnsignedInt parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from an InputStream.
+ */
+ public static XmlUnsignedInt parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from an InputStream.
+ */
+ public static XmlUnsignedInt parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a Reader.
+ */
+ public static XmlUnsignedInt parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a Reader.
+ */
+ public static XmlUnsignedInt parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a DOM Node.
+ */
+ public static XmlUnsignedInt parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from a DOM Node.
+ */
+ public static XmlUnsignedInt parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedInt parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedInt} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedInt parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedInt) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlUnsignedLong.java b/src/main/java/org/apache/xmlbeans/XmlUnsignedLong.java
new file mode 100644
index 0000000..8b55954
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlUnsignedLong.java
@@ -0,0 +1,165 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+import java.math.BigInteger;
+
+
+/**
+ * Corresponds to the XML Schema
+ * xs:unsignedLong type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be in the range 0..264-1 when validating.
+ *
+ * Convertible to {@link BigInteger}.
+ */
+public interface XmlUnsignedLong extends XmlNonNegativeInteger {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_unsignedLong");
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlUnsignedLong}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlUnsignedLong}
+ */
+ public static XmlUnsignedLong newInstance() {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlUnsignedLong}
+ */
+ public static XmlUnsignedLong newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlUnsignedLong} value
+ */
+ public static XmlUnsignedLong newValue(Object obj) {
+ return (XmlUnsignedLong) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a String. For example: "<xml-fragment>123456789</xml-fragment>".
+ */
+ public static XmlUnsignedLong parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a String. For example: "<xml-fragment>123456789</xml-fragment>".
+ */
+ public static XmlUnsignedLong parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a File.
+ */
+ public static XmlUnsignedLong parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a File.
+ */
+ public static XmlUnsignedLong parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a URL.
+ */
+ public static XmlUnsignedLong parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a URL.
+ */
+ public static XmlUnsignedLong parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from an InputStream.
+ */
+ public static XmlUnsignedLong parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from an InputStream.
+ */
+ public static XmlUnsignedLong parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a Reader.
+ */
+ public static XmlUnsignedLong parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a Reader.
+ */
+ public static XmlUnsignedLong parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a DOM Node.
+ */
+ public static XmlUnsignedLong parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from a DOM Node.
+ */
+ public static XmlUnsignedLong parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedLong parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedLong} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedLong parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedLong) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java b/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java
new file mode 100644
index 0000000..05c21dc
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java
@@ -0,0 +1,172 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans;
+
+/**
+ * Corresponds to the XML Schema
+ * xs:unsignedShort type.
+ * One of the derived types based on xs:decimal.
+ *
+ * Verified to be in the range 0..65535 when validating.
+ *
+ * Convertible to a Java int.
+ */
+public interface XmlUnsignedShort extends XmlUnsignedInt {
+ /**
+ * The constant {@link SchemaType} object representing this schema type.
+ */
+ SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_unsignedShort");
+
+ /**
+ * Returns this value as an int
+ */
+ int getIntValue();
+
+ /**
+ * Sets this value as an int
+ */
+ void setIntValue(int v);
+
+ /**
+ * A class with methods for creating instances
+ * of {@link XmlUnsignedShort}.
+ */
+ final class Factory {
+ /**
+ * Creates an empty instance of {@link XmlUnsignedShort}
+ */
+ public static XmlUnsignedShort newInstance() {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().newInstance(type, null);
+ }
+
+ /**
+ * Creates an empty instance of {@link XmlUnsignedShort}
+ */
+ public static XmlUnsignedShort newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().newInstance(type, options);
+ }
+
+ /**
+ * Creates an immutable {@link XmlUnsignedShort} value
+ */
+ public static XmlUnsignedShort newValue(Object obj) {
+ return (XmlUnsignedShort) type.newValue(obj);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a String. For example: "<xml-fragment>12345</xml-fragment>".
+ */
+ public static XmlUnsignedShort parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(s, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a String. For example: "<xml-fragment>12345</xml-fragment>".
+ */
+ public static XmlUnsignedShort parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(s, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a File.
+ */
+ public static XmlUnsignedShort parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(f, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a File.
+ */
+ public static XmlUnsignedShort parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(f, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a URL.
+ */
+ public static XmlUnsignedShort parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(u, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a URL.
+ */
+ public static XmlUnsignedShort parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(u, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from an InputStream.
+ */
+ public static XmlUnsignedShort parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(is, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from an InputStream.
+ */
+ public static XmlUnsignedShort parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(is, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a Reader.
+ */
+ public static XmlUnsignedShort parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(r, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a Reader.
+ */
+ public static XmlUnsignedShort parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(r, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a DOM Node.
+ */
+ public static XmlUnsignedShort parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(node, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from a DOM Node.
+ */
+ public static XmlUnsignedShort parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(node, type, options);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedShort parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
+ }
+
+ /**
+ * Parses a {@link XmlUnsignedShort} fragment from an XMLStreamReader.
+ */
+ public static XmlUnsignedShort parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
+ return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
+ }
+
+ private Factory() {
+ // No instance of this class allowed
+ }
+ }
+}
+
diff --git a/src/xmlpublic/org/apache/xmlbeans/XmlValidationError.java b/src/main/java/org/apache/xmlbeans/XmlValidationError.java
similarity index 99%
rename from src/xmlpublic/org/apache/xmlbeans/XmlValidationError.java
rename to src/main/java/org/apache/xmlbeans/XmlValidationError.java
index 74a6776..518f70d 100644
--- a/src/xmlpublic/org/apache/xmlbeans/XmlValidationError.java
+++ b/src/main/java/org/apache/xmlbeans/XmlValidationError.java
@@ -235,7 +235,7 @@ public String getMessage()
if (_fieldQName != null)
{
String msg = super.getMessage();
- StringBuffer sb = new StringBuffer(msg.length() + 100);
+ StringBuilder sb = new StringBuilder(msg.length() + 100);
sb.append(msg);
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java b/src/main/java/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java
new file mode 100755
index 0000000..f11cd49
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java
@@ -0,0 +1,43 @@
+/* Copyright 2019 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import java.io.InputStream;
+
+import org.apache.xmlbeans.ResourceLoader;
+
+public class DefaultClassLoaderResourceLoader implements ResourceLoader
+{
+ public InputStream getResourceAsStream(String resourceName) {
+ InputStream in = null;
+ try {
+ in = getResourceAsStream(Thread.currentThread().getContextClassLoader(), resourceName);
+ } catch (SecurityException securityexception) {}
+ if (in == null) {
+ in = getResourceAsStream(DefaultClassLoaderResourceLoader.class.getClassLoader(), resourceName);
+ }
+ if (in == null) {
+ in = DefaultClassLoaderResourceLoader.class.getResourceAsStream(resourceName);
+ }
+ return in;
+ }
+
+ public void close() {}
+
+ private InputStream getResourceAsStream(ClassLoader loader, String resourceName) {
+ return loader == null ? null : loader.getResourceAsStream(resourceName);
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/DocumentHelper.java b/src/main/java/org/apache/xmlbeans/impl/common/DocumentHelper.java
similarity index 94%
rename from src/common/org/apache/xmlbeans/impl/common/DocumentHelper.java
rename to src/main/java/org/apache/xmlbeans/impl/common/DocumentHelper.java
index 7dd0bbf..f6e873a 100644
--- a/src/common/org/apache/xmlbeans/impl/common/DocumentHelper.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/DocumentHelper.java
@@ -15,27 +15,24 @@
package org.apache.xmlbeans.impl.common;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.util.concurrent.TimeUnit;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.events.Namespace;
-
import org.apache.xmlbeans.XmlOptionsBean;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.concurrent.TimeUnit;
+
public final class DocumentHelper {
- private static XBLogger logger = XBLogFactory.getLogger(DocumentHelper.class);
+ private static final XBLogger logger = XBLogFactory.getLogger(DocumentHelper.class);
private static long lastLog;
private DocumentHelper() {}
@@ -58,7 +55,7 @@ public void fatalError(SAXParseException exception) throws SAXException {
/** Prints the error message. */
private void printError(int type, SAXParseException ex) {
StringBuilder sb = new StringBuilder();
-
+
String systemId = ex.getSystemId();
if (systemId != null) {
int index = systemId.lastIndexOf('/');
@@ -76,7 +73,7 @@ private void printError(int type, SAXParseException ex) {
logger.log(type, sb.toString(), ex);
}
}
-
+
/**
* Creates a new document builder, with sensible defaults
*
@@ -84,7 +81,7 @@ private void printError(int type, SAXParseException ex) {
* @throws IllegalStateException If creating the DocumentBuilder fails, e.g.
* due to {@link ParserConfigurationException}.
*/
- public static synchronized DocumentBuilder newDocumentBuilder(XmlOptionsBean xmlOptions) {
+ public static DocumentBuilder newDocumentBuilder(XmlOptionsBean xmlOptions) {
try {
DocumentBuilder documentBuilder = documentBuilderFactory(xmlOptions).newDocumentBuilder();
documentBuilder.setEntityResolver(SAXHelper.IGNORING_ENTITY_RESOLVER);
@@ -115,7 +112,7 @@ private static void trySetFeature(DocumentBuilderFactory dbf, String feature, bo
logger.log(XBLogger.WARN, "Cannot set SAX feature because outdated XML parser in classpath", feature, ame);
}
}
-
+
private static void trySetXercesSecurityManager(DocumentBuilderFactory dbf, XmlOptionsBean options) {
// Try built-in JVM one first, standalone if not
for (String securityManagerClassName : new String[]{
@@ -123,7 +120,7 @@ private static void trySetXercesSecurityManager(DocumentBuilderFactory dbf, XmlO
"org.apache.xerces.util.SecurityManager"
}) {
try {
- Object mgr = Class.forName(securityManagerClassName).newInstance();
+ Object mgr = Class.forName(securityManagerClassName).getDeclaredConstructor().newInstance();
Method setLimit = mgr.getClass().getMethod("setEntityExpansionLimit", Integer.TYPE);
setLimit.invoke(mgr, options.getEntityExpansionLimit());
dbf.setAttribute(XMLBeansConstants.SECURITY_MANAGER, mgr);
@@ -154,7 +151,7 @@ private static void trySetXercesSecurityManager(DocumentBuilderFactory dbf, XmlO
* Parses the given stream via the default (sensible)
* DocumentBuilder
* @param inp Stream to read the XML data from
- * @return the parsed Document
+ * @return the parsed Document
*/
public static Document readDocument(XmlOptionsBean xmlOptions, InputStream inp) throws IOException, SAXException {
return newDocumentBuilder(xmlOptions).parse(inp);
@@ -164,7 +161,7 @@ public static Document readDocument(XmlOptionsBean xmlOptions, InputStream inp)
* Parses the given stream via the default (sensible)
* DocumentBuilder
* @param inp sax source to read the XML data from
- * @return the parsed Document
+ * @return the parsed Document
*/
public static Document readDocument(XmlOptionsBean xmlOptions, InputSource inp) throws IOException, SAXException {
return newDocumentBuilder(xmlOptions).parse(inp);
@@ -176,7 +173,7 @@ public static Document readDocument(XmlOptionsBean xmlOptions, InputSource inp)
/**
* Creates a new DOM Document
*/
- public static synchronized Document createDocument() {
+ public static Document createDocument() {
return documentBuilderSingleton.newDocument();
}
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/EncodingMap.java b/src/main/java/org/apache/xmlbeans/impl/common/EncodingMap.java
new file mode 100644
index 0000000..654982c
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/EncodingMap.java
@@ -0,0 +1,422 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+public class EncodingMap {
+ public static String getJava2IANAMapping(String java) {
+ String iana = _java_to_iana.get(java.toUpperCase(Locale.ROOT));
+ if (iana != null) {
+ return iana;
+ }
+ // Try to use the information in the JDK to see if it is an encoding it supports
+ if (Charset.isSupported(java)) {
+ try {
+ iana = Charset.forName(java).name();
+ return iana;
+ } catch (IllegalArgumentException iae) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static String getIANA2JavaMapping(String iana) {
+ String java = _iana_to_java.get(iana.toUpperCase(Locale.ROOT));
+ if (java != null) {
+ return java;
+ } else if (Charset.isSupported(iana)) {
+ return iana;
+ } else {
+ return null;
+ }
+ }
+
+ private EncodingMap() {
+ }
+
+ private final static Map _iana_to_java = new HashMap<>();
+ private final static HashMap _java_to_iana = new HashMap<>();
+
+ private static void addMapping(
+ String java, String iana, boolean isDefault) {
+ assert !_iana_to_java.containsKey(iana);
+ assert java.toUpperCase(Locale.ROOT).equals(java);
+ assert iana.toUpperCase(Locale.ROOT).equals(iana);
+
+ _iana_to_java.put(iana, java);
+
+ if (isDefault) {
+ assert !_java_to_iana.containsKey(java);
+ _java_to_iana.put(java, iana);
+ }
+ }
+
+ private static boolean completeMappings() {
+ HashMap m = new HashMap<>();
+
+ for (String s : _iana_to_java.keySet()) {
+ m.put(_iana_to_java.get(s), null);
+ }
+
+ for (String k : m.keySet()) {
+ assert _java_to_iana.containsKey(k) : k;
+ }
+
+ return true;
+ }
+
+ static {
+ addMapping("ASCII", "ANSI_X3.4-1986", false);
+ addMapping("ASCII", "ASCII", true);
+ addMapping("ASCII", "CP367", false);
+ addMapping("ASCII", "CSASCII", false);
+ addMapping("ASCII", "IBM-367", false);
+ addMapping("ASCII", "IBM367", false);
+ addMapping("ASCII", "ISO-IR-6", false);
+ addMapping("ASCII", "ISO646-US", false);
+ addMapping("ASCII", "ISO_646.IRV:1991", false);
+ addMapping("ASCII", "US", false);
+ addMapping("ASCII", "US-ASCII", false);
+ addMapping("BIG5", "BIG5", true);
+ addMapping("BIG5", "CSBIG5", false);
+ addMapping("CP037", "CP037", false);
+ addMapping("CP037", "CSIBM037", false);
+ addMapping("CP037", "EBCDIC-CP-CA", false);
+ addMapping("CP037", "EBCDIC-CP-NL", false);
+ addMapping("CP037", "EBCDIC-CP-US", true);
+ addMapping("CP037", "EBCDIC-CP-WT", false);
+ addMapping("CP037", "IBM-37", false);
+ addMapping("CP037", "IBM037", false);
+ addMapping("CP1026", "CP1026", false);
+ addMapping("CP1026", "CSIBM1026", false);
+ addMapping("CP1026", "IBM-1026", false);
+ addMapping("CP1026", "IBM1026", true);
+ addMapping("CP1047", "CP1047", false);
+ addMapping("CP1047", "IBM-1047", false);
+ addMapping("CP1047", "IBM1047", true);
+ addMapping("CP1140", "CCSID01140", false);
+ addMapping("CP1140", "CP01140", false);
+ addMapping("CP1140", "IBM-1140", false);
+ addMapping("CP1140", "IBM01140", true);
+ addMapping("CP1141", "CCSID01141", false);
+ addMapping("CP1141", "CP01141", false);
+ addMapping("CP1141", "IBM-1141", false);
+ addMapping("CP1141", "IBM01141", true);
+ addMapping("CP1142", "CCSID01142", false);
+ addMapping("CP1142", "CP01142", false);
+ addMapping("CP1142", "IBM-1142", false);
+ addMapping("CP1142", "IBM01142", true);
+ addMapping("CP1143", "CCSID01143", false);
+ addMapping("CP1143", "CP01143", false);
+ addMapping("CP1143", "IBM-1143", false);
+ addMapping("CP1143", "IBM01143", true);
+ addMapping("CP1144", "CCSID01144", false);
+ addMapping("CP1144", "CP01144", false);
+ addMapping("CP1144", "IBM-1144", false);
+ addMapping("CP1144", "IBM01144", true);
+ addMapping("CP1145", "CCSID01145", false);
+ addMapping("CP1145", "CP01145", false);
+ addMapping("CP1145", "IBM-1145", false);
+ addMapping("CP1145", "IBM01145", true);
+ addMapping("CP1146", "CCSID01146", false);
+ addMapping("CP1146", "CP01146", false);
+ addMapping("CP1146", "IBM-1146", false);
+ addMapping("CP1146", "IBM01146", true);
+ addMapping("CP1147", "CCSID01147", false);
+ addMapping("CP1147", "CP01147", false);
+ addMapping("CP1147", "IBM-1147", false);
+ addMapping("CP1147", "IBM01147", true);
+ addMapping("CP1148", "CCSID01148", false);
+ addMapping("CP1148", "CP01148", false);
+ addMapping("CP1148", "IBM-1148", false);
+ addMapping("CP1148", "IBM01148", true);
+ addMapping("CP1149", "CCSID01149", false);
+ addMapping("CP1149", "CP01149", false);
+ addMapping("CP1149", "IBM-1149", false);
+ addMapping("CP1149", "IBM01149", true);
+ addMapping("CP1250", "WINDOWS-1250", true);
+ addMapping("CP1251", "WINDOWS-1251", true);
+ addMapping("CP1252", "WINDOWS-1252", true);
+ addMapping("CP1253", "WINDOWS-1253", true);
+ addMapping("CP1254", "WINDOWS-1254", true);
+ addMapping("CP1255", "WINDOWS-1255", true);
+ addMapping("CP1256", "WINDOWS-1256", true);
+ addMapping("CP1257", "WINDOWS-1257", true);
+ addMapping("CP1258", "WINDOWS-1258", true);
+ addMapping("CP273", "CP273", false);
+ addMapping("CP273", "CSIBM273", false);
+ addMapping("CP273", "IBM-273", false);
+ addMapping("CP273", "IBM273", true);
+ addMapping("CP277", "CP277", false);
+ addMapping("CP277", "CSIBM277", false);
+ addMapping("CP277", "EBCDIC-CP-DK", true);
+ addMapping("CP277", "EBCDIC-CP-NO", false);
+ addMapping("CP277", "IBM-277", false);
+ addMapping("CP277", "IBM277", false);
+ addMapping("CP278", "CP278", false);
+ addMapping("CP278", "CSIBM278", false);
+ addMapping("CP278", "EBCDIC-CP-FI", true);
+ addMapping("CP278", "EBCDIC-CP-SE", false);
+ addMapping("CP278", "IBM-278", false);
+ addMapping("CP278", "IBM278", false);
+ addMapping("CP280", "CP280", false);
+ addMapping("CP280", "CSIBM280", false);
+ addMapping("CP280", "EBCDIC-CP-IT", true);
+ addMapping("CP280", "IBM-280", false);
+ addMapping("CP280", "IBM280", false);
+ addMapping("CP284", "CP284", false);
+ addMapping("CP284", "CSIBM284", false);
+ addMapping("CP284", "EBCDIC-CP-ES", true);
+ addMapping("CP284", "IBM-284", false);
+ addMapping("CP284", "IBM284", false);
+ addMapping("CP285", "CP285", false);
+ addMapping("CP285", "CSIBM285", false);
+ addMapping("CP285", "EBCDIC-CP-GB", true);
+ addMapping("CP285", "IBM-285", false);
+ addMapping("CP285", "IBM285", false);
+ addMapping("CP290", "CP290", false);
+ addMapping("CP290", "CSIBM290", false);
+ addMapping("CP290", "EBCDIC-JP-KANA", true);
+ addMapping("CP290", "IBM-290", false);
+ addMapping("CP290", "IBM290", false);
+ addMapping("CP297", "CP297", false);
+ addMapping("CP297", "CSIBM297", false);
+ addMapping("CP297", "EBCDIC-CP-FR", true);
+ addMapping("CP297", "IBM-297", false);
+ addMapping("CP297", "IBM297", false);
+ addMapping("CP420", "CP420", false);
+ addMapping("CP420", "CSIBM420", false);
+ addMapping("CP420", "EBCDIC-CP-AR1", true);
+ addMapping("CP420", "IBM-420", false);
+ addMapping("CP420", "IBM420", false);
+ addMapping("CP424", "CP424", false);
+ addMapping("CP424", "CSIBM424", false);
+ addMapping("CP424", "EBCDIC-CP-HE", true);
+ addMapping("CP424", "IBM-424", false);
+ addMapping("CP424", "IBM424", false);
+ addMapping("CP437", "437", false);
+ addMapping("CP437", "CP437", false);
+ addMapping("CP437", "CSPC8CODEPAGE437", false);
+ addMapping("CP437", "IBM-437", false);
+ addMapping("CP437", "IBM437", true);
+ addMapping("CP500", "CP500", false);
+ addMapping("CP500", "CSIBM500", false);
+ addMapping("CP500", "EBCDIC-CP-BE", false);
+ addMapping("CP500", "EBCDIC-CP-CH", true);
+ addMapping("CP500", "IBM-500", false);
+ addMapping("CP500", "IBM500", false);
+ addMapping("CP775", "CP775", false);
+ addMapping("CP775", "CSPC775BALTIC", false);
+ addMapping("CP775", "IBM-775", false);
+ addMapping("CP775", "IBM775", true);
+ addMapping("CP850", "850", false);
+ addMapping("CP850", "CP850", false);
+ addMapping("CP850", "CSPC850MULTILINGUAL", false);
+ addMapping("CP850", "IBM-850", false);
+ addMapping("CP850", "IBM850", true);
+ addMapping("CP852", "852", false);
+ addMapping("CP852", "CP852", false);
+ addMapping("CP852", "CSPCP852", false);
+ addMapping("CP852", "IBM-852", false);
+ addMapping("CP852", "IBM852", true);
+ addMapping("CP855", "855", false);
+ addMapping("CP855", "CP855", false);
+ addMapping("CP855", "CSIBM855", false);
+ addMapping("CP855", "IBM-855", false);
+ addMapping("CP855", "IBM855", true);
+ addMapping("CP857", "857", false);
+ addMapping("CP857", "CP857", false);
+ addMapping("CP857", "CSIBM857", false);
+ addMapping("CP857", "IBM-857", false);
+ addMapping("CP857", "IBM857", true);
+ addMapping("CP858", "CCSID00858", false);
+ addMapping("CP858", "CP00858", false);
+ addMapping("CP858", "IBM-858", false);
+ addMapping("CP858", "IBM00858", true);
+ addMapping("CP860", "860", false);
+ addMapping("CP860", "CP860", false);
+ addMapping("CP860", "CSIBM860", false);
+ addMapping("CP860", "IBM-860", false);
+ addMapping("CP860", "IBM860", true);
+ addMapping("CP861", "861", false);
+ addMapping("CP861", "CP-IS", false);
+ addMapping("CP861", "CP861", false);
+ addMapping("CP861", "CSIBM861", false);
+ addMapping("CP861", "IBM-861", false);
+ addMapping("CP861", "IBM861", true);
+ addMapping("CP862", "862", false);
+ addMapping("CP862", "CP862", false);
+ addMapping("CP862", "CSPC862LATINHEBREW", false);
+ addMapping("CP862", "IBM-862", false);
+ addMapping("CP862", "IBM862", true);
+ addMapping("CP863", "863", false);
+ addMapping("CP863", "CP863", false);
+ addMapping("CP863", "CSIBM863", false);
+ addMapping("CP863", "IBM-863", false);
+ addMapping("CP863", "IBM863", true);
+ addMapping("CP864", "CP864", false);
+ addMapping("CP864", "CSIBM864", false);
+ addMapping("CP864", "IBM-864", false);
+ addMapping("CP864", "IBM864", true);
+ addMapping("CP865", "865", false);
+ addMapping("CP865", "CP865", false);
+ addMapping("CP865", "CSIBM865", false);
+ addMapping("CP865", "IBM-865", false);
+ addMapping("CP865", "IBM865", true);
+ addMapping("CP866", "866", false);
+ addMapping("CP866", "CP866", false);
+ addMapping("CP866", "CSIBM866", false);
+ addMapping("CP866", "IBM-866", false);
+ addMapping("CP866", "IBM866", true);
+ addMapping("CP868", "CP-AR", false);
+ addMapping("CP868", "CP868", false);
+ addMapping("CP868", "CSIBM868", false);
+ addMapping("CP868", "IBM-868", false);
+ addMapping("CP868", "IBM868", true);
+ addMapping("CP869", "CP-GR", false);
+ addMapping("CP869", "CP869", false);
+ addMapping("CP869", "CSIBM869", false);
+ addMapping("CP869", "IBM-869", false);
+ addMapping("CP869", "IBM869", true);
+ addMapping("CP870", "CP870", false);
+ addMapping("CP870", "CSIBM870", false);
+ addMapping("CP870", "EBCDIC-CP-ROECE", true);
+ addMapping("CP870", "EBCDIC-CP-YU", false);
+ addMapping("CP870", "IBM-870", false);
+ addMapping("CP870", "IBM870", false);
+ addMapping("CP871", "CP871", false);
+ addMapping("CP871", "CSIBM871", false);
+ addMapping("CP871", "EBCDIC-CP-IS", true);
+ addMapping("CP871", "IBM-871", false);
+ addMapping("CP871", "IBM871", false);
+ addMapping("CP918", "CP918", false);
+ addMapping("CP918", "CSIBM918", false);
+ addMapping("CP918", "EBCDIC-CP-AR2", true);
+ addMapping("CP918", "IBM-918", false);
+ addMapping("CP918", "IBM918", false);
+ addMapping("CP924", "CCSID00924", false);
+ addMapping("CP924", "CP00924", false);
+ addMapping("CP924", "EBCDIC-LATIN9--EURO", false);
+ addMapping("CP924", "IBM-924", false);
+ addMapping("CP924", "IBM00924", true);
+ addMapping("CP936", "GBK", true);
+ addMapping("CP936", "CP936", false);
+ addMapping("CP936", "MS936", false);
+ addMapping("CP936", "WINDOWS-936", false);
+ addMapping("EUCJIS", "CSEUCPKDFMTJAPANESE", false);
+ addMapping("EUCJIS", "EUC-JP", true);
+ addMapping("EUCJIS", "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", false);
+ addMapping("GB18030", "GB18030", true);
+ addMapping("GB2312", "CSGB2312", false);
+ addMapping("GB2312", "GB2312", true);
+ addMapping("ISO2022CN", "ISO-2022-CN", true);
+ addMapping("ISO2022KR", "CSISO2022KR", false);
+ addMapping("ISO2022KR", "ISO-2022-KR", true);
+ addMapping("ISO8859_1", "CP819", false);
+ addMapping("ISO8859_1", "CSISOLATIN1", false);
+ addMapping("ISO8859_1", "IBM-819", false);
+ addMapping("ISO8859_1", "IBM819", false);
+ addMapping("ISO8859_1", "ISO-8859-1", true);
+ addMapping("ISO8859_1", "ISO-IR-100", false);
+ addMapping("ISO8859_1", "ISO_8859-1", false);
+ addMapping("ISO8859_1", "L1", false);
+ addMapping("ISO8859_1", "LATIN1", false);
+ addMapping("ISO8859_2", "CSISOLATIN2", false);
+ addMapping("ISO8859_2", "ISO-8859-2", true);
+ addMapping("ISO8859_2", "ISO-IR-101", false);
+ addMapping("ISO8859_2", "ISO_8859-2", false);
+ addMapping("ISO8859_2", "L2", false);
+ addMapping("ISO8859_2", "LATIN2", false);
+ addMapping("ISO8859_3", "CSISOLATIN3", false);
+ addMapping("ISO8859_3", "ISO-8859-3", true);
+ addMapping("ISO8859_3", "ISO-IR-109", false);
+ addMapping("ISO8859_3", "ISO_8859-3", false);
+ addMapping("ISO8859_3", "L3", false);
+ addMapping("ISO8859_3", "LATIN3", false);
+ addMapping("ISO8859_4", "CSISOLATIN4", false);
+ addMapping("ISO8859_4", "ISO-8859-4", true);
+ addMapping("ISO8859_4", "ISO-IR-110", false);
+ addMapping("ISO8859_4", "ISO_8859-4", false);
+ addMapping("ISO8859_4", "L4", false);
+ addMapping("ISO8859_4", "LATIN4", false);
+ addMapping("ISO8859_5", "CSISOLATINCYRILLIC", false);
+ addMapping("ISO8859_5", "CYRILLIC", false);
+ addMapping("ISO8859_5", "ISO-8859-5", true);
+ addMapping("ISO8859_5", "ISO-IR-144", false);
+ addMapping("ISO8859_5", "ISO_8859-5", false);
+ addMapping("ISO8859_6", "ARABIC", false);
+ addMapping("ISO8859_6", "ASMO-708", false);
+ addMapping("ISO8859_6", "CSISOLATINARABIC", false);
+ addMapping("ISO8859_6", "ECMA-114", false);
+ addMapping("ISO8859_6", "ISO-8859-6", true);
+ addMapping("ISO8859_6", "ISO-IR-127", false);
+ addMapping("ISO8859_6", "ISO_8859-6", false);
+ addMapping("ISO8859_7", "CSISOLATINGREEK", false);
+ addMapping("ISO8859_7", "ECMA-118", false);
+ addMapping("ISO8859_7", "ELOT_928", false);
+ addMapping("ISO8859_7", "GREEK", false);
+ addMapping("ISO8859_7", "GREEK8", false);
+ addMapping("ISO8859_7", "ISO-8859-7", true);
+ addMapping("ISO8859_7", "ISO-IR-126", false);
+ addMapping("ISO8859_7", "ISO_8859-7", false);
+ addMapping("ISO8859_8", "CSISOLATINHEBREW", false);
+ addMapping("ISO8859_8", "HEBREW", false);
+ addMapping("ISO8859_8", "ISO-8859-8", true);
+ addMapping("ISO8859_8", "ISO-8859-8-I", false);
+ addMapping("ISO8859_8", "ISO-IR-138", false);
+ addMapping("ISO8859_8", "ISO_8859-8", false);
+ addMapping("ISO8859_9", "CSISOLATIN5", false);
+ addMapping("ISO8859_9", "ISO-8859-9", true);
+ addMapping("ISO8859_9", "ISO-IR-148", false);
+ addMapping("ISO8859_9", "ISO_8859-9", false);
+ addMapping("ISO8859_9", "L5", false);
+ addMapping("ISO8859_9", "LATIN5", false);
+ addMapping("JIS", "CSISO2022JP", false);
+ addMapping("JIS", "ISO-2022-JP", true);
+ addMapping("JIS0201", "CSISO13JISC6220JP", false);
+ addMapping("JIS0201", "X0201", true);
+ addMapping("JIS0208", "CSISO87JISX0208", false);
+ addMapping("JIS0208", "ISO-IR-87", false);
+ addMapping("JIS0208", "X0208", true);
+ addMapping("JIS0208", "X0208DBIJIS_X0208-1983", false);
+ addMapping("JIS0212", "CSISO159JISX02121990", false);
+ addMapping("JIS0212", "ISO-IR-159", true);
+ addMapping("JIS0212", "X0212", false);
+ addMapping("KOI8_R", "CSKOI8R", false);
+ addMapping("KOI8_R", "KOI8-R", true);
+ addMapping("KSC5601", "EUC-KR", true);
+ addMapping("MS932", "CSWINDOWS31J", false);
+ addMapping("MS932", "WINDOWS-31J", true);
+ addMapping("SJIS", "CSSHIFTJIS", false);
+ addMapping("SJIS", "MS_KANJI", false);
+ addMapping("SJIS", "SHIFT_JIS", true);
+ addMapping("TIS620", "TIS-620", true);
+ addMapping("UNICODE", "UTF-16", true);
+ addMapping("UTF-16BE", "UTF-16BE", true);
+ addMapping("UTF-16BE", "UTF_16BE", false);
+ addMapping("ISO-10646-UCS-2", "ISO-10646-UCS-2", true);
+ addMapping("UTF-16LE", "UTF-16LE", true);
+ addMapping("UTF-16LE", "UTF_16LE", false);
+ addMapping("UTF8", "UTF-8", true);
+
+ assert completeMappings();
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/GlobalLock.java b/src/main/java/org/apache/xmlbeans/impl/common/GlobalLock.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/GlobalLock.java
rename to src/main/java/org/apache/xmlbeans/impl/common/GlobalLock.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/IOUtil.java b/src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/IOUtil.java
rename to src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java b/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
new file mode 100644
index 0000000..55242e6
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
@@ -0,0 +1,664 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.common.ValidatorListener.Event;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathExecutionContext;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import java.util.*;
+
+/**
+ * Identity constraint engine. Performs streaming validation of identity constraints.
+ * This includes key, keyref, & unique, as well as ID & IDRef.
+ */
+public class IdentityConstraint {
+
+ private ConstraintState _constraintStack;
+ private ElementState _elementStack;
+ private Collection _errorListener;
+ private boolean _invalid;
+ private boolean _trackIdrefs; // We only track idrefs if validating from the root element
+
+ public IdentityConstraint(Collection errorListener, boolean trackIdrefs) {
+ _errorListener = errorListener;
+ _trackIdrefs = trackIdrefs;
+ }
+
+ public void element(Event e, SchemaType st, SchemaIdentityConstraint[] ics) {
+
+ // Construct a new state for the element
+ newState();
+
+ // First dispatch this element event
+ for (ConstraintState cs = _constraintStack; cs != null; cs = cs._next) {
+ cs.element(e, st);
+ }
+
+ // Create a new SelectorState for each new Identity Constraint
+
+ for (int i = 0; ics != null && i < ics.length; i++) {
+ newConstraintState(ics[i], e, st);
+ }
+ }
+
+ public void endElement(Event e) {
+ // Pop the element state stack and any constraints at this depth
+ if (_elementStack._hasConstraints) {
+ for (ConstraintState cs = _constraintStack; cs != null && cs != _elementStack._savePoint; cs = cs._next) {
+ cs.remove(e);
+ }
+
+ _constraintStack = _elementStack._savePoint;
+ }
+
+ _elementStack = _elementStack._next;
+
+ // Dispatch the event
+ for (ConstraintState cs = _constraintStack; cs != null; cs = cs._next) {
+ cs.endElement(e);
+ }
+
+ }
+
+ public void attr(Event e, QName name, SchemaType st, String value) {
+ for (ConstraintState cs = _constraintStack; cs != null; cs = cs._next) {
+ cs.attr(e, name, st, value);
+ }
+ }
+
+ public void text(Event e, SchemaType st, String value, boolean emptyContent) {
+ for (ConstraintState cs = _constraintStack; cs != null; cs = cs._next) {
+ cs.text(e, st, value, emptyContent);
+ }
+ }
+
+ public boolean isValid() {
+ return !_invalid;
+ }
+
+ private void newConstraintState(SchemaIdentityConstraint ic, Event e, SchemaType st) {
+ if (ic.getConstraintCategory() == SchemaIdentityConstraint.CC_KEYREF) {
+ new KeyrefState(ic, e, st);
+ } else {
+ new SelectorState(ic, e, st);
+ }
+ }
+
+ private void buildIdStates() {
+ // Construct states to hold the values for IDs and IDRefs
+ IdState ids = new IdState();
+ if (_trackIdrefs) {
+ new IdRefState(ids);
+ }
+ }
+
+ private void newState() {
+ boolean firstTime = _elementStack == null;
+
+ ElementState st = new ElementState();
+ st._next = _elementStack;
+ _elementStack = st;
+
+ if (firstTime) {
+ buildIdStates();
+ }
+ }
+
+ private void emitError(Event event, String code, Object[] args) {
+ _invalid = true;
+
+ if (_errorListener != null) {
+ assert event != null;
+
+ _errorListener.add(errorForEvent(code, args, XmlError.SEVERITY_ERROR, event));
+ }
+ }
+
+ public static XmlError errorForEvent(String code, Object[] args, int severity, Event event) {
+ XmlCursor loc = event.getLocationAsCursor();
+ XmlError error;
+ if (loc != null) {
+ error = XmlError.forCursor(code, args, severity, loc);
+ } else {
+ Location location = event.getLocation();
+ if (location != null) {
+ error = XmlError.forLocation(code, args, severity,
+ location.getSystemId(), location.getLineNumber(),
+ location.getColumnNumber(), location.getCharacterOffset());
+ } else {
+ error = XmlError.forMessage(code, args, severity);
+ }
+ }
+ return error;
+ }
+
+ private void emitError(Event event, String msg) {
+ _invalid = true;
+
+ if (_errorListener != null) {
+ assert event != null;
+
+ _errorListener.add(errorForEvent(msg, XmlError.SEVERITY_ERROR, event));
+ }
+ }
+
+ public static XmlError errorForEvent(String msg, int severity, Event event) {
+ XmlCursor loc = event.getLocationAsCursor();
+ XmlError error;
+ if (loc != null) {
+ error = XmlError.forCursor(msg, severity, loc);
+ } else {
+ Location location = event.getLocation();
+ if (location != null) {
+ error = XmlError.forLocation(msg, severity,
+ location.getSystemId(), location.getLineNumber(),
+ location.getColumnNumber(), location.getCharacterOffset());
+ } else {
+ error = XmlError.forMessage(msg, severity);
+ }
+ }
+ return error;
+ }
+
+ private void setSavePoint(ConstraintState cs) {
+ if (!_elementStack._hasConstraints) {
+ _elementStack._savePoint = cs;
+ }
+
+ _elementStack._hasConstraints = true;
+ }
+
+ private static XmlObject newValue(SchemaType st, String value) {
+ try {
+ return st.newValue(value);
+ } catch (IllegalArgumentException e) {
+ // This is a bit hacky. newValue throws XmlValueOutOfRangeException which is
+ // unchecked and declared in typeimpl. I can only catch its parent class,
+ // typeimpl is built after common.
+
+ // Ignore these exceptions. Assume that validation will catch them.
+ return null;
+ }
+ }
+
+ /**
+ * Return the simple type for schema type. If the schema type is already
+ * simple, just return it. If it is a complex type with simple content,
+ * return the simple type it extends.
+ */
+ static SchemaType getSimpleType(SchemaType st) {
+ assert st.isSimpleType() || st.getContentType() == SchemaType.SIMPLE_CONTENT :
+ st + " does not have simple content.";
+
+ while (!st.isSimpleType()) {
+ st = st.getBaseType();
+ }
+
+ return st;
+ }
+
+ static boolean hasSimpleContent(SchemaType st) {
+ return st.isSimpleType() || st.getContentType() == SchemaType.SIMPLE_CONTENT;
+ }
+
+ public abstract class ConstraintState {
+ ConstraintState _next;
+
+ ConstraintState() {
+ setSavePoint(_constraintStack);
+ _next = _constraintStack;
+ _constraintStack = this;
+ }
+
+ abstract void element(Event e, SchemaType st);
+
+ abstract void endElement(Event e);
+
+ abstract void attr(Event e, QName name, SchemaType st, String value);
+
+ abstract void text(Event e, SchemaType st, String value, boolean emptyContent);
+
+ abstract void remove(Event e);
+
+ }
+
+ public class SelectorState extends ConstraintState {
+ SchemaIdentityConstraint _constraint;
+ Set _values = new LinkedHashSet();
+ XPathExecutionContext _context;
+
+ SelectorState(SchemaIdentityConstraint constraint, Event e, SchemaType st) {
+ _constraint = constraint;
+ _context = new XPathExecutionContext();
+ _context.init((XPath) _constraint.getSelectorPath());
+
+ if ((_context.start() & XPathExecutionContext.HIT) != 0) {
+ createFieldState(e, st);
+ }
+ }
+
+ void addFields(XmlObjectList fields, Event e) {
+ if (_constraint.getConstraintCategory() == SchemaIdentityConstraint.CC_KEYREF) {
+ _values.add(fields);
+ } else if (_values.contains(fields)) {
+ if (_constraint.getConstraintCategory() == SchemaIdentityConstraint.CC_UNIQUE) {
+ emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$DUPLICATE_UNIQUE,
+ new Object[]{fields, QNameHelper.pretty(_constraint.getName())});
+ } else {
+ emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$DUPLICATE_KEY,
+ new Object[]{fields, QNameHelper.pretty(_constraint.getName())});
+ }
+ } else {
+ _values.add(fields);
+ }
+ }
+
+ void element(Event e, SchemaType st) {
+ if ((_context.element(e.getName()) & XPathExecutionContext.HIT) != 0) {
+ createFieldState(e, st);
+ }
+ }
+
+ void endElement(Event e) {
+ _context.end();
+ }
+
+ void createFieldState(Event e, SchemaType st) {
+ new FieldState(this, e, st);
+ }
+
+ void remove(Event e) {
+ // Bubble up key, unique values to keyrefs
+ for (ConstraintState cs = _next; cs != null; cs = cs._next) {
+ if (cs instanceof KeyrefState) {
+ KeyrefState kr = (KeyrefState) cs;
+ if (kr._constraint.getReferencedKey() == this._constraint) {
+ kr.addKeyValues(_values, true);
+ }
+ }
+ }
+ }
+
+ void attr(Event e, QName name, SchemaType st, String value) {
+ }
+
+ void text(Event e, SchemaType st, String value, boolean emptyContent) {
+ }
+ }
+
+ public class KeyrefState extends SelectorState {
+ Map _keyValues = new HashMap();
+ private Object CHILD_ADDED = new Object();
+ private Object CHILD_REMOVED = new Object();
+ private Object SELF_ADDED = new Object();
+
+ KeyrefState(SchemaIdentityConstraint constraint, Event e, SchemaType st) {
+ super(constraint, e, st);
+ }
+
+ void addKeyValues(final Set values, boolean child) {
+ /** If the key values are added by children, then if two or
+ more children add the same value, the value dissapears from the map
+ but if is added by the element in question directly then it will
+ be present in the map regardless of what children contained */
+ for (Iterator it = values.iterator(); it.hasNext(); ) {
+ Object key = it.next();
+ Object value = _keyValues.get(key);
+ if (value == null) {
+ _keyValues.put(key, child ? CHILD_ADDED : SELF_ADDED);
+ } else if (value == CHILD_ADDED) {
+ if (child) {
+ _keyValues.put(key, CHILD_REMOVED);
+ } else {
+ _keyValues.put(key, SELF_ADDED);
+ }
+ } else if (value == CHILD_REMOVED) {
+ if (!child) {
+ _keyValues.put(key, SELF_ADDED);
+ }
+ }
+ }
+ }
+
+ private boolean hasKeyValue(Object key) {
+ Object value = _keyValues.get(key);
+ return value != null && value != CHILD_REMOVED;
+ }
+
+ void remove(Event e) {
+ // First check if there are any keys at the same stack level as this
+ // that may contribute key values to me
+ for (ConstraintState cs = _next; cs != null && cs != _elementStack._savePoint; cs = cs._next) {
+ if (cs instanceof SelectorState) {
+ SelectorState sel = (SelectorState) cs;
+ if (sel._constraint == _constraint.getReferencedKey()) {
+ addKeyValues(sel._values, false);
+ }
+ }
+ }
+
+
+ // validate all values have been seen
+ for (Iterator it = _values.iterator(); it.hasNext(); ) {
+
+ XmlObjectList fields = (XmlObjectList) it.next();
+ if (fields.unfilled() < 0 && !hasKeyValue(fields)) {
+ // KHK: cvc-identity-constraint.4.3 ?
+ emitError(e, XmlErrorCodes.IDENTITY_CONSTRAINT_VALID$KEYREF_KEY_NOT_FOUND,
+ new Object[]{fields, QNameHelper.pretty(_constraint.getName())});
+ return;
+ }
+ }
+ }
+ }
+
+ public class FieldState extends ConstraintState {
+ SelectorState _selector;
+ XPathExecutionContext[] _contexts;
+ boolean[] _needsValue;
+ XmlObjectList _value;
+
+ FieldState(SelectorState selector, Event e, SchemaType st) {
+
+ // System.out.println("Creating new Field State for: " + e.getName());
+
+ _selector = selector;
+ SchemaIdentityConstraint ic = selector._constraint;
+
+ int fieldCount = ic.getFields().length;
+ _contexts = new XPathExecutionContext[fieldCount];
+ _needsValue = new boolean[fieldCount];
+ _value = new XmlObjectList(fieldCount);
+
+ for (int i = 0; i < fieldCount; i++) {
+ _contexts[i] = new XPathExecutionContext();
+ _contexts[i].init((XPath) ic.getFieldPath(i));
+ if ((_contexts[i].start() & XPathExecutionContext.HIT) != 0) {
+ // System.out.println("hit for element: " + e.getName());
+
+ if (!hasSimpleContent(st))
+ // KHK: cvc-identity-constraint.3
+ {
+ emitError(e, "Identity constraint field must have simple content");
+ } else {
+ _needsValue[i] = true;
+ }
+ }
+ }
+
+ }
+
+ void element(Event e, SchemaType st) {
+ for (int i = 0; i < _contexts.length; i++) {
+ if (_needsValue[i]) {
+ // KHK: cvc-identity-constraint.3
+ emitError(e, "Identity constraint field must have simple content");
+ _needsValue[i] = false;
+ }
+ }
+
+ for (int i = 0; i < _contexts.length; i++) {
+ if ((_contexts[i].element(e.getName()) & XPathExecutionContext.HIT) != 0) {
+ if (!hasSimpleContent(st)) {
+ // KHK: cvc-identity-constraint.3
+ emitError(e, "Identity constraint field must have simple content");
+ } else {
+ _needsValue[i] = true;
+ }
+ }
+ }
+ }
+
+ void attr(Event e, QName name, SchemaType st, String value) {
+
+ // Null value indicates previously reported validation problem
+ if (value == null) {
+ return;
+ }
+
+ for (int i = 0; i < _contexts.length; i++) {
+ if (_contexts[i].attr(name)) {
+ XmlObject o = newValue(st, value);
+
+ // Ignore invalid values. Assume that validation catches these
+ if (o == null) {
+ return;
+ }
+
+ boolean set = _value.set(o, i);
+
+ // KHK: ?
+ if (!set) {
+ emitError(e, "Multiple instances of field with xpath: '"
+ + _selector._constraint.getFields()[i] + "' for a selector");
+ }
+ }
+
+ }
+ }
+
+
+ void text(Event e, SchemaType st, String value, boolean emptyContent) {
+
+ // Null value indicates previously reported validation problem
+ if (value == null && !emptyContent) {
+ return;
+ }
+
+ for (int i = 0; i < _contexts.length; i++) {
+ if (_needsValue[i]) {
+
+ if (emptyContent || !hasSimpleContent(st)) {
+ // KHK: cvc-identity-constraint.3
+ emitError(e, "Identity constraint field must have simple content");
+ return;
+ }
+
+ SchemaType simpleType = getSimpleType(st);
+ XmlObject o = newValue(simpleType, value);
+
+ // Ignore invalid values. Assume that validation catches these
+ if (o == null) {
+ return;
+ }
+
+ boolean set = _value.set(o, i);
+
+ // KHK: ?
+ if (!set) {
+ emitError(e, "Multiple instances of field with xpath: '"
+ + _selector._constraint.getFields()[i] + "' for a selector");
+ }
+ }
+ }
+ }
+
+ void endElement(Event e) {
+ // reset any _needsValue flags
+ // assume that if we didn't see the text, it was because of another validation
+ // error, so don't emit another one.
+ for (int i = 0; i < _needsValue.length; i++) {
+ _contexts[i].end();
+ _needsValue[i] = false;
+ }
+
+ }
+
+ void remove(Event e) {
+
+ if (_selector._constraint.getConstraintCategory() == SchemaIdentityConstraint.CC_KEY &&
+ _value.unfilled() >= 0) {
+ // KHK: cvc-identity-constraint.4.2.1 ?
+ // keys must have all values supplied
+ emitError(e, "Key " + QNameHelper.pretty(_selector._constraint.getName()) + " is missing field with xpath: '" + _selector._constraint.getFields()[_value.unfilled()] + "'");
+ } else {
+ // Finished. Add these fields to the selector state
+ _selector.addFields(_value, e);
+ }
+ }
+
+ }
+
+ public class IdState extends ConstraintState {
+ Set _values = new LinkedHashSet();
+
+ IdState() {
+ }
+
+ void attr(Event e, QName name, SchemaType st, String value) {
+ handleValue(e, st, value);
+ }
+
+ void text(Event e, SchemaType st, String value, boolean emptyContent) {
+ if (emptyContent) {
+ return;
+ }
+
+ handleValue(e, st, value);
+ }
+
+ private void handleValue(Event e, SchemaType st, String value) {
+
+ // Null value indicates previously reported validation problem
+ if (value == null) {
+ return;
+ }
+
+ if (st == null || st.isNoType()) {
+ // ignore invalid values. Assume that validation catches these
+ return;
+ }
+
+ if (XmlID.type.isAssignableFrom(st)) {
+ XmlObjectList xmlValue = new XmlObjectList(1);
+ XmlObject o = newValue(XmlID.type, value);
+
+ // Ignore invalid values. Assume that validation catches these
+ if (o == null) {
+ return;
+ }
+
+ xmlValue.set(o, 0);
+
+ if (_values.contains(xmlValue)) {
+ emitError(e, XmlErrorCodes.ID_VALID$DUPLICATE, new Object[]{value});
+ } else {
+ _values.add(xmlValue);
+ }
+ }
+ }
+
+ void element(Event e, SchemaType st) {
+ }
+
+ void endElement(Event e) {
+ }
+
+ void remove(Event e) {
+ }
+
+ }
+
+ public class IdRefState extends ConstraintState {
+ IdState _ids;
+ List _values;
+
+ IdRefState(IdState ids) {
+ _ids = ids;
+ _values = new ArrayList();
+ }
+
+ private void handleValue(Event e, SchemaType st, String value) {
+ // Null value indicates previously reported validation problem
+ if (value == null) {
+ return;
+ }
+
+ if (st == null || st.isNoType()) {
+ // ignore invalid values. Assume that validation catches these
+ return;
+ }
+ if (XmlIDREFS.type.isAssignableFrom(st)) {
+ XmlIDREFS lv = (XmlIDREFS) newValue(XmlIDREFS.type, value);
+
+ // Ignore invalid values. Assume that validation catches these
+ if (lv == null) {
+ return;
+ }
+
+ List l = lv.xgetListValue();
+
+ // Add one value for each idref in the list
+ for (int i = 0; i < l.size(); i++) {
+ XmlObjectList xmlValue = new XmlObjectList(1);
+ XmlIDREF idref = (XmlIDREF) l.get(i);
+ xmlValue.set(idref, 0);
+ _values.add(xmlValue);
+ }
+ } else if (XmlIDREF.type.isAssignableFrom(st)) {
+ XmlObjectList xmlValue = new XmlObjectList(1);
+ XmlIDREF idref = (XmlIDREF) st.newValue(value);
+
+ // Ignore invalid values. Assume that validation catches these
+ if (idref == null) {
+ return;
+ }
+
+ xmlValue.set(idref, 0);
+ _values.add(xmlValue);
+ }
+ }
+
+ void attr(Event e, QName name, SchemaType st, String value) {
+ handleValue(e, st, value);
+ }
+
+ void text(Event e, SchemaType st, String value, boolean emptyContent) {
+ if (emptyContent) {
+ return;
+ }
+
+ handleValue(e, st, value);
+ }
+
+ void remove(Event e) {
+ // Validate each ref has a corresponding ID
+ for (Iterator it = _values.iterator(); it.hasNext(); ) {
+ Object o = it.next();
+ if (!_ids._values.contains(o)) {
+ // KHK: cvc-id.1
+ emitError(e, "ID not found for IDRef value '" + o + "'");
+ }
+ }
+ }
+
+ void element(Event e, SchemaType st) {
+ }
+
+ void endElement(Event e) {
+ }
+ }
+
+ private static class ElementState {
+ ElementState _next;
+ boolean _hasConstraints;
+ ConstraintState _savePoint;
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/InvalidLexicalValueException.java b/src/main/java/org/apache/xmlbeans/impl/common/InvalidLexicalValueException.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/InvalidLexicalValueException.java
rename to src/main/java/org/apache/xmlbeans/impl/common/InvalidLexicalValueException.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/JarHelper.java b/src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/JarHelper.java
rename to src/main/java/org/apache/xmlbeans/impl/common/JarHelper.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/Levenshtein.java b/src/main/java/org/apache/xmlbeans/impl/common/Levenshtein.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/Levenshtein.java
rename to src/main/java/org/apache/xmlbeans/impl/common/Levenshtein.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/LoadSaveUtils.java b/src/main/java/org/apache/xmlbeans/impl/common/LoadSaveUtils.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/LoadSaveUtils.java
rename to src/main/java/org/apache/xmlbeans/impl/common/LoadSaveUtils.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/Mutex.java b/src/main/java/org/apache/xmlbeans/impl/common/Mutex.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/Mutex.java
rename to src/main/java/org/apache/xmlbeans/impl/common/Mutex.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/NameUtil.java b/src/main/java/org/apache/xmlbeans/impl/common/NameUtil.java
new file mode 100644
index 0000000..c0e7c8a
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/NameUtil.java
@@ -0,0 +1,777 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import javax.xml.namespace.QName;
+import java.util.*;
+
+public class NameUtil {
+ // punctuation characters
+ public final static char HYPHEN = '\u002D';
+ public final static char PERIOD = '\u002E';
+ public final static char COLON = '\u003A';
+ public final static char USCORE = '\u005F';
+ public final static char DOT = '\u00B7';
+ public final static char TELEIA = '\u0387';
+ public final static char AYAH = '\u06DD';
+ public final static char ELHIZB = '\u06DE';
+
+ private final static Set javaWords = new HashSet<>(Arrays.asList(
+ "assert",
+ "abstract",
+ "boolean",
+ "break",
+ "byte",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "double",
+ "else",
+ "enum", // since JDK1.5
+ "extends",
+ "false", // not a keyword
+ "final",
+ "finally",
+ "float",
+ "for",
+ "goto",
+ "if",
+ "implements",
+ "import",
+ "instanceof",
+ "int",
+ "interface",
+ "long",
+ "native",
+ "new",
+ "null", // not a keyword
+ "package",
+ "private",
+ "protected",
+ "public",
+ "return",
+ "short",
+ "static",
+ "strictfp",
+ "super",
+ "switch",
+ "synchronized",
+ "this",
+ "threadsafe",
+ "throw",
+ "throws",
+ "transient",
+ "true", // not a keyword
+ "try",
+ "void",
+ "volatile",
+ "while"));
+
+ private final static Set extraWords = new HashSet<>(Arrays.asList(
+ "i", // used for indexes
+ "target", // used for parameter
+ "org", // used for package names
+ "com" // used for package names
+ ));
+
+ /*
+ private final static Set javaNames = new HashSet(Arrays.asList(
+ new String[]
+ {
+ "CharSequence",
+ "Cloneable",
+ "Comparable",
+ "Runnable",
+
+ "Boolean",
+ "Byte",
+ "Character",
+ "Class",
+ "ClassLoader",
+ "Compiler",
+ "Double",
+ "Float",
+ "InheritableThreadLocal",
+ "Integer",
+ "Long",
+ "Math",
+ "Number",
+ "Object",
+ "Package",
+ "Process",
+ "Runtime",
+ "RuntimePermission",
+ "SecurityManager",
+ "Short",
+ "StackTraceElement",
+ "StrictMath",
+ "String",
+ "StringBuffer",
+ "System",
+ "Thread",
+ "ThreadGroup",
+ "ThreadLocal",
+ "Throwable",
+ "Void",
+
+ "ArithmeticException",
+ "ArrayIndexOutOfBoundsException",
+ "ArrayStoreException",
+ "ClassCastException",
+ "ClassNotFoundException",
+ "CloneNotSupportedException",
+ "Exception",
+ "IllegalAccessException",
+ "IllegalArgumentException",
+ "IllegalMonitorStateException",
+ "IllegalStateException",
+ "IllegalThreadStateException",
+ "IndexOutOfBoundsException",
+ "InstantiationException",
+ "InterruptedException",
+ "NegativeArraySizeException",
+ "NoSuchFieldException",
+ "NoSuchMethodException",
+ "NullPointerException",
+ "NumberFormatException",
+ "RuntimeException",
+ "SecurityException",
+ "StringIndexOutOfBoundsException",
+ "UnsupportedOperationException",
+
+ "AbstractMethodError",
+ "AssertionError",
+ "ClassCircularityError",
+ "ClassFormatError",
+ "Error",
+ "ExceptionInInitializerError",
+ "IllegalAccessError",
+ "IncompatibleClassChangeError",
+ "InstantiationError",
+ "InternalError",
+ "LinkageError",
+ "NoClassDefFoundError",
+ "NoSuchFieldError",
+ "NoSuchMethodError",
+ "OutOfMemoryError",
+ "StackOverflowError",
+ "ThreadDeath",
+ "UnknownError",
+ "UnsatisfiedLinkError",
+ "UnsupportedClassVersionError",
+ "VerifyError",
+ "VirtualMachineError",
+ }
+ ));
+ */
+
+ private final static Set javaNames = new HashSet<>(Arrays.asList(
+ // 1. all the Java.lang classes [1.4.1 JDK].
+ "CharSequence",
+ "Cloneable",
+ "Comparable",
+ "Runnable",
+
+ "Boolean",
+ "Byte",
+ "Character",
+ "Class",
+ "ClassLoader",
+ "Compiler",
+ "Double",
+ "Float",
+ "InheritableThreadLocal",
+ "Integer",
+ "Long",
+ "Math",
+ "Number",
+ "Object",
+ "Package",
+ "Process",
+ "Runtime",
+ "RuntimePermission",
+ "SecurityManager",
+ "Short",
+ "StackTraceElement",
+ "StrictMath",
+ "String",
+ "StringBuffer",
+ "System",
+ "Thread",
+ "ThreadGroup",
+ "ThreadLocal",
+ "Throwable",
+ "Void",
+
+ "ArithmeticException",
+ "ArrayIndexOutOfBoundsException",
+ "ArrayStoreException",
+ "ClassCastException",
+ "ClassNotFoundException",
+ "CloneNotSupportedException",
+ "Exception",
+ "IllegalAccessException",
+ "IllegalArgumentException",
+ "IllegalMonitorStateException",
+ "IllegalStateException",
+ "IllegalThreadStateException",
+ "IndexOutOfBoundsException",
+ "InstantiationException",
+ "InterruptedException",
+ "NegativeArraySizeException",
+ "NoSuchFieldException",
+ "NoSuchMethodException",
+ "NullPointerException",
+ "NumberFormatException",
+ "RuntimeException",
+ "SecurityException",
+ "StringIndexOutOfBoundsException",
+ "UnsupportedOperationException",
+
+ "AbstractMethodError",
+ "AssertionError",
+ "ClassCircularityError",
+ "ClassFormatError",
+ "Error",
+ "ExceptionInInitializerError",
+ "IllegalAccessError",
+ "IncompatibleClassChangeError",
+ "InstantiationError",
+ "InternalError",
+ "LinkageError",
+ "NoClassDefFoundError",
+ "NoSuchFieldError",
+ "NoSuchMethodError",
+ "OutOfMemoryError",
+ "StackOverflowError",
+ "ThreadDeath",
+ "UnknownError",
+ "UnsatisfiedLinkError",
+ "UnsupportedClassVersionError",
+ "VerifyError",
+ "VirtualMachineError",
+
+ // 2. other classes used as primitive types by xml beans
+ "BigInteger",
+ "BigDecimal",
+ "Enum",
+ "Date",
+ "GDate",
+ "GDuration",
+ "QName",
+ "List",
+
+ // 3. the top few org.apache.xmlbeans names
+ "XmlObject",
+ "XmlCursor",
+ "XmlBeans",
+ "SchemaType"));
+
+ public static boolean isValidJavaIdentifier(String id) {
+ if (id == null) {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+
+ int len = id.length();
+ if (len == 0) {
+ return false;
+ }
+
+ if (javaWords.contains(id)) {
+ return false;
+ }
+
+ if (!Character.isJavaIdentifierStart(id.charAt(0))) {
+ return false;
+ }
+
+ for (int i = 1; i < len; i++) {
+ if (!Character.isJavaIdentifierPart(id.charAt(i))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static String getClassNameFromQName(QName qname) {
+ return getClassNameFromQName(qname, false);
+ }
+
+ public static String getClassNameFromQName(QName qname, boolean useJaxRpcRules) {
+ String java_type = upperCamelCase(qname.getLocalPart(), useJaxRpcRules);
+
+ String uri = qname.getNamespaceURI();
+
+ String java_pkg = getPackageFromNamespace(uri, useJaxRpcRules);
+
+ if (java_pkg != null) {
+ return java_pkg + "." + java_type;
+ } else {
+ return java_type;
+ }
+ }
+
+ private static final String JAVA_NS_PREFIX = "java:";
+
+ public static String getNamespaceFromPackage(final Class> clazz) {
+ Class> curr_clazz = clazz;
+
+ while (curr_clazz.isArray()) {
+ curr_clazz = curr_clazz.getComponentType();
+ }
+
+ String fullname = clazz.getName();
+ int lastdot = fullname.lastIndexOf('.');
+ String pkg_name = lastdot < 0 ? "" : fullname.substring(0, lastdot);
+
+ //special case for builtin types
+ /*
+ if (curr_clazz.isPrimitive())
+ {
+ pkg_name = c.getJavaLanguageNamespaceUri();
+ }
+ else if (pkg_name.startsWith(LANG_PREFIX))
+ {
+ final String rem_str = pkg_name.substring(LANG_PREFIX.length());
+ pkg_name = c.getJavaLanguageNamespaceUri() + "." + rem_str;
+ }
+ */
+ return JAVA_NS_PREFIX + pkg_name;
+ }
+
+ private static boolean isUriSchemeChar(char ch) {
+ return (ch >= 'a' && ch <= 'z' ||
+ ch >= 'A' && ch <= 'Z' ||
+ ch >= '0' && ch <= '9' ||
+ ch == '-' || ch == '.' || ch == '+');
+ }
+
+ private static boolean isUriAlphaChar(char ch) {
+ return (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z');
+ }
+
+ private static int findSchemeColon(String uri) {
+ int len = uri.length();
+ if (len == 0) {
+ return -1;
+ }
+ if (!isUriAlphaChar(uri.charAt(0))) {
+ return -1;
+ }
+ int i;
+ for (i = 1; i < len; i++) {
+ if (!isUriSchemeChar(uri.charAt(i))) {
+ break;
+ }
+ }
+ if (i == len) {
+ return -1;
+ }
+ if (uri.charAt(i) != ':') {
+ return -1;
+ }
+ // consume consecutive colons
+ for (; i < len; i++) {
+ if (uri.charAt(i) != ':') {
+ break;
+ }
+ }
+ // for the "scheme:::" case, return len-1
+ return i - 1;
+ }
+
+ private static String jls77String(String name) {
+ StringBuilder buf = new StringBuilder(name);
+ for (int i = 0; i < name.length(); i++) {
+ // We need to also make sure that our package names don't contain the
+ // "$" character in them, which, although a valid Java identifier part,
+ // would create confusion when trying to generate fully-qualified names
+ if (!Character.isJavaIdentifierPart(buf.charAt(i)) || '$' == buf.charAt(i)) {
+ buf.setCharAt(i, '_');
+ }
+ }
+ if (buf.length() == 0 || !Character.isJavaIdentifierStart(buf.charAt(0))) {
+ buf.insert(0, '_');
+ }
+ if (isJavaReservedWord(name)) {
+ buf.append('_');
+ }
+ return buf.toString();
+ }
+
+ private static List splitDNS(String dns) {
+ // JAXB says: only split+reverse DNS if TLD matches known TLDs or ISO 3166
+ // We are ignoring this now (TH)
+
+ List result = new ArrayList<>();
+
+ int end = dns.length();
+ int begin = dns.lastIndexOf('.');
+ for (; begin != -1; begin--) {
+ if (dns.charAt(begin) == '.') {
+ result.add(jls77String(dns.substring(begin + 1, end)));
+ end = begin;
+ }
+ }
+ result.add(jls77String(dns.substring(0, end)));
+
+ // JAXB draft example implies removal of www
+ if (result.size() >= 3 &&
+ result.get(result.size() - 1).toLowerCase(Locale.ROOT).equals("www")) {
+ result.remove(result.size() - 1);
+ }
+
+ return result;
+ }
+
+ private static String processFilename(String filename) {
+ // JAXB says: strip 2 or 3 letter extension or ".html"
+
+ int i = filename.lastIndexOf('.');
+ if (i > 0 && (
+ i + 1 + 2 == filename.length() ||
+ i + 1 + 3 == filename.length() ||
+ "html".equals(filename.substring(i + 1).toLowerCase(Locale.ROOT)))) {
+ return filename.substring(0, i);
+ }
+
+ return filename;
+ }
+
+ public static String getPackageFromNamespace(String uri) {
+ return getPackageFromNamespace(uri, false);
+ }
+
+ public static String getPackageFromNamespace(String uri, boolean useJaxRpcRules) {
+ // special case: no namespace -> package "noNamespace"
+ if (uri == null || uri.length() == 0) {
+ return "noNamespace";
+ }
+
+ // apply draft JAXB rules
+ int len = uri.length();
+ int i = findSchemeColon(uri);
+ List result;
+
+ if (i == len - 1) {
+ // XMLBEANS-57: colon is at end so just use scheme as the package name
+ result = new ArrayList<>();
+ result.add(uri.substring(0, i));
+ } else if (i >= 0 && uri.substring(0, i).equals("java")) {
+ result = Arrays.asList(uri.substring(i + 1).split("\\."));
+ } else {
+ result = new ArrayList<>();
+ outer:
+ for (i = i + 1; i < len; ) {
+ while (uri.charAt(i) == '/') {
+ if (++i >= len) {
+ break outer;
+ }
+ }
+ int start = i;
+ while (uri.charAt(i) != '/') {
+ if (++i >= len) {
+ break;
+ }
+ }
+ int end = i;
+ result.add(uri.substring(start, end));
+ }
+ if (result.size() > 1) {
+ result.set(result.size() - 1, processFilename(result.get(result.size() - 1)));
+ }
+
+ if (result.size() > 0) {
+ List splitdns = splitDNS(result.get(0));
+ result.remove(0);
+ result.addAll(0, splitdns);
+ }
+ }
+
+ StringBuilder buf = new StringBuilder();
+ for (String s : result) {
+ String part = nonJavaKeyword(lowerCamelCase(s, useJaxRpcRules, true));
+ if (part.length() > 0) {
+ buf.append(part);
+ buf.append('.');
+ }
+ }
+ if (buf.length() == 0) {
+ return "noNamespace";
+ }
+ if (useJaxRpcRules) {
+ return buf.substring(0, buf.length() - 1).toLowerCase(Locale.ROOT);
+ }
+ return buf.substring(0, buf.length() - 1); // chop off extra dot
+ }
+
+ public static void main(String[] args) {
+ for (String arg : args) {
+ System.out.println(upperCaseUnderbar(arg));
+ }
+ }
+
+ /**
+ * Returns a upper-case-and-underbar string using the JAXB rules.
+ * Always starts with a capital letter that is a valid
+ * java identifier start. (If JAXB rules don't produce
+ * one, then "X_" is prepended.)
+ */
+ public static String upperCaseUnderbar(String xml_name) {
+ StringBuilder buf = new StringBuilder();
+ List words = splitWords(xml_name, false);
+
+ final int sz = words.size() - 1;
+ if (sz >= 0 && !Character.isJavaIdentifierStart(words.get(0).charAt(0))) {
+ buf.append("X_");
+ }
+
+ for (int i = 0; i < sz; i++) {
+ buf.append(words.get(i));
+ buf.append(USCORE);
+ }
+
+ if (sz >= 0) {
+ buf.append(words.get(sz));
+ }
+
+ //upcase entire buffer
+ final int len = buf.length();
+ for (int j = 0; j < len; j++) {
+ char c = buf.charAt(j);
+ buf.setCharAt(j, Character.toUpperCase(c));
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Returns a camel-cased string using the JAXB rules.
+ * Always starts with a capital letter that is a valid
+ * java identifier start. (If JAXB rules don't produce
+ * one, then "X" is prepended.)
+ */
+ public static String upperCamelCase(String xml_name) {
+ return upperCamelCase(xml_name, false);
+ }
+
+ /**
+ * Returns a camel-cased string, but either JAXB or JAX-RPC rules
+ * are used
+ */
+ public static String upperCamelCase(String xml_name, boolean useJaxRpcRules) {
+ StringBuilder buf = new StringBuilder();
+ List words = splitWords(xml_name, useJaxRpcRules);
+
+ if (words.size() > 0) {
+ if (!Character.isJavaIdentifierStart(words.get(0).charAt(0))) {
+ buf.append("X");
+ }
+
+ for (String word : words) {
+ buf.append(word);
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Returns a camel-cased string using the JAXB rules,
+ * where the first component is lowercased. Note that
+ * if the first component is an acronym, the whole
+ * thigns gets lowercased.
+ * Always starts with a lowercase letter that is a valid
+ * java identifier start. (If JAXB rules don't produce
+ * one, then "x" is prepended.)
+ */
+ public static String lowerCamelCase(String xml_name) {
+ return lowerCamelCase(xml_name, false, true);
+ }
+
+ /**
+ * Returns a camel-cased string using the JAXB or JAX-RPC rules
+ */
+ public static String lowerCamelCase(String xml_name, boolean useJaxRpcRules,
+ boolean fixGeneratedName) {
+ StringBuilder buf = new StringBuilder();
+ List words = splitWords(xml_name, useJaxRpcRules);
+
+ if (words.size() > 0) {
+ String first = words.get(0).toLowerCase(Locale.ROOT);
+ char f = first.charAt(0);
+ if (!Character.isJavaIdentifierStart(f) && fixGeneratedName) {
+ buf.append("x");
+ }
+ buf.append(first);
+
+ Iterator itr = words.iterator();
+ itr.next(); // skip already-lowercased word
+ while (itr.hasNext()) {
+ buf.append(itr.next());
+ }
+ }
+ return buf.toString();
+ }
+
+ public static String upperCaseFirstLetter(String s) {
+ if (s.length() == 0 || Character.isUpperCase(s.charAt(0))) {
+ return s;
+ }
+
+ StringBuilder buf = new StringBuilder(s);
+ buf.setCharAt(0, Character.toUpperCase(buf.charAt(0)));
+ return buf.toString();
+ }
+
+
+ /**
+ * split an xml name into words via JAXB approach, upcasing first
+ * letter of each word as needed, if upcase is true
+ *
+ * ncname is xml ncname (i.e. no colons).
+ */
+ private static void addCapped(List list, String str) {
+ if (str.length() > 0) {
+ list.add(upperCaseFirstLetter(str));
+ }
+ }
+
+ public static List splitWords(String name, boolean useJaxRpcRules) {
+ List list = new ArrayList<>();
+ int len = name.length();
+ int start = 0;
+ int prefix = START;
+ for (int i = 0; i < len; i++) {
+ int current = getCharClass(name.charAt(i), useJaxRpcRules);
+ if (prefix != PUNCT && current == PUNCT) {
+ addCapped(list, name.substring(start, i));
+ while ((current = getCharClass(name.charAt(i), useJaxRpcRules)) == PUNCT) {
+ if (++i >= len) {
+ return list;
+ }
+ }
+ start = i;
+ } else if ((prefix == DIGIT) != (current == DIGIT) ||
+ (prefix == LOWER && current != LOWER) ||
+ (isLetter(prefix) != isLetter(current))) {
+ addCapped(list, name.substring(start, i));
+ start = i;
+ } else if (prefix == UPPER && current == LOWER && i > start + 1) {
+ addCapped(list, name.substring(start, i - 1));
+ start = i - 1;
+ }
+ prefix = current;
+ }
+ addCapped(list, name.substring(start));
+ return list;
+ }
+
+ //char classes
+ private final static int START = 0;
+ private final static int PUNCT = 1;
+ private final static int DIGIT = 2;
+ private final static int MARK = 3;
+ private final static int UPPER = 4;
+ private final static int LOWER = 5;
+ private final static int NOCASE = 6;
+
+ public static int getCharClass(char c, boolean useJaxRpcRules) {
+ //ordering is important here.
+ if (isPunctuation(c, useJaxRpcRules)) {
+ return PUNCT;
+ } else if (Character.isDigit(c)) {
+ return DIGIT;
+ } else if (Character.isUpperCase(c)) {
+ return UPPER;
+ } else if (Character.isLowerCase(c)) {
+ return LOWER;
+ } else if (Character.isLetter(c)) {
+ return NOCASE;
+ } else if (Character.isJavaIdentifierPart(c)) {
+ return MARK;
+ } else {
+ return PUNCT; // not covered by JAXB: treat it as punctuation
+ }
+ }
+
+ private static boolean isLetter(int state) {
+ return (state == UPPER
+ || state == LOWER
+ || state == NOCASE);
+ }
+
+ public static boolean isPunctuation(char c, boolean useJaxRpcRules) {
+ return (c == HYPHEN
+ || c == PERIOD
+ || c == COLON
+ || c == DOT
+ || (c == USCORE && !useJaxRpcRules)
+ || c == TELEIA
+ || c == AYAH
+ || c == ELHIZB);
+ }
+
+ /**
+ * Intended to be applied to a lowercase-starting identifier that
+ * may collide with a Java keyword. If it does collide, this
+ * prepends the letter "x".
+ */
+ public static String nonJavaKeyword(String word) {
+ if (isJavaReservedWord(word)) {
+ return 'x' + word;
+ }
+ return word;
+ }
+
+ /**
+ * Intended to be applied to a lowercase-starting identifier that
+ * may collide with a Java keyword. If it does collide, this
+ * prepends the letter "x".
+ */
+ public static String nonExtraKeyword(String word) {
+ return isExtraReservedWord(word) ? word + "Value" : word;
+ }
+
+ /**
+ * Intended to be applied to an uppercase-starting identifier that
+ * may collide with a java.lang.* classname. If it does collide, this
+ * prepends the letter "X".
+ */
+ public static String nonJavaCommonClassName(String name) {
+ if (isJavaCommonClassName(name)) {
+ return "X" + name;
+ }
+ return name;
+ }
+
+ private static boolean isJavaReservedWord(String word) {
+ return javaWords.contains(word.toLowerCase(Locale.ROOT));
+ }
+
+ private static boolean isExtraReservedWord(String word) {
+ return extraWords.contains(word.toLowerCase(Locale.ROOT));
+ }
+
+ public static boolean isJavaCommonClassName(String word) {
+ return javaNames.contains(word);
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/NullLogger.java b/src/main/java/org/apache/xmlbeans/impl/common/NullLogger.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/NullLogger.java
rename to src/main/java/org/apache/xmlbeans/impl/common/NullLogger.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/PrefixResolver.java b/src/main/java/org/apache/xmlbeans/impl/common/PrefixResolver.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/PrefixResolver.java
rename to src/main/java/org/apache/xmlbeans/impl/common/PrefixResolver.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/PushedInputStream.java b/src/main/java/org/apache/xmlbeans/impl/common/PushedInputStream.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/PushedInputStream.java
rename to src/main/java/org/apache/xmlbeans/impl/common/PushedInputStream.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/QNameHelper.java b/src/main/java/org/apache/xmlbeans/impl/common/QNameHelper.java
similarity index 96%
rename from src/common/org/apache/xmlbeans/impl/common/QNameHelper.java
rename to src/main/java/org/apache/xmlbeans/impl/common/QNameHelper.java
index b6c4458..7617aaf 100644
--- a/src/common/org/apache/xmlbeans/impl/common/QNameHelper.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/QNameHelper.java
@@ -15,18 +15,18 @@
package org.apache.xmlbeans.impl.common;
-import javax.xml.namespace.QName;
+import org.apache.xmlbeans.SchemaField;
+import org.apache.xmlbeans.SchemaType;
import org.apache.xmlbeans.xml.stream.XMLName;
+import javax.xml.namespace.QName;
+import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.Map;
-import java.util.HashMap;
import java.util.Collections;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaField;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
public class QNameHelper
{
@@ -36,10 +36,10 @@ public static XMLName getXMLName(QName qname)
{
if (qname == null)
return null;
-
+
return XMLNameHelper.forLNS( qname.getLocalPart(), qname.getNamespaceURI() );
}
-
+
public static QName forLNS(String localname, String uri)
{
if (uri == null)
@@ -67,7 +67,7 @@ public static String pretty(QName name)
if (name.getNamespaceURI() == null || name.getNamespaceURI().length() == 0)
return name.getLocalPart();
-
+
return name.getLocalPart() + "@" + name.getNamespaceURI();
}
@@ -102,13 +102,13 @@ private static boolean isSafe(int c)
//
// The reason for the "shortening" is to avoid filenames longer than about
// 256 characters, which are prohibited on Windows NT.
-
+
public static final int MAX_NAME_LENGTH = 64;
public static final String URI_SHA1_PREFIX = "URI_SHA_1_";
public static String hexsafe(String s)
{
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++)
{
char ch = s.charAt(i);
@@ -136,11 +136,11 @@ public static String hexsafe(String s)
}
}
}
-
+
// short enough? Done!
if (result.length() <= MAX_NAME_LENGTH)
return result.toString();
-
+
// too long? use SHA1
try
{
@@ -157,7 +157,7 @@ public static String hexsafe(String s)
}
byte[] digest = md.digest(inputBytes);
assert(digest.length == 20); // SHA1 160 bits == 20 bytes
- result = new StringBuffer(URI_SHA1_PREFIX);
+ result = new StringBuilder(URI_SHA1_PREFIX);
for (int j = 0; j < digest.length; j++)
{
result.append(hexdigits[(digest[j] >> 4) & 0xF]);
@@ -201,25 +201,25 @@ public static String readable(SchemaType sType, Map nsPrefix)
{
return readable(sType.getName(), nsPrefix);
}
-
+
if (sType.isAttributeType())
{
return "attribute type " + readable(sType.getAttributeTypeAttributeName(), nsPrefix);
}
-
+
if (sType.isDocumentType())
{
return "document type " + readable(sType.getDocumentElementName(), nsPrefix);
}
-
+
if (sType.isNoType() || sType.getOuterType() == null)
{
return "invalid type";
}
-
+
SchemaType outerType = sType.getOuterType();
SchemaField container = sType.getContainerField();
-
+
if (outerType.isAttributeType())
{
return "type of attribute " + readable(container.getName(), nsPrefix);
@@ -228,7 +228,7 @@ else if (outerType.isDocumentType())
{
return "type of element " + readable(container.getName(), nsPrefix);
}
-
+
if (container != null)
{
if (container.isAttribute())
@@ -240,7 +240,7 @@ else if (outerType.isDocumentType())
return "type of " + container.getName().getLocalPart() + " element in " + readable(outerType, nsPrefix);
}
}
-
+
if (outerType.getBaseType() == sType)
return "base type of " + readable(outerType, nsPrefix);
else if (outerType.getSimpleVariety() == SchemaType.LIST)
@@ -248,9 +248,9 @@ else if (outerType.getSimpleVariety() == SchemaType.LIST)
else if (outerType.getSimpleVariety() == SchemaType.UNION)
return "member type " + sType.getAnonymousUnionMemberOrdinal() + " of " + readable(outerType, nsPrefix);
else
- return "inner type in " + readable(outerType, nsPrefix);
+ return "inner type in " + readable(outerType, nsPrefix);
}
-
+
public static String readable(QName name)
{
return readable(name, WELL_KNOWN_PREFIXES);
@@ -265,13 +265,13 @@ public static String readable(QName name, Map prefixes)
return prefix + ":" + name.getLocalPart();
return name.getLocalPart() + " in namespace " + name.getNamespaceURI();
}
-
+
public static String suggestPrefix(String namespace)
{
String result = (String)WELL_KNOWN_PREFIXES.get(namespace);
if (result != null)
return result;
-
+
int len = namespace.length();
int i = namespace.lastIndexOf('/');
if (i > 0 && i == namespace.length() - 1)
@@ -279,21 +279,21 @@ public static String suggestPrefix(String namespace)
len = i;
i = namespace.lastIndexOf('/', i - 1);
}
-
+
i += 1; // skip '/', also covers -1 case.
-
+
if (namespace.startsWith("www.", i))
{
i += 4; // "www.".length()
}
-
+
while (i < len)
{
if (XMLChar.isNCNameStart(namespace.charAt(i)))
break;
i += 1;
}
-
+
for (int end = i + 1; end < len; end += 1)
{
if (!XMLChar.isNCName(namespace.charAt(end)) || !Character.isLetterOrDigit(namespace.charAt(end)))
@@ -302,7 +302,7 @@ public static String suggestPrefix(String namespace)
break;
}
}
-
+
// prefixes starting with "xml" are forbidden, so change "xmls" -> "xs"
if (namespace.length() >= i + 3 && startsWithXml(namespace, i))
{
@@ -310,7 +310,7 @@ public static String suggestPrefix(String namespace)
return "x" + Character.toLowerCase(namespace.charAt(i + 3));
return "ns";
}
-
+
if (len - i > 4) // four or less? leave it.
{
if (isVowel(namespace.charAt(i + 2)) && !isVowel(namespace.charAt(i + 3)))
@@ -318,28 +318,28 @@ public static String suggestPrefix(String namespace)
else
len = i + 3; // more than four? truncate to 3.
}
-
+
if (len - i == 0)
return "ns";
-
- return namespace.substring(i, len).toLowerCase();
+
+ return namespace.substring(i, len).toLowerCase(Locale.ROOT);
}
-
+
private static boolean startsWithXml(String s, int i)
{
if (s.length() < i + 3)
return false;
-
+
if (s.charAt(i) != 'X' && s.charAt(i) != 'x')
return false;
if (s.charAt(i + 1) != 'M' && s.charAt(i + 1) != 'm')
return false;
if (s.charAt(i + 2) != 'L' && s.charAt(i + 2) != 'l')
return false;
-
+
return true;
}
-
+
private static boolean isVowel(char ch)
{
switch (ch)
@@ -359,7 +359,7 @@ private static boolean isVowel(char ch)
return false;
}
}
-
+
public static String namespace(SchemaType sType)
{
while (sType != null)
diff --git a/src/common/org/apache/xmlbeans/impl/common/ReaderInputStream.java b/src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/ReaderInputStream.java
rename to src/main/java/org/apache/xmlbeans/impl/common/ReaderInputStream.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/ResolverUtil.java b/src/main/java/org/apache/xmlbeans/impl/common/ResolverUtil.java
new file mode 100644
index 0000000..391cd5c
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/ResolverUtil.java
@@ -0,0 +1,68 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import org.apache.xmlbeans.SystemProperties;
+import org.xml.sax.EntityResolver;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * Author: Cezar Andrei (cezar.andrei at bea.com)
+ * Date: Dec 3, 2003
+ */
+public class ResolverUtil {
+ private static EntityResolver _entityResolver = null;
+
+ static {
+ try {
+ String erClassName = SystemProperties.getProperty("xmlbean.entityResolver");
+ if (erClassName != null) {
+ Object o = Class.forName(erClassName).getDeclaredConstructor().newInstance();
+ _entityResolver = (EntityResolver) o;
+ }
+ } catch (Exception e) {
+ _entityResolver = null;
+ }
+ }
+
+ public static EntityResolver getGlobalEntityResolver() {
+ return _entityResolver;
+ }
+
+ public static EntityResolver resolverForCatalog(String catalogFile) {
+ if (catalogFile == null) {
+ return null;
+ }
+
+ try {
+ Class> cmClass = Class.forName("org.apache.xml.resolver.CatalogManager");
+ Constructor> cstrCm = cmClass.getDeclaredConstructor();
+ Object cmObj = cstrCm.newInstance();
+ Method cmMethod = cmClass.getMethod("setCatalogFiles", String.class);
+ cmMethod.invoke(cmObj, catalogFile);
+
+ Class> crClass = Class.forName("org.apache.xml.resolver.tools.CatalogResolver");
+ Constructor> cstrCr = crClass.getDeclaredConstructor(cmClass);
+ Object crObj = cstrCr.newInstance(cmObj);
+
+ return (EntityResolver) crObj;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/SAXHelper.java b/src/main/java/org/apache/xmlbeans/impl/common/SAXHelper.java
similarity index 87%
rename from src/common/org/apache/xmlbeans/impl/common/SAXHelper.java
rename to src/main/java/org/apache/xmlbeans/impl/common/SAXHelper.java
index e3040c9..366cd86 100644
--- a/src/common/org/apache/xmlbeans/impl/common/SAXHelper.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/SAXHelper.java
@@ -15,21 +15,21 @@
package org.apache.xmlbeans.impl.common;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.Method;
-import java.util.concurrent.TimeUnit;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-
+import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.XmlOptionsBean;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.util.concurrent.TimeUnit;
+
/**
* Provides handy methods for working with SAX parsers and readers
*/
@@ -37,23 +37,24 @@ public final class SAXHelper {
private static final XBLogger logger = XBLogFactory.getLogger(SAXHelper.class);
private static long lastLog;
- private SAXHelper() {}
+ private SAXHelper() {
+ }
/**
* Creates a new SAX XMLReader, with sensible defaults
*/
- public static XMLReader newXMLReader(XmlOptionsBean options) throws SAXException, ParserConfigurationException {
+ public static XMLReader newXMLReader(XmlOptions options) throws SAXException, ParserConfigurationException {
XMLReader xmlReader = saxFactory(options).newSAXParser().getXMLReader();
xmlReader.setEntityResolver(IGNORING_ENTITY_RESOLVER);
trySetSAXFeature(xmlReader, XMLConstants.FEATURE_SECURE_PROCESSING);
trySetXercesSecurityManager(xmlReader, options);
return xmlReader;
}
-
+
public static final EntityResolver IGNORING_ENTITY_RESOLVER = new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
+ throws SAXException, IOException {
return new InputSource(new StringReader(""));
}
};
@@ -62,7 +63,7 @@ static SAXParserFactory saxFactory() {
return saxFactory(new XmlOptionsBean());
}
- static SAXParserFactory saxFactory(XmlOptionsBean options) {
+ static SAXParserFactory saxFactory(XmlOptions options) {
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
saxFactory.setValidating(false);
saxFactory.setNamespaceAware(true);
@@ -91,15 +92,15 @@ private static void trySetSAXFeature(XMLReader xmlReader, String feature) {
logger.log(XBLogger.WARN, "Cannot set SAX feature because outdated XML parser in classpath", feature, ame);
}
}
-
- private static void trySetXercesSecurityManager(XMLReader xmlReader, XmlOptionsBean options) {
+
+ private static void trySetXercesSecurityManager(XMLReader xmlReader, XmlOptions options) {
// Try built-in JVM one first, standalone if not
- for (String securityManagerClassName : new String[] {
- //"com.sun.org.apache.xerces.internal.util.SecurityManager",
- "org.apache.xerces.util.SecurityManager"
+ for (String securityManagerClassName : new String[]{
+ //"com.sun.org.apache.xerces.internal.util.SecurityManager",
+ "org.apache.xerces.util.SecurityManager"
}) {
try {
- Object mgr = Class.forName(securityManagerClassName).newInstance();
+ Object mgr = Class.forName(securityManagerClassName).getDeclaredConstructor().newInstance();
Method setLimit = mgr.getClass().getMethod("setEntityExpansionLimit", Integer.TYPE);
setLimit.invoke(mgr, options.getEntityExpansionLimit());
xmlReader.setProperty(XMLBeansConstants.SECURITY_MANAGER, mgr);
@@ -107,7 +108,7 @@ private static void trySetXercesSecurityManager(XMLReader xmlReader, XmlOptionsB
return;
} catch (Throwable e) { // NOSONAR - also catch things like NoClassDefError here
// throttle the log somewhat as it can spam the log otherwise
- if(System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
+ if (System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
logger.log(XBLogger.WARN, "SAX Security Manager could not be setup [log suppressed for 5 minutes]", e);
lastLog = System.currentTimeMillis();
}
@@ -119,7 +120,7 @@ private static void trySetXercesSecurityManager(XMLReader xmlReader, XmlOptionsB
xmlReader.setProperty(XMLBeansConstants.ENTITY_EXPANSION_LIMIT, options.getEntityExpansionLimit());
} catch (SAXException e) { // NOSONAR - also catch things like NoClassDefError here
// throttle the log somewhat as it can spam the log otherwise
- if(System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
+ if (System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5)) {
logger.log(XBLogger.WARN, "SAX Security Manager could not be setup [log suppressed for 5 minutes]", e);
lastLog = System.currentTimeMillis();
}
diff --git a/src/common/org/apache/xmlbeans/impl/common/Sax2Dom.java b/src/main/java/org/apache/xmlbeans/impl/common/Sax2Dom.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/Sax2Dom.java
rename to src/main/java/org/apache/xmlbeans/impl/common/Sax2Dom.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/SniffedXmlInputStream.java b/src/main/java/org/apache/xmlbeans/impl/common/SniffedXmlInputStream.java
new file mode 100644
index 0000000..6f2a4eb
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/SniffedXmlInputStream.java
@@ -0,0 +1,283 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import java.io.*;
+import java.nio.charset.Charset;
+
+public class SniffedXmlInputStream extends BufferedInputStream {
+ // We don't sniff more than 192 bytes.
+ public static final int MAX_SNIFFED_BYTES = 192;
+
+ public SniffedXmlInputStream(InputStream stream) throws IOException {
+ super(stream);
+
+ // read byte order marks and detect EBCDIC etc
+ _encoding = sniffFourBytes();
+
+ if (_encoding != null && _encoding.equals("IBM037")) {
+ // First four bytes suggest EBCDIC with
+ // assuming we can read it as UTF-8.
+ _encoding = sniffForXmlDecl("UTF-8");
+ }
+
+ if (_encoding == null) {
+ // The XML spec says these two things:
+
+ // (1) "In the absence of external character encoding information
+ // (such as MIME headers), parsed entities which are stored in an
+ // encoding other than UTF-8 or UTF-16 must begin with a text
+ // declaration (see 4.3.1 The Text Declaration) containing an
+ // encoding declaration:"
+
+ // (2) "In the absence of information provided by an external
+ // transport protocol (e.g. HTTP or MIME), it is an error
+ // for an entity including an encoding declaration to be
+ // presented to the XML processor in an encoding other than
+ // that named in the declaration, or for an entity which begins
+ // with neither a Byte Order Mark nor an encoding declaration
+ // to use an encoding other than UTF-8."
+
+ // Since we're using a sniffed stream, we do not have external
+ // character encoding information.
+
+ // Since we're here, we also don't have a recognized byte order
+ // mark or an explicit encoding declaration that can be read in
+ // either ASCII or EBDIC style.
+
+ // Therefore, we must use UTF-8.
+
+ _encoding = "UTF-8";
+ }
+ }
+
+ private int readAsMuchAsPossible(byte[] buf, int startAt, int len) throws IOException {
+ int total = 0;
+ while (total < len) {
+ int count = read(buf, startAt + total, len - total);
+ if (count < 0) {
+ break;
+ }
+ total += count;
+ }
+ return total;
+ }
+
+ private String sniffFourBytes() throws IOException {
+ mark(4);
+ int skip = 0;
+ try {
+ byte[] buf = new byte[4];
+ if (readAsMuchAsPossible(buf, 0, 4) < 4) {
+ return null;
+ }
+ long result = 0xFF000000 & (buf[0] << 24) | 0x00FF0000 & (buf[1] << 16) | 0x0000FF00 & (buf[2] << 8) | 0x000000FF & buf[3];
+
+ if (result == 0x0000FEFF) {
+ return "UCS-4";
+ } else if (result == 0xFFFE0000) {
+ return "UCS-4";
+ } else if (result == 0x0000003C) {
+ return "UCS-4BE";
+ } else if (result == 0x3C000000) {
+ return "UCS-4LE";
+ } else if (result == 0x003C003F) {
+ return "UTF-16BE";
+ } else if (result == 0x3C003F00) {
+ return "UTF-16LE";
+ } else if (result == 0x3C3F786D) {
+ return null; // looks like US-ASCII with = 0) {
+ int i = xmlpi + 5;
+ ScannedAttribute attr = new ScannedAttribute();
+ while (i < limit) {
+ i = scanAttribute(buf, i, limit, attr);
+ if (i < 0) {
+ return null;
+ }
+ if (attr.name.equals("encoding")) {
+ return attr.value;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static int firstIndexOf(String s, char[] buf, int startAt, int limit) {
+ assert (s.length() > 0);
+ char[] lookFor = s.toCharArray();
+
+ char firstchar = lookFor[0];
+ searching:
+ for (limit -= lookFor.length; startAt < limit; startAt++) {
+ if (buf[startAt] == firstchar) {
+ for (int i = 1; i < lookFor.length; i++) {
+ if (buf[startAt + i] != lookFor[i]) {
+ continue searching;
+ }
+ }
+ return startAt;
+ }
+ }
+
+ return -1;
+ }
+
+ private static int nextNonmatchingByte(char[] lookFor, char[] buf, int startAt, int limit) {
+ searching:
+ for (; startAt < limit; startAt++) {
+ int thischar = buf[startAt];
+ for (int i = 0; i < lookFor.length; i++) {
+ if (thischar == lookFor[i]) {
+ continue searching;
+ }
+ }
+ return startAt;
+ }
+ return -1;
+ }
+
+ private static int nextMatchingByte(char[] lookFor, char[] buf, int startAt, int limit) {
+ searching:
+ for (; startAt < limit; startAt++) {
+ int thischar = buf[startAt];
+ for (int i = 0; i < lookFor.length; i++) {
+ if (thischar == lookFor[i]) {
+ return startAt;
+ }
+ }
+ }
+ return -1;
+ }
+
+ private static int nextMatchingByte(char lookFor, char[] buf, int startAt, int limit) {
+ searching:
+ for (; startAt < limit; startAt++) {
+ if (buf[startAt] == lookFor) {
+ return startAt;
+ }
+ }
+ return -1;
+ }
+
+ private static char[] WHITESPACE = new char[]{' ', '\r', '\t', '\n'};
+ private static char[] NOTNAME = new char[]{'=', ' ', '\r', '\t', '\n', '?', '>', '<', '\'', '\"'};
+
+ private static class ScannedAttribute {
+ public String name;
+ public String value;
+ }
+
+ private static int scanAttribute(char[] buf, int startAt, int limit, ScannedAttribute attr) {
+ int nameStart = nextNonmatchingByte(WHITESPACE, buf, startAt, limit);
+ if (nameStart < 0) {
+ return -1;
+ }
+ int nameEnd = nextMatchingByte(NOTNAME, buf, nameStart, limit);
+ if (nameEnd < 0) {
+ return -1;
+ }
+ int equals = nextNonmatchingByte(WHITESPACE, buf, nameEnd, limit);
+ if (equals < 0) {
+ return -1;
+ }
+ if (buf[equals] != '=') {
+ return -1;
+ }
+ int valQuote = nextNonmatchingByte(WHITESPACE, buf, equals + 1, limit);
+ if (buf[valQuote] != '\'' && buf[valQuote] != '\"') {
+ return -1;
+ }
+ int valEndquote = nextMatchingByte(buf[valQuote], buf, valQuote + 1, limit);
+ if (valEndquote < 0) {
+ return -1;
+ }
+ attr.name = new String(buf, nameStart, nameEnd - nameStart);
+ attr.value = new String(buf, valQuote + 1, valEndquote - valQuote - 1);
+ return valEndquote + 1;
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/SniffedXmlReader.java b/src/main/java/org/apache/xmlbeans/impl/common/SniffedXmlReader.java
similarity index 82%
rename from src/common/org/apache/xmlbeans/impl/common/SniffedXmlReader.java
rename to src/main/java/org/apache/xmlbeans/impl/common/SniffedXmlReader.java
index b497814..214ec4d 100644
--- a/src/common/org/apache/xmlbeans/impl/common/SniffedXmlReader.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/SniffedXmlReader.java
@@ -15,30 +15,27 @@
package org.apache.xmlbeans.impl.common;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
-import java.io.BufferedReader;
import java.nio.charset.Charset;
-public class SniffedXmlReader extends BufferedReader
-{
+public class SniffedXmlReader extends BufferedReader {
// We don't sniff more than 192 bytes.
- public static int MAX_SNIFFED_CHARS = 192;
+ public static final int MAX_SNIFFED_CHARS = 192;
- public SniffedXmlReader(Reader reader) throws IOException
- {
+ public SniffedXmlReader(Reader reader) throws IOException {
super(reader);
_encoding = sniffForXmlDecl();
}
- private int readAsMuchAsPossible(char[] buf, int startAt, int len) throws IOException
- {
+ private int readAsMuchAsPossible(char[] buf, int startAt, int len) throws IOException {
int total = 0;
- while (total < len)
- {
+ while (total < len) {
int count = read(buf, startAt + total, len - total);
- if (count < 0)
+ if (count < 0) {
break;
+ }
total += count;
}
return total;
@@ -56,25 +53,20 @@ private int readAsMuchAsPossible(char[] buf, int startAt, int len) throws IOExce
private static Charset dummy7 = Charset.forName("Cp1252");
- private String sniffForXmlDecl() throws IOException
- {
+ private String sniffForXmlDecl() throws IOException {
mark(MAX_SNIFFED_CHARS);
- try
- {
+ try {
char[] buf = new char[MAX_SNIFFED_CHARS];
int limit = readAsMuchAsPossible(buf, 0, MAX_SNIFFED_CHARS);
return SniffedXmlInputStream.extractXmlDeclEncoding(buf, 0, limit);
- }
- finally
- {
+ } finally {
reset();
}
}
private String _encoding;
- public String getXmlEncoding()
- {
+ public String getXmlEncoding() {
return _encoding;
}
}
diff --git a/src/common/org/apache/xmlbeans/impl/common/SoftCache.java b/src/main/java/org/apache/xmlbeans/impl/common/SoftCache.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/SoftCache.java
rename to src/main/java/org/apache/xmlbeans/impl/common/SoftCache.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/StaxHelper.java b/src/main/java/org/apache/xmlbeans/impl/common/StaxHelper.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/StaxHelper.java
rename to src/main/java/org/apache/xmlbeans/impl/common/StaxHelper.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java b/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java
new file mode 100644
index 0000000..a6d6f47
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/SystemCache.java
@@ -0,0 +1,97 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xmlbeans.impl.common;
+
+import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.SystemProperties;
+
+import java.lang.ref.SoftReference;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * This class encapsulates the caching strategy for XmlBeans.
+ * By subclassing this, a client of XmlBeans can implement caches that are
+ * more suitable for different applications using information that XmlBeans
+ * cannot know.
+ *
+ * This class works as a singleton and as a default implementation for the cache.
+ * You can set a particular implementation using the "xmlbean.systemcacheimpl"
+ * system property or using the static {@link #set(SystemCache)} method.
+ * Subclasses of this need to be thread-safe. An implementation can be replaced
+ * at any time, so use of static variables is discouraged to ensure proper cleanup.
+ */
+public class SystemCache {
+ private static SystemCache INSTANCE = new SystemCache();
+
+ static {
+ String cacheClass = SystemProperties.getProperty("xmlbean.systemcacheimpl");
+ Object impl = null;
+ if (cacheClass != null) {
+ try {
+ impl = Class.forName(cacheClass).getDeclaredConstructor().newInstance();
+ if (!(impl instanceof SystemCache)) {
+ throw new ClassCastException("Value for system property " +
+ "\"xmlbean.systemcacheimpl\" points to a class (" + cacheClass +
+ ") which does not derive from SystemCache");
+ }
+ } catch (ClassNotFoundException cnfe) {
+ throw new RuntimeException("Cache class " + cacheClass +
+ " specified by \"xmlbean.systemcacheimpl\" was not found.",
+ cnfe);
+ } catch (InstantiationException | NoSuchMethodException | InvocationTargetException ie) {
+ throw new RuntimeException("Could not instantiate class " +
+ cacheClass + " as specified by \"xmlbean.systemcacheimpl\"." +
+ " An empty constructor may be missing.", ie);
+ } catch (IllegalAccessException iae) {
+ throw new RuntimeException("Could not instantiate class " +
+ cacheClass + " as specified by \"xmlbean.systemcacheimpl\"." +
+ " A public empty constructor may be missing.", iae);
+ }
+ }
+ if (impl != null) {
+ INSTANCE = (SystemCache) impl;
+ }
+ }
+
+ public static synchronized void set(SystemCache instance) {
+ INSTANCE = instance;
+ }
+
+ public static SystemCache get() {
+ return INSTANCE;
+ }
+
+ public SchemaTypeLoader getFromTypeLoaderCache(ClassLoader cl) {
+ return null;
+ }
+
+ public void addToTypeLoaderCache(SchemaTypeLoader stl, ClassLoader cl) {
+ }
+
+ private ThreadLocal tl_saxLoaders = new ThreadLocal<>();
+
+ public void clearThreadLocals() {
+ tl_saxLoaders.remove();
+ }
+
+ public Object getSaxLoader() {
+ SoftReference s = tl_saxLoaders.get();
+ return s == null ? null : s.get();
+ }
+
+ public void setSaxLoader(Object saxLoader) {
+ tl_saxLoaders.set(new SoftReference(saxLoader));
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/ValidationContext.java b/src/main/java/org/apache/xmlbeans/impl/common/ValidationContext.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/ValidationContext.java
rename to src/main/java/org/apache/xmlbeans/impl/common/ValidationContext.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/ValidatorListener.java b/src/main/java/org/apache/xmlbeans/impl/common/ValidatorListener.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/ValidatorListener.java
rename to src/main/java/org/apache/xmlbeans/impl/common/ValidatorListener.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XBLogFactory.java b/src/main/java/org/apache/xmlbeans/impl/common/XBLogFactory.java
similarity index 97%
rename from src/common/org/apache/xmlbeans/impl/common/XBLogFactory.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XBLogFactory.java
index 0afac4d..f0b8840 100644
--- a/src/common/org/apache/xmlbeans/impl/common/XBLogFactory.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/XBLogFactory.java
@@ -101,7 +101,7 @@ public static XBLogger getLogger(final String cat) {
@SuppressWarnings("unchecked")
Class extends XBLogger> loggerClass =
(Class extends XBLogger>) Class.forName(_loggerClassName);
- logger = loggerClass.newInstance();
+ logger = loggerClass.getDeclaredConstructor().newInstance();
logger.initialize(cat);
} catch(Exception e) {
// Give up and use the null logger
diff --git a/src/common/org/apache/xmlbeans/impl/common/XBLogger.java b/src/main/java/org/apache/xmlbeans/impl/common/XBLogger.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XBLogger.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XBLogger.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java b/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java
new file mode 100644
index 0000000..b2b62af
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/XBeanDebug.java
@@ -0,0 +1,100 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import org.apache.xmlbeans.SystemProperties;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+
+public class XBeanDebug {
+ public static final int TRACE_SCHEMA_LOADING = 0x0001;
+ public static final String traceProp = "org.apache.xmlbeans.impl.debug";
+ public static final String defaultProp = ""; // "TRACE_SCHEMA_LOADING";
+
+ private static int _enabled = initializeBitsFromProperty();
+ private static int _indent = 0;
+
+ private static int initializeBitsFromProperty() {
+ String prop = SystemProperties.getProperty(traceProp, defaultProp);
+ return (prop.contains("TRACE_SCHEMA_LOADING")) ? TRACE_SCHEMA_LOADING : 0;
+ }
+
+ public static void enable(int bits) {
+ _enabled = _enabled | bits;
+ }
+
+ public static void disable(int bits) {
+ _enabled = _enabled & ~bits;
+ }
+
+ public static void trace(int bits, String message, int indent) {
+ if (test(bits)) {
+ synchronized (XBeanDebug.class) {
+ if (indent < 0) {
+ _indent += indent;
+ }
+
+ String _indentspace = " ";
+ String spaces = _indent < 0 ? "" : _indent > _indentspace.length() ? _indentspace : _indentspace.substring(0, _indent);
+ String logmessage = Thread.currentThread().getName() + ": " + spaces + message + "\n";
+ System.err.print(logmessage);
+
+ if (indent > 0) {
+ _indent += indent;
+ }
+ }
+ }
+ }
+
+ public static boolean test(int bits) {
+ return (_enabled & bits) != 0;
+ }
+
+ static PrintStream _err;
+
+ public static String log(String message) {
+ log(message, null);
+ return message;
+ }
+
+ public static String logStackTrace(String message) {
+ log(message, new Throwable());
+ return message;
+ }
+
+ private synchronized static String log(String message, Throwable stackTrace) {
+ if (_err == null) {
+ try {
+ File diagnosticFile = File.createTempFile("xmlbeandebug", ".log");
+ _err = new PrintStream(diagnosticFile, "UTF-8");
+ System.err.println("Diagnostic XML Bean debug log file created: " + diagnosticFile);
+ } catch (IOException e) {
+ _err = System.err;
+ }
+ }
+ _err.println(message);
+ if (stackTrace != null) {
+ stackTrace.printStackTrace(_err);
+ }
+ return message;
+ }
+
+ public static void logException(Throwable t) {
+ log(t.getMessage(), t);
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/XMLBeansConstants.java b/src/main/java/org/apache/xmlbeans/impl/common/XMLBeansConstants.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XMLBeansConstants.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XMLBeansConstants.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XMLChar.java b/src/main/java/org/apache/xmlbeans/impl/common/XMLChar.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XMLChar.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XMLChar.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XMLNameHelper.java b/src/main/java/org/apache/xmlbeans/impl/common/XMLNameHelper.java
similarity index 98%
rename from src/common/org/apache/xmlbeans/impl/common/XMLNameHelper.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XMLNameHelper.java
index 505c76c..eceeec7 100644
--- a/src/common/org/apache/xmlbeans/impl/common/XMLNameHelper.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/XMLNameHelper.java
@@ -76,7 +76,7 @@ private static boolean isSafe(int c)
public static String hexsafe(String s)
{
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++)
{
char ch = s.charAt(i);
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlEncodingSniffer.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlEncodingSniffer.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlEncodingSniffer.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlEncodingSniffer.java
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XmlErrorPrinter.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlErrorPrinter.java
new file mode 100644
index 0000000..2183252
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/XmlErrorPrinter.java
@@ -0,0 +1,54 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import org.apache.xmlbeans.XmlError;
+
+import java.net.URI;
+import java.util.AbstractCollection;
+import java.util.Collections;
+import java.util.Iterator;
+
+public class XmlErrorPrinter extends AbstractCollection {
+ private final boolean _noisy;
+ private final URI _baseURI;
+
+ public XmlErrorPrinter(boolean noisy, URI baseURI) {
+ _noisy = noisy;
+ _baseURI = baseURI;
+ }
+
+ public boolean add(XmlError err) {
+ if (err != null) {
+ if (err.getSeverity() == XmlError.SEVERITY_ERROR ||
+ err.getSeverity() == XmlError.SEVERITY_WARNING) {
+ System.err.println(err.toString(_baseURI));
+ } else if (_noisy) {
+ System.out.println(err.toString(_baseURI));
+ }
+ }
+ return false;
+ }
+
+ public Iterator iterator() {
+ return Collections.emptyIterator();
+ }
+
+ public int size() {
+ return 0;
+ }
+}
+
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XmlErrorWatcher.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlErrorWatcher.java
new file mode 100644
index 0000000..b13ab5e
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/common/XmlErrorWatcher.java
@@ -0,0 +1,66 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import org.apache.xmlbeans.XmlError;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+public class XmlErrorWatcher extends AbstractCollection {
+ private final Collection _underlying;
+ private XmlError _firstError;
+
+ public XmlErrorWatcher(Collection underlying) {
+ _underlying = underlying;
+ }
+
+ public boolean add(XmlError o) {
+ if (_firstError == null && o != null && o.getSeverity() == XmlError.SEVERITY_ERROR) {
+ _firstError = o;
+ }
+ if (_underlying == null) {
+ return false;
+ }
+ return _underlying.add(o);
+ }
+
+ public Iterator iterator() {
+ if (_underlying == null) {
+ return Collections.emptyIterator();
+ }
+
+ return _underlying.iterator();
+ }
+
+ public int size() {
+ if (_underlying == null) {
+ return 0;
+ }
+
+ return _underlying.size();
+ }
+
+ public boolean hasError() {
+ return _firstError != null;
+ }
+
+ public XmlError firstError() {
+ return _firstError;
+ }
+}
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlEventBase.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlEventBase.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlEventBase.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlEventBase.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlLocale.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlLocale.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlLocale.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlLocale.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlNameImpl.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlNameImpl.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlNameImpl.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlNameImpl.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlObjectList.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlObjectList.java
similarity index 98%
rename from src/common/org/apache/xmlbeans/impl/common/XmlObjectList.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlObjectList.java
index ca8970e..cce6f24 100644
--- a/src/common/org/apache/xmlbeans/impl/common/XmlObjectList.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/XmlObjectList.java
@@ -120,7 +120,7 @@ private static String prettytrim(String s)
}
public String toString() {
- StringBuffer b = new StringBuffer();
+ StringBuilder b = new StringBuilder();
for (int i = 0 ; i < _objects.length ; i++)
{
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlReaderToWriter.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlReaderToWriter.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlReaderToWriter.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlReaderToWriter.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlStreamUtils.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlStreamUtils.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlStreamUtils.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlStreamUtils.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/XmlWhitespace.java b/src/main/java/org/apache/xmlbeans/impl/common/XmlWhitespace.java
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/XmlWhitespace.java
rename to src/main/java/org/apache/xmlbeans/impl/common/XmlWhitespace.java
diff --git a/src/common/org/apache/xmlbeans/impl/common/readme.txt b/src/main/java/org/apache/xmlbeans/impl/common/readme.txt
similarity index 100%
rename from src/common/org/apache/xmlbeans/impl/common/readme.txt
rename to src/main/java/org/apache/xmlbeans/impl/common/readme.txt
diff --git a/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java b/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java
new file mode 100755
index 0000000..08d87a7
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java
@@ -0,0 +1,331 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.config;
+
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.schema.StscState;
+import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument.Config;
+import org.apache.xmlbeans.impl.xb.xmlconfig.*;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.util.*;
+
+/**
+ * An implementation of BindingConfig
+ */
+public class BindingConfigImpl extends BindingConfig {
+ private final Map _packageMap = new LinkedHashMap();
+ private final Map _prefixMap = new LinkedHashMap();
+ private final Map _suffixMap = new LinkedHashMap();
+ // uri prefix -> package
+ private final Map