remove xpath/xquery delegate constructs
rearrange xpath classes to one package
extract xpath factory methods to separate package
use generics instead of raw containers
git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/trunk@1881423 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/xmlbeans/XmlOptions.java b/src/main/java/org/apache/xmlbeans/XmlOptions.java
index fc0e649..6e3e484 100644
--- a/src/main/java/org/apache/xmlbeans/XmlOptions.java
+++ b/src/main/java/org/apache/xmlbeans/XmlOptions.java
@@ -150,8 +150,7 @@
LOAD_EXTERNAL_DTD,
SAAJ_IMPL,
LOAD_USE_LOCALE_CHAR_UTIL,
- PATH_DELEGATE_INTERFACE,
- XPATH_USE_DELEGATE,
+ XPATH_USE_SAXON,
XPATH_USE_XMLBEANS,
ATTTRIBUTE_VALIDATION_COMPAT_MODE
}
@@ -1273,7 +1272,7 @@
}
public boolean isCopyUseNewSynchronizationDomain() {
- Boolean flag = (Boolean)get(XmlOptionsKeys.COPY_USE_NEW_SYNC_DOMAIN);
+ Boolean flag = (Boolean) get(XmlOptionsKeys.COPY_USE_NEW_SYNC_DOMAIN);
return flag != null && flag;
}
@@ -1365,7 +1364,7 @@
}
public Saaj getSaaj() {
- return (Saaj)get(XmlOptionsKeys.SAAJ_IMPL);
+ return (Saaj) get(XmlOptionsKeys.SAAJ_IMPL);
}
public XmlOptions setLoadUseLocaleCharUtil(boolean useCharUtil) {
@@ -1377,29 +1376,29 @@
return flag != null && flag;
}
- public XmlOptions setXPathUseDelegate() {
- return setXPathUseDelegate(true);
+ public XmlOptions setXPathUseSaxon() {
+ return setXPathUseSaxon(true);
}
- public XmlOptions setXPathUseDelegate(boolean xpathUseDelegate) {
- return set(XmlOptionsKeys.XPATH_USE_DELEGATE, xpathUseDelegate);
+ public XmlOptions setXPathUseSaxon(boolean xpathUseSaxon) {
+ return set(XmlOptionsKeys.XPATH_USE_SAXON, xpathUseSaxon);
}
- public boolean isXPathUseDelegate() {
- Boolean flag = (Boolean)get(XmlOptionsKeys.XPATH_USE_DELEGATE);
+ public boolean isXPathUseSaxon() {
+ Boolean flag = (Boolean) get(XmlOptionsKeys.XPATH_USE_SAXON);
return flag != null && flag;
}
public XmlOptions setXPathUseXmlBeans() {
- return setXPathUseDelegate(true);
+ return setXPathUseSaxon(true);
}
- public XmlOptions setXPathUseXmlBeans(boolean xpathUseDelegate) {
- return set(XmlOptionsKeys.XPATH_USE_XMLBEANS, xpathUseDelegate);
+ public XmlOptions setXPathUseXmlBeans(boolean xpathUseXmlBeans) {
+ return set(XmlOptionsKeys.XPATH_USE_XMLBEANS, xpathUseXmlBeans);
}
public boolean isXPathUseXmlBeans() {
- Boolean flag = (Boolean)get(XmlOptionsKeys.XPATH_USE_XMLBEANS);
+ Boolean flag = (Boolean) get(XmlOptionsKeys.XPATH_USE_XMLBEANS);
return flag != null && flag;
}
@@ -1408,7 +1407,7 @@
}
public boolean isAttributeValidationCompatMode() {
- Boolean flag = (Boolean)get(XmlOptionsKeys.ATTTRIBUTE_VALIDATION_COMPAT_MODE);
+ Boolean flag = (Boolean) get(XmlOptionsKeys.ATTTRIBUTE_VALIDATION_COMPAT_MODE);
return flag != null && flag;
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java b/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
index b39300e..55242e6 100644
--- a/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
+++ b/src/main/java/org/apache/xmlbeans/impl/common/IdentityConstraint.java
@@ -17,6 +17,8 @@
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;
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
index 196d24a..f06c544 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
@@ -15,18 +15,14 @@
package org.apache.xmlbeans.impl.schema;
-import org.apache.xmlbeans.SchemaIdentityConstraint;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.SchemaAnnotation;
-import org.apache.xmlbeans.SchemaComponent;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.impl.common.XPath;
-import javax.xml.namespace.QName;
-import java.util.Map;
-import java.util.Collections;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.xpath.XPath;
-public class SchemaIdentityConstraintImpl implements SchemaIdentityConstraint
-{
+import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.Map;
+
+public class SchemaIdentityConstraintImpl implements SchemaIdentityConstraint {
private SchemaContainer _container;
private String _selector;
private String[] _fields;
@@ -49,11 +45,13 @@
_container = c;
}
- public void setFilename(String filename)
- { _filename = filename; }
+ public void setFilename(String filename) {
+ _filename = filename;
+ }
- public String getSourceName()
- { return _filename; }
+ public String getSourceName() {
+ return _filename;
+ }
public String getSelector() {
@@ -66,22 +64,19 @@
try {
buildPaths();
p = _selectorPath;
- }
- catch (XPath.XPathCompileException e) {
- assert false: "Failed to compile xpath. Should be caught by compiler " + e;
+ } catch (XPath.XPathCompileException e) {
+ assert false : "Failed to compile xpath. Should be caught by compiler " + e;
return null;
}
}
return p;
}
- public void setAnnotation(SchemaAnnotation ann)
- {
+ public void setAnnotation(SchemaAnnotation ann) {
_annotation = ann;
}
- public SchemaAnnotation getAnnotation()
- {
+ public SchemaAnnotation getAnnotation() {
return _annotation;
}
@@ -115,9 +110,8 @@
try {
buildPaths();
p = _fieldPaths;
- }
- catch (XPath.XPathCompileException e) {
- assert false: "Failed to compile xpath. Should be caught by compiler " + e;
+ } catch (XPath.XPathCompileException e) {
+ assert false : "Failed to compile xpath. Should be caught by compiler " + e;
return null;
}
}
@@ -129,8 +123,9 @@
_selectorPath = XPath.compileXPath(_selector, _nsMap);
_fieldPaths = new XPath[_fields.length];
- for (int i = 0 ; i < _fieldPaths.length ; i++)
+ for (int i = 0; i < _fieldPaths.length; i++) {
_fieldPaths[i] = XPath.compileXPath(_fields[i], _nsMap);
+ }
}
public void setReferencedKey(SchemaIdentityConstraint.Ref key) {
@@ -199,15 +194,19 @@
private SchemaIdentityConstraint.Ref _selfref = new SchemaIdentityConstraint.Ref(this);
- public SchemaIdentityConstraint.Ref getRef()
- { return _selfref; }
+ public SchemaIdentityConstraint.Ref getRef() {
+ return _selfref;
+ }
- public SchemaComponent.Ref getComponentRef()
- { return getRef(); }
+ public SchemaComponent.Ref getComponentRef() {
+ return getRef();
+ }
- public Object getUserData()
- { return _userData; }
+ public Object getUserData() {
+ return _userData;
+ }
- public void setUserData(Object data)
- { _userData = data; }
+ public void setUserData(Object data) {
+ _userData = data;
+ }
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java
index ff80dcb..1dfc45f 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderBase.java
@@ -19,6 +19,7 @@
import org.apache.xmlbeans.impl.common.QNameHelper;
import org.apache.xmlbeans.impl.store.Locale;
import org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
import org.apache.xmlbeans.xml.stream.XMLInputStream;
import org.apache.xmlbeans.xml.stream.XMLStreamException;
import org.w3c.dom.DOMImplementation;
@@ -27,8 +28,6 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@@ -41,39 +40,12 @@
public abstract class SchemaTypeLoaderBase implements SchemaTypeLoader {
private static final String USER_AGENT = "XMLBeans/" + XmlBeans.getVersion() + " (" + XmlBeans.getTitle() + ")";
- private static final Method _pathCompiler = getMethod("org.apache.xmlbeans.impl.store.Path", "compilePath", new Class[]{String.class, XmlOptions.class});
- private static final Method _queryCompiler = getMethod("org.apache.xmlbeans.impl.store.Query", "compileQuery", new Class[]{String.class, XmlOptions.class});
-
- private static Method getMethod(String className, String methodName, Class[] args) {
- try {
- return
- Class.forName(className).
- getDeclaredMethod(methodName, args);
- } catch (Exception e) {
- throw new IllegalStateException(
- "Cannot find " + className + "." + methodName +
- ". verify that xmlstore " +
- "(from xbean.jar) is on classpath");
- }
- }
-
- private static Object invokeMethod(Method method, Object[] args) {
- try {
- return method.invoke(method, args);
- } catch (InvocationTargetException e) {
- Throwable t = e.getCause();
- throw new IllegalStateException(t.getMessage(), t);
- } catch (Exception e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
private static String doCompilePath(String pathExpr, XmlOptions options) {
- return (String) invokeMethod(_pathCompiler, new Object[]{pathExpr, options});
+ return XPathFactory.compilePath(pathExpr, options);
}
private static String doCompileQuery(String queryExpr, XmlOptions options) {
- return (String) invokeMethod(_queryCompiler, new Object[]{queryExpr, options});
+ return XPathFactory.compileQuery(queryExpr, options);
}
public SchemaType findType(QName name) {
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java b/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java
index 365f73e..3ed0e75 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/StscJavaizer.java
@@ -15,30 +15,14 @@
package org.apache.xmlbeans.impl.schema;
+import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.common.NameUtil;
-import org.apache.xmlbeans.QNameSetBuilder;
-import org.apache.xmlbeans.SchemaField;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaProperty;
-import org.apache.xmlbeans.QNameSet;
-import org.apache.xmlbeans.UserType;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.SchemaStringEnumEntry;
-import org.apache.xmlbeans.XmlByte;
-import org.apache.xmlbeans.XmlShort;
-import org.apache.xmlbeans.InterfaceExtension;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.PrePostExtension;
-import org.apache.xmlbeans.BindingConfig;
-
-import java.util.*;
-import java.math.BigInteger;
import javax.xml.namespace.QName;
+import java.math.BigInteger;
+import java.util.*;
-public class StscJavaizer
-{
+public class StscJavaizer {
/**
* XMLBEANS-307
@@ -46,35 +30,35 @@
* xmlbeans scomp will fail with a code too large error
*/
private static final int MAX_ENUM_COUNT = 3668;
+
/**
* Does a topo walk of all the types to resolve them.
*/
- public static void javaizeAllTypes(boolean javaize)
- {
+ public static void javaizeAllTypes(boolean javaize) {
StscState state = StscState.get();
- List allSeenTypes = new ArrayList();
+ List<SchemaType> allSeenTypes = new ArrayList<>();
allSeenTypes.addAll(Arrays.asList(state.documentTypes()));
allSeenTypes.addAll(Arrays.asList(state.attributeTypes()));
allSeenTypes.addAll(Arrays.asList(state.globalTypes()));
// First distribute the global names among the top entities.
- if (javaize)
+ if (javaize) {
assignGlobalJavaNames(allSeenTypes);
+ }
// now fully javaize everything deeply.
- for (int i = 0; i < allSeenTypes.size(); i++)
- {
- SchemaType gType = (SchemaType)allSeenTypes.get(i);
- if (javaize)
- {
- javaizeType((SchemaTypeImpl)gType);
+ for (int i = 0; i < allSeenTypes.size(); i++) {
+ SchemaType gType = allSeenTypes.get(i);
+ if (javaize) {
+ javaizeType((SchemaTypeImpl) gType);
String className = gType.getFullJavaName();
- if (className != null)
+ if (className != null) {
state.addClassname(className.replace('$', '.'), gType);
+ }
+ } else {
+ skipJavaizingType((SchemaTypeImpl) gType);
}
- else
- skipJavaizingType((SchemaTypeImpl)gType);
allSeenTypes.addAll(Arrays.asList(gType.getAnonymousTypes()));
// We need to javaize the anonymous types defined inside redefined types
// since redefined type do not get a Java class of their own.
@@ -84,19 +68,16 @@
}
}
- static void assignGlobalJavaNames(Collection schemaTypes)
- {
- HashSet usedNames = new HashSet();
+ static void assignGlobalJavaNames(Collection<SchemaType> schemaTypes) {
+ HashSet<String> usedNames = new HashSet<>();
StscState state = StscState.get();
- for (Iterator i = schemaTypes.iterator(); i.hasNext(); )
- {
- SchemaTypeImpl sImpl = (SchemaTypeImpl)i.next();
+ for (SchemaType schemaType : schemaTypes) {
+ SchemaTypeImpl sImpl = (SchemaTypeImpl) schemaType;
QName topName = findTopName(sImpl);
String pickedName = state.getJavaname(topName, sImpl.isDocumentType() ?
BindingConfig.QNAME_DOCUMENT_TYPE : BindingConfig.QNAME_TYPE);
- if (sImpl.isUnjavaized())
- {
+ if (sImpl.isUnjavaized()) {
sImpl.setFullJavaName(pickFullJavaClassName(usedNames, findTopName(sImpl), pickedName, sImpl.isDocumentType(), sImpl.isAttributeType()));
sImpl.setFullJavaImplName(pickFullJavaImplName(usedNames, sImpl.getFullJavaName()));
@@ -109,84 +90,77 @@
verifyInterfaceNameCollisions(usedNames, state);
}
- private static void verifyInterfaceNameCollisions(Set usedNames, StscState state)
- {
+ private static void verifyInterfaceNameCollisions(Set<String> usedNames, StscState state) {
BindingConfig config = state.getBindingConfig();
- if (config == null)
+ if (config == null) {
return;
+ }
InterfaceExtension[] exts = config.getInterfaceExtensions();
- for (int i = 0; i < exts.length; i++)
- {
- if (usedNames.contains(exts[i].getInterface().toLowerCase()))
- state.error("InterfaceExtension interface '" + exts[i].getInterface() + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+ for (InterfaceExtension ext : exts) {
+ if (usedNames.contains(ext.getInterface().toLowerCase())) {
+ state.error("InterfaceExtension interface '" + ext.getInterface() + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+ }
- String handler = exts[i].getStaticHandler();
- if (handler != null && usedNames.contains(handler.toLowerCase()))
+ String handler = ext.getStaticHandler();
+ if (handler != null && usedNames.contains(handler.toLowerCase())) {
state.error("InterfaceExtension handler class '" + handler + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+ }
}
PrePostExtension[] prepost = config.getPrePostExtensions();
- for (int i = 0; i < prepost.length; i++)
- {
- String handler = prepost[i].getStaticHandler();
- if (handler != null && usedNames.contains(handler.toLowerCase()))
+ for (PrePostExtension prePostExtension : prepost) {
+ String handler = prePostExtension.getStaticHandler();
+ if (handler != null && usedNames.contains(handler.toLowerCase())) {
state.error("PrePostExtension handler class '" + handler + "' creates a name collision with one of the generated interfaces or classes.", XmlError.SEVERITY_ERROR, null);
+ }
}
}
- private static void setUserTypes(SchemaTypeImpl sImpl, StscState state)
- {
+ private static void setUserTypes(SchemaTypeImpl sImpl, StscState state) {
BindingConfig config = state.getBindingConfig();
- if (config != null)
- {
+ if (config != null) {
UserType utype = config.lookupUserTypeForQName(sImpl.getName());
- if (utype != null)
- {
+ if (utype != null) {
sImpl.setUserTypeName(utype.getJavaName());
sImpl.setUserTypeHandlerName(utype.getStaticHandler());
}
}
}
- private static void setExtensions(SchemaTypeImpl sImpl, StscState state)
- {
+ private static void setExtensions(SchemaTypeImpl sImpl, StscState state) {
String javaName = sImpl.getFullJavaName();
BindingConfig config = state.getBindingConfig();
- if (javaName != null && config != null)
- {
+ if (javaName != null && config != null) {
sImpl.setInterfaceExtensions(config.getInterfaceExtensions(javaName));
sImpl.setPrePostExtension(config.getPrePostExtension(javaName));
}
}
- private static boolean isStringType(SchemaType type)
- {
- if (type == null || type.getSimpleVariety() != SchemaType.ATOMIC)
+ private static boolean isStringType(SchemaType type) {
+ if (type == null || type.getSimpleVariety() != SchemaType.ATOMIC) {
return false;
+ }
return (type.getPrimitiveType().getBuiltinTypeCode() == SchemaType.BTC_STRING);
}
- static String pickConstantName(Set usedNames, String words)
- {
+ static String pickConstantName(Set<String> usedNames, String words) {
String base = NameUtil.upperCaseUnderbar(words);
- if (base.length() == 0)
- {
+ if (base.length() == 0) {
base = "X";
}
- if (base.startsWith("INT_")) // reserved for int codes
- {
+ if (base.startsWith("INT_")) {
+ // reserved for int codes
base = "X_" + base;
}
String uniqName;
int index = 1;
- for (uniqName = base; usedNames.contains(uniqName); )
- {
+ for (uniqName = base; usedNames.contains(uniqName); ) {
index++;
uniqName = base + "_" + index;
}
@@ -196,77 +170,73 @@
return uniqName;
}
- static void skipJavaizingType(SchemaTypeImpl sImpl)
- {
- if (sImpl.isJavaized())
+ static void skipJavaizingType(SchemaTypeImpl sImpl) {
+ if (sImpl.isJavaized()) {
return;
-
- SchemaTypeImpl baseType = (SchemaTypeImpl)sImpl.getBaseType();
- if (baseType != null)
+ }
+
+ SchemaTypeImpl baseType = (SchemaTypeImpl) sImpl.getBaseType();
+ if (baseType != null) {
skipJavaizingType(baseType);
-
+ }
+
sImpl.startJavaizing();
secondPassProcessType(sImpl);
sImpl.finishJavaizing();
}
- static void secondPassProcessType(SchemaTypeImpl sImpl)
- {
- if (isStringType(sImpl))
- {
- XmlAnySimpleType[] enumVals = sImpl.getEnumerationValues();
+ static void secondPassProcessType(SchemaTypeImpl sImpl) {
+ if (!isStringType(sImpl)) {
+ return;
+ }
- // if this is an enumerated string type, values are to be
- // javaized as constants.
- if (enumVals != null)
- {
- //ERROR is found at > 3668
- if (enumVals.length > MAX_ENUM_COUNT)
- {
- StscState.get().warning("SchemaType Enumeration found with too many enumeration values " +
- "to create a Java enumeration. The base SchemaType \"" +
- sImpl.getBaseEnumType() + "\" will be used instead", XmlError.SEVERITY_WARNING, null);
+ XmlAnySimpleType[] enumVals = sImpl.getEnumerationValues();
- sImpl = (SchemaTypeImpl) sImpl.getBaseEnumType();
- }
- else
- {
- SchemaStringEnumEntry[] entryArray = new SchemaStringEnumEntry[enumVals.length];
- SchemaType basedOn = sImpl.getBaseEnumType();
- if (basedOn == sImpl)
- {
- Set usedNames = new HashSet();
- for (int i = 0; i < enumVals.length; i++)
- {
- String val = enumVals[i].getStringValue();
+ // if this is an enumerated string type, values are to be
+ // javaized as constants.
+ if (enumVals == null) {
+ return;
+ }
- entryArray[i] = new SchemaStringEnumEntryImpl(val, i + 1, pickConstantName(usedNames, val));
- }
- }
- else
- {
- for (int i = 0; i < enumVals.length; i++)
- {
- String val = enumVals[i].getStringValue();
- entryArray[i] = basedOn.enumEntryForString(val);
- }
- }
- sImpl.setStringEnumEntries(entryArray);
- }
+ // ERROR is found at > 3668
+ if (enumVals.length > MAX_ENUM_COUNT) {
+ StscState.get().warning("SchemaType Enumeration found with too many enumeration values to create a Java " +
+ "enumeration. The base SchemaType \"" + sImpl.getBaseEnumType() + "\" will be used instead", XmlError.SEVERITY_WARNING, null);
+ return;
+ }
+ SchemaType basedOn = sImpl.getBaseEnumType();
+ if (basedOn == null) {
+ return;
+ }
+
+ SchemaStringEnumEntry[] entryArray = new SchemaStringEnumEntry[enumVals.length];
+ if (basedOn == sImpl) {
+ Set<String> usedNames = new HashSet<>();
+ for (int i = 0; i < enumVals.length; i++) {
+ String val = enumVals[i].getStringValue();
+ entryArray[i] = new SchemaStringEnumEntryImpl(val, i + 1, pickConstantName(usedNames, val));
+ }
+ } else {
+ for (int i = 0; i < enumVals.length; i++) {
+ String val = enumVals[i].getStringValue();
+ entryArray[i] = basedOn.enumEntryForString(val);
}
}
+ sImpl.setStringEnumEntries(entryArray);
}
- static void javaizeType(SchemaTypeImpl sImpl)
- {
- if (sImpl.isJavaized())
+ static void javaizeType(SchemaTypeImpl sImpl) {
+ if (sImpl.isJavaized()) {
return;
+ }
- SchemaTypeImpl baseType = (SchemaTypeImpl)sImpl.getBaseType();
- if (baseType != null)
+ SchemaTypeImpl baseType = (SchemaTypeImpl) sImpl.getBaseType();
+ if (baseType != null) {
javaizeType(baseType);
- if (sImpl.getContentBasedOnType() != null && sImpl.getContentBasedOnType() != baseType)
+ }
+ if (sImpl.getContentBasedOnType() != null && sImpl.getContentBasedOnType() != baseType) {
javaizeType((SchemaTypeImpl) sImpl.getContentBasedOnType());
+ }
sImpl.startJavaizing();
@@ -274,21 +244,19 @@
secondPassProcessType(sImpl);
- if (!sImpl.isSimpleType())
- {
+ if (!sImpl.isSimpleType()) {
SchemaProperty[] eltProps = sImpl.getElementProperties();
SchemaProperty[] attrProps = sImpl.getAttributeProperties();
// Handing out java names - this permits us to avoid collisions.
- Set usedPropNames = new HashSet();
+ Set<String> usedPropNames = new HashSet<>();
// First, copy all used property names from base, since these
// cannnot be changed at this point and they may be arbitrary
// because of derivation by restriction and the "nopvr" switch
SchemaProperty[] baseProps = baseType.getProperties();
- for (int i = 0; i < baseProps.length; i++)
- {
- String name = baseProps[i].getJavaPropertyName();
+ for (SchemaProperty baseProp : baseProps) {
+ String name = baseProp.getJavaPropertyName();
assert !usedPropNames.contains(name);
usedPropNames.add(name);
}
@@ -297,15 +265,16 @@
avoidExtensionMethods(usedPropNames, sImpl);
// Assign names in two passes: first inherited names, then others.
- for (boolean doInherited = true; ; doInherited = false)
- {
- if (eltProps.length > 0)
+ for (boolean doInherited = true; ; doInherited = false) {
+ if (eltProps.length > 0) {
assignJavaPropertyNames(usedPropNames, eltProps, baseType, doInherited);
+ }
assignJavaPropertyNames(usedPropNames, attrProps, baseType, doInherited);
- if (doInherited == false)
+ if (!doInherited) {
break;
+ }
}
SchemaProperty[] allprops = sImpl.getProperties();
@@ -322,50 +291,45 @@
// assign java type names to anonymous types
// for redefined types, this step was performed when javaizing the redefinition
- if (sImpl.getFullJavaName() != null || sImpl.getOuterType() != null)
+ if (sImpl.getFullJavaName() != null || sImpl.getOuterType() != null) {
assignJavaAnonymousTypeNames(sImpl);
+ }
sImpl.finishJavaizing();
}
private static final String[] PREFIXES = new String[]{"get", "xget", "isNil", "isSet", "sizeOf", "set",
- "xset", "addNew", "setNil", "unset", "insert", "add", "insertNew", "addNew", "remove"};
+ "xset", "addNew", "setNil", "unset", "insert", "add", "insertNew", "addNew", "remove"};
- private static void avoidExtensionMethods(Set usedPropNames, SchemaTypeImpl sImpl)
- {
+ private static void avoidExtensionMethods(Set<String> usedPropNames, SchemaTypeImpl sImpl) {
InterfaceExtension[] exts = sImpl.getInterfaceExtensions();
- if (exts != null) for (int i = 0; i < exts.length; i++)
- {
- InterfaceExtension ext = exts[i];
- InterfaceExtension.MethodSignature[] methods = ext.getMethods();
- for (int j = 0; j < methods.length; j++)
- {
- String methodName = methods[j].getName();
- for (int k = 0; k < PREFIXES.length; k++)
- {
- String prefix = PREFIXES[k];
- if (methodName.startsWith(prefix))
- usedPropNames.add(methodName.substring(prefix.length()));
+ if (exts != null) {
+ for (InterfaceExtension ext : exts) {
+ InterfaceExtension.MethodSignature[] methods = ext.getMethods();
+ for (InterfaceExtension.MethodSignature method : methods) {
+ String methodName = method.getName();
+ for (String prefix : PREFIXES) {
+ if (methodName.startsWith(prefix)) {
+ usedPropNames.add(methodName.substring(prefix.length()));
+ }
+ }
}
}
}
}
- static void assignJavaAnonymousTypeNames(SchemaTypeImpl outerType)
- {
- Set usedTypeNames = new HashSet();
+ static void assignJavaAnonymousTypeNames(SchemaTypeImpl outerType) {
+ Set<String> usedTypeNames = new HashSet<>();
SchemaType[] anonymousTypes = outerType.getAnonymousTypes();
StscState state = StscState.get();
int nrOfAnonTypes = anonymousTypes.length;
- if (outerType.isRedefinition())
- {
+ if (outerType.isRedefinition()) {
// We have to add the anonymous types for redefinitions to the list
// since they don't have another outer class
- ArrayList list = new ArrayList();
+ ArrayList<SchemaType> list = new ArrayList<>();
addAnonymousTypesFromRedefinition(outerType, list);
- if (list.size() > 0)
- {
+ if (list.size() > 0) {
SchemaType[] temp = new SchemaType[nrOfAnonTypes + list.size()];
list.toArray(temp);
System.arraycopy(anonymousTypes, 0, temp, list.size(), nrOfAnonTypes);
@@ -377,18 +341,16 @@
// interface names must not be the same as an ancestor, use up
// the ancestors
- for ( SchemaType scanOuterType = outerType ;
- scanOuterType != null ;
- scanOuterType = scanOuterType.getOuterType() )
- {
- usedTypeNames.add( scanOuterType.getShortJavaName() );
+ for (SchemaType scanOuterType = outerType;
+ scanOuterType != null;
+ scanOuterType = scanOuterType.getOuterType()) {
+ usedTypeNames.add(scanOuterType.getShortJavaName());
}
- for ( SchemaType scanOuterType = outerType ;
- scanOuterType != null ;
- scanOuterType = scanOuterType.getOuterType() )
- {
- usedTypeNames.add( scanOuterType.getShortJavaImplName() );
+ for (SchemaType scanOuterType = outerType;
+ scanOuterType != null;
+ scanOuterType = scanOuterType.getOuterType()) {
+ usedTypeNames.add(scanOuterType.getShortJavaImplName());
}
// and because things are problematic if an inner type name
@@ -397,54 +359,52 @@
usedTypeNames.add(getOutermostPackage(outerType.getFullJavaName()));
// assign names
- for (int i = 0; i < anonymousTypes.length; i++)
- {
- SchemaTypeImpl sImpl = (SchemaTypeImpl)anonymousTypes[i];
+ for (int i = 0; i < anonymousTypes.length; i++) {
+ SchemaTypeImpl sImpl = (SchemaTypeImpl) anonymousTypes[i];
if (sImpl == null) // already handled in first pass
+ {
continue;
- if (sImpl.isSkippedAnonymousType())
+ }
+ if (sImpl.isSkippedAnonymousType()) {
continue;
+ }
String localname = null;
- String javaname = null;
+ String javaname;
SchemaField containerField = sImpl.getContainerField();
- if (containerField != null)
- {
+ if (containerField != null) {
QName qname = sImpl.getContainerField().getName();
localname = qname.getLocalPart();
javaname = state.getJavaname(sImpl.getContainerField().getName(), BindingConfig.QNAME_TYPE);
- }
- else
- {
+ } else {
// not defined inside an Elt or Attr: must be a nested simple type
- switch (sImpl.getOuterType().getSimpleVariety())
- {
+ switch (sImpl.getOuterType().getSimpleVariety()) {
case SchemaType.UNION:
- javaname = "Member"; break;
+ javaname = "Member";
+ break;
case SchemaType.LIST:
- javaname = "Item"; break;
+ javaname = "Item";
+ break;
case SchemaType.ATOMIC:
default:
- assert(false) : "Weird type " + sImpl.toString();
- javaname = "Base"; break;
+ assert (false) : "Weird type " + sImpl.toString();
+ javaname = "Base";
+ break;
}
}
- if (i < nrOfAnonTypes)
- {
+ if (i < nrOfAnonTypes) {
sImpl.setShortJavaName(
pickInnerJavaClassName(usedTypeNames, localname, javaname));
sImpl.setShortJavaImplName(
pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null : javaname + "Impl"));
- }
- else
- {
+ } else {
// This comes from redefined types, so we have to compute the
// full name here
sImpl.setFullJavaName(outerType.getFullJavaName() + "$" +
- pickInnerJavaClassName(usedTypeNames, localname, javaname));
+ pickInnerJavaClassName(usedTypeNames, localname, javaname));
sImpl.setFullJavaImplName(outerType.getFullJavaImplName() + "$" +
- pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null : javaname + "Impl"));
+ pickInnerJavaImplName(usedTypeNames, localname, javaname == null ? null : javaname + "Impl"));
}
// TODO(radup) why is this inside this loop here?
@@ -452,62 +412,58 @@
}
}
- static void assignJavaPropertyNames(Set usedNames, SchemaProperty[] props, SchemaType baseType, boolean doInherited)
- {
+ static void assignJavaPropertyNames(Set<String> usedNames, SchemaProperty[] props, SchemaType baseType, boolean doInherited) {
StscState state = StscState.get();
// two passes: first deal with inherited properties, then with new ones.
// this ensures that we match up with base class definitions cleanly
// BUGBUG(radup) We have to look for particles that have been removed
// in the derivation tree for this type using derivation by restriction,
- // because they have not been removed in Java and may collide with
+ // because they have not been removed in Java and may collide with
// this type's properties.
- for (int i = 0; i < props.length; i++)
- {
- SchemaPropertyImpl sImpl = (SchemaPropertyImpl)props[i];
+ for (SchemaProperty prop : props) {
+ SchemaPropertyImpl sImpl = (SchemaPropertyImpl) prop;
SchemaProperty baseProp =
- (sImpl.isAttribute() ?
+ (sImpl.isAttribute() ?
baseType.getAttributeProperty(sImpl.getName()) :
baseType.getElementProperty(sImpl.getName()));
- if ((baseProp != null) != doInherited)
+ if ((baseProp == null) == doInherited) {
continue;
+ }
QName propQName = sImpl.getName();
String theName;
- if (baseProp == null)
+ if (baseProp == null) {
theName = pickJavaPropertyName(usedNames, propQName.getLocalPart(),
state.getJavaname(propQName, sImpl.isAttribute() ? BindingConfig.QNAME_ACCESSOR_ATTRIBUTE :
- BindingConfig.QNAME_ACCESSOR_ELEMENT));
- else
+ BindingConfig.QNAME_ACCESSOR_ELEMENT));
+ } else {
theName = baseProp.getJavaPropertyName();
+ }
sImpl.setJavaPropertyName(theName);
boolean isArray = (sImpl.getMaxOccurs() == null ||
- sImpl.getMaxOccurs().compareTo(BigInteger.ONE) > 0);
+ sImpl.getMaxOccurs().compareTo(BigInteger.ONE) > 0);
boolean isSingleton = !isArray && (sImpl.getMaxOccurs().signum() > 0);
boolean isOption = isSingleton && (sImpl.getMinOccurs().signum() == 0);
SchemaType javaBasedOnType = sImpl.getType();
- if (baseProp != null)
- {
- if (baseProp.extendsJavaArray())
- {
+ if (baseProp != null) {
+ if (baseProp.extendsJavaArray()) {
isSingleton = false;
isOption = false;
isArray = true;
}
- if (baseProp.extendsJavaSingleton())
- {
+ if (baseProp.extendsJavaSingleton()) {
isSingleton = true;
}
- if (baseProp.extendsJavaOption())
- {
+ if (baseProp.extendsJavaOption()) {
isOption = true;
}
javaBasedOnType = baseProp.javaBasedOnType();
@@ -518,59 +474,60 @@
}
- static void assignJavaTypeCodes(SchemaProperty[] properties)
- {
- for (int i = 0; i < properties.length; i++)
- {
- SchemaPropertyImpl sImpl = (SchemaPropertyImpl)properties[i];
+ static void assignJavaTypeCodes(SchemaProperty[] properties) {
+ for (SchemaProperty property : properties) {
+ SchemaPropertyImpl sImpl = (SchemaPropertyImpl) property;
SchemaType sType = sImpl.javaBasedOnType();
sImpl.setJavaTypeCode(javaTypeCodeForType(sType));
}
}
- static int javaTypeCodeInCommon(SchemaType[] types)
- {
- if (types == null || types.length == 0)
+ static int javaTypeCodeInCommon(SchemaType[] types) {
+ if (types == null || types.length == 0) {
return SchemaProperty.XML_OBJECT;
+ }
int code = javaTypeCodeForType(types[0]);
- if (code == SchemaProperty.JAVA_OBJECT)
+ if (code == SchemaProperty.JAVA_OBJECT) {
return code;
- for (int i = 1; i < types.length; i++)
- {
+ }
+ for (int i = 1; i < types.length; i++) {
// if any two are different, the answer is java.lang.Object
- if (code != javaTypeCodeForType(types[i]))
+ if (code != javaTypeCodeForType(types[i])) {
return SchemaProperty.JAVA_OBJECT;
+ }
}
return code;
}
- static int javaTypeCodeForType(SchemaType sType)
- {
- if (!sType.isSimpleType())
+ static int javaTypeCodeForType(SchemaType sType) {
+ if (!sType.isSimpleType()) {
return SchemaProperty.XML_OBJECT;
-
- if (((SchemaTypeImpl)sType).getUserTypeHandlerName() != null)
- return SchemaProperty.JAVA_USER;
-
- if (sType.getSimpleVariety() == SchemaType.UNION)
- {
- // see if we can find an interesting common base type, e.g., for string enums
- SchemaType baseType = sType.getUnionCommonBaseType();
- if (baseType != null && !baseType.isURType())
- sType = baseType;
- else
- return javaTypeCodeInCommon(sType.getUnionConstituentTypes());
}
- if (sType.getSimpleVariety() == SchemaType.LIST)
+ if (((SchemaTypeImpl) sType).getUserTypeHandlerName() != null) {
+ return SchemaProperty.JAVA_USER;
+ }
+
+ if (sType.getSimpleVariety() == SchemaType.UNION) {
+ // see if we can find an interesting common base type, e.g., for string enums
+ SchemaType baseType = sType.getUnionCommonBaseType();
+ if (baseType != null && !baseType.isURType()) {
+ sType = baseType;
+ } else {
+ return javaTypeCodeInCommon(sType.getUnionConstituentTypes());
+ }
+ }
+
+ if (sType.getSimpleVariety() == SchemaType.LIST) {
return SchemaProperty.JAVA_LIST;
+ }
- if (sType.isURType())
+ if (sType.isURType()) {
return SchemaProperty.XML_OBJECT;
+ }
- switch (sType.getPrimitiveType().getBuiltinTypeCode())
- {
+ switch (sType.getPrimitiveType().getBuiltinTypeCode()) {
case SchemaType.BTC_ANY_SIMPLE:
// return SchemaProperty.XML_OBJECT;
return SchemaProperty.JAVA_STRING;
@@ -600,8 +557,7 @@
return SchemaProperty.JAVA_DOUBLE;
case SchemaType.BTC_DECIMAL:
- switch (sType.getDecimalSize())
- {
+ switch (sType.getDecimalSize()) {
case SchemaType.SIZE_BYTE:
return SchemaProperty.JAVA_BYTE;
case SchemaType.SIZE_SHORT:
@@ -618,20 +574,16 @@
}
case SchemaType.BTC_STRING:
- if (isStringType(sType.getBaseEnumType()))
- {
+ if (isStringType(sType.getBaseEnumType())) {
// This is necessary for local types, etc.
// schema enums with > ~3668 cause a Java Src file to be created
// that cannot be compiled due to JVM restrictions
// FIXFIX: http://issues.apache.org/jira/browse/XMLBEANS-307
// FIXFIX: XMLBeans scomp throws error "code too large"
if (sType.getEnumerationValues() != null &&
- sType.getEnumerationValues().length > MAX_ENUM_COUNT)
- {
+ sType.getEnumerationValues().length > MAX_ENUM_COUNT) {
return SchemaProperty.JAVA_STRING;
- }
- else
- {
+ } else {
return SchemaProperty.JAVA_ENUM;
}
}
@@ -654,40 +606,37 @@
return SchemaProperty.JAVA_CALENDAR;
default:
- assert(false) : "unrecognized code " + sType.getPrimitiveType().getBuiltinTypeCode();
+ assert (false) : "unrecognized code " + sType.getPrimitiveType().getBuiltinTypeCode();
throw new IllegalStateException("unrecognized code " + sType.getPrimitiveType().getBuiltinTypeCode() + " of " + sType.getPrimitiveType().getName());
}
}
- static boolean isPropertyModelOrderInsensitive(SchemaProperty[] properties)
- {
- for (int i = 0; i < properties.length; i++)
- {
- SchemaProperty prop = properties[i];
- if (prop.hasNillable() == SchemaProperty.VARIABLE)
+ static boolean isPropertyModelOrderInsensitive(SchemaProperty[] properties) {
+ for (SchemaProperty prop : properties) {
+ if (prop.hasNillable() == SchemaProperty.VARIABLE) {
return false;
- if (prop.hasDefault() == SchemaProperty.VARIABLE)
+ }
+ if (prop.hasDefault() == SchemaProperty.VARIABLE) {
return false;
- if (prop.hasFixed() == SchemaProperty.VARIABLE)
+ }
+ if (prop.hasFixed() == SchemaProperty.VARIABLE) {
return false;
+ }
if (prop.hasDefault() != SchemaProperty.NEVER &&
- prop.getDefaultText() == null)
+ prop.getDefaultText() == null) {
return false;
+ }
}
return true;
}
- static boolean protectReservedGlobalClassNames(String name)
- {
+ static boolean protectReservedGlobalClassNames(String name) {
int i = name.lastIndexOf('.');
String lastSegment = name.substring(i + 1);
- if (lastSegment.endsWith("Document") && !lastSegment.equals("Document"))
- return true;
- return false;
+ return lastSegment.endsWith("Document") && !lastSegment.equals("Document");
}
- static boolean protectReservedInnerClassNames(String name)
- {
+ static boolean protectReservedInnerClassNames(String name) {
return (name.equals("Enum") || name.equals("Factory"));
}
@@ -713,27 +662,22 @@
"ObjectValue",
"Class",
};
- static Set PROTECTED_PROPERTIES_SET = new HashSet(Arrays.asList(PROTECTED_PROPERTIES));
+ static Set<String> PROTECTED_PROPERTIES_SET = new HashSet<>(Arrays.asList(PROTECTED_PROPERTIES));
- static boolean protectReservedPropertyNames(String name)
- {
+ static boolean protectReservedPropertyNames(String name) {
return PROTECTED_PROPERTIES_SET.contains(name) ||
- (name.endsWith("Array") && !name.equals("Array"));
+ (name.endsWith("Array") && !name.equals("Array"));
}
- static String pickFullJavaClassName(Set usedNames, QName qName, String configname, boolean isDocument, boolean isAttrType)
- {
+ static String pickFullJavaClassName(Set<String> usedNames, QName qName, String configname, boolean isDocument, boolean isAttrType) {
String base;
boolean protect;
- if (configname != null && configname.indexOf('.') >= 0)
- {
+ if (configname != null && configname.indexOf('.') >= 0) {
// a configname with dots defines the fully qualified java class name
base = configname;
protect = protectReservedGlobalClassNames(base);
- }
- else
- {
+ } else {
StscState state = StscState.get();
String uri = qName.getNamespaceURI();
@@ -745,8 +689,7 @@
String pkgPrefix = state.getPackageOverride(uri);
- if (pkgPrefix != null)
- {
+ if (pkgPrefix != null) {
// Form the new qualified class name from the new package name
// and the old class name
base = pkgPrefix + "." + base.substring(base.lastIndexOf('.') + 1);
@@ -754,28 +697,29 @@
// See if there is a prefix...
String javaPrefix = state.getJavaPrefix(uri);
- if (javaPrefix != null)
+ if (javaPrefix != null) {
base = base.substring(0, base.lastIndexOf('.') + 1) + javaPrefix + base.substring(base.lastIndexOf('.') + 1);
+ }
// a configname without dots may override the shortname part.
- if (configname != null)
- {
+ if (configname != null) {
base = base.substring(0, base.lastIndexOf('.') + 1) + configname;
}
protect = protectReservedGlobalClassNames(base);
- if (configname == null)
- {
+ if (configname == null) {
// add special suffix
- if (isDocument)
+ if (isDocument) {
base = base + "Document";
- else if (isAttrType)
+ } else if (isAttrType) {
base = base + "Attribute";
+ }
// add configured suffix
String javaSuffix = state.getJavaSuffix(uri);
- if (javaSuffix != null)
+ if (javaSuffix != null) {
base = base + javaSuffix;
+ }
}
}
@@ -783,12 +727,12 @@
int index = 1;
String uniqName;
- if (protect)
+ if (protect) {
uniqName = base + index;
- else
+ } else {
uniqName = base;
- while (usedNames.contains(uniqName.toLowerCase()) || uniqName.equals(outermostPkg))
- {
+ }
+ while (usedNames.contains(uniqName.toLowerCase()) || uniqName.equals(outermostPkg)) {
index++;
uniqName = base + index;
}
@@ -798,28 +742,27 @@
return uniqName;
}
- static String getOutermostPackage(String fqcn)
- {
- if (fqcn == null)
+ static String getOutermostPackage(String fqcn) {
+ if (fqcn == null) {
return "";
+ }
// remove class name
int lastdot = fqcn.indexOf('.');
- if (lastdot < 0)
+ if (lastdot < 0) {
return "";
+ }
// remove outer package names
return fqcn.substring(0, lastdot);
}
- static String pickFullJavaImplName(Set usedNames, String intfName)
- {
+ static String pickFullJavaImplName(Set<String> usedNames, String intfName) {
// Strip off the package from the class name so we can replace it
String className = intfName;
String pkgName = null;
int index = intfName.lastIndexOf('.');
- if (index >= 0)
- {
+ if (index >= 0) {
className = intfName.substring(index + 1);
pkgName = intfName.substring(0, index);
}
@@ -830,8 +773,7 @@
index = 1;
String uniqName = base;
- while (usedNames.contains(uniqName.toLowerCase()))
- {
+ while (usedNames.contains(uniqName.toLowerCase())) {
index++;
uniqName = base + index;
}
@@ -841,19 +783,19 @@
return uniqName;
}
- static String pickJavaPropertyName(Set usedNames, String localName, String javaName)
- {
- if (javaName == null)
+ static String pickJavaPropertyName(Set<String> usedNames, String localName, String javaName) {
+ if (javaName == null) {
javaName = NameUtil.upperCamelCase(localName);
+ }
boolean protect = protectReservedPropertyNames(javaName);
String uniqName;
int index = 1;
- if (protect)
+ if (protect) {
uniqName = javaName + index;
- else
+ } else {
uniqName = javaName;
- while (usedNames.contains(uniqName))
- {
+ }
+ while (usedNames.contains(uniqName)) {
index++;
uniqName = javaName + index;
}
@@ -863,19 +805,19 @@
return uniqName;
}
- static String pickInnerJavaClassName(Set usedNames, String localName, String javaName)
- {
- if (javaName == null)
+ static String pickInnerJavaClassName(Set<String> usedNames, String localName, String javaName) {
+ if (javaName == null) {
javaName = NameUtil.upperCamelCase(localName);
+ }
boolean protect = protectReservedInnerClassNames(javaName);
String uniqName;
int index = 1;
- if (protect)
+ if (protect) {
uniqName = javaName + index;
- else
+ } else {
uniqName = javaName;
- while (usedNames.contains(uniqName))
- {
+ }
+ while (usedNames.contains(uniqName)) {
index++;
uniqName = javaName + index;
}
@@ -885,14 +827,13 @@
return uniqName;
}
- static String pickInnerJavaImplName(Set usedNames, String localName, String javaName)
- {
- if (javaName == null)
+ static String pickInnerJavaImplName(Set<String> usedNames, String localName, String javaName) {
+ if (javaName == null) {
javaName = NameUtil.upperCamelCase(localName) + "Impl";
+ }
String uniqName = javaName;
int index = 1;
- while (usedNames.contains(uniqName))
- {
+ while (usedNames.contains(uniqName)) {
index++;
uniqName = javaName + index;
}
@@ -902,42 +843,41 @@
return uniqName;
}
- static QName findTopName(SchemaType sType)
- {
- if (sType.getName() != null)
+ static QName findTopName(SchemaType sType) {
+ if (sType.getName() != null) {
return sType.getName();
+ }
- if (sType.isDocumentType())
- {
+ if (sType.isDocumentType()) {
// A document type must have a content model consisting of a single elt
- if (sType.getContentModel() == null || sType.getContentModel().getParticleType() != SchemaParticle.ELEMENT)
+ if (sType.getContentModel() == null || sType.getContentModel().getParticleType() != SchemaParticle.ELEMENT) {
throw new IllegalStateException();
+ }
return (sType.getDocumentElementName());
}
- if (sType.isAttributeType())
- {
- if (sType.getAttributeModel() == null || sType.getAttributeModel().getAttributes().length != 1)
+ if (sType.isAttributeType()) {
+ if (sType.getAttributeModel() == null || sType.getAttributeModel().getAttributes().length != 1) {
throw new IllegalStateException();
+ }
return sType.getAttributeTypeAttributeName();
}
SchemaField sElt = sType.getContainerField();
- assert(sElt != null);
- assert(sType.getOuterType() == null);
+ assert (sElt != null);
+ assert (sType.getOuterType() == null);
return sElt.getName();
}
- static void addAnonymousTypesFromRedefinition(SchemaType sType, List result)
- {
- while (((SchemaTypeImpl)sType).isRedefinition() &&
- (sType.getDerivationType() == SchemaType.DT_EXTENSION ||
- sType.isSimpleType()))
- {
+ static void addAnonymousTypesFromRedefinition(SchemaType sType, List<SchemaType> result) {
+ while (((SchemaTypeImpl) sType).isRedefinition() &&
+ (sType.getDerivationType() == SchemaType.DT_EXTENSION ||
+ sType.isSimpleType())) {
sType = sType.getBaseType();
SchemaType[] newAnonTypes = sType.getAnonymousTypes();
- if (newAnonTypes.length > 0)
+ if (newAnonTypes.length > 0) {
result.addAll(Arrays.asList(newAnonTypes));
+ }
}
}
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java b/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java
index 2909fd8..34e41fc 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/StscTranslator.java
@@ -18,7 +18,6 @@
import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.common.QNameHelper;
import org.apache.xmlbeans.impl.common.XMLChar;
-import org.apache.xmlbeans.impl.common.XPath;
import org.apache.xmlbeans.impl.schema.StscImporter.SchemaToProcess;
import org.apache.xmlbeans.impl.values.NamespaceContext;
import org.apache.xmlbeans.impl.values.XmlNonNegativeIntegerImpl;
@@ -27,6 +26,7 @@
import org.apache.xmlbeans.impl.xb.xsdschema.*;
import org.apache.xmlbeans.impl.xb.xsdschema.RedefineDocument.Redefine;
import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument.Schema;
+import org.apache.xmlbeans.impl.xpath.XPath;
import org.apache.xmlbeans.soap.SOAPArrayType;
import javax.xml.namespace.QName;
diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java b/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
index 41aed8d..e53e066 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/XQuerySchemaTypeSystem.java
@@ -15,6 +15,13 @@
package org.apache.xmlbeans.impl.schema;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.values.XmlIntegerImpl;
+import org.apache.xmlbeans.impl.values.XmlStringImpl;
+import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
+
+import javax.xml.namespace.QName;
import java.io.File;
import java.io.InputStream;
import java.math.BigInteger;
@@ -22,40 +29,20 @@
import java.util.HashMap;
import java.util.Map;
-import javax.xml.namespace.QName;
-
-import org.apache.xmlbeans.Filer;
-import org.apache.xmlbeans.QNameSet;
-import org.apache.xmlbeans.SchemaAnnotation;
-import org.apache.xmlbeans.SchemaAttributeGroup;
-import org.apache.xmlbeans.SchemaAttributeModel;
-import org.apache.xmlbeans.SchemaComponent;
-import org.apache.xmlbeans.SchemaGlobalAttribute;
-import org.apache.xmlbeans.SchemaGlobalElement;
-import org.apache.xmlbeans.SchemaIdentityConstraint;
-import org.apache.xmlbeans.SchemaModelGroup;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.impl.common.QNameHelper;
-import org.apache.xmlbeans.impl.values.XmlIntegerImpl;
-import org.apache.xmlbeans.impl.values.XmlStringImpl;
-import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
-
/**
* Same as {@link BuiltinSchemaTypeSystem} but adds three extra types
- * (<i>dayTimeDuration</i>, <i>yearMonthDuration</i> and <i>anyAtomicType</i>)
+ * (<i>dayTimeDuration</i>, <i>yearMonthDuration</i> and <i>anyAtomicType</i>)
* and makes all the primitives extend <i>anyAtomicType</i>.
- *
- * @author Radu Preotiuc
*
+ * @author Radu Preotiuc
*/
+@SuppressWarnings("unused")
public class XQuerySchemaTypeSystem extends SchemaTypeLoaderBase implements
- SchemaTypeSystem
-{
+ SchemaTypeSystem {
// The global builtin type system
- public static SchemaTypeSystem get()
- { return _global; }
+ public static SchemaTypeSystem get() {
+ return _global;
+ }
// Extra constants; since the extra types are going to be part of XMLSchema 1.1
// we will want to eventually move these to SchemaType
@@ -74,7 +61,7 @@
private static final SchemaAttributeGroup[] EMPTY_SCHEMAATTRIBUTEGROUP_ARRAY = new SchemaAttributeGroup[0];
private static final SchemaAnnotation[] EMPTY_SCHEMAANNOTATION_ARRAY = new SchemaAnnotation[0];
- private static XQuerySchemaTypeSystem _global = new XQuerySchemaTypeSystem();
+ private static final XQuerySchemaTypeSystem _global = new XQuerySchemaTypeSystem();
// UR types
public static final SchemaTypeImpl ST_ANY_TYPE = _global.getBuiltinType(SchemaType.BTC_ANY_TYPE);
@@ -144,88 +131,88 @@
private final static XmlValueRef XMLSTR_COLLAPSE = buildString("preserve");
private final static XmlValueRef[] FACETS_NONE = new XmlValueRef[]
- { null, null, null, null, null, null, null, null, null,
- null, null, null };
+ {null, null, null, null, null, null, null, null, null,
+ null, null, null};
private final static boolean[] FIXED_FACETS_NONE = new boolean[]
- { false, false, false, false, false, false, false, false, false,
- false, false, false };
+ {false, false, false, false, false, false, false, false, false,
+ false, false, false};
private final static XmlValueRef[] FACETS_WS_COLLAPSE = new XmlValueRef[]
- { null, null, null, null, null, null, null, null, null,
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, null, null, null, null, null,
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_WS_REPLACE = new XmlValueRef[]
- { null, null, null, null, null, null, null, null, null,
- build_wsstring(SchemaType.WS_REPLACE), null, null };
+ {null, null, null, null, null, null, null, null, null,
+ build_wsstring(SchemaType.WS_REPLACE), null, null};
private final static XmlValueRef[] FACETS_WS_PRESERVE = new XmlValueRef[]
- { null, null, null, null, null, null, null, null, null,
- build_wsstring(SchemaType.WS_PRESERVE), null, null };
+ {null, null, null, null, null, null, null, null, null,
+ build_wsstring(SchemaType.WS_PRESERVE), null, null};
private final static XmlValueRef[] FACETS_INTEGER = new XmlValueRef[]
- { null, null, null, null, null, null, null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, null, null, null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_LONG = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.valueOf(Long.MIN_VALUE)), buildInteger(BigInteger.valueOf(Long.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.valueOf(Long.MIN_VALUE)), buildInteger(BigInteger.valueOf(Long.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_INT = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.valueOf(Integer.MIN_VALUE)), buildInteger(BigInteger.valueOf(Integer.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.valueOf(Integer.MIN_VALUE)), buildInteger(BigInteger.valueOf(Integer.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_SHORT = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.valueOf(Short.MIN_VALUE)), buildInteger(BigInteger.valueOf(Short.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.valueOf(Short.MIN_VALUE)), buildInteger(BigInteger.valueOf(Short.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_BYTE = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.valueOf(Byte.MIN_VALUE)), buildInteger(BigInteger.valueOf(Byte.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.valueOf(Byte.MIN_VALUE)), buildInteger(BigInteger.valueOf(Byte.MAX_VALUE)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_NONNEGATIVE = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.ZERO), null, null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.ZERO), null, null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_POSITIVE = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.ONE), null, null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.ONE), null, null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_NONPOSITIVE = new XmlValueRef[]
- { null, null, null, null, null, buildInteger(BigInteger.ZERO), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, null, buildInteger(BigInteger.ZERO), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_NEGATIVE = new XmlValueRef[]
- { null, null, null, null, null, buildInteger(BigInteger.ONE.negate()), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, null, buildInteger(BigInteger.ONE.negate()), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_UNSIGNED_LONG = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(new BigInteger("18446744073709551615")), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(new BigInteger("18446744073709551615")), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_UNSIGNED_INT = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(BigInteger.valueOf(4294967295L)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(BigInteger.valueOf(4294967295L)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_UNSIGNED_SHORT = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(BigInteger.valueOf(65535)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(BigInteger.valueOf(65535)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_UNSIGNED_BYTE = new XmlValueRef[]
- { null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(BigInteger.valueOf(255)), null, null, buildNnInteger(BigInteger.ZERO),
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, null, null, null, buildInteger(BigInteger.ZERO), buildInteger(BigInteger.valueOf(255)), null, null, buildNnInteger(BigInteger.ZERO),
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static XmlValueRef[] FACETS_BUILTIN_LIST = new XmlValueRef[]
- { null, buildNnInteger(BigInteger.ONE), null, null, null, null, null, null, null,
- build_wsstring(SchemaType.WS_COLLAPSE), null, null };
+ {null, buildNnInteger(BigInteger.ONE), null, null, null, null, null, null, null,
+ build_wsstring(SchemaType.WS_COLLAPSE), null, null};
private final static boolean[] FIXED_FACETS_WS = new boolean[]
- { false, false, false, false, false, false, false, false, false,
- true, false, false };
+ {false, false, false, false, false, false, false, false, false,
+ true, false, false};
private final static boolean[] FIXED_FACETS_INTEGER = new boolean[]
- { false, false, false, false, false, false, false, false, true,
- true, false, false };
+ {false, false, false, false, false, false, false, false, true,
+ true, false, false};
final static XmlValueRef[] FACETS_UNION = FACETS_NONE;
final static boolean[] FIXED_FACETS_UNION = FIXED_FACETS_NONE;
@@ -238,31 +225,27 @@
* LAST Static initializer
*/
static {
- for (int i = SchemaType.BTC_NOT_BUILTIN; i <= SchemaType.BTC_LAST_BUILTIN; i++)
- {
+ for (int i = SchemaType.BTC_NOT_BUILTIN; i <= SchemaType.BTC_LAST_BUILTIN; i++) {
_global.fillInType(i);
}
- for (int i = BTC_FIRST_XQUERY; i <= BTC_LAST_XQUERY; i++)
- {
+ for (int i = BTC_FIRST_XQUERY; i <= BTC_LAST_XQUERY; i++) {
_global.fillInType(i);
}
}
- private Map _typeMap = new HashMap();
- private SchemaTypeImpl[] _typeArray = new SchemaTypeImpl[SchemaType.BTC_LAST_BUILTIN + 1 +
- BTC_LAST_XQUERY - BTC_FIRST_XQUERY + 1];
- private Map _handlesToObjects = new HashMap();
- private Map _objectsToHandles = new HashMap();
- private Map _typesByClassname = new HashMap();
- private SchemaContainer _container = new SchemaContainer("http://www.w3.org/2001/XMLSchema");
+ private final Map<QName, SchemaType> _typeMap = new HashMap<>();
+ private final SchemaTypeImpl[] _typeArray = new SchemaTypeImpl[SchemaType.BTC_LAST_BUILTIN + 1 +
+ BTC_LAST_XQUERY - BTC_FIRST_XQUERY + 1];
+ private final Map<String, SchemaType> _handlesToObjects = new HashMap<>();
+ private final Map<SchemaType, String> _objectsToHandles = new HashMap<>();
+ private final Map<String, SchemaType> _typesByClassname = new HashMap<>();
+ private final SchemaContainer _container = new SchemaContainer("http://www.w3.org/2001/XMLSchema");
- private SchemaTypeImpl getBuiltinType(int btc)
- {
+ private SchemaTypeImpl getBuiltinType(int btc) {
return _typeArray[arrayIndexForBtc(btc)];
}
- private XQuerySchemaTypeSystem()
- {
+ private XQuerySchemaTypeSystem() {
_container.setTypeSystem(this);
// UR types
setupType(SchemaType.BTC_ANY_TYPE, "anyType", "org.apache.xmlbeans.XmlObject");
@@ -333,98 +316,80 @@
/**
* Returns the name of this loader.
*/
- public String getName()
- {
+ public String getName() {
return "xquery.typesystem.builtin";
}
- public boolean isNamespaceDefined(String namespace)
- {
+ public boolean isNamespaceDefined(String namespace) {
return namespace.equals("http://www.w3.org/2001/XMLSchema");
}
- public SchemaType findType(QName name)
- {
- return (SchemaType)_typeMap.get(name);
+ public SchemaType findType(QName name) {
+ return _typeMap.get(name);
}
- public SchemaType findDocumentType(QName name)
- {
+ public SchemaType findDocumentType(QName name) {
return null;
}
- public SchemaType findAttributeType(QName name)
- {
+ public SchemaType findAttributeType(QName name) {
return null;
}
- public SchemaGlobalElement findElement(QName name)
- {
+ public SchemaGlobalElement findElement(QName name) {
return null;
}
- public SchemaGlobalAttribute findAttribute(QName name)
- {
+ public SchemaGlobalAttribute findAttribute(QName name) {
return null;
}
- public SchemaType.Ref findTypeRef(QName name)
- {
+ public SchemaType.Ref findTypeRef(QName name) {
SchemaType type = findType(name);
return (type == null ? null : type.getRef());
}
- public SchemaType.Ref findDocumentTypeRef(QName name)
- {
+ public SchemaType.Ref findDocumentTypeRef(QName name) {
return null;
}
- public SchemaType.Ref findAttributeTypeRef(QName name)
- {
+ public SchemaType.Ref findAttributeTypeRef(QName name) {
return null;
}
- public SchemaGlobalElement.Ref findElementRef(QName name)
- {
+ public SchemaGlobalElement.Ref findElementRef(QName name) {
return null;
}
- public SchemaGlobalAttribute.Ref findAttributeRef(QName name)
- {
+ public SchemaGlobalAttribute.Ref findAttributeRef(QName name) {
return null;
}
- public SchemaModelGroup.Ref findModelGroupRef(QName name)
- {
+ public SchemaModelGroup.Ref findModelGroupRef(QName name) {
return null;
}
- public SchemaAttributeGroup.Ref findAttributeGroupRef(QName name)
- {
+ public SchemaAttributeGroup.Ref findAttributeGroupRef(QName name) {
return null;
}
- public SchemaIdentityConstraint.Ref findIdentityConstraintRef(QName name)
- {
+ public SchemaIdentityConstraint.Ref findIdentityConstraintRef(QName name) {
return null;
}
- public SchemaType typeForClassname(String classname)
- {
- return (SchemaType)_typesByClassname.get(classname);
+ public SchemaType typeForClassname(String classname) {
+ return _typesByClassname.get(classname);
}
- public InputStream getSourceAsStream(String sourceName)
- {
+ public InputStream getSourceAsStream(String sourceName) {
return null; // builtin schema type system has no source.
}
/**
* Returns the global types defined in this loader.
*/
- public SchemaType[] globalTypes()
- {
+ public SchemaType[] globalTypes() {
SchemaType[] result = new SchemaType[_typeArray.length - 1];
System.arraycopy(_typeArray, 1, result, 0, result.length);
return result;
@@ -433,101 +398,87 @@
/**
* Returns the document types defined in this loader.
*/
- public SchemaType[] documentTypes()
- {
+ public SchemaType[] documentTypes() {
return EMPTY_SCHEMATYPE_ARRAY;
}
/**
* Returns the attribute types defined in this loader.
*/
- public SchemaType[] attributeTypes()
- {
+ public SchemaType[] attributeTypes() {
return EMPTY_SCHEMATYPE_ARRAY;
}
/**
* Returns the global elements defined in this loader.
*/
- public SchemaGlobalElement[] globalElements()
- {
+ public SchemaGlobalElement[] globalElements() {
return EMPTY_SCHEMAELEMENT_ARRAY;
}
/**
* Returns the global attributes defined in this loader.
*/
- public SchemaGlobalAttribute[] globalAttributes()
- {
+ public SchemaGlobalAttribute[] globalAttributes() {
return EMPTY_SCHEMAATTRIBUTE_ARRAY;
}
/**
* Returns the model groups defined in this loader.
*/
- public SchemaModelGroup[] modelGroups()
- {
+ public SchemaModelGroup[] modelGroups() {
return EMPTY_SCHEMAMODELGROUP_ARRAY;
}
/**
* Returns the attribute groups defined in this loader.
*/
- public SchemaAttributeGroup[] attributeGroups()
- {
+ public SchemaAttributeGroup[] attributeGroups() {
return EMPTY_SCHEMAATTRIBUTEGROUP_ARRAY;
}
/*
* Returns the top-level annotations.
*/
- public SchemaAnnotation[] annotations()
- {
+ public SchemaAnnotation[] annotations() {
return EMPTY_SCHEMAANNOTATION_ARRAY;
}
/**
* Returns the handle for the given type within this loader.
*/
- public String handleForType(SchemaType type)
- {
- return (String)_objectsToHandles.get(type);
+ public String handleForType(SchemaType type) {
+ return _objectsToHandles.get(type);
}
/**
* Returns the classloader used by this loader for resolving types.
*/
- public ClassLoader getClassLoader()
- {
+ public ClassLoader getClassLoader() {
return BuiltinSchemaTypeSystem.class.getClassLoader();
}
/**
* Saves this type to a directory.
*/
- public void saveToDirectory(File classDir)
- {
+ public void saveToDirectory(File classDir) {
throw new UnsupportedOperationException("The builtin schema type system cannot be saved.");
}
/**
* Saves this type system using a Filer
*/
- public void save(Filer filer)
- {
+ public void save(Filer filer) {
throw new UnsupportedOperationException("The builtin schema type system cannot be saved.");
}
- private int arrayIndexForBtc(int btc)
- {
+ private int arrayIndexForBtc(int btc) {
return btc > SchemaType.BTC_LAST_BUILTIN ?
btc - BTC_FIRST_XQUERY + SchemaType.BTC_LAST_BUILTIN + 1 : btc;
}
- private static XmlValueRef build_wsstring(int wsr)
- {
- switch (wsr)
- {
+ private static XmlValueRef build_wsstring(int wsr) {
+ switch (wsr) {
case SchemaType.WS_PRESERVE:
return XMLSTR_PRESERVE;
case SchemaType.WS_REPLACE:
@@ -538,107 +489,95 @@
return null;
}
- private static XmlValueRef buildNnInteger(BigInteger bigInt)
- {
- if (bigInt == null)
+ private static XmlValueRef buildNnInteger(BigInteger bigInt) {
+ if (bigInt == null) {
return null;
- if (bigInt.signum() < 0)
+ }
+ if (bigInt.signum() < 0) {
return null;
- try
- {
+ }
+ try {
XmlIntegerImpl i = new XmlIntegerImpl();
i.setBigIntegerValue(bigInt);
i.setImmutable();
return new XmlValueRef(i);
- }
- catch (XmlValueOutOfRangeException e)
- {
+ } catch (XmlValueOutOfRangeException e) {
return null;
}
}
- private static XmlValueRef buildInteger(BigInteger bigInt)
- {
- if (bigInt == null)
+ private static XmlValueRef buildInteger(BigInteger bigInt) {
+ if (bigInt == null) {
return null;
- try
- {
+ }
+ try {
XmlIntegerImpl i = new XmlIntegerImpl();
i.setBigIntegerValue(bigInt);
i.setImmutable();
return new XmlValueRef(i);
- }
- catch (XmlValueOutOfRangeException e)
- {
+ } catch (XmlValueOutOfRangeException e) {
return null;
}
}
- private static XmlValueRef buildString(String str)
- {
- if (str == null)
+ private static XmlValueRef buildString(String str) {
+ if (str == null) {
return null;
+ }
- try
- {
+ try {
XmlStringImpl i = new XmlStringImpl();
i.setStringValue(str);
i.setImmutable();
return new XmlValueRef(i);
- }
- catch (XmlValueOutOfRangeException e)
- {
+ } catch (XmlValueOutOfRangeException e) {
return null;
}
}
- private void setupType(int btc, String localname, String classname)
- {
+ private void setupType(int btc, String localname, String classname) {
SchemaTypeImpl result = new SchemaTypeImpl(_container, true);
_container.addGlobalType(result.getRef());
QName name = localname == null ? null : QNameHelper.forLNS(localname, "http://www.w3.org/2001/XMLSchema");
String handle = "_BI_" + (localname == null ? "NO_TYPE" : localname);
result.setName(name);
result.setBuiltinTypeCode(btc);
- if (classname != null)
+ if (classname != null) {
result.setFullJavaName(classname);
+ }
_typeArray[arrayIndexForBtc(btc)] = result;
_typeMap.put(name, result);
_handlesToObjects.put(handle, result);
_objectsToHandles.put(result, handle);
- if (classname != null)
+ if (classname != null) {
_typesByClassname.put(classname, result);
+ }
}
- public void resolve()
- {
+ public void resolve() {
// we're born resolved and don't need to do anything.
}
- public SchemaType typeForHandle(String handle)
- {
- return (SchemaType)_handlesToObjects.get(handle);
+ public SchemaType typeForHandle(String handle) {
+ return _handlesToObjects.get(handle);
}
- public SchemaComponent resolveHandle(String handle)
- {
- return (SchemaComponent)_handlesToObjects.get(handle);
+ public SchemaComponent resolveHandle(String handle) {
+ return _handlesToObjects.get(handle);
}
/**
* Links a type.
*/
- public void fillInType(int btc)
- {
+ public void fillInType(int btc) {
SchemaTypeImpl result = getBuiltinType(btc);
SchemaType base;
SchemaType item = null;
int variety = SchemaType.ATOMIC;
int derivationType = SchemaType.DT_RESTRICTION;
- switch (btc)
- {
+ switch (btc) {
case SchemaType.BTC_NOT_BUILTIN:
variety = SchemaType.NOT_SIMPLE;
base = ST_ANY_TYPE;
@@ -651,13 +590,15 @@
break;
default:
- assert(false);
+ assert (false);
case SchemaType.BTC_ANY_SIMPLE:
- base = ST_ANY_TYPE; break;
+ base = ST_ANY_TYPE;
+ break;
case BTC_ANY_ATOMIC:
base = ST_ANY_SIMPLE;
+ break;
case SchemaType.BTC_BOOLEAN:
case SchemaType.BTC_BASE_64_BINARY:
@@ -678,81 +619,102 @@
case SchemaType.BTC_G_MONTH_DAY:
case SchemaType.BTC_G_DAY:
case SchemaType.BTC_G_MONTH:
- base = ST_ANY_ATOMIC; break;
+ base = ST_ANY_ATOMIC;
+ break;
// derived numerics
case SchemaType.BTC_INTEGER:
- base = ST_DECIMAL; break;
+ base = ST_DECIMAL;
+ break;
case SchemaType.BTC_LONG:
- base = ST_INTEGER; break;
+ base = ST_INTEGER;
+ break;
case SchemaType.BTC_INT:
- base = ST_LONG; break;
+ base = ST_LONG;
+ break;
case SchemaType.BTC_SHORT:
- base = ST_INT; break;
+ base = ST_INT;
+ break;
case SchemaType.BTC_BYTE:
- base = ST_SHORT; break;
+ base = ST_SHORT;
+ break;
case SchemaType.BTC_NON_POSITIVE_INTEGER:
- base = ST_INTEGER; break;
+ base = ST_INTEGER;
+ break;
case SchemaType.BTC_NEGATIVE_INTEGER:
- base = ST_NON_POSITIVE_INTEGER; break;
+ base = ST_NON_POSITIVE_INTEGER;
+ break;
case SchemaType.BTC_NON_NEGATIVE_INTEGER:
- base = ST_INTEGER; break;
+ base = ST_INTEGER;
+ break;
case SchemaType.BTC_POSITIVE_INTEGER:
- base = ST_NON_NEGATIVE_INTEGER; break;
+ base = ST_NON_NEGATIVE_INTEGER;
+ break;
case SchemaType.BTC_UNSIGNED_LONG:
- base = ST_NON_NEGATIVE_INTEGER; break;
+ base = ST_NON_NEGATIVE_INTEGER;
+ break;
case SchemaType.BTC_UNSIGNED_INT:
- base = ST_UNSIGNED_LONG; break;
+ base = ST_UNSIGNED_LONG;
+ break;
case SchemaType.BTC_UNSIGNED_SHORT:
- base = ST_UNSIGNED_INT; break;
+ base = ST_UNSIGNED_INT;
+ break;
case SchemaType.BTC_UNSIGNED_BYTE:
- base = ST_UNSIGNED_SHORT; break;
+ base = ST_UNSIGNED_SHORT;
+ break;
// derived strings
case SchemaType.BTC_NORMALIZED_STRING:
- base = ST_STRING; break;
+ base = ST_STRING;
+ break;
case SchemaType.BTC_TOKEN:
- base = ST_NORMALIZED_STRING; break;
+ base = ST_NORMALIZED_STRING;
+ break;
case SchemaType.BTC_NAME:
- base = ST_TOKEN; break;
+ base = ST_TOKEN;
+ break;
case SchemaType.BTC_NCNAME:
- base = ST_NAME; break;
+ base = ST_NAME;
+ break;
case SchemaType.BTC_ID:
case SchemaType.BTC_IDREF:
case SchemaType.BTC_ENTITY:
- base = ST_NCNAME; break;
+ base = ST_NCNAME;
+ break;
case SchemaType.BTC_LANGUAGE:
case SchemaType.BTC_NMTOKEN:
- base = ST_TOKEN; break;
+ base = ST_TOKEN;
+ break;
case SchemaType.BTC_IDREFS:
case SchemaType.BTC_ENTITIES:
case SchemaType.BTC_NMTOKENS:
variety = SchemaType.LIST;
base = ST_ANY_SIMPLE;
- if (btc == SchemaType.BTC_IDREFS)
+ if (btc == SchemaType.BTC_IDREFS) {
item = ST_IDREF;
- else if (btc == SchemaType.BTC_ENTITIES)
+ } else if (btc == SchemaType.BTC_ENTITIES) {
item = ST_ENTITY;
- else
+ } else {
item = ST_NMTOKEN;
+ }
break;
// derived durations
@@ -765,26 +727,24 @@
result.setDerivationType(derivationType);
result.setSimpleTypeVariety(variety);
- if (variety != SchemaType.NOT_SIMPLE)
- {
+ if (variety != SchemaType.NOT_SIMPLE) {
result.setSimpleType(true);
- }
- else
- {
+ } else {
assert (btc == SchemaType.BTC_ANY_TYPE || btc == SchemaType.BTC_NOT_BUILTIN);
}
result.setBaseTypeRef(base == null ? null : base.getRef());
- result.setBaseDepth(base == null ? 0 : ((SchemaTypeImpl)base).getBaseDepth() + 1);
+ result.setBaseDepth(base == null ? 0 : ((SchemaTypeImpl) base).getBaseDepth() + 1);
result.setListItemTypeRef(item == null ? null : item.getRef());
if (btc >= SchemaType.BTC_FIRST_PRIMITIVE && btc <= SchemaType.BTC_LAST_PRIMITIVE ||
- btc == BTC_ANY_ATOMIC)
+ btc == BTC_ANY_ATOMIC) {
result.setPrimitiveTypeRef(result.getRef());
- else if (variety == SchemaType.ATOMIC)
- {
- if (base == null)
+ } else if (variety == SchemaType.ATOMIC) {
+ if (base == null) {
throw new IllegalStateException("Base was null for " + btc);
- if (base.getPrimitiveType() == null)
+ }
+ if (base.getPrimitiveType() == null) {
throw new IllegalStateException("Base.gpt was null for " + btc);
+ }
result.setPrimitiveTypeRef(base.getPrimitiveType().getRef());
}
@@ -794,10 +754,9 @@
int decimalSize = SchemaType.NOT_DECIMAL;
// now set up facets
- switch (btc)
- {
+ switch (btc) {
default:
- assert(false);
+ assert (false);
case SchemaType.BTC_ANY_TYPE:
case SchemaType.BTC_ANY_SIMPLE:
@@ -955,7 +914,7 @@
fixedf = FIXED_FACETS_WS;
wsr = SchemaType.WS_COLLAPSE;
break;
-
+
}
// fundamental facets
@@ -964,10 +923,9 @@
boolean isFinite = false;
boolean isBounded = false;
- switch (btc)
- {
+ switch (btc) {
default:
- assert(false);
+ assert (false);
case SchemaType.BTC_ANY_TYPE:
case SchemaType.BTC_NOT_BUILTIN:
@@ -1051,14 +1009,13 @@
String pattern = null;
boolean hasPattern = false;
- switch (btc)
- {
+ switch (btc) {
case SchemaType.BTC_LANGUAGE:
- pattern = "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"; // we used to have ([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*", but s4s uses the more lenient pattern to the left.
+ pattern = "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"; // we used to have ([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*", but s4s uses the more lenient pattern to the left.
hasPattern = true;
break;
case SchemaType.BTC_NMTOKEN:
- pattern = "\\c+";
+ pattern = "\\c+";
hasPattern = true;
break;
case SchemaType.BTC_NAME:
@@ -1086,20 +1043,20 @@
break;
}
- if (pattern != null)
- {
+ if (pattern != null) {
org.apache.xmlbeans.impl.regex.RegularExpression p = null;
- try { p = org.apache.xmlbeans.impl.regex.SchemaRegularExpression.forPattern(pattern); }
- catch (org.apache.xmlbeans.impl.regex.ParseException e) { assert false; }
- result.setPatterns(new org.apache.xmlbeans.impl.regex.RegularExpression[] {p});
+ try {
+ p = org.apache.xmlbeans.impl.regex.SchemaRegularExpression.forPattern(pattern);
+ } catch (org.apache.xmlbeans.impl.regex.ParseException e) {
+ assert false;
+ }
+ result.setPatterns(new org.apache.xmlbeans.impl.regex.RegularExpression[]{p});
}
result.setPatternFacet(hasPattern);
-
// ANY_TYPE has to be able to act like a complex type
- if (btc == SchemaType.BTC_ANY_TYPE)
- {
+ if (btc == SchemaType.BTC_ANY_TYPE) {
SchemaParticleImpl contentModel = new SchemaParticleImpl();
contentModel.setParticleType(SchemaParticle.WILDCARD);
contentModel.setWildcardSet(QNameSet.ALL);
@@ -1117,9 +1074,7 @@
result.setContentModel(contentModel, attrModel, Collections.EMPTY_MAP, Collections.EMPTY_MAP, false);
result.setAnonymousTypeRefs(EMPTY_SCHEMATYPEREF_ARRAY);
result.setWildcardSummary(QNameSet.ALL, true, QNameSet.ALL, true);
- }
- else if (btc == SchemaType.BTC_NOT_BUILTIN)
- {
+ } else if (btc == SchemaType.BTC_NOT_BUILTIN) {
// so does the no_type : it permits no contents (and even empty contents is invalid, but that's special-cased)
SchemaParticleImpl contentModel = null; // empty
SchemaAttributeModelImpl attrModel = new SchemaAttributeModelImpl(); // empty
@@ -1132,8 +1087,7 @@
result.setOrderSensitive(false);
}
- public static SchemaType getNoType()
- {
+ public static SchemaType getNoType() {
return ST_NO_TYPE;
}
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Cur.java b/src/main/java/org/apache/xmlbeans/impl/store/Cur.java
index 93ea0f1..73446e3 100755
--- a/src/main/java/org/apache/xmlbeans/impl/store/Cur.java
+++ b/src/main/java/org/apache/xmlbeans/impl/store/Cur.java
@@ -31,7 +31,7 @@
// DOM Level 3
-final class Cur {
+public final class Cur {
static final int TEXT = 0; // Must be 0
static final int ROOT = 1;
static final int ELEM = 2;
@@ -47,6 +47,37 @@
static final int END_POS = -1;
static final int NO_POS = -2;
+ Locale _locale;
+
+ Xobj _xobj;
+ int _pos;
+
+ int _state;
+
+ String _id;
+
+ Cur _nextTemp;
+ Cur _prevTemp;
+ int _tempFrame;
+
+ Cur _next;
+ Cur _prev;
+
+ Locale.Ref _ref;
+
+ int _stackTop;
+
+ int _selectionFirst;
+ int _selectionN;
+ int _selectionLoc;
+ int _selectionCount;
+
+ private int _posTemp;
+
+ int _offSrc;
+ int _cchSrc;
+
+
Cur(Locale l) {
_locale = l;
_pos = NO_POS;
@@ -62,7 +93,7 @@
_selectionCount = 0;
}
- boolean isPositioned() {
+ public boolean isPositioned() {
assert isNormal();
return _xobj != null;
}
@@ -75,74 +106,74 @@
return k == -ELEM || k == -ROOT;
}
- int kind() {
+ public int kind() {
assert isPositioned();
int kind = _xobj.kind();
return _pos == 0 ? kind : (_pos == END_POS ? -kind : TEXT);
}
- boolean isRoot() {
+ public boolean isRoot() {
assert isPositioned();
return _pos == 0 && _xobj.kind() == ROOT;
}
- boolean isElem() {
+ public boolean isElem() {
assert isPositioned();
return _pos == 0 && _xobj.kind() == ELEM;
}
- boolean isAttr() {
+ public boolean isAttr() {
assert isPositioned();
return _pos == 0 && _xobj.kind() == ATTR;
}
- boolean isComment() {
+ public boolean isComment() {
assert isPositioned();
return _pos == 0 && _xobj.kind() == COMMENT;
}
- boolean isProcinst() {
+ public boolean isProcinst() {
assert isPositioned();
return _pos == 0 && _xobj.kind() == PROCINST;
}
- boolean isText() {
+ public boolean isText() {
assert isPositioned();
return _pos > 0;
}
- boolean isEnd() {
+ public boolean isEnd() {
assert isPositioned();
return _pos == END_POS && _xobj.kind() == ELEM;
}
- boolean isEndRoot() {
+ public boolean isEndRoot() {
assert isPositioned();
return _pos == END_POS && _xobj.kind() == ROOT;
}
- boolean isNode() {
+ public boolean isNode() {
assert isPositioned();
return _pos == 0;
}
- boolean isContainer() {
+ public boolean isContainer() {
assert isPositioned();
return _pos == 0 && kindIsContainer(_xobj.kind());
}
- boolean isFinish() {
+ public boolean isFinish() {
assert isPositioned();
return _pos == END_POS && kindIsContainer(_xobj.kind());
}
- boolean isUserNode() {
+ public boolean isUserNode() {
assert isPositioned();
int k = kind();
return k == ELEM || k == ROOT || (k == ATTR && !isXmlns());
}
- boolean isContainerOrFinish() {
+ public boolean isContainerOrFinish() {
assert isPositioned();
if (_pos != 0 && _pos != END_POS) {
@@ -153,55 +184,55 @@
return kind == ELEM || kind == -ELEM || kind == ROOT || kind == -ROOT;
}
- boolean isNormalAttr() {
+ public boolean isNormalAttr() {
return isNode() && _xobj.isNormalAttr();
}
- boolean isXmlns() {
+ public boolean isXmlns() {
return isNode() && _xobj.isXmlns();
}
- boolean isTextCData() {
+ public boolean isTextCData() {
return _xobj.hasBookmark(CDataBookmark.class, _pos);
}
- QName getName() {
+ public QName getName() {
assert isNode() || isEnd();
return _xobj._name;
}
- String getLocal() {
+ public String getLocal() {
return getName().getLocalPart();
}
- String getUri() {
+ public String getUri() {
return getName().getNamespaceURI();
}
- String getXmlnsPrefix() {
+ public String getXmlnsPrefix() {
assert isXmlns();
return _xobj.getXmlnsPrefix();
}
- String getXmlnsUri() {
+ public String getXmlnsUri() {
assert isXmlns();
return _xobj.getXmlnsUri();
}
- boolean isDomDocRoot() {
+ public boolean isDomDocRoot() {
return isRoot() && _xobj.getDom() instanceof Document;
}
- boolean isDomFragRoot() {
+ public boolean isDomFragRoot() {
return isRoot() && _xobj.getDom() instanceof DocumentFragment;
}
- int cchRight() {
+ public int cchRight() {
assert isPositioned();
return _xobj.cchRight(_pos);
}
- int cchLeft() {
+ public int cchLeft() {
assert isPositioned();
return _xobj.cchLeft(_pos);
}
@@ -758,7 +789,7 @@
private int _naked; // Entries without Curs
}
- void push() {
+ public void push() {
assert isPositioned();
int i = _locale._locations.allocate(this);
@@ -788,13 +819,13 @@
return _locale._locations.isSamePos(_stackTop, this);
}
- boolean isAtEndOfLastPush() {
+ public boolean isAtEndOfLastPush() {
assert _stackTop != Locations.NULL;
return _locale._locations.isAtEndOf(_stackTop, this);
}
- void addToSelection(Cur that) {
+ public void addToSelection(Cur that) {
assert that != null && that.isNormal();
assert isPositioned() && that.isPositioned();
@@ -804,7 +835,7 @@
_selectionCount++;
}
- void addToSelection() {
+ public void addToSelection() {
assert isPositioned();
int i = _locale._locations.allocate(this);
@@ -854,17 +885,17 @@
_selectionCount--;
}
- int selectionCount() {
+ public int selectionCount() {
return _selectionCount;
}
- void moveToSelection(int i) {
+ public void moveToSelection(int i) {
assert i >= 0 && i < _selectionCount;
_locale._locations.moveTo(selectionIndex(i), this);
}
- void clearSelection() {
+ public void clearSelection() {
assert _selectionCount >= 0;
while (_selectionCount > 0) {
@@ -872,23 +903,23 @@
}
}
- boolean toParent() {
+ public boolean toParent() {
return toParent(false);
}
- boolean toParentRaw() {
+ public boolean toParentRaw() {
return toParent(true);
}
- Xobj getParent() {
+ public Xobj getParent() {
return getParent(false);
}
- Xobj getParentRaw() {
+ public Xobj getParentRaw() {
return getParent(true);
}
- boolean hasParent() {
+ public boolean hasParent() {
assert isPositioned();
if (_pos == END_POS || (_pos >= 1 && _pos < _xobj.posAfter())) {
@@ -900,7 +931,7 @@
return _xobj._parent != null;
}
- Xobj getParentNoRoot() {
+ public Xobj getParentNoRoot() {
assert isPositioned();
if (_pos == END_POS || (_pos >= 1 && _pos < _xobj.posAfter())) {
@@ -916,7 +947,7 @@
return null;
}
- Xobj getParent(boolean raw) {
+ public Xobj getParent(boolean raw) {
assert isPositioned();
if (_pos == END_POS || (_pos >= 1 && _pos < _xobj.posAfter())) {
@@ -946,7 +977,7 @@
return root;
}
- boolean toParent(boolean raw) {
+ public boolean toParent(boolean raw) {
Xobj parent = getParent(raw);
if (parent == null) {
@@ -958,7 +989,7 @@
return true;
}
- void toRoot() {
+ public void toRoot() {
Xobj xobj = _xobj;
while (!xobj.isRoot()) {
if (xobj._parent == null) {
@@ -980,25 +1011,25 @@
moveTo(xobj);
}
- boolean hasText() {
+ public boolean hasText() {
assert isNode();
return _xobj.hasTextEnsureOccupancy();
}
- boolean hasAttrs() {
+ public boolean hasAttrs() {
assert isNode();
return _xobj.hasAttrs();
}
- boolean hasChildren() {
+ public boolean hasChildren() {
assert isNode();
return _xobj.hasChildren();
}
- boolean toFirstChild() {
+ public boolean toFirstChild() {
assert isNode();
if (!_xobj.hasChildren()) {
@@ -1013,7 +1044,7 @@
}
}
- protected boolean toLastChild() {
+ public boolean toLastChild() {
assert isNode();
if (!_xobj.hasChildren()) {
@@ -1025,7 +1056,7 @@
return true;
}
- boolean toNextSibling() {
+ public boolean toNextSibling() {
assert isNode();
if (_xobj.isAttr()) {
@@ -1041,7 +1072,7 @@
return false;
}
- void setValueAsQName(QName qname) {
+ public void setValueAsQName(QName qname) {
assert isNode();
String value = qname.getLocalPart();
@@ -1058,7 +1089,7 @@
setValue(value);
}
- void setValue(String value) {
+ public void setValue(String value) {
assert isNode();
moveNodeContents(null, false);
@@ -1070,7 +1101,7 @@
toParent();
}
- void removeFollowingAttrs() {
+ public void removeFollowingAttrs() {
assert isAttr();
QName attrName = getName();
@@ -1090,7 +1121,7 @@
pop();
}
- String getAttrValue(QName name) {
+ public String getAttrValue(QName name) {
String s = null;
push();
@@ -1104,7 +1135,7 @@
return s;
}
- void setAttrValueAsQName(QName value) {
+ public void setAttrValueAsQName(QName value) {
assert isContainer();
final QName name = Locale._xsiType;
@@ -1124,19 +1155,19 @@
toParent();
}
- boolean removeAttr(QName name) {
+ public boolean removeAttr(QName name) {
assert isContainer();
return _xobj.removeAttr(name);
}
- void setAttrValue(QName name, String value) {
+ public void setAttrValue(QName name, String value) {
assert isContainer();
_xobj.setAttr(name, value);
}
- boolean toAttr(QName name) {
+ public boolean toAttr(QName name) {
assert isNode();
Xobj a = _xobj.getAttr(name);
@@ -1150,7 +1181,7 @@
return true;
}
- boolean toFirstAttr() {
+ public boolean toFirstAttr() {
assert isNode();
Xobj firstAttr = _xobj.firstAttr();
@@ -1164,7 +1195,7 @@
return true;
}
- boolean toLastAttr() {
+ public boolean toLastAttr() {
assert isNode();
if (!toFirstAttr()) {
@@ -1179,7 +1210,7 @@
return true;
}
- boolean toNextAttr() {
+ public boolean toNextAttr() {
assert isAttr() || isContainer();
Xobj nextAttr = _xobj.nextAttr();
@@ -1194,7 +1225,7 @@
}
@SuppressWarnings("UnusedReturnValue")
- boolean toPrevAttr() {
+ public boolean toPrevAttr() {
if (isAttr()) {
if (_xobj._prevSibling == null) {
moveTo(_xobj.ensureParent());
@@ -1216,7 +1247,7 @@
}
@SuppressWarnings("UnusedReturnValue")
- boolean skipWithAttrs() {
+ public boolean skipWithAttrs() {
assert isNode();
if (skip()) {
@@ -1236,7 +1267,7 @@
return true;
}
- boolean skip() {
+ public boolean skip() {
assert isNode();
if (_xobj.isRoot()) {
@@ -1256,13 +1287,13 @@
return true;
}
- void toEnd() {
+ public void toEnd() {
assert isNode();
moveTo(_xobj, END_POS);
}
- void moveToCharNode(CharNode node) {
+ public void moveToCharNode(CharNode node) {
assert node.getDom() != null && node.getDom().locale() == _locale;
moveToDom(node.getDom());
@@ -1295,7 +1326,7 @@
}
@SuppressWarnings("UnusedReturnValue")
- boolean prevWithAttrs() {
+ public boolean prevWithAttrs() {
if (prev()) {
return true;
}
@@ -1309,7 +1340,7 @@
return true;
}
- boolean prev() {
+ public boolean prev() {
assert isPositioned();
if (_xobj.isRoot() && _pos == 0) {
@@ -1360,11 +1391,11 @@
}
@SuppressWarnings("UnusedReturnValue")
- boolean next(boolean withAttrs) {
+ public boolean next(boolean withAttrs) {
return withAttrs ? nextWithAttrs() : next();
}
- boolean nextWithAttrs() {
+ public boolean nextWithAttrs() {
int k = kind();
if (kindIsContainer(k)) {
@@ -1386,7 +1417,7 @@
return next();
}
- boolean next() {
+ public boolean next() {
assert isNormal();
Xobj x = _xobj;
@@ -2325,7 +2356,7 @@
}
}
- Cur weakCur(Object o) {
+ public Cur weakCur(Object o) {
Cur c = _locale.weakCur(o);
c.moveToCur(this);
return c;
@@ -2529,7 +2560,7 @@
return _xobj._user;
}
- XmlObject getObject() {
+ public XmlObject getObject() {
return isUserNode() ? (XmlObject) getUser() : null;
}
@@ -2539,7 +2570,7 @@
return _xobj.getUser();
}
- Dom getDom() {
+ public Dom getDom() {
assert isNormal();
assert isPositioned();
@@ -2556,7 +2587,7 @@
return _xobj.getDom();
}
- void release() {
+ public void release() {
if (_tempFrame >= 0) {
if (_nextTemp != null) {
_nextTemp._prevTemp = _prevTemp;
@@ -2695,8 +2726,8 @@
return isOnList(_locale._registered);
}
- static final class CurLoadContext extends LoadContext {
- CurLoadContext(Locale l, XmlOptions options) {
+ public static final class CurLoadContext extends LoadContext {
+ public CurLoadContext(Locale l, XmlOptions options) {
options = XmlOptions.maskNull(options);
_locale = l;
@@ -2876,7 +2907,7 @@
_lastPos = 0;
}
- protected void attr(QName name, String value) {
+ public void attr(QName name, String value) {
assert parent().isContainer();
// BUGBUG - should assert there that there is no text before this attr
@@ -3019,7 +3050,7 @@
finish().release();
}
- protected Cur finish() {
+ public Cur finish() {
flushText();
if (_after) {
@@ -3391,37 +3422,7 @@
_id = id;
}
- //
- //
- //
-
- Locale _locale;
-
- Xobj _xobj;
- int _pos;
-
- int _state;
-
- String _id;
-
- Cur _nextTemp;
- Cur _prevTemp;
- int _tempFrame;
-
- Cur _next;
- Cur _prev;
-
- Locale.Ref _ref;
-
- int _stackTop;
-
- int _selectionFirst;
- int _selectionN;
- int _selectionLoc;
- int _selectionCount;
-
- private int _posTemp;
-
- int _offSrc;
- int _cchSrc;
+ public Locale getLocale() {
+ return _locale;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Cursor.java b/src/main/java/org/apache/xmlbeans/impl/store/Cursor.java
index acdd4bb..1df26b8 100755
--- a/src/main/java/org/apache/xmlbeans/impl/store/Cursor.java
+++ b/src/main/java/org/apache/xmlbeans/impl/store/Cursor.java
@@ -22,8 +22,9 @@
import org.apache.xmlbeans.impl.common.GlobalLock;
import org.apache.xmlbeans.impl.common.XMLChar;
import org.apache.xmlbeans.impl.store.Locale.ChangeListener;
-import org.apache.xmlbeans.impl.store.Path.PathEngine;
import org.apache.xmlbeans.impl.store.Saver.TextSaver;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
import org.apache.xmlbeans.xml.stream.XMLInputStream;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
@@ -46,7 +47,7 @@
static final int TEXT = Cur.TEXT;
private Cur _cur;
- private PathEngine _pathEngine;
+ private XPathEngine _pathEngine;
private int _currentSelection;
private ChangeListener _nextChangeListener;
@@ -57,7 +58,7 @@
_currentSelection = -1;
}
- Cursor(Cur c) {
+ public Cursor(Cur c) {
this(c._xobj, c._pos);
}
@@ -728,7 +729,7 @@
assert _pathEngine == null;
- _pathEngine = Path.getCompiledPath(pathExpr, options).execute(_cur, options);
+ _pathEngine = XPathFactory.getCompiledPath(pathExpr, options).execute(_cur, options);
_cur._locale.registerForChange(this);
}
@@ -816,7 +817,7 @@
return _cur.prefixForNamespace(ns, null, true);
}
- public void _getAllNamespaces(Map<String,String> addToThis) {
+ public void _getAllNamespaces(Map<String, String> addToThis) {
if (!_cur.isContainer()) {
throw new IllegalStateException("Not on a container");
}
@@ -1192,7 +1193,7 @@
public XmlCursor _execQuery(String query, XmlOptions options) {
checkThisCursor();
- return Query.cursorExecQuery(_cur, query, options);
+ return XPathFactory.cursorExecQuery(_cur, query, options);
}
@@ -2097,7 +2098,7 @@
return syncWrap(() -> _prefixForNamespace(namespaceURI));
}
- public void getAllNamespaces(Map<String,String> addToThis) {
+ public void getAllNamespaces(Map<String, String> addToThis) {
syncWrap(() -> _getAllNamespaces(addToThis));
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java b/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java
index 8102667..db5dc43 100755
--- a/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java
+++ b/src/main/java/org/apache/xmlbeans/impl/store/DomImpl.java
@@ -33,56 +33,71 @@
// DOM Level 3
-final class DomImpl
-{
- static final int ELEMENT = Node.ELEMENT_NODE;
- static final int ATTR = Node.ATTRIBUTE_NODE;
- static final int TEXT = Node.TEXT_NODE;
- static final int CDATA = Node.CDATA_SECTION_NODE;
+public final class DomImpl {
+ static final int ELEMENT = Node.ELEMENT_NODE;
+ static final int ATTR = Node.ATTRIBUTE_NODE;
+ static final int TEXT = Node.TEXT_NODE;
+ static final int CDATA = Node.CDATA_SECTION_NODE;
static final int ENTITYREF = Node.ENTITY_REFERENCE_NODE;
- static final int ENTITY = Node.ENTITY_NODE;
- static final int PROCINST = Node.PROCESSING_INSTRUCTION_NODE;
- static final int COMMENT = Node.COMMENT_NODE;
- static final int DOCUMENT = Node.DOCUMENT_NODE;
- static final int DOCTYPE = Node.DOCUMENT_TYPE_NODE;
- static final int DOCFRAG = Node.DOCUMENT_FRAGMENT_NODE;
- static final int NOTATION = Node.NOTATION_NODE;
+ static final int ENTITY = Node.ENTITY_NODE;
+ static final int PROCINST = Node.PROCESSING_INSTRUCTION_NODE;
+ static final int COMMENT = Node.COMMENT_NODE;
+ static final int DOCUMENT = Node.DOCUMENT_NODE;
+ static final int DOCTYPE = Node.DOCUMENT_TYPE_NODE;
+ static final int DOCFRAG = Node.DOCUMENT_FRAGMENT_NODE;
+ static final int NOTATION = Node.NOTATION_NODE;
- interface Dom
- {
- Locale locale ( );
- int nodeType ( );
- Cur tempCur ( );
- QName getQName ( );
- boolean nodeCanHavePrefixUri( );
+ public interface Dom {
+ Locale locale();
- void dump ( );
- void dump ( PrintStream o );
- void dump ( PrintStream o, Object ref );
- };
+ int nodeType();
- static Dom parent ( Dom d ) { return node_getParentNode ( d ); }
- static Dom firstChild ( Dom d ) { return node_getFirstChild ( d ); }
- static Dom nextSibling ( Dom d ) { return node_getNextSibling( d ); }
- static Dom prevSibling ( Dom d ) { return node_getPreviousSibling( d ); }
+ Cur tempCur();
- public static Dom append ( Dom n, Dom p )
- {
- return node_insertBefore( p, n, null );
+ QName getQName();
+
+ boolean nodeCanHavePrefixUri();
+
+ void dump();
+
+ void dump(PrintStream o);
+
+ void dump(PrintStream o, Object ref);
}
- public static Dom insert ( Dom n, Dom b )
- {
+ ;
+
+ static Dom parent(Dom d) {
+ return node_getParentNode(d);
+ }
+
+ static Dom firstChild(Dom d) {
+ return node_getFirstChild(d);
+ }
+
+ static Dom nextSibling(Dom d) {
+ return node_getNextSibling(d);
+ }
+
+ static Dom prevSibling(Dom d) {
+ return node_getPreviousSibling(d);
+ }
+
+ public static Dom append(Dom n, Dom p) {
+ return node_insertBefore(p, n, null);
+ }
+
+ public static Dom insert(Dom n, Dom b) {
assert b != null;
- return node_insertBefore( parent( b ), n, b );
+ return node_insertBefore(parent(b), n, b);
}
- public static Dom remove ( Dom n )
- {
- Dom p = parent( n );
+ public static Dom remove(Dom n) {
+ Dom p = parent(n);
- if (p != null)
- node_removeChild( p, n );
+ if (p != null) {
+ node_removeChild(p, n);
+ }
return n;
}
@@ -91,304 +106,356 @@
// Handy dandy Dom exceptions
//
- static class HierarchyRequestErr extends DOMException
- {
- HierarchyRequestErr ( ) { this( "This node isn't allowed there" ); }
- HierarchyRequestErr ( String message ) { super( HIERARCHY_REQUEST_ERR, message ); }
+ static class HierarchyRequestErr extends DOMException {
+ HierarchyRequestErr() {
+ this("This node isn't allowed there");
+ }
+
+ HierarchyRequestErr(String message) {
+ super(HIERARCHY_REQUEST_ERR, message);
+ }
}
- static class WrongDocumentErr extends DOMException
- {
- WrongDocumentErr ( ) { this( "Nodes do not belong to the same document" ); }
- WrongDocumentErr ( String message ) { super( WRONG_DOCUMENT_ERR, message ); }
+ static class WrongDocumentErr extends DOMException {
+ WrongDocumentErr() {
+ this("Nodes do not belong to the same document");
+ }
+
+ WrongDocumentErr(String message) {
+ super(WRONG_DOCUMENT_ERR, message);
+ }
}
- static class NotFoundErr extends DOMException
- {
- NotFoundErr ( ) { this( "Node not found" ); }
- NotFoundErr ( String message ) { super( NOT_FOUND_ERR, message ); }
+ static class NotFoundErr extends DOMException {
+ NotFoundErr() {
+ this("Node not found");
+ }
+
+ NotFoundErr(String message) {
+ super(NOT_FOUND_ERR, message);
+ }
}
- static class NamespaceErr extends DOMException
- {
- NamespaceErr ( ) { this( "Namespace error" ); }
- NamespaceErr ( String message ) { super( NAMESPACE_ERR, message ); }
+ static class NamespaceErr extends DOMException {
+ NamespaceErr() {
+ this("Namespace error");
+ }
+
+ NamespaceErr(String message) {
+ super(NAMESPACE_ERR, message);
+ }
}
- static class NoModificationAllowedErr extends DOMException
- {
- NoModificationAllowedErr ( ) { this( "No modification allowed error" ); }
- NoModificationAllowedErr ( String message ) { super( NO_MODIFICATION_ALLOWED_ERR, message ); }
+ static class NoModificationAllowedErr extends DOMException {
+ NoModificationAllowedErr() {
+ this("No modification allowed error");
+ }
+
+ NoModificationAllowedErr(String message) {
+ super(NO_MODIFICATION_ALLOWED_ERR, message);
+ }
}
- static class InuseAttributeError extends DOMException
- {
- InuseAttributeError ( ) { this( "Attribute currently in use error" ); }
- InuseAttributeError ( String message ) { super( INUSE_ATTRIBUTE_ERR, message ); }
+ static class InuseAttributeError extends DOMException {
+ InuseAttributeError() {
+ this("Attribute currently in use error");
+ }
+
+ InuseAttributeError(String message) {
+ super(INUSE_ATTRIBUTE_ERR, message);
+ }
}
- static class IndexSizeError extends DOMException
- {
- IndexSizeError ( ) { this( "Index Size Error" ); }
- IndexSizeError ( String message ) { super( INDEX_SIZE_ERR, message ); }
+ static class IndexSizeError extends DOMException {
+ IndexSizeError() {
+ this("Index Size Error");
+ }
+
+ IndexSizeError(String message) {
+ super(INDEX_SIZE_ERR, message);
+ }
}
- static class NotSupportedError extends DOMException
- {
- NotSupportedError ( ) { this( "This operation is not supported" ); }
- NotSupportedError ( String message ) { super( NOT_SUPPORTED_ERR, message ); }
+ static class NotSupportedError extends DOMException {
+ NotSupportedError() {
+ this("This operation is not supported");
+ }
+
+ NotSupportedError(String message) {
+ super(NOT_SUPPORTED_ERR, message);
+ }
}
- static class InvalidCharacterError extends DOMException
- {
- InvalidCharacterError ( ) { this( "The name contains an invalid character" ); }
- InvalidCharacterError ( String message ) { super( INVALID_CHARACTER_ERR, message ); }
+ static class InvalidCharacterError extends DOMException {
+ InvalidCharacterError() {
+ this("The name contains an invalid character");
+ }
+
+ InvalidCharacterError(String message) {
+ super(INVALID_CHARACTER_ERR, message);
+ }
}
//
// Helper fcns
//
- private static final class EmptyNodeList implements NodeList
- {
- public int getLength ( ) { return 0; }
- public Node item ( int i ) { return null; }
+ private static final class EmptyNodeList implements NodeList {
+ public int getLength() {
+ return 0;
+ }
+
+ public Node item(int i) {
+ return null;
+ }
}
public static NodeList _emptyNodeList = new EmptyNodeList();
- static String nodeKindName ( int t )
- {
- switch ( t )
- {
- case ATTR : return "attribute";
- case CDATA : return "cdata section";
- case COMMENT : return "comment";
- case DOCFRAG : return "document fragment";
- case DOCUMENT : return "document";
- case DOCTYPE : return "document type";
- case ELEMENT : return "element";
- case ENTITY : return "entity";
- case ENTITYREF : return "entity reference";
- case NOTATION : return "notation";
- case PROCINST : return "processing instruction";
- case TEXT : return "text";
+ static String nodeKindName(int t) {
+ switch (t) {
+ case ATTR:
+ return "attribute";
+ case CDATA:
+ return "cdata section";
+ case COMMENT:
+ return "comment";
+ case DOCFRAG:
+ return "document fragment";
+ case DOCUMENT:
+ return "document";
+ case DOCTYPE:
+ return "document type";
+ case ELEMENT:
+ return "element";
+ case ENTITY:
+ return "entity";
+ case ENTITYREF:
+ return "entity reference";
+ case NOTATION:
+ return "notation";
+ case PROCINST:
+ return "processing instruction";
+ case TEXT:
+ return "text";
- default : throw new RuntimeException( "Unknown node type" );
+ default:
+ throw new RuntimeException("Unknown node type");
}
}
- private static String isValidChild ( Dom parent, Dom child )
- {
+ private static String isValidChild(Dom parent, Dom child) {
int pk = parent.nodeType();
int ck = child.nodeType();
- switch ( pk )
- {
- case DOCUMENT :
- {
- switch ( ck )
- {
- case ELEMENT :
- {
- if (document_getDocumentElement( parent ) != null)
- return "Documents may only have a maximum of one document element";
+ switch (pk) {
+ case DOCUMENT: {
+ switch (ck) {
+ case ELEMENT: {
+ if (document_getDocumentElement(parent) != null) {
+ return "Documents may only have a maximum of one document element";
+ }
- return null;
- }
- case DOCTYPE :
- {
- if (document_getDoctype( parent ) != null)
- return "Documents may only have a maximum of one document type node";
+ return null;
+ }
+ case DOCTYPE: {
+ if (document_getDoctype(parent) != null) {
+ return "Documents may only have a maximum of one document type node";
+ }
- return null;
- }
- case PROCINST :
- case COMMENT :
- return null;
+ return null;
+ }
+ case PROCINST:
+ case COMMENT:
+ return null;
+ }
+
+ break;
}
- break;
- }
+ case ATTR: {
+ if (ck == TEXT || ck == ENTITYREF) {
+ return null;
+ }
- case ATTR :
- {
- if (ck == TEXT || ck == ENTITYREF)
- return null;
+ // TODO -- traverse the entity tree, making sure that there are
+ // only entity refs and text nodes in it.
- // TODO -- traverse the entity tree, making sure that there are
- // only entity refs and text nodes in it.
-
- break;
- }
-
- case DOCFRAG :
- case ELEMENT :
- case ENTITY :
- case ENTITYREF :
- {
- switch ( ck )
- {
- case ELEMENT :
- case ENTITYREF:
- case CDATA :
- case TEXT :
- case COMMENT :
- case PROCINST :
- return null;
+ break;
}
- break;
- }
+ case DOCFRAG:
+ case ELEMENT:
+ case ENTITY:
+ case ENTITYREF: {
+ switch (ck) {
+ case ELEMENT:
+ case ENTITYREF:
+ case CDATA:
+ case TEXT:
+ case COMMENT:
+ case PROCINST:
+ return null;
+ }
- case CDATA :
- case TEXT :
- case COMMENT :
- case PROCINST :
- case DOCTYPE :
- case NOTATION :
- return nodeKindName( pk ) + " nodes may not have any children";
+ break;
+ }
+
+ case CDATA:
+ case TEXT:
+ case COMMENT:
+ case PROCINST:
+ case DOCTYPE:
+ case NOTATION:
+ return nodeKindName(pk) + " nodes may not have any children";
}
return
- nodeKindName( pk ) + " nodes may not have " +
- nodeKindName( ck ) + " nodes as children";
+ nodeKindName(pk) + " nodes may not have " +
+ nodeKindName(ck) + " nodes as children";
}
- private static void validateNewChild ( Dom parent, Dom child )
- {
- String msg = isValidChild( parent, child );
+ private static void validateNewChild(Dom parent, Dom child) {
+ String msg = isValidChild(parent, child);
- if (msg != null)
- throw new HierarchyRequestErr( msg );
+ if (msg != null) {
+ throw new HierarchyRequestErr(msg);
+ }
- if (parent == child)
- throw new HierarchyRequestErr( "New child and parent are the same node" );
+ if (parent == child) {
+ throw new HierarchyRequestErr("New child and parent are the same node");
+ }
- while ( (parent = parent( parent )) != null )
- {
+ while ((parent = parent(parent)) != null) {
// TODO - use read only state on a node to know if it is under an
// entity ref
- if (child.nodeType() == ENTITYREF)
- throw new NoModificationAllowedErr( "Entity reference trees may not be modified" );
+ if (child.nodeType() == ENTITYREF) {
+ throw new NoModificationAllowedErr("Entity reference trees may not be modified");
+ }
- if (child == parent)
- throw new HierarchyRequestErr( "New child is an ancestor node of the parent node" );
+ if (child == parent) {
+ throw new HierarchyRequestErr("New child is an ancestor node of the parent node");
+ }
}
}
- private static String validatePrefix (
- String prefix, String uri, String local, boolean isAttr )
- {
- validateNcName( prefix );
+ private static String validatePrefix(
+ String prefix, String uri, String local, boolean isAttr) {
+ validateNcName(prefix);
- if (prefix == null)
+ if (prefix == null) {
prefix = "";
-
- if (uri == null)
- uri = "";
-
- if (prefix.length() > 0 && uri.length() == 0)
- throw new NamespaceErr( "Attempt to give a prefix for no namespace" );
-
- if (prefix.equals( "xml" ) && !uri.equals( Locale._xml1998Uri ))
- throw new NamespaceErr( "Invalid prefix - begins with 'xml'" );
-
- if (isAttr)
- {
- if (prefix.length() > 0)
- {
- if (local.equals( "xmlns" ))
- throw new NamespaceErr( "Invalid namespace - attr is default namespace already" );
-
- if (Locale.beginsWithXml( local ))
- throw new NamespaceErr( "Invalid namespace - attr prefix begins with 'xml'" );
-
- if (prefix.equals( "xmlns" ) && !uri.equals( Locale._xmlnsUri ))
- throw new NamespaceErr( "Invalid namespace - uri is not '" + Locale._xmlnsUri+";" );
- }
- else
- {
- if (local.equals( "xmlns" ) && !uri.equals( Locale._xmlnsUri ))
- throw new NamespaceErr( "Invalid namespace - uri is not '" + Locale._xmlnsUri+";" );
- }
}
- else if (Locale.beginsWithXml( prefix ))
- throw new NamespaceErr( "Invalid prefix - begins with 'xml'" );
+
+ if (uri == null) {
+ uri = "";
+ }
+
+ if (prefix.length() > 0 && uri.length() == 0) {
+ throw new NamespaceErr("Attempt to give a prefix for no namespace");
+ }
+
+ if (prefix.equals("xml") && !uri.equals(Locale._xml1998Uri)) {
+ throw new NamespaceErr("Invalid prefix - begins with 'xml'");
+ }
+
+ if (isAttr) {
+ if (prefix.length() > 0) {
+ if (local.equals("xmlns")) {
+ throw new NamespaceErr("Invalid namespace - attr is default namespace already");
+ }
+
+ if (Locale.beginsWithXml(local)) {
+ throw new NamespaceErr("Invalid namespace - attr prefix begins with 'xml'");
+ }
+
+ if (prefix.equals("xmlns") && !uri.equals(Locale._xmlnsUri)) {
+ throw new NamespaceErr("Invalid namespace - uri is not '" + Locale._xmlnsUri + ";");
+ }
+ } else {
+ if (local.equals("xmlns") && !uri.equals(Locale._xmlnsUri)) {
+ throw new NamespaceErr("Invalid namespace - uri is not '" + Locale._xmlnsUri + ";");
+ }
+ }
+ } else if (Locale.beginsWithXml(prefix)) {
+ throw new NamespaceErr("Invalid prefix - begins with 'xml'");
+ }
return prefix;
}
- private static void validateName ( String name )
- {
- if (name == null)
- throw new IllegalArgumentException( "Name is null" );
+ private static void validateName(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name is null");
+ }
- if (name.length() == 0)
- throw new IllegalArgumentException( "Name is empty" );
+ if (name.length() == 0) {
+ throw new IllegalArgumentException("Name is empty");
+ }
- if (!XMLChar.isValidName( name ))
- throw new InvalidCharacterError( "Name has an invalid character" );
+ if (!XMLChar.isValidName(name)) {
+ throw new InvalidCharacterError("Name has an invalid character");
+ }
}
- private static void validateNcName ( String name )
- {
- if (name != null && name.length() > 0 && !XMLChar.isValidNCName( name ))
+ private static void validateNcName(String name) {
+ if (name != null && name.length() > 0 && !XMLChar.isValidNCName(name)) {
throw new InvalidCharacterError();
+ }
}
- private static void validateQualifiedName ( String name, String uri, boolean isAttr )
- {
+ private static void validateQualifiedName(String name, String uri, boolean isAttr) {
assert name != null;
- if (uri == null)
+ if (uri == null) {
uri = "";
+ }
- int i = name.indexOf( ':' );
+ int i = name.indexOf(':');
String local;
- if (i < 0)
- {
- validateNcName( local = name );
+ if (i < 0) {
+ validateNcName(local = name);
- if (isAttr && local.equals( "xmlns" ) && !uri.equals( Locale._xmlnsUri ))
- {
+ if (isAttr && local.equals("xmlns") && !uri.equals(Locale._xmlnsUri)) {
throw
new NamespaceErr(
- "Default xmlns attribute does not have namespace: " + Locale._xmlnsUri );
+ "Default xmlns attribute does not have namespace: " + Locale._xmlnsUri);
+ }
+ } else {
+ if (i == 0) {
+ throw new NamespaceErr("Invalid qualified name, no prefix specified");
+ }
+
+ String prefix = name.substring(0, i);
+
+ validateNcName(prefix);
+
+ if (uri.length() == 0) {
+ throw new NamespaceErr("Attempt to give a prefix for no namespace");
+ }
+
+ local = name.substring(i + 1);
+
+ if (local.indexOf(':') >= 0) {
+ throw new NamespaceErr("Invalid qualified name, more than one colon");
+ }
+
+ validateNcName(local);
+
+ if (prefix.equals("xml") && !uri.equals(Locale._xml1998Uri)) {
+ throw new NamespaceErr("Invalid prefix - begins with 'xml'");
}
}
- else
- {
- if (i == 0)
- throw new NamespaceErr( "Invalid qualified name, no prefix specified" );
- String prefix = name.substring( 0, i );
-
- validateNcName( prefix );
-
- if (uri.length() == 0)
- throw new NamespaceErr( "Attempt to give a prefix for no namespace" );
-
- local = name.substring( i + 1 );
-
- if (local.indexOf( ':' ) >= 0)
- throw new NamespaceErr( "Invalid qualified name, more than one colon" );
-
- validateNcName( local );
-
- if (prefix.equals( "xml" ) && !uri.equals( Locale._xml1998Uri ))
- throw new NamespaceErr( "Invalid prefix - begins with 'xml'" );
+ if (local.length() == 0) {
+ throw new NamespaceErr("Invalid qualified name, no local part specified");
}
-
- if (local.length() == 0)
- throw new NamespaceErr( "Invalid qualified name, no local part specified" );
}
- private static void removeNode ( Dom n )
- {
+ private static void removeNode(Dom n) {
assert n.nodeType() != TEXT && n.nodeType() != CDATA;
Cur cFrom = n.tempCur();
@@ -399,28 +466,24 @@
// Next here does two things, it tells me if I can get after the move to remove (all nodes
// but the root) and it positions me at the place where there are char nodes after.
- if (cFrom.next())
- {
+ if (cFrom.next()) {
CharNode fromNodes = cFrom.getCharNodes();
- if (fromNodes != null)
- {
- cFrom.setCharNodes( null );
+ if (fromNodes != null) {
+ cFrom.setCharNodes(null);
Cur cTo = n.tempCur();
- cTo.setCharNodes( CharNode.appendNodes( cTo.getCharNodes(), fromNodes ) );
+ cTo.setCharNodes(CharNode.appendNodes(cTo.getCharNodes(), fromNodes));
cTo.release();
}
}
cFrom.release();
- Cur.moveNode( (Xobj) n, null );
+ Cur.moveNode((Xobj) n, null);
}
- private abstract static class ElementsNodeList implements NodeList
- {
- ElementsNodeList ( Dom root )
- {
+ private abstract static class ElementsNodeList implements NodeList {
+ ElementsNodeList(Dom root) {
assert root.nodeType() == DOCUMENT || root.nodeType() == ELEMENT;
_root = root;
@@ -428,24 +491,22 @@
_version = 0;
}
- public int getLength ( )
- {
+ public int getLength() {
ensureElements();
return _elements.size();
}
- public Node item ( int i )
- {
+ public Node item(int i) {
ensureElements();
- return i < 0 || i >= _elements.size() ? (Node) null : (Node) _elements.get( i );
+ return i < 0 || i >= _elements.size() ? (Node) null : (Node) _elements.get(i);
}
- private void ensureElements ( )
- {
- if (_version == _locale.version())
+ private void ensureElements() {
+ if (_version == _locale.version()) {
return;
+ }
_version = _locale.version();
@@ -453,66 +514,74 @@
Locale l = _locale;
- if (l.noSync()) { l.enter(); try { addElements( _root ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { addElements( _root ); } finally { l.exit(); } }
- }
-
- private void addElements ( Dom node )
- {
- for ( Dom c = firstChild( node ) ; c != null ; c = nextSibling( c ) )
- {
- if (c.nodeType() == ELEMENT)
- {
- if (match( c ))
- _elements.add( c );
-
- addElements( c );
+ if (l.noSync()) {
+ l.enter();
+ try {
+ addElements(_root);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ addElements(_root);
+ } finally {
+ l.exit();
+ }
}
}
}
- protected abstract boolean match ( Dom element );
+ private void addElements(Dom node) {
+ for (Dom c = firstChild(node); c != null; c = nextSibling(c)) {
+ if (c.nodeType() == ELEMENT) {
+ if (match(c)) {
+ _elements.add(c);
+ }
- private Dom _root;
- private Locale _locale;
- private long _version;
+ addElements(c);
+ }
+ }
+ }
+
+ protected abstract boolean match(Dom element);
+
+ private Dom _root;
+ private Locale _locale;
+ private long _version;
private ArrayList _elements;
}
- private static class ElementsByTagNameNodeList extends ElementsNodeList
- {
- ElementsByTagNameNodeList ( Dom root, String name )
- {
- super( root );
+ private static class ElementsByTagNameNodeList extends ElementsNodeList {
+ ElementsByTagNameNodeList(Dom root, String name) {
+ super(root);
_name = name;
}
- protected boolean match ( Dom element )
- {
- return _name.equals( "*" ) ? true : _node_getNodeName( element ).equals( _name );
+ protected boolean match(Dom element) {
+ return _name.equals("*") ? true : _node_getNodeName(element).equals(_name);
}
private String _name;
}
- private static class ElementsByTagNameNSNodeList extends ElementsNodeList
- {
- ElementsByTagNameNSNodeList ( Dom root, String uri, String local )
- {
- super( root );
+ private static class ElementsByTagNameNSNodeList extends ElementsNodeList {
+ ElementsByTagNameNSNodeList(Dom root, String uri, String local) {
+ super(root);
_uri = uri == null ? "" : uri;
_local = local;
}
- protected boolean match ( Dom element )
- {
- if (!(_uri.equals( "*" ) ? true : _node_getNamespaceURI( element ).equals( _uri )))
+ protected boolean match(Dom element) {
+ if (!(_uri.equals("*") ? true : _node_getNamespaceURI(element).equals(_uri))) {
return false;
+ }
- return _local.equals( "*" ) ? true : _node_getLocalName( element ).equals( _local );
- }
+ return _local.equals("*") ? true : _node_getLocalName(element).equals(_local);
+ }
private String _uri;
private String _local;
@@ -522,19 +591,32 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Document _domImplementation_createDocument (
- Locale l, String u, String n, DocumentType t )
- {
+ public static Document _domImplementation_createDocument(
+ Locale l, String u, String n, DocumentType t) {
Document d;
- if (l.noSync()) { l.enter(); try { return domImplementation_createDocument( l, u, n, t ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return domImplementation_createDocument( l, u, n, t ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return domImplementation_createDocument(l, u, n, t);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return domImplementation_createDocument(l, u, n, t);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Document domImplementation_createDocument (
- Locale l, String namespaceURI, String qualifiedName, DocumentType doctype )
- {
- validateQualifiedName( qualifiedName, namespaceURI, false );
+ public static Document domImplementation_createDocument(
+ Locale l, String namespaceURI, String qualifiedName, DocumentType doctype) {
+ validateQualifiedName(qualifiedName, namespaceURI, false);
Cur c = l.tempCur();
@@ -544,20 +626,18 @@
c.next();
- c.createElement( l.makeQualifiedQName( namespaceURI, qualifiedName ) );
+ c.createElement(l.makeQualifiedQName(namespaceURI, qualifiedName));
- if (doctype != null)
- throw new RuntimeException( "Not impl" );
+ if (doctype != null) {
+ throw new RuntimeException("Not impl");
+ }
c.toParent();
- try
- {
- Locale.autoTypeDocument( c, null, null );
- }
- catch (XmlException e )
- {
- throw new XmlRuntimeException( e );
+ try {
+ Locale.autoTypeDocument(c, null, null);
+ } catch (XmlException e) {
+ throw new XmlRuntimeException(e);
}
c.release();
@@ -569,22 +649,23 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _domImplementation_hasFeature ( Locale l, String feature, String version )
- {
- if (feature == null)
- return false;
-
- if (version != null && version.length() > 0 &&
- !version.equals( "1.0" ) && !version.equals( "2.0" ))
- {
+ public static boolean _domImplementation_hasFeature(Locale l, String feature, String version) {
+ if (feature == null) {
return false;
}
- if (feature.equalsIgnoreCase( "core" ))
- return true;
+ if (version != null && version.length() > 0 &&
+ !version.equals("1.0") && !version.equals("2.0")) {
+ return false;
+ }
- if (feature.equalsIgnoreCase( "xml" ))
+ if (feature.equalsIgnoreCase("core")) {
return true;
+ }
+
+ if (feature.equalsIgnoreCase("xml")) {
+ return true;
+ }
return false;
}
@@ -593,24 +674,37 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Element _document_getDocumentElement ( Dom d )
- {
+ public static Element _document_getDocumentElement(Dom d) {
Locale l = d.locale();
Dom e;
- if (l.noSync()) { l.enter(); try { e = document_getDocumentElement( d ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { e = document_getDocumentElement( d ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ e = document_getDocumentElement(d);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ e = document_getDocumentElement(d);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Element) e;
}
- public static Dom document_getDocumentElement ( Dom d )
- {
- for ( d = firstChild( d ) ; d != null ; d = nextSibling( d ) )
- {
- if (d.nodeType() == ELEMENT)
+ public static Dom document_getDocumentElement(Dom d) {
+ for (d = firstChild(d); d != null; d = nextSibling(d)) {
+ if (d.nodeType() == ELEMENT) {
return d;
+ }
}
return null;
@@ -620,20 +714,33 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static DocumentFragment _document_createDocumentFragment ( Dom d )
- {
+ public static DocumentFragment _document_createDocumentFragment(Dom d) {
Locale l = d.locale();
Dom f;
- if (l.noSync()) { l.enter(); try { f = document_createDocumentFragment( d ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { f = document_createDocumentFragment( d ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ f = document_createDocumentFragment(d);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ f = document_createDocumentFragment(d);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (DocumentFragment) f;
}
- public static Dom document_createDocumentFragment ( Dom d )
- {
+ public static Dom document_createDocumentFragment(Dom d) {
Cur c = d.locale().tempCur();
c.createDomDocFragRoot();
@@ -649,32 +756,45 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Element _document_createElement ( Dom d, String name )
- {
+ public static Element _document_createElement(Dom d, String name) {
Locale l = d.locale();
Dom e;
- if (l.noSync()) { l.enter(); try { e = document_createElement( d, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { e = document_createElement( d, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ e = document_createElement(d, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ e = document_createElement(d, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Element) e;
}
- public static Dom document_createElement ( Dom d, String name )
- {
- validateName( name );
+ public static Dom document_createElement(Dom d, String name) {
+ validateName(name);
Locale l = d.locale();
Cur c = l.tempCur();
- c.createElement( l.makeQualifiedQName( "", name ) );
+ c.createElement(l.makeQualifiedQName("", name));
Dom e = c.getDom();
c.release();
- ((ElementXobj)e)._canHavePrefixUri = false;
+ ((ElementXobj) e)._canHavePrefixUri = false;
return e;
}
@@ -682,27 +802,40 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Element _document_createElementNS ( Dom d, String uri, String qname )
- {
+ public static Element _document_createElementNS(Dom d, String uri, String qname) {
Locale l = d.locale();
Dom e;
- if (l.noSync()) { l.enter(); try { e = document_createElementNS( d, uri, qname ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { e = document_createElementNS( d, uri, qname ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ e = document_createElementNS(d, uri, qname);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ e = document_createElementNS(d, uri, qname);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Element) e;
}
- public static Dom document_createElementNS ( Dom d, String uri, String qname )
- {
- validateQualifiedName( qname, uri, false );
+ public static Dom document_createElementNS(Dom d, String uri, String qname) {
+ validateQualifiedName(qname, uri, false);
Locale l = d.locale();
Cur c = l.tempCur();
- c.createElement( l.makeQualifiedQName( uri, qname ) );
+ c.createElement(l.makeQualifiedQName(uri, qname));
Dom e = c.getDom();
@@ -715,32 +848,45 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _document_createAttribute ( Dom d, String name )
- {
+ public static Attr _document_createAttribute(Dom d, String name) {
Locale l = d.locale();
Dom a;
- if (l.noSync()) { l.enter(); try { a = document_createAttribute( d, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { a = document_createAttribute( d, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ a = document_createAttribute(d, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ a = document_createAttribute(d, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Attr) a;
}
- public static Dom document_createAttribute ( Dom d, String name )
- {
- validateName( name );
+ public static Dom document_createAttribute(Dom d, String name) {
+ validateName(name);
Locale l = d.locale();
Cur c = l.tempCur();
- c.createAttr( l.makeQualifiedQName( "", name ) );
+ c.createAttr(l.makeQualifiedQName("", name));
Dom e = c.getDom();
c.release();
- ((AttrXobj)e)._canHavePrefixUri = false;
+ ((AttrXobj) e)._canHavePrefixUri = false;
return e;
}
@@ -748,27 +894,40 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _document_createAttributeNS ( Dom d, String uri, String qname )
- {
+ public static Attr _document_createAttributeNS(Dom d, String uri, String qname) {
Locale l = d.locale();
Dom a;
- if (l.noSync()) { l.enter(); try { a = document_createAttributeNS( d, uri, qname ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { a = document_createAttributeNS( d, uri, qname ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ a = document_createAttributeNS(d, uri, qname);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ a = document_createAttributeNS(d, uri, qname);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Attr) a;
}
- public static Dom document_createAttributeNS ( Dom d, String uri, String qname )
- {
- validateQualifiedName( qname, uri, true );
+ public static Dom document_createAttributeNS(Dom d, String uri, String qname) {
+ validateQualifiedName(qname, uri, true);
Locale l = d.locale();
Cur c = l.tempCur();
- c.createAttr( l.makeQualifiedQName( uri, qname ) );
+ c.createAttr(l.makeQualifiedQName(uri, qname));
Dom e = c.getDom();
@@ -781,20 +940,33 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Comment _document_createComment ( Dom d, String data )
- {
+ public static Comment _document_createComment(Dom d, String data) {
Locale l = d.locale();
Dom c;
- if (l.noSync()) { l.enter(); try { c = document_createComment( d, data ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { c = document_createComment( d, data ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ c = document_createComment(d, data);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ c = document_createComment(d, data);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Comment) c;
}
- public static Dom document_createComment ( Dom d, String data )
- {
+ public static Dom document_createComment(Dom d, String data) {
Locale l = d.locale();
Cur c = l.tempCur();
@@ -803,10 +975,9 @@
Dom comment = c.getDom();
- if (data != null)
- {
+ if (data != null) {
c.next();
- c.insertString( data );
+ c.insertString(data);
}
c.release();
@@ -818,44 +989,60 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static ProcessingInstruction _document_createProcessingInstruction ( Dom d, String target, String data )
- {
+ public static ProcessingInstruction _document_createProcessingInstruction(Dom d, String target, String data) {
Locale l = d.locale();
Dom pi;
- if (l.noSync()) { l.enter(); try { pi = document_createProcessingInstruction( d, target, data ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { pi = document_createProcessingInstruction( d, target, data ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ pi = document_createProcessingInstruction(d, target, data);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ pi = document_createProcessingInstruction(d, target, data);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (ProcessingInstruction) pi;
}
- public static Dom document_createProcessingInstruction ( Dom d, String target, String data )
- {
- if (target == null)
- throw new IllegalArgumentException( "Target is null" );
+ public static Dom document_createProcessingInstruction(Dom d, String target, String data) {
+ if (target == null) {
+ throw new IllegalArgumentException("Target is null");
+ }
- if (target.length() == 0)
- throw new IllegalArgumentException( "Target is empty" );
+ if (target.length() == 0) {
+ throw new IllegalArgumentException("Target is empty");
+ }
- if (!XMLChar.isValidName( target ))
- throw new InvalidCharacterError( "Target has an invalid character" );
+ if (!XMLChar.isValidName(target)) {
+ throw new InvalidCharacterError("Target has an invalid character");
+ }
- if (Locale.beginsWithXml( target ) && target.length() == 3)
- throw new InvalidCharacterError( "Invalid target - is 'xml'" );
+ if (Locale.beginsWithXml(target) && target.length() == 3) {
+ throw new InvalidCharacterError("Invalid target - is 'xml'");
+ }
Locale l = d.locale();
Cur c = l.tempCur();
- c.createProcinst( target );
+ c.createProcinst(target);
Dom pi = c.getDom();
- if (data != null)
- {
+ if (data != null) {
c.next();
- c.insertString( data );
+ c.insertString(data);
}
c.release();
@@ -867,19 +1054,18 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static CDATASection _document_createCDATASection ( Dom d, String data )
- {
- return (CDATASection) document_createCDATASection( d, data );
+ public static CDATASection _document_createCDATASection(Dom d, String data) {
+ return (CDATASection) document_createCDATASection(d, data);
}
- public static Dom document_createCDATASection ( Dom d, String data )
- {
+ public static Dom document_createCDATASection(Dom d, String data) {
TextNode t = d.locale().createCdataNode();
- if (data == null)
+ if (data == null) {
data = "";
+ }
- t.setChars( data, 0, data.length() );
+ t.setChars(data, 0, data.length());
return t;
}
@@ -888,19 +1074,18 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Text _document_createTextNode ( Dom d, String data )
- {
- return (Text) document_createTextNode( d, data );
+ public static Text _document_createTextNode(Dom d, String data) {
+ return (Text) document_createTextNode(d, data);
}
- public static CharNode document_createTextNode ( Dom d, String data )
- {
+ public static CharNode document_createTextNode(Dom d, String data) {
TextNode t = d.locale().createTextNode();
- if (data == null)
+ if (data == null) {
data = "";
+ }
- t.setChars( data, 0, data.length() );
+ t.setChars(data, 0, data.length());
return t;
}
@@ -909,60 +1094,83 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static EntityReference _document_createEntityReference ( Dom d, String name )
- {
- throw new RuntimeException( "Not implemented" );
+ public static EntityReference _document_createEntityReference(Dom d, String name) {
+ throw new RuntimeException("Not implemented");
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Element _document_getElementById ( Dom d, String elementId )
- {
- throw new RuntimeException( "Not implemented" );
+ public static Element _document_getElementById(Dom d, String elementId) {
+ throw new RuntimeException("Not implemented");
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static NodeList _document_getElementsByTagName ( Dom d, String name )
- {
+ public static NodeList _document_getElementsByTagName(Dom d, String name) {
Locale l = d.locale();
- if (l.noSync()) { l.enter(); try { return document_getElementsByTagName( d, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return document_getElementsByTagName( d, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return document_getElementsByTagName(d, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return document_getElementsByTagName(d, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static NodeList document_getElementsByTagName ( Dom d, String name )
- {
- return new ElementsByTagNameNodeList( d, name );
+ public static NodeList document_getElementsByTagName(Dom d, String name) {
+ return new ElementsByTagNameNodeList(d, name);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static NodeList _document_getElementsByTagNameNS ( Dom d, String uri, String local )
- {
+ public static NodeList _document_getElementsByTagNameNS(Dom d, String uri, String local) {
Locale l = d.locale();
- if (l.noSync()) { l.enter(); try { return document_getElementsByTagNameNS( d, uri, local ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return document_getElementsByTagNameNS( d, uri, local ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return document_getElementsByTagNameNS(d, uri, local);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return document_getElementsByTagNameNS(d, uri, local);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static NodeList document_getElementsByTagNameNS ( Dom d, String uri, String local )
- {
- return new ElementsByTagNameNSNodeList( d, uri, local );
+ public static NodeList document_getElementsByTagNameNS(Dom d, String uri, String local) {
+ return new ElementsByTagNameNSNodeList(d, uri, local);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static DOMImplementation _document_getImplementation ( Dom d )
- {
+ public static DOMImplementation _document_getImplementation(Dom d) {
return (DOMImplementation) d.locale();
}
@@ -970,8 +1178,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _document_importNode ( Dom d, Node n, boolean deep )
- {
+ public static Node _document_importNode(Dom d, Node n, boolean deep) {
Locale l = d.locale();
Dom i;
@@ -981,128 +1188,137 @@
// else
// TODO -- I'm importing my own nodes through DOM methods! -- make this faster
{
- if (l.noSync()) { l.enter(); try { i = document_importNode( d, n, deep ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { i = document_importNode( d, n, deep ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ i = document_importNode(d, n, deep);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ i = document_importNode(d, n, deep);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
return (Node) i;
}
- public static Dom document_importNode ( Dom d, Node n, boolean deep )
- {
- if (n == null)
+ public static Dom document_importNode(Dom d, Node n, boolean deep) {
+ if (n == null) {
return null;
+ }
Dom i;
boolean copyChildren = false;
- switch ( n.getNodeType() )
- {
- case DOCUMENT :
- throw new NotSupportedError( "Document nodes may not be imported" );
+ switch (n.getNodeType()) {
+ case DOCUMENT:
+ throw new NotSupportedError("Document nodes may not be imported");
- case DOCTYPE :
- throw new NotSupportedError( "Document type nodes may not be imported" );
+ case DOCTYPE:
+ throw new NotSupportedError("Document type nodes may not be imported");
- case ELEMENT :
- {
- String local = n.getLocalName();
+ case ELEMENT: {
+ String local = n.getLocalName();
- if (local == null || local.length() == 0)
- i = document_createElement( d, n.getNodeName() );
- else
- {
- String prefix = n.getPrefix();
- String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
- String uri = n.getNamespaceURI();
+ if (local == null || local.length() == 0) {
+ i = document_createElement(d, n.getNodeName());
+ } else {
+ String prefix = n.getPrefix();
+ String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
+ String uri = n.getNamespaceURI();
- if (uri == null || uri.length() == 0)
- i = document_createElement( d, name );
- else
- i = document_createElementNS( d, uri, name );
+ if (uri == null || uri.length() == 0) {
+ i = document_createElement(d, name);
+ } else {
+ i = document_createElementNS(d, uri, name);
+ }
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+
+ for (int a = 0; a < attrs.getLength(); a++) {
+ attributes_setNamedItem(i, document_importNode(d, attrs.item(a), true));
+ }
+
+ copyChildren = deep;
+
+ break;
}
- NamedNodeMap attrs = n.getAttributes();
+ case ATTR: {
+ String local = n.getLocalName();
- for ( int a = 0 ; a < attrs.getLength() ; a++ )
- attributes_setNamedItem( i, document_importNode( d, attrs.item( a ), true ) );
+ if (local == null || local.length() == 0) {
+ i = document_createAttribute(d, n.getNodeName());
+ } else {
+ String prefix = n.getPrefix();
+ String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
+ String uri = n.getNamespaceURI();
- copyChildren = deep;
+ if (uri == null || uri.length() == 0) {
+ i = document_createAttribute(d, name);
+ } else {
+ i = document_createAttributeNS(d, uri, name);
+ }
+ }
- break;
- }
+ copyChildren = true;
- case ATTR :
- {
- String local = n.getLocalName();
-
- if (local == null || local.length() == 0)
- i = document_createAttribute( d, n.getNodeName() );
- else
- {
- String prefix = n.getPrefix();
- String name = prefix == null || prefix.length() == 0 ? local : prefix + ":" + local;
- String uri = n.getNamespaceURI();
-
- if (uri == null || uri.length() == 0)
- i = document_createAttribute( d, name );
- else
- i = document_createAttributeNS( d, uri, name );
+ break;
}
- copyChildren = true;
+ case DOCFRAG: {
+ i = document_createDocumentFragment(d);
- break;
+ copyChildren = deep;
+
+ break;
+ }
+
+ case PROCINST: {
+ i = document_createProcessingInstruction(d, n.getNodeName(), n.getNodeValue());
+ break;
+ }
+
+ case COMMENT: {
+ i = document_createComment(d, n.getNodeValue());
+ break;
+ }
+
+ case TEXT: {
+ i = document_createTextNode(d, n.getNodeValue());
+ break;
+ }
+
+ case CDATA: {
+ i = document_createCDATASection(d, n.getNodeValue());
+ break;
+ }
+
+ case ENTITYREF:
+ case ENTITY:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
+
+ default:
+ throw new RuntimeException("Unknown kind");
}
- case DOCFRAG :
- {
- i = document_createDocumentFragment( d );
-
- copyChildren = deep;
-
- break;
- }
-
- case PROCINST :
- {
- i = document_createProcessingInstruction( d, n.getNodeName(), n.getNodeValue() );
- break;
- }
-
- case COMMENT :
- {
- i = document_createComment( d, n.getNodeValue() );
- break;
- }
-
- case TEXT :
- {
- i = document_createTextNode( d, n.getNodeValue() );
- break;
- }
-
- case CDATA :
- {
- i = document_createCDATASection( d, n.getNodeValue() );
- break;
- }
-
- case ENTITYREF :
- case ENTITY :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
-
- default : throw new RuntimeException( "Unknown kind" );
- }
-
- if (copyChildren)
- {
+ if (copyChildren) {
NodeList children = n.getChildNodes();
- for ( int c = 0 ; c < children.getLength() ; c++ )
- node_insertBefore( i, document_importNode( d, children.item( c ), true ), null);
+ for (int c = 0; c < children.getLength(); c++) {
+ node_insertBefore(i, document_importNode(d, children.item(c), true), null);
+ }
}
return i;
@@ -1112,20 +1328,33 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static DocumentType _document_getDoctype ( Dom d )
- {
+ public static DocumentType _document_getDoctype(Dom d) {
Locale l = d.locale();
Dom dt;
- if (l.noSync()) { l.enter(); try { dt = document_getDoctype( d ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { dt = document_getDoctype( d ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ dt = document_getDoctype(d);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ dt = document_getDoctype(d);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (DocumentType) dt;
}
- public static Dom document_getDoctype ( Dom d )
- {
+ public static Dom document_getDoctype(Dom d) {
return null;
}
@@ -1133,27 +1362,40 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Document _node_getOwnerDocument ( Dom n )
- {
+ public static Document _node_getOwnerDocument(Dom n) {
Locale l = n.locale();
Dom d;
- if (l.noSync()) { l.enter(); try { d = node_getOwnerDocument( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { d = node_getOwnerDocument( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ d = node_getOwnerDocument(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ d = node_getOwnerDocument(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Document) d;
}
- public static Dom node_getOwnerDocument ( Dom n )
- {
- if (n.nodeType() == DOCUMENT)
+ public static Dom node_getOwnerDocument(Dom n) {
+ if (n.nodeType() == DOCUMENT) {
return null;
+ }
Locale l = n.locale();
- if (l._ownerDoc == null)
- {
+ if (l._ownerDoc == null) {
Cur c = l.tempCur();
c.createDomDocumentRoot();
l._ownerDoc = c.getDom();
@@ -1167,64 +1409,76 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_getParentNode ( Dom n )
- {
+ public static Node _node_getParentNode(Dom n) {
Locale l = n.locale();
Dom p;
- if (l.noSync()) { l.enter(); try { p = node_getParentNode( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { p = node_getParentNode( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ p = node_getParentNode(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ p = node_getParentNode(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) p;
}
- public static Dom node_getParentNode ( Dom n )
- {
+ public static Dom node_getParentNode(Dom n) {
Cur c = null;
- switch ( n.nodeType() )
- {
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
- break;
+ switch (n.nodeType()) {
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
+ break;
- case PROCINST :
- case COMMENT :
- case ELEMENT :
- {
- if (!(c = n.tempCur()).toParentRaw())
- {
- c.release();
- c = null;
+ case PROCINST:
+ case COMMENT:
+ case ELEMENT: {
+ if (!(c = n.tempCur()).toParentRaw()) {
+ c.release();
+ c = null;
+ }
+
+ break;
}
- break;
+ case TEXT:
+ case CDATA: {
+ if ((c = n.tempCur()) != null) {
+ c.toParent();
+ }
+
+ break;
+ }
+
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
+
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
+
+ default:
+ throw new RuntimeException("Unknown kind");
}
- case TEXT :
- case CDATA :
- {
- if ((c = n.tempCur()) != null)
- c.toParent();
-
- break;
- }
-
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
-
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
-
- default : throw new RuntimeException( "Unknown kind" );
- }
-
- if (c == null)
+ if (c == null) {
return null;
+ }
Dom d = c.getDom();
@@ -1237,73 +1491,79 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_getFirstChild ( Dom n ) {
+ public static Node _node_getFirstChild(Dom n) {
Locale l = n.locale();
Dom fc;
assert n instanceof Xobj;
- Xobj node = (Xobj)n;
- if (!node.isVacant())
- {
- if (node.isFirstChildPtrDomUsable())
+ Xobj node = (Xobj) n;
+ if (!node.isVacant()) {
+ if (node.isFirstChildPtrDomUsable()) {
return (Node) node._firstChild;
+ }
Xobj lastAttr = node.lastAttr();
if (lastAttr != null &&
- lastAttr.isNextSiblingPtrDomUsable())
+ lastAttr.isNextSiblingPtrDomUsable()) {
return (NodeXobj) lastAttr._nextSibling;
- if (node.isExistingCharNodesValueUsable())
+ }
+ if (node.isExistingCharNodesValueUsable()) {
return node._charNodesValue;
+ }
}
- if (l.noSync()) { fc = node_getFirstChild( n ); }
- else synchronized ( l ) { fc = node_getFirstChild( n ); }
+ if (l.noSync()) {
+ fc = node_getFirstChild(n);
+ } else {
+ synchronized (l) {
+ fc = node_getFirstChild(n);
+ }
+ }
return (Node) fc;
}
- public static Dom node_getFirstChild ( Dom n )
- {
+ public static Dom node_getFirstChild(Dom n) {
Dom fc = null;
- switch ( n.nodeType() )
- {
- case TEXT :
- case CDATA :
- case PROCINST :
- case COMMENT :
- break;
+ switch (n.nodeType()) {
+ case TEXT:
+ case CDATA:
+ case PROCINST:
+ case COMMENT:
+ break;
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- case ELEMENT :
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
- {
+ case ELEMENT:
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR: {
- Xobj node = (Xobj) n;
- node.ensureOccupancy();
- if (node.isFirstChildPtrDomUsable())
- return (NodeXobj) node._firstChild;
- Xobj lastAttr = node.lastAttr();
- if (lastAttr != null)
- {
- if (lastAttr.isNextSiblingPtrDomUsable())
- return (NodeXobj) lastAttr._nextSibling;
- else if (lastAttr.isCharNodesAfterUsable())
- return (CharNode) lastAttr._charNodesAfter;
+ Xobj node = (Xobj) n;
+ node.ensureOccupancy();
+ if (node.isFirstChildPtrDomUsable()) {
+ return (NodeXobj) node._firstChild;
+ }
+ Xobj lastAttr = node.lastAttr();
+ if (lastAttr != null) {
+ if (lastAttr.isNextSiblingPtrDomUsable()) {
+ return (NodeXobj) lastAttr._nextSibling;
+ } else if (lastAttr.isCharNodesAfterUsable()) {
+ return (CharNode) lastAttr._charNodesAfter;
+ }
+ }
+ if (node.isCharNodesValueUsable()) {
+ return node._charNodesValue;
+ }
+
+
+ break;
}
- if (node.isCharNodesValueUsable())
- return node._charNodesValue;
-
-
- break;
- }
}
// TODO - handle entity refs here ...
@@ -1315,40 +1575,52 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_getLastChild ( Dom n )
- {
+ public static Node _node_getLastChild(Dom n) {
Locale l = n.locale();
Dom lc;
- if (l.noSync()) { l.enter(); try { lc = node_getLastChild( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { lc = node_getLastChild( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ lc = node_getLastChild(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ lc = node_getLastChild(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) lc;
}
- public static Dom node_getLastChild ( Dom n )
- {
- switch ( n.nodeType() )
- {
- case TEXT :
- case CDATA :
- case PROCINST :
- case COMMENT :
+ public static Dom node_getLastChild(Dom n) {
+ switch (n.nodeType()) {
+ case TEXT:
+ case CDATA:
+ case PROCINST:
+ case COMMENT:
return null;
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- case ELEMENT :
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
+ case ELEMENT:
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
break;
}
@@ -1357,25 +1629,23 @@
Cur c = n.tempCur();
- if (c.toLastChild())
- {
+ if (c.toLastChild()) {
lc = c.getDom();
c.skip();
- if ((nodes = c.getCharNodes()) != null)
+ if ((nodes = c.getCharNodes()) != null) {
lc = null;
- }
- else
- {
+ }
+ } else {
c.next();
nodes = c.getCharNodes();
}
- if (lc == null && nodes != null)
- {
- while ( nodes._next != null )
+ if (lc == null && nodes != null) {
+ while (nodes._next != null) {
nodes = nodes._next;
+ }
lc = nodes;
}
@@ -1391,85 +1661,89 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_getNextSibling ( Dom n )
- {
+ public static Node _node_getNextSibling(Dom n) {
Locale l = n.locale();
Dom ns;
- if (l.noSync()) { ns = node_getNextSibling( n ); }
- else synchronized ( l ) { ns = node_getNextSibling( n ); }
+ if (l.noSync()) {
+ ns = node_getNextSibling(n);
+ } else {
+ synchronized (l) {
+ ns = node_getNextSibling(n);
+ }
+ }
return (Node) ns;
}
- public static Dom node_getNextSibling ( Dom n )
- {
+ public static Dom node_getNextSibling(Dom n) {
Dom ns = null;
- switch ( n.nodeType() )
- {
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
- break;
+ switch (n.nodeType()) {
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
+ break;
- case TEXT :
- case CDATA :
- {
- CharNode cn = (CharNode) n;
- //if src is attr & next is null , ret null;
- //if src is container and
- // a) this node is aftertext && src._nextSib = null; ret null
- // b) this node is value && src._fc = null; ret null
+ case TEXT:
+ case CDATA: {
+ CharNode cn = (CharNode) n;
+ //if src is attr & next is null , ret null;
+ //if src is container and
+ // a) this node is aftertext && src._nextSib = null; ret null
+ // b) this node is value && src._fc = null; ret null
- if (! (cn.getObject() instanceof Xobj) )
- return null;
- Xobj src = (Xobj) cn.getObject();
- //if src is attr this node is always value and
- // next is always the next ptr of the attr
- src._charNodesAfter =
- Cur.updateCharNodes( src._locale, src, src._charNodesAfter, src._cchAfter );
+ if (!(cn.getObject() instanceof Xobj)) {
+ return null;
+ }
+ Xobj src = (Xobj) cn.getObject();
+ //if src is attr this node is always value and
+ // next is always the next ptr of the attr
+ src._charNodesAfter =
+ Cur.updateCharNodes(src._locale, src, src._charNodesAfter, src._cchAfter);
- src._charNodesValue =
- Cur.updateCharNodes( src._locale, src, src._charNodesValue, src._cchValue );
+ src._charNodesValue =
+ Cur.updateCharNodes(src._locale, src, src._charNodesValue, src._cchValue);
- if (cn._next != null)
- {
- ns = cn._next;
+ if (cn._next != null) {
+ ns = cn._next;
+ break;
+ }
+ boolean isThisNodeAfterText = cn.isNodeAftertext();
+
+ if (isThisNodeAfterText) {
+ ns = (NodeXobj) src._nextSibling;
+ } else //srcValue or attribute source
+ {
+ ns = (NodeXobj) src._firstChild;
+ }
+ break;
+
+ }
+
+ case PROCINST:
+ case COMMENT:
+ case ELEMENT: {
+ assert n instanceof Xobj : "PI, Comments and Elements always backed up by Xobj";
+ Xobj node = (Xobj) n;
+ node.ensureOccupancy();
+ if (node.isNextSiblingPtrDomUsable()) {
+ return
+ (NodeXobj) node._nextSibling;
+ }
+ if (node.isCharNodesAfterUsable()) {
+ return node._charNodesAfter;
+ }
break;
}
- boolean isThisNodeAfterText = cn.isNodeAftertext();
- if (isThisNodeAfterText)
- ns = (NodeXobj) src._nextSibling;
- else //srcValue or attribute source
- ns = (NodeXobj) src._firstChild;
- break;
-
- }
-
- case PROCINST :
- case COMMENT :
- case ELEMENT :
- {
- assert n instanceof Xobj: "PI, Comments and Elements always backed up by Xobj";
- Xobj node = (Xobj) n;
- node.ensureOccupancy();
- if (node.isNextSiblingPtrDomUsable())
- return
- (NodeXobj) node._nextSibling;
- if (node.isCharNodesAfterUsable())
- return node._charNodesAfter;
- break;
- }
-
- case ENTITY :
- case NOTATION :
- case ENTITYREF :
- case DOCTYPE :
- throw new RuntimeException( "Not implemented" );
+ case ENTITY:
+ case NOTATION:
+ case ENTITYREF:
+ case DOCTYPE:
+ throw new RuntimeException("Not implemented");
}
// TODO - handle entity refs here ...
@@ -1481,35 +1755,40 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_getPreviousSibling ( Dom n )
- {
+ public static Node _node_getPreviousSibling(Dom n) {
Locale l = n.locale();
Dom ps;
- if (l.noSync()) { ps = node_getPreviousSibling( n ); }
- else synchronized ( l ) { ps = node_getPreviousSibling( n ); }
+ if (l.noSync()) {
+ ps = node_getPreviousSibling(n);
+ } else {
+ synchronized (l) {
+ ps = node_getPreviousSibling(n);
+ }
+ }
return (Node) ps;
}
- public static Dom node_getPreviousSibling ( Dom n )
- {
+ public static Dom node_getPreviousSibling(Dom n) {
Dom prev;
switch (n.nodeType()) {
case TEXT:
case CDATA: {
- assert n instanceof CharNode: "Text/CData should be a CharNode";
+ assert n instanceof CharNode : "Text/CData should be a CharNode";
CharNode node = (CharNode) n;
- if (!(node.getObject() instanceof Xobj))
+ if (!(node.getObject() instanceof Xobj)) {
return null;
+ }
Xobj src = (Xobj) node.getObject();
src.ensureOccupancy();
boolean isThisNodeAfterText = node.isNodeAftertext();
prev = node._prev;
- if (prev == null)
+ if (prev == null) {
prev = isThisNodeAfterText ? (Dom) src :
src._charNodesValue;
+ }
break;
}
default: {
@@ -1533,20 +1812,32 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _node_hasAttributes ( Dom n )
- {
+ public static boolean _node_hasAttributes(Dom n) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { return node_hasAttributes( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return node_hasAttributes( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return node_hasAttributes(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return node_hasAttributes(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static boolean node_hasAttributes ( Dom n )
- {
+ public static boolean node_hasAttributes(Dom n) {
boolean hasAttrs = false;
- if (n.nodeType() == ELEMENT)
- {
+ if (n.nodeType() == ELEMENT) {
Cur c = n.tempCur();
hasAttrs = c.hasAttrs();
@@ -1561,45 +1852,56 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _node_isSupported ( Dom n, String feature, String version )
- {
- return _domImplementation_hasFeature( n.locale(), feature, version );
+ public static boolean _node_isSupported(Dom n, String feature, String version) {
+ return _domImplementation_hasFeature(n.locale(), feature, version);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _node_normalize ( Dom n )
- {
+ public static void _node_normalize(Dom n) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { node_normalize( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { node_normalize( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ node_normalize(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ node_normalize(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void node_normalize ( Dom n )
- {
- switch ( n.nodeType() )
- {
- case TEXT :
- case CDATA :
- case PROCINST :
- case COMMENT :
+ public static void node_normalize(Dom n) {
+ switch (n.nodeType()) {
+ case TEXT:
+ case CDATA:
+ case PROCINST:
+ case COMMENT:
return;
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- case ELEMENT :
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
+ case ELEMENT:
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
break;
}
@@ -1607,37 +1909,30 @@
c.push();
- do
- {
+ do {
c.nextWithAttrs();
CharNode cn = c.getCharNodes();
- if (cn != null)
- {
- if (!c.isText())
- {
- while ( cn != null )
- {
- cn.setChars( null, 0, 0 );
- cn = CharNode.remove( cn, cn );
+ if (cn != null) {
+ if (!c.isText()) {
+ while (cn != null) {
+ cn.setChars(null, 0, 0);
+ cn = CharNode.remove(cn, cn);
}
- }
- else if (cn._next != null)
- {
- while ( cn._next != null )
- {
- cn.setChars( null, 0, 0 );
- cn = CharNode.remove( cn, cn._next );
+ } else if (cn._next != null) {
+ while (cn._next != null) {
+ cn.setChars(null, 0, 0);
+ cn = CharNode.remove(cn, cn._next);
}
cn._cch = Integer.MAX_VALUE;
}
- c.setCharNodes( cn );
+ c.setCharNodes(cn);
}
}
- while ( ! c.isAtEndOfLastPush() );
+ while (!c.isAtEndOfLastPush());
c.release();
@@ -1648,68 +1943,81 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _node_hasChildNodes ( Dom n ) {
+ public static boolean _node_hasChildNodes(Dom n) {
// TODO - make this faster
- return n instanceof Xobj && _node_getFirstChild( n ) != null;
+ return n instanceof Xobj && _node_getFirstChild(n) != null;
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_appendChild ( Dom p, Node newChild )
- {
- return _node_insertBefore( p, newChild, null );
+ public static Node _node_appendChild(Dom p, Node newChild) {
+ return _node_insertBefore(p, newChild, null);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_replaceChild ( Dom p, Node newChild, Node oldChild )
- {
+ public static Node _node_replaceChild(Dom p, Node newChild, Node oldChild) {
Locale l = p.locale();
- if (newChild == null)
- throw new IllegalArgumentException( "Child to add is null" );
+ if (newChild == null) {
+ throw new IllegalArgumentException("Child to add is null");
+ }
- if (oldChild == null)
- throw new NotFoundErr( "Child to replace is null" );
+ if (oldChild == null) {
+ throw new NotFoundErr("Child to replace is null");
+ }
Dom nc;
- if (!(newChild instanceof Dom) || (nc = (Dom) newChild).locale() != l)
- throw new WrongDocumentErr( "Child to add is from another document" );
+ if (!(newChild instanceof Dom) || (nc = (Dom) newChild).locale() != l) {
+ throw new WrongDocumentErr("Child to add is from another document");
+ }
Dom oc = null;
- if (!(oldChild instanceof Dom) || (oc = (Dom) oldChild).locale() != l)
- throw new WrongDocumentErr( "Child to replace is from another document" );
+ if (!(oldChild instanceof Dom) || (oc = (Dom) oldChild).locale() != l) {
+ throw new WrongDocumentErr("Child to replace is from another document");
+ }
Dom d;
- if (l.noSync()) { l.enter(); try { d = node_replaceChild( p, nc, oc ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { d = node_replaceChild( p, nc, oc ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ d = node_replaceChild(p, nc, oc);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ d = node_replaceChild(p, nc, oc);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) d;
}
- public static Dom node_replaceChild ( Dom p, Dom newChild, Dom oldChild )
- {
+ public static Dom node_replaceChild(Dom p, Dom newChild, Dom oldChild) {
// Remove the old child firest to avoid a dom exception raised
// when inserting two document elements
- Dom nextNode = node_getNextSibling( oldChild );
+ Dom nextNode = node_getNextSibling(oldChild);
- node_removeChild( p, oldChild );
+ node_removeChild(p, oldChild);
- try
- {
- node_insertBefore( p, newChild, nextNode );
- }
- catch ( DOMException e )
- {
- node_insertBefore( p, oldChild, nextNode );
+ try {
+ node_insertBefore(p, newChild, nextNode);
+ } catch (DOMException e) {
+ node_insertBefore(p, oldChild, nextNode);
throw e;
}
@@ -1721,63 +2029,80 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_insertBefore ( Dom p, Node newChild, Node refChild )
- {
+ public static Node _node_insertBefore(Dom p, Node newChild, Node refChild) {
Locale l = p.locale();
- if (newChild == null)
- throw new IllegalArgumentException( "Child to add is null" );
+ if (newChild == null) {
+ throw new IllegalArgumentException("Child to add is null");
+ }
Dom nc;
- if (!(newChild instanceof Dom) || (nc = (Dom) newChild).locale() != l)
- throw new WrongDocumentErr( "Child to add is from another document" );
+ if (!(newChild instanceof Dom) || (nc = (Dom) newChild).locale() != l) {
+ throw new WrongDocumentErr("Child to add is from another document");
+ }
Dom rc = null;
- if (refChild != null)
- {
- if (!(refChild instanceof Dom) || (rc = (Dom) refChild).locale() != l)
- throw new WrongDocumentErr( "Reference child is from another document" );
+ if (refChild != null) {
+ if (!(refChild instanceof Dom) || (rc = (Dom) refChild).locale() != l) {
+ throw new WrongDocumentErr("Reference child is from another document");
+ }
}
Dom d;
- if (l.noSync()) { l.enter(); try { d = node_insertBefore( p, nc, rc ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { d = node_insertBefore( p, nc, rc ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ d = node_insertBefore(p, nc, rc);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ d = node_insertBefore(p, nc, rc);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) d;
}
- public static Dom node_insertBefore ( Dom p, Dom nc, Dom rc )
- {
+ public static Dom node_insertBefore(Dom p, Dom nc, Dom rc) {
assert nc != null;
// Inserting self before self is a no-op
- if (nc == rc)
+ if (nc == rc) {
return nc;
+ }
- if (rc != null && parent( rc ) != p)
- throw new NotFoundErr( "RefChild is not a child of this node" );
+ if (rc != null && parent(rc) != p) {
+ throw new NotFoundErr("RefChild is not a child of this node");
+ }
// TODO - obey readonly status of a substree
int nck = nc.nodeType();
- if (nck == DOCFRAG)
- {
- for ( Dom c = firstChild( nc ) ; c != null ; c = nextSibling( c ) )
- validateNewChild( p, c );
+ if (nck == DOCFRAG) {
+ for (Dom c = firstChild(nc); c != null; c = nextSibling(c)) {
+ validateNewChild(p, c);
+ }
- for ( Dom c = firstChild( nc ) ; c != null ; )
- {
- Dom n = nextSibling( c );
+ for (Dom c = firstChild(nc); c != null; ) {
+ Dom n = nextSibling(c);
- if (rc == null)
- append( c, p );
- else
- insert( c, rc );
+ if (rc == null) {
+ append(c, p);
+ } else {
+ insert(c, rc);
+ }
c = n;
}
@@ -1789,134 +2114,122 @@
// Make sure the new child is allowed here
//
- validateNewChild( p, nc );
+ validateNewChild(p, nc);
//
// Orphan the child before establishing a new parent
//
- remove( nc );
+ remove(nc);
int pk = p.nodeType();
// Only these nodes can be modifiable parents
assert pk == ATTR || pk == DOCFRAG || pk == DOCUMENT || pk == ELEMENT;
- switch ( nck )
- {
- case ELEMENT :
- case COMMENT :
- case PROCINST :
- {
- if (rc == null)
- {
- Cur cTo = p.tempCur();
- cTo.toEnd();
- Cur.moveNode( (Xobj) nc, cTo );
- cTo.release();
- }
- else
- {
- int rck = rc.nodeType();
-
- if (rck == TEXT || rck == CDATA)
- {
- // Quick and dirty impl....
-
- ArrayList charNodes = new ArrayList();
-
- while ( rc != null && (rc.nodeType() == TEXT || rc.nodeType() == CDATA ) )
- {
- Dom next = nextSibling( rc );
- charNodes.add( remove( rc ) );
- rc = next;
- }
-
- if (rc == null)
- append( nc, p );
- else
- insert( nc, rc );
-
- rc = nextSibling( nc );
-
- for ( int i = 0 ; i < charNodes.size() ; i++ )
- {
- Dom n = (Dom) charNodes.get( i );
-
- if (rc == null)
- append( n, p );
- else
- insert( n, rc );
- }
- }
- else if (rck == ENTITYREF)
- {
- throw new RuntimeException( "Not implemented" );
- }
- else
- {
- assert rck == ELEMENT || rck == PROCINST || rck == COMMENT;
- Cur cTo = rc.tempCur();
- Cur.moveNode( (Xobj) nc, cTo );
+ switch (nck) {
+ case ELEMENT:
+ case COMMENT:
+ case PROCINST: {
+ if (rc == null) {
+ Cur cTo = p.tempCur();
+ cTo.toEnd();
+ Cur.moveNode((Xobj) nc, cTo);
cTo.release();
+ } else {
+ int rck = rc.nodeType();
+
+ if (rck == TEXT || rck == CDATA) {
+ // Quick and dirty impl....
+
+ ArrayList charNodes = new ArrayList();
+
+ while (rc != null && (rc.nodeType() == TEXT || rc.nodeType() == CDATA)) {
+ Dom next = nextSibling(rc);
+ charNodes.add(remove(rc));
+ rc = next;
+ }
+
+ if (rc == null) {
+ append(nc, p);
+ } else {
+ insert(nc, rc);
+ }
+
+ rc = nextSibling(nc);
+
+ for (int i = 0; i < charNodes.size(); i++) {
+ Dom n = (Dom) charNodes.get(i);
+
+ if (rc == null) {
+ append(n, p);
+ } else {
+ insert(n, rc);
+ }
+ }
+ } else if (rck == ENTITYREF) {
+ throw new RuntimeException("Not implemented");
+ } else {
+ assert rck == ELEMENT || rck == PROCINST || rck == COMMENT;
+ Cur cTo = rc.tempCur();
+ Cur.moveNode((Xobj) nc, cTo);
+ cTo.release();
+ }
}
+
+ break;
}
- break;
- }
+ case TEXT:
+ case CDATA: {
+ CharNode n = (CharNode) nc;
- case TEXT :
- case CDATA :
- {
- CharNode n = (CharNode) nc;
+ assert n._prev == null && n._next == null;
- assert n._prev == null && n._next == null;
+ CharNode refCharNode = null;
+ Cur c = p.tempCur();
- CharNode refCharNode = null;
- Cur c = p.tempCur();
+ if (rc == null) {
+ c.toEnd();
+ } else {
+ int rck = rc.nodeType();
- if (rc == null)
- c.toEnd();
- else
- {
- int rck = rc.nodeType();
+ if (rck == TEXT || rck == CDATA) {
+ c.moveToCharNode(refCharNode = (CharNode) rc);
+ } else if (rck == ENTITYREF) {
+ throw new RuntimeException("Not implemented");
+ } else {
+ c.moveToDom(rc);
+ }
+ }
- if (rck == TEXT || rck == CDATA)
- c.moveToCharNode( refCharNode = (CharNode) rc );
- else if (rck == ENTITYREF)
- throw new RuntimeException( "Not implemented" );
- else
- c.moveToDom( rc );
+ CharNode nodes = c.getCharNodes();
+
+ nodes = CharNode.insertNode(nodes, n, refCharNode);
+
+ c.insertChars(n.getObject(), n._off, n._cch);
+
+ c.setCharNodes(nodes);
+
+ c.release();
+
+ break;
}
- CharNode nodes = c.getCharNodes();
+ case ENTITYREF: {
+ throw new RuntimeException("Not implemented");
+ }
- nodes = CharNode.insertNode( nodes, n, refCharNode );
+ case DOCTYPE: {
+ // TODO - don't actually insert this here, associate it with the
+ // doc?? Hmm .. Perhaps I should disallow insertion into the tree
+ // at all.
- c.insertChars( n.getObject(), n._off, n._cch );
+ throw new RuntimeException("Not implemented");
+ }
- c.setCharNodes( nodes );
-
- c.release();
-
- break;
- }
-
- case ENTITYREF :
- {
- throw new RuntimeException( "Not implemented" );
- }
-
- case DOCTYPE :
- {
- // TODO - don't actually insert this here, associate it with the
- // doc?? Hmm .. Perhaps I should disallow insertion into the tree
- // at all.
-
- throw new RuntimeException( "Not implemented" );
- }
-
- default : throw new RuntimeException( "Unexpected child node type" );
+ default:
+ throw new RuntimeException("Unexpected child node type");
}
return nc;
@@ -1926,73 +2239,88 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_removeChild ( Dom p, Node child )
- {
+ public static Node _node_removeChild(Dom p, Node child) {
Locale l = p.locale();
- if (child == null)
- throw new NotFoundErr( "Child to remove is null" );
+ if (child == null) {
+ throw new NotFoundErr("Child to remove is null");
+ }
Dom c;
- if (!(child instanceof Dom) || (c = (Dom) child).locale() != l)
- throw new WrongDocumentErr( "Child to remove is from another document" );
+ if (!(child instanceof Dom) || (c = (Dom) child).locale() != l) {
+ throw new WrongDocumentErr("Child to remove is from another document");
+ }
Dom d;
- if (l.noSync()) { l.enter(); try { d = node_removeChild( p, c ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { d = node_removeChild( p, c ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ d = node_removeChild(p, c);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ d = node_removeChild(p, c);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) d;
}
- public static Dom node_removeChild ( Dom parent, Dom child )
- {
- if (parent( child ) != parent)
- throw new NotFoundErr( "Child to remove is not a child of given parent" );
-
- switch ( child.nodeType() )
- {
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
- throw new IllegalStateException();
-
- case ELEMENT :
- case PROCINST :
- case COMMENT :
- removeNode( child );
- break;
-
- case TEXT :
- case CDATA :
- {
- Cur c = child.tempCur();
-
- CharNode nodes = c.getCharNodes();
-
- CharNode cn = (CharNode) child;
-
- assert(cn.getDom() != null);
-
- cn.setChars( c.moveChars( null, cn._cch ), c._offSrc, c._cchSrc );
-
- c.setCharNodes( CharNode.remove( nodes, cn ) );
-
- c.release();
-
- break;
+ public static Dom node_removeChild(Dom parent, Dom child) {
+ if (parent(child) != parent) {
+ throw new NotFoundErr("Child to remove is not a child of given parent");
}
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
+ switch (child.nodeType()) {
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
+ throw new IllegalStateException();
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ELEMENT:
+ case PROCINST:
+ case COMMENT:
+ removeNode(child);
+ break;
- default : throw new RuntimeException( "Unknown kind" );
+ case TEXT:
+ case CDATA: {
+ Cur c = child.tempCur();
+
+ CharNode nodes = c.getCharNodes();
+
+ CharNode cn = (CharNode) child;
+
+ assert (cn.getDom() != null);
+
+ cn.setChars(c.moveChars(null, cn._cch), c._offSrc, c._cchSrc);
+
+ c.setCharNodes(CharNode.remove(nodes, cn));
+
+ c.release();
+
+ break;
+ }
+
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
+
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
+
+ default:
+ throw new RuntimeException("Unknown kind");
}
return child;
@@ -2002,121 +2330,128 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _node_cloneNode ( Dom n, boolean deep )
- {
+ public static Node _node_cloneNode(Dom n, boolean deep) {
Locale l = n.locale();
Dom c;
- if (l.noSync()) { l.enter(); try { c = node_cloneNode( n, deep ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { c = node_cloneNode( n, deep ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ c = node_cloneNode(n, deep);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ c = node_cloneNode(n, deep);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) c;
}
- public static Dom node_cloneNode ( Dom n, boolean deep )
- {
+ public static Dom node_cloneNode(Dom n, boolean deep) {
Locale l = n.locale();
Dom clone = null;
- if (!deep)
- {
+ if (!deep) {
Cur shallow = null;
- switch ( n.nodeType() )
- {
- case DOCUMENT :
- shallow = l.tempCur();
- shallow.createDomDocumentRoot();
- break;
+ switch (n.nodeType()) {
+ case DOCUMENT:
+ shallow = l.tempCur();
+ shallow.createDomDocumentRoot();
+ break;
- case DOCFRAG :
- shallow = l.tempCur();
- shallow.createDomDocFragRoot();
- break;
+ case DOCFRAG:
+ shallow = l.tempCur();
+ shallow.createDomDocFragRoot();
+ break;
- case ELEMENT :
- {
- shallow = l.tempCur();
- shallow.createElement( n.getQName() );
+ case ELEMENT: {
+ shallow = l.tempCur();
+ shallow.createElement(n.getQName());
- Element elem = (Element) shallow.getDom();
- NamedNodeMap attrs = ((Element) n).getAttributes();
+ Element elem = (Element) shallow.getDom();
+ NamedNodeMap attrs = ((Element) n).getAttributes();
- for ( int i = 0 ; i < attrs.getLength() ; i++ )
- elem.setAttributeNodeNS( (Attr) attrs.item( i ).cloneNode( true ) );
+ for (int i = 0; i < attrs.getLength(); i++) {
+ elem.setAttributeNodeNS((Attr) attrs.item(i).cloneNode(true));
+ }
- break;
+ break;
+ }
+
+ case ATTR:
+ shallow = l.tempCur();
+ shallow.createAttr(n.getQName());
+ break;
+
+ case PROCINST:
+ case COMMENT:
+ case TEXT:
+ case CDATA:
+ case ENTITYREF:
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ break;
}
- case ATTR :
- shallow = l.tempCur();
- shallow.createAttr( n.getQName() );
- break;
-
- case PROCINST :
- case COMMENT :
- case TEXT :
- case CDATA :
- case ENTITYREF :
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- break;
- }
-
- if (shallow != null)
- {
+ if (shallow != null) {
clone = shallow.getDom();
shallow.release();
}
}
- if (clone == null)
- {
- switch ( n.nodeType() )
- {
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
- case ELEMENT :
- case PROCINST :
- case COMMENT :
- {
- Cur cClone = l.tempCur();
- Cur cSrc = n.tempCur();
- cSrc.copyNode( cClone );
- clone = cClone.getDom();
- cClone.release();
- cSrc.release();
+ if (clone == null) {
+ switch (n.nodeType()) {
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
+ case ELEMENT:
+ case PROCINST:
+ case COMMENT: {
+ Cur cClone = l.tempCur();
+ Cur cSrc = n.tempCur();
+ cSrc.copyNode(cClone);
+ clone = cClone.getDom();
+ cClone.release();
+ cSrc.release();
- break;
- }
+ break;
+ }
- case TEXT :
- case CDATA :
- {
- Cur c = n.tempCur();
+ case TEXT:
+ case CDATA: {
+ Cur c = n.tempCur();
- CharNode cn = n.nodeType() == TEXT ? l.createTextNode() : l.createCdataNode();
+ CharNode cn = n.nodeType() == TEXT ? l.createTextNode() : l.createCdataNode();
- cn.setChars( c.getChars( ((CharNode) n)._cch ), c._offSrc, c._cchSrc );
+ cn.setChars(c.getChars(((CharNode) n)._cch), c._offSrc, c._cchSrc);
- clone = cn;
+ clone = cn;
- c.release();
+ c.release();
- break;
- }
+ break;
+ }
- case ENTITYREF :
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ENTITYREF:
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- default : throw new RuntimeException( "Unknown kind" );
+ default:
+ throw new RuntimeException("Unknown kind");
}
}
@@ -2127,9 +2462,10 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getLocalName ( Dom n )
- {
- if (! n.nodeCanHavePrefixUri() ) return null;
+ public static String _node_getLocalName(Dom n) {
+ if (!n.nodeCanHavePrefixUri()) {
+ return null;
+ }
QName name = n.getQName();
return name == null ? "" : name.getLocalPart();
}
@@ -2138,12 +2474,13 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getNamespaceURI ( Dom n )
- {
- if (! n.nodeCanHavePrefixUri() ) return null;
+ public static String _node_getNamespaceURI(Dom n) {
+ if (!n.nodeCanHavePrefixUri()) {
+ return null;
+ }
QName name = n.getQName();
// TODO - should return the correct namespace for xmlns ...
- return name == null ? "":
+ return name == null ? "" :
//name.getNamespaceURI().equals("")? null:
name.getNamespaceURI();
}
@@ -2152,16 +2489,29 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _node_setPrefix ( Dom n, String prefix )
- {
+ public static void _node_setPrefix(Dom n, String prefix) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { node_setPrefix( n, prefix ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { node_setPrefix( n, prefix ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ node_setPrefix(n, prefix);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ node_setPrefix(n, prefix);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void node_setPrefix ( Dom n, String prefix )
- {
+ public static void node_setPrefix(Dom n, String prefix) {
// TODO - make it possible to set the prefix of an xmlns
// TODO - test to make use prefix: xml maps to the predefined namespace
// if set???? hmmm ... perhaps I should not allow the setting of any
@@ -2169,30 +2519,30 @@
// one and the prefix is 'xml' all other prefixes which start with
// 'xml' should fail.
- if (n.nodeType() == ELEMENT || n.nodeType() == ATTR)
- {
+ if (n.nodeType() == ELEMENT || n.nodeType() == ATTR) {
Cur c = n.tempCur();
QName name = c.getName();
String uri = name.getNamespaceURI();
String local = name.getLocalPart();
- prefix = validatePrefix( prefix, uri, local, n.nodeType() == ATTR );
+ prefix = validatePrefix(prefix, uri, local, n.nodeType() == ATTR);
- c.setName( n.locale().makeQName( uri, local, prefix ) );
+ c.setName(n.locale().makeQName(uri, local, prefix));
c.release();
+ } else {
+ validatePrefix(prefix, "", "", false);
}
- else
- validatePrefix( prefix, "", "", false );
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getPrefix ( Dom n )
- {
- if (! n.nodeCanHavePrefixUri() ) return null;
+ public static String _node_getPrefix(Dom n) {
+ if (!n.nodeCanHavePrefixUri()) {
+ return null;
+ }
QName name = n.getQName();
return name == null ? "" :
name.getPrefix();
@@ -2202,32 +2552,36 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getNodeName ( Dom n )
- {
- switch ( n.nodeType() )
- {
- case CDATA : return "#cdata-section";
- case COMMENT : return "#comment";
- case DOCFRAG : return "#document-fragment";
- case DOCUMENT : return "#document";
- case PROCINST : return n.getQName().getLocalPart();
- case TEXT : return "#text";
+ public static String _node_getNodeName(Dom n) {
+ switch (n.nodeType()) {
+ case CDATA:
+ return "#cdata-section";
+ case COMMENT:
+ return "#comment";
+ case DOCFRAG:
+ return "#document-fragment";
+ case DOCUMENT:
+ return "#document";
+ case PROCINST:
+ return n.getQName().getLocalPart();
+ case TEXT:
+ return "#text";
- case ATTR :
- case ELEMENT :
- {
- QName name = n.getQName();
- String prefix = name.getPrefix();
- return prefix.length() == 0 ? name.getLocalPart() : prefix + ":" + name.getLocalPart();
- }
+ case ATTR:
+ case ELEMENT: {
+ QName name = n.getQName();
+ String prefix = name.getPrefix();
+ return prefix.length() == 0 ? name.getLocalPart() : prefix + ":" + name.getLocalPart();
+ }
- case DOCTYPE :
- case ENTITY :
- case ENTITYREF :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case DOCTYPE:
+ case ENTITY:
+ case ENTITYREF:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- default : throw new RuntimeException( "Unknown node type" );
+ default:
+ throw new RuntimeException("Unknown node type");
}
}
@@ -2235,8 +2589,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static short _node_getNodeType ( Dom n )
- {
+ public static short _node_getNodeType(Dom n) {
return (short) n.nodeType();
}
@@ -2244,67 +2597,73 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _node_setNodeValue ( Dom n, String nodeValue )
- {
+ public static void _node_setNodeValue(Dom n, String nodeValue) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { node_setNodeValue( n, nodeValue ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { node_setNodeValue( n, nodeValue ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ node_setNodeValue(n, nodeValue);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ node_setNodeValue(n, nodeValue);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void node_setNodeValue ( Dom n, String nodeValue )
- {
- if (nodeValue == null)
+ public static void node_setNodeValue(Dom n, String nodeValue) {
+ if (nodeValue == null) {
nodeValue = "";
+ }
- switch ( n.nodeType() )
- {
- case TEXT :
- case CDATA :
- {
+ switch (n.nodeType()) {
+ case TEXT:
+ case CDATA: {
CharNode cn = (CharNode) n;
Cur c;
- if ((c = cn.tempCur()) != null)
- {
- c.moveChars( null, cn._cch );
+ if ((c = cn.tempCur()) != null) {
+ c.moveChars(null, cn._cch);
cn._cch = nodeValue.length();
- c.insertString( nodeValue );
+ c.insertString(nodeValue);
c.release();
+ } else {
+ cn.setChars(nodeValue, 0, nodeValue.length());
}
- else
- cn.setChars( nodeValue, 0, nodeValue.length() );
break;
}
- case ATTR :
- {
+ case ATTR: {
// Try to set an exisiting text node to contain the new value
NodeList children = ((Node) n).getChildNodes();
- while ( children.getLength() > 1 )
- node_removeChild( n, (Dom) children.item( 1 ) );
+ while (children.getLength() > 1) {
+ node_removeChild(n, (Dom) children.item(1));
+ }
- if (children.getLength() == 0)
- {
+ if (children.getLength() == 0) {
TextNode tn = n.locale().createTextNode();
- tn.setChars( nodeValue, 0, nodeValue.length() );
- node_insertBefore( n, tn, null );
- }
- else
- {
+ tn.setChars(nodeValue, 0, nodeValue.length());
+ node_insertBefore(n, tn, null);
+ } else {
assert children.getLength() == 1;
- children.item( 0 ).setNodeValue( nodeValue );
+ children.item(0).setNodeValue(nodeValue);
}
- if (((AttrXobj) n).isId())
- {
+ if (((AttrXobj) n).isId()) {
Dom d = DomImpl.node_getOwnerDocument(n);
String val = node_getNodeValue(n);
- if (d instanceof DocumentXobj)
- {
+ if (d instanceof DocumentXobj) {
((DocumentXobj) d).removeIdElement(val);
((DocumentXobj) d).addIdElement(nodeValue,
attr_getOwnerElement(n));
@@ -2314,15 +2673,14 @@
break;
}
- case PROCINST :
- case COMMENT :
- {
+ case PROCINST:
+ case COMMENT: {
Cur c = n.tempCur();
c.next();
- c.getChars( -1 );
- c.moveChars( null, c._cchSrc );
- c.insertString( nodeValue );
+ c.getChars(-1);
+ c.moveChars(null, c._cchSrc);
+ c.insertString(nodeValue);
c.release();
@@ -2335,53 +2693,52 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getNodeValue ( Dom n )
- {
+ public static String _node_getNodeValue(Dom n) {
Locale l = n.locale();
- if (l.noSync()) { return node_getNodeValue( n ); }
- else synchronized ( l ) { return node_getNodeValue( n ); }
+ if (l.noSync()) {
+ return node_getNodeValue(n);
+ } else {
+ synchronized (l) {
+ return node_getNodeValue(n);
+ }
+ }
}
- public static String node_getNodeValue ( Dom n )
- {
+ public static String node_getNodeValue(Dom n) {
String s = null;
- switch ( n.nodeType() )
- {
- case ATTR :
- case PROCINST :
- case COMMENT :
- {
- s = ((Xobj)n).getValueAsString();
- break;
- }
-
- case TEXT :
- case CDATA :
- {
- assert n instanceof CharNode: "Text/CData should be a CharNode";
- CharNode node = (CharNode) n;
- if (! (node.getObject() instanceof Xobj) ) {
- s = CharUtil.getString(node.getObject(), node._off, node._cch);
- }else{
- Xobj src = (Xobj) node.getObject();
- src.ensureOccupancy();
- boolean isThisNodeAfterText = node.isNodeAftertext();
- if( isThisNodeAfterText ){
- src._charNodesAfter =
- Cur.updateCharNodes( src._locale, src, src._charNodesAfter, src._cchAfter );
- s = src.getCharsAfterAsString(node._off, node._cch);
- }
- else{
- src._charNodesValue =
- Cur.updateCharNodes( src._locale, src, src._charNodesValue, src._cchValue );
- s = src.getCharsValueAsString(node._off, node._cch);
- }
-
+ switch (n.nodeType()) {
+ case ATTR:
+ case PROCINST:
+ case COMMENT: {
+ s = ((Xobj) n).getValueAsString();
+ break;
}
- break;
- }
+
+ case TEXT:
+ case CDATA: {
+ assert n instanceof CharNode : "Text/CData should be a CharNode";
+ CharNode node = (CharNode) n;
+ if (!(node.getObject() instanceof Xobj)) {
+ s = CharUtil.getString(node.getObject(), node._off, node._cch);
+ } else {
+ Xobj src = (Xobj) node.getObject();
+ src.ensureOccupancy();
+ boolean isThisNodeAfterText = node.isNodeAftertext();
+ if (isThisNodeAfterText) {
+ src._charNodesAfter =
+ Cur.updateCharNodes(src._locale, src, src._charNodesAfter, src._cchAfter);
+ s = src.getCharsAfterAsString(node._off, node._cch);
+ } else {
+ src._charNodesValue =
+ Cur.updateCharNodes(src._locale, src, src._charNodesValue, src._cchValue);
+ s = src.getCharsValueAsString(node._off, node._cch);
+ }
+
+ }
+ break;
+ }
}
return s;
@@ -2391,7 +2748,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Object _node_getUserData ( Dom n, String key ) {
+ public static Object _node_getUserData(Dom n, String key) {
throw new DomLevel3NotImplemented();
}
@@ -2399,7 +2756,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Object _node_setUserData ( Dom n, String key, Object data, UserDataHandler handler ) {
+ public static Object _node_setUserData(Dom n, String key, Object data, UserDataHandler handler) {
throw new DomLevel3NotImplemented();
}
@@ -2407,7 +2764,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Object _node_getFeature ( Dom n, String feature, String version ) {
+ public static Object _node_getFeature(Dom n, String feature, String version) {
throw new DomLevel3NotImplemented();
}
@@ -2415,7 +2772,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _node_isEqualNode ( Dom n, Node arg ) {
+ public static boolean _node_isEqualNode(Dom n, Node arg) {
throw new DomLevel3NotImplemented();
}
@@ -2423,14 +2780,14 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _node_isSameNode ( Dom n, Node arg ) {
+ public static boolean _node_isSameNode(Dom n, Node arg) {
// TODO: check if relying on object identity is ok
boolean ret;
if (n instanceof CharNode) {
// ret = ((CharNode)n).getDom().equals(arg);
ret = n.equals(arg);
} else if (n instanceof NodeXobj) {
- ret = ((NodeXobj)n).getDom().equals(arg);
+ ret = ((NodeXobj) n).getDom().equals(arg);
} else {
throw new DomLevel3NotImplemented();
}
@@ -2441,7 +2798,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_lookupNamespaceURI ( Dom n, String prefix ) {
+ public static String _node_lookupNamespaceURI(Dom n, String prefix) {
throw new DomLevel3NotImplemented();
}
@@ -2449,7 +2806,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _node_isDefaultNamespace ( Dom n, String namespaceURI ) {
+ public static boolean _node_isDefaultNamespace(Dom n, String namespaceURI) {
throw new DomLevel3NotImplemented();
}
@@ -2457,7 +2814,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_lookupPrefix ( Dom n, String namespaceURI ) {
+ public static String _node_lookupPrefix(Dom n, String namespaceURI) {
throw new DomLevel3NotImplemented();
}
@@ -2465,7 +2822,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _node_setTextContent ( Dom n, String textContent ) {
+ public static void _node_setTextContent(Dom n, String textContent) {
throw new DomLevel3NotImplemented();
}
@@ -2473,7 +2830,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getTextContent ( Dom n ) {
+ public static String _node_getTextContent(Dom n) {
throw new DomLevel3NotImplemented();
}
@@ -2481,12 +2838,12 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static short _node_compareDocumentPosition ( Dom n, Node other ) {
+ public static short _node_compareDocumentPosition(Dom n, Node other) {
// TODO: find a faster way to compare, may be based on the locale / cursor elements inside the nodes
if (!(n instanceof Node)) {
return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
}
- Iterator<Node> nAncIter = ancestorAndSelf((Node)n).iterator();
+ Iterator<Node> nAncIter = ancestorAndSelf((Node) n).iterator();
Iterator<Node> oAncIter = ancestorAndSelf(other).iterator();
Node nAnc, oAnc;
@@ -2494,7 +2851,7 @@
do {
nAnc = nAncIter.next();
oAnc = oAncIter.next();
- isEqual = Objects.equals(nAnc,oAnc);
+ isEqual = Objects.equals(nAnc, oAnc);
if (isFirst && !isEqual) {
// if root node differ, the elements are from different documents
return Node.DOCUMENT_POSITION_DISCONNECTED;
@@ -2508,7 +2865,7 @@
: (oAncIter.hasNext()
? Node.DOCUMENT_POSITION_CONTAINED_BY | Node.DOCUMENT_POSITION_FOLLOWING
: Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
- );
+ );
} else {
Node prevSib = nAnc;
while ((prevSib = prevSib.getPreviousSibling()) != null) {
@@ -2535,7 +2892,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _node_getBaseURI ( Dom n ) {
+ public static String _node_getBaseURI(Dom n) {
throw new DomLevel3NotImplemented();
}
@@ -2543,47 +2900,53 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _childNodes_item ( Dom n, int i )
- {
+ public static Node _childNodes_item(Dom n, int i) {
Locale l = n.locale();
Dom d;
- if (i == 0) return _node_getFirstChild(n);
- if (l.noSync()) { d = childNodes_item( n, i ); }
- else synchronized ( l ) { d = childNodes_item( n, i ); }
+ if (i == 0) {
+ return _node_getFirstChild(n);
+ }
+ if (l.noSync()) {
+ d = childNodes_item(n, i);
+ } else {
+ synchronized (l) {
+ d = childNodes_item(n, i);
+ }
+ }
return (Node) d;
}
- public static Dom childNodes_item ( Dom n, int i )
- {
- if (i < 0)
+ public static Dom childNodes_item(Dom n, int i) {
+ if (i < 0) {
return null;
+ }
- switch ( n.nodeType() )
- {
- case TEXT :
- case CDATA :
- case PROCINST :
- case COMMENT :
+ switch (n.nodeType()) {
+ case TEXT:
+ case CDATA:
+ case PROCINST:
+ case COMMENT:
return null;
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- case ELEMENT :
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
+ case ELEMENT:
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
break;
}
- if ( i == 0 )
- return node_getFirstChild ( n );
+ if (i == 0) {
+ return node_getFirstChild(n);
+ }
return n.locale().findDomNthChild(n, i);
}
@@ -2591,41 +2954,44 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static int _childNodes_getLength ( Dom n )
- {
+ public static int _childNodes_getLength(Dom n) {
Locale l = n.locale();
assert n instanceof Xobj;
int count;
Xobj node = (Xobj) n;
if (!node.isVacant() &&
- (count = node.getDomZeroOneChildren()) < 2)
+ (count = node.getDomZeroOneChildren()) < 2) {
return count;
- if (l.noSync()) { return childNodes_getLength( n ); }
- else synchronized ( l ) { return childNodes_getLength( n ); }
+ }
+ if (l.noSync()) {
+ return childNodes_getLength(n);
+ } else {
+ synchronized (l) {
+ return childNodes_getLength(n);
+ }
+ }
}
- public static int childNodes_getLength ( Dom n )
- {
- switch ( n.nodeType() )
- {
- case TEXT :
- case CDATA :
- case PROCINST :
- case COMMENT :
+ public static int childNodes_getLength(Dom n) {
+ switch (n.nodeType()) {
+ case TEXT:
+ case CDATA:
+ case PROCINST:
+ case COMMENT:
return 0;
- case ENTITYREF :
- throw new RuntimeException( "Not impl" );
+ case ENTITYREF:
+ throw new RuntimeException("Not impl");
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
- case ELEMENT :
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
+ case ELEMENT:
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
break;
}
@@ -2633,8 +2999,9 @@
assert n instanceof Xobj;
Xobj node = (Xobj) n;
node.ensureOccupancy();
- if ((count = node.getDomZeroOneChildren()) < 2)
+ if ((count = node.getDomZeroOneChildren()) < 2) {
return count;
+ }
return n.locale().domLength(n);
}
@@ -2642,54 +3009,48 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _element_getTagName ( Dom e )
- {
- return _node_getNodeName( e );
+ public static String _element_getTagName(Dom e) {
+ return _node_getNodeName(e);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _element_getAttributeNode ( Dom e, String name )
- {
- return (Attr) _attributes_getNamedItem( e, name );
+ public static Attr _element_getAttributeNode(Dom e, String name) {
+ return (Attr) _attributes_getNamedItem(e, name);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _element_getAttributeNodeNS ( Dom e, String uri, String local )
- {
- return (Attr) _attributes_getNamedItemNS( e, uri, local );
+ public static Attr _element_getAttributeNodeNS(Dom e, String uri, String local) {
+ return (Attr) _attributes_getNamedItemNS(e, uri, local);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _element_setAttributeNode ( Dom e, Attr newAttr )
- {
- return (Attr) _attributes_setNamedItem( e, newAttr );
+ public static Attr _element_setAttributeNode(Dom e, Attr newAttr) {
+ return (Attr) _attributes_setNamedItem(e, newAttr);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _element_setAttributeNodeNS ( Dom e, Attr newAttr )
- {
- return (Attr) _attributes_setNamedItemNS( e, newAttr );
+ public static Attr _element_setAttributeNodeNS(Dom e, Attr newAttr) {
+ return (Attr) _attributes_setNamedItemNS(e, newAttr);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _element_getAttribute ( Dom e, String name )
- {
- Node a = _attributes_getNamedItem( e, name );
+ public static String _element_getAttribute(Dom e, String name) {
+ Node a = _attributes_getNamedItem(e, name);
return a == null ? "" : a.getNodeValue();
}
@@ -2697,9 +3058,8 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _element_getAttributeNS ( Dom e, String uri, String local )
- {
- Node a = _attributes_getNamedItemNS( e, uri, local );
+ public static String _element_getAttributeNS(Dom e, String uri, String local) {
+ Node a = _attributes_getNamedItemNS(e, uri, local);
return a == null ? "" : a.getNodeValue();
}
@@ -2707,32 +3067,26 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _element_hasAttribute ( Dom e, String name )
- {
- return _attributes_getNamedItem( e, name ) != null;
+ public static boolean _element_hasAttribute(Dom e, String name) {
+ return _attributes_getNamedItem(e, name) != null;
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _element_hasAttributeNS ( Dom e, String uri, String local )
- {
- return _attributes_getNamedItemNS( e, uri, local ) != null;
+ public static boolean _element_hasAttributeNS(Dom e, String uri, String local) {
+ return _attributes_getNamedItemNS(e, uri, local) != null;
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _element_removeAttribute ( Dom e, String name )
- {
- try
- {
- _attributes_removeNamedItem( e, name );
- }
- catch ( NotFoundErr ex )
- {
+ public static void _element_removeAttribute(Dom e, String name) {
+ try {
+ _attributes_removeNamedItem(e, name);
+ } catch (NotFoundErr ex) {
}
}
@@ -2740,14 +3094,10 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _element_removeAttributeNS ( Dom e, String uri, String local )
- {
- try
- {
- _attributes_removeNamedItemNS( e, uri, local );
- }
- catch ( NotFoundErr ex )
- {
+ public static void _element_removeAttributeNS(Dom e, String uri, String local) {
+ try {
+ _attributes_removeNamedItemNS(e, uri, local);
+ } catch (NotFoundErr ex) {
}
}
@@ -2755,131 +3105,197 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Attr _element_removeAttributeNode ( Dom e, Attr oldAttr )
- {
- if (oldAttr == null)
- throw new NotFoundErr( "Attribute to remove is null" );
+ public static Attr _element_removeAttributeNode(Dom e, Attr oldAttr) {
+ if (oldAttr == null) {
+ throw new NotFoundErr("Attribute to remove is null");
+ }
- if (oldAttr.getOwnerElement() != e)
- throw new NotFoundErr( "Attribute to remove does not belong to this element" );
+ if (oldAttr.getOwnerElement() != e) {
+ throw new NotFoundErr("Attribute to remove does not belong to this element");
+ }
- return (Attr) _attributes_removeNamedItem( e, oldAttr.getNodeName() );
+ return (Attr) _attributes_removeNamedItem(e, oldAttr.getNodeName());
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _element_setAttribute ( Dom e, String name, String value )
- {
+ public static void _element_setAttribute(Dom e, String name, String value) {
// TODO - validate all attr/element names in all apprpraite
// methdos
Locale l = e.locale();
- if (l.noSync()) { l.enter(); try { element_setAttribute( e, name, value ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { element_setAttribute( e, name, value ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ element_setAttribute(e, name, value);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ element_setAttribute(e, name, value);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void element_setAttribute ( Dom e, String name, String value )
- {
- Dom a = attributes_getNamedItem( e, name );
+ public static void element_setAttribute(Dom e, String name, String value) {
+ Dom a = attributes_getNamedItem(e, name);
- if (a == null)
- {
- a = document_createAttribute( node_getOwnerDocument( e ), name );
- attributes_setNamedItem( e, a );
+ if (a == null) {
+ a = document_createAttribute(node_getOwnerDocument(e), name);
+ attributes_setNamedItem(e, a);
}
- node_setNodeValue( a, value );
+ node_setNodeValue(a, value);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _element_setAttributeNS ( Dom e, String uri, String qname, String value )
- {
+ public static void _element_setAttributeNS(Dom e, String uri, String qname, String value) {
Locale l = e.locale();
- if (l.noSync()) { l.enter(); try { element_setAttributeNS( e, uri, qname, value ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { element_setAttributeNS( e, uri, qname, value ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ element_setAttributeNS(e, uri, qname, value);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ element_setAttributeNS(e, uri, qname, value);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void element_setAttributeNS ( Dom e, String uri, String qname, String value )
- {
- validateQualifiedName( qname, uri, true );
+ public static void element_setAttributeNS(Dom e, String uri, String qname, String value) {
+ validateQualifiedName(qname, uri, true);
- QName name = e.locale().makeQualifiedQName( uri, qname );
+ QName name = e.locale().makeQualifiedQName(uri, qname);
String local = name.getLocalPart();
- String prefix = validatePrefix( name.getPrefix(), uri, local, true );
+ String prefix = validatePrefix(name.getPrefix(), uri, local, true);
- Dom a = attributes_getNamedItemNS( e, uri, local );
+ Dom a = attributes_getNamedItemNS(e, uri, local);
- if (a == null)
- {
- a = document_createAttributeNS( node_getOwnerDocument( e ), uri, local );
- attributes_setNamedItemNS( e, a );
+ if (a == null) {
+ a = document_createAttributeNS(node_getOwnerDocument(e), uri, local);
+ attributes_setNamedItemNS(e, a);
}
- node_setPrefix( a, prefix );
- node_setNodeValue( a, value );
+ node_setPrefix(a, prefix);
+ node_setNodeValue(a, value);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static NodeList _element_getElementsByTagName ( Dom e, String name )
- {
+ public static NodeList _element_getElementsByTagName(Dom e, String name) {
Locale l = e.locale();
- if (l.noSync()) { l.enter(); try { return element_getElementsByTagName( e, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return element_getElementsByTagName( e, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return element_getElementsByTagName(e, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return element_getElementsByTagName(e, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static NodeList element_getElementsByTagName ( Dom e, String name )
- {
- return new ElementsByTagNameNodeList( e, name );
+
+ public static NodeList element_getElementsByTagName(Dom e, String name) {
+ return new ElementsByTagNameNodeList(e, name);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static NodeList _element_getElementsByTagNameNS ( Dom e, String uri, String local )
- {
+ public static NodeList _element_getElementsByTagNameNS(Dom e, String uri, String local) {
Locale l = e.locale();
- if (l.noSync()) { l.enter(); try { return element_getElementsByTagNameNS( e, uri, local ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return element_getElementsByTagNameNS( e, uri, local ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return element_getElementsByTagNameNS(e, uri, local);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return element_getElementsByTagNameNS(e, uri, local);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static NodeList element_getElementsByTagNameNS ( Dom e, String uri, String local )
- {
- return new ElementsByTagNameNSNodeList( e, uri, local );
+ public static NodeList element_getElementsByTagNameNS(Dom e, String uri, String local) {
+ return new ElementsByTagNameNSNodeList(e, uri, local);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static int _attributes_getLength ( Dom e )
- {
+ public static int _attributes_getLength(Dom e) {
Locale l = e.locale();
- if (l.noSync()) { l.enter(); try { return attributes_getLength( e ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return attributes_getLength( e ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return attributes_getLength(e);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return attributes_getLength(e);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static int attributes_getLength ( Dom e )
- {
+ public static int attributes_getLength(Dom e) {
int n = 0;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
+ while (c.toNextAttr()) {
n++;
+ }
c.release();
@@ -2890,66 +3306,77 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_setNamedItem ( Dom e, Node attr )
- {
+ public static Node _attributes_setNamedItem(Dom e, Node attr) {
Locale l = e.locale();
- if (attr == null)
- throw new IllegalArgumentException( "Attr to set is null" );
+ if (attr == null) {
+ throw new IllegalArgumentException("Attr to set is null");
+ }
Dom a;
- if (!(attr instanceof Dom) || (a = (Dom) attr).locale() != l)
- throw new WrongDocumentErr( "Attr to set is from another document" );
+ if (!(attr instanceof Dom) || (a = (Dom) attr).locale() != l) {
+ throw new WrongDocumentErr("Attr to set is from another document");
+ }
Dom oldA;
- if (l.noSync()) { l.enter(); try { oldA = attributes_setNamedItem( e, a ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { oldA = attributes_setNamedItem( e, a ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ oldA = attributes_setNamedItem(e, a);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ oldA = attributes_setNamedItem(e, a);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) oldA;
}
- public static Dom attributes_setNamedItem ( Dom e, Dom a )
- {
- if (attr_getOwnerElement( a ) != null)
+ public static Dom attributes_setNamedItem(Dom e, Dom a) {
+ if (attr_getOwnerElement(a) != null) {
throw new InuseAttributeError();
+ }
- if (a.nodeType() != ATTR)
- throw new HierarchyRequestErr( "Node is not an attribute" );
+ if (a.nodeType() != ATTR) {
+ throw new HierarchyRequestErr("Node is not an attribute");
+ }
- String name = _node_getNodeName( a );
+ String name = _node_getNodeName(a);
Dom oldAttr = null;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
- {
+ while (c.toNextAttr()) {
Dom aa = c.getDom();
- if (_node_getNodeName( aa ).equals( name ))
- {
- if (oldAttr == null)
+ if (_node_getNodeName(aa).equals(name)) {
+ if (oldAttr == null) {
oldAttr = aa;
- else
- {
- removeNode( aa );
+ } else {
+ removeNode(aa);
c.toPrevAttr();
}
}
}
- if (oldAttr == null)
- {
- c.moveToDom( e );
+ if (oldAttr == null) {
+ c.moveToDom(e);
c.next();
- Cur.moveNode( (Xobj) a, c );
- }
- else
- {
- c.moveToDom( oldAttr );
- Cur.moveNode( (Xobj) a, c );
- removeNode( oldAttr );
+ Cur.moveNode((Xobj) a, c);
+ } else {
+ c.moveToDom(oldAttr);
+ Cur.moveNode((Xobj) a, c);
+ removeNode(oldAttr);
}
c.release();
@@ -2961,30 +3388,41 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_getNamedItem ( Dom e, String name )
- {
+ public static Node _attributes_getNamedItem(Dom e, String name) {
Locale l = e.locale();
Dom n;
- if (l.noSync()) { l.enter(); try { n = attributes_getNamedItem( e, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { n = attributes_getNamedItem( e, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ n = attributes_getNamedItem(e, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ n = attributes_getNamedItem(e, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) n;
}
- public static Dom attributes_getNamedItem ( Dom e, String name )
- {
+ public static Dom attributes_getNamedItem(Dom e, String name) {
Dom a = null;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
- {
+ while (c.toNextAttr()) {
Dom d = c.getDom();
- if (_node_getNodeName( d ).equals( name ))
- {
+ if (_node_getNodeName(d).equals(name)) {
a = d;
break;
}
@@ -2999,35 +3437,47 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_getNamedItemNS ( Dom e, String uri, String local )
- {
+ public static Node _attributes_getNamedItemNS(Dom e, String uri, String local) {
Locale l = e.locale();
Dom n;
- if (l.noSync()) { l.enter(); try { n = attributes_getNamedItemNS( e, uri, local ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { n = attributes_getNamedItemNS( e, uri, local ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ n = attributes_getNamedItemNS(e, uri, local);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ n = attributes_getNamedItemNS(e, uri, local);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) n;
}
- public static Dom attributes_getNamedItemNS ( Dom e, String uri, String local )
- {
- if (uri == null)
+ public static Dom attributes_getNamedItemNS(Dom e, String uri, String local) {
+ if (uri == null) {
uri = "";
+ }
Dom a = null;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
- {
+ while (c.toNextAttr()) {
Dom d = c.getDom();
QName n = d.getQName();
- if (n.getNamespaceURI().equals( uri ) && n.getLocalPart().equals( local ))
- {
+ if (n.getNamespaceURI().equals(uri) && n.getLocalPart().equals(local)) {
a = d;
break;
}
@@ -3042,39 +3492,51 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_removeNamedItem ( Dom e, String name )
- {
+ public static Node _attributes_removeNamedItem(Dom e, String name) {
Locale l = e.locale();
Dom n;
- if (l.noSync()) { l.enter(); try { n = attributes_removeNamedItem( e, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { n = attributes_removeNamedItem( e, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ n = attributes_removeNamedItem(e, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ n = attributes_removeNamedItem(e, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) n;
}
- public static Dom attributes_removeNamedItem ( Dom e, String name )
- {
+ public static Dom attributes_removeNamedItem(Dom e, String name) {
Dom oldAttr = null;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
- {
+ while (c.toNextAttr()) {
Dom aa = c.getDom();
- if (_node_getNodeName(aa).equals(name))
- {
- if (oldAttr == null)
+ if (_node_getNodeName(aa).equals(name)) {
+ if (oldAttr == null) {
oldAttr = aa;
+ }
- if (((AttrXobj) aa).isId())
- {
+ if (((AttrXobj) aa).isId()) {
Dom d = DomImpl.node_getOwnerDocument(aa);
- String val = node_getNodeValue( aa );
- if (d instanceof DocumentXobj)
+ String val = node_getNodeValue(aa);
+ if (d instanceof DocumentXobj) {
((DocumentXobj) d).removeIdElement(val);
+ }
}
removeNode(aa);
c.toPrevAttr();
@@ -3083,8 +3545,9 @@
c.release();
- if (oldAttr == null)
- throw new NotFoundErr( "Named item not found: " + name );
+ if (oldAttr == null) {
+ throw new NotFoundErr("Named item not found: " + name);
+ }
return oldAttr;
}
@@ -3093,45 +3556,58 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_removeNamedItemNS ( Dom e, String uri, String local )
- {
+ public static Node _attributes_removeNamedItemNS(Dom e, String uri, String local) {
Locale l = e.locale();
Dom n;
- if (l.noSync()) { l.enter(); try { n = attributes_removeNamedItemNS( e, uri, local ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { n = attributes_removeNamedItemNS( e, uri, local ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ n = attributes_removeNamedItemNS(e, uri, local);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ n = attributes_removeNamedItemNS(e, uri, local);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) n;
}
- public static Dom attributes_removeNamedItemNS ( Dom e, String uri, String local )
- {
- if (uri == null)
+ public static Dom attributes_removeNamedItemNS(Dom e, String uri, String local) {
+ if (uri == null) {
uri = "";
+ }
Dom oldAttr = null;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
- {
+ while (c.toNextAttr()) {
Dom aa = c.getDom();
QName qn = aa.getQName();
- if (qn.getNamespaceURI().equals( uri ) && qn.getLocalPart().equals( local ))
- {
- if (oldAttr == null)
+ if (qn.getNamespaceURI().equals(uri) && qn.getLocalPart().equals(local)) {
+ if (oldAttr == null) {
oldAttr = aa;
- if (((AttrXobj) aa).isId())
- {
- Dom d = DomImpl.node_getOwnerDocument(aa);
- String val = node_getNodeValue( aa );
- if (d instanceof DocumentXobj)
- ((DocumentXobj) d).removeIdElement(val);
- }
- removeNode( aa );
+ }
+ if (((AttrXobj) aa).isId()) {
+ Dom d = DomImpl.node_getOwnerDocument(aa);
+ String val = node_getNodeValue(aa);
+ if (d instanceof DocumentXobj) {
+ ((DocumentXobj) d).removeIdElement(val);
+ }
+ }
+ removeNode(aa);
c.toPrevAttr();
}
@@ -3139,8 +3615,9 @@
c.release();
- if (oldAttr == null)
- throw new NotFoundErr( "Named item not found: uri=" + uri + ", local=" + local );
+ if (oldAttr == null) {
+ throw new NotFoundErr("Named item not found: uri=" + uri + ", local=" + local);
+ }
return oldAttr;
}
@@ -3149,71 +3626,83 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_setNamedItemNS ( Dom e, Node attr )
- {
+ public static Node _attributes_setNamedItemNS(Dom e, Node attr) {
Locale l = e.locale();
- if (attr == null)
- throw new IllegalArgumentException( "Attr to set is null" );
+ if (attr == null) {
+ throw new IllegalArgumentException("Attr to set is null");
+ }
Dom a;
- if (!(attr instanceof Dom) || (a = (Dom) attr).locale() != l)
- throw new WrongDocumentErr( "Attr to set is from another document" );
+ if (!(attr instanceof Dom) || (a = (Dom) attr).locale() != l) {
+ throw new WrongDocumentErr("Attr to set is from another document");
+ }
Dom oldA;
- if (l.noSync()) { l.enter(); try { oldA = attributes_setNamedItemNS( e, a ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { oldA = attributes_setNamedItemNS( e, a ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ oldA = attributes_setNamedItemNS(e, a);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ oldA = attributes_setNamedItemNS(e, a);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) oldA;
}
- public static Dom attributes_setNamedItemNS ( Dom e, Dom a )
- {
- Dom owner = attr_getOwnerElement( a );
+ public static Dom attributes_setNamedItemNS(Dom e, Dom a) {
+ Dom owner = attr_getOwnerElement(a);
- if (owner == e)
+ if (owner == e) {
return a;
+ }
- if (owner != null)
+ if (owner != null) {
throw new InuseAttributeError();
+ }
- if (a.nodeType() != ATTR)
- throw new HierarchyRequestErr( "Node is not an attribute" );
+ if (a.nodeType() != ATTR) {
+ throw new HierarchyRequestErr("Node is not an attribute");
+ }
QName name = a.getQName();
Dom oldAttr = null;
Cur c = e.tempCur();
- while ( c.toNextAttr() )
- {
+ while (c.toNextAttr()) {
Dom aa = c.getDom();
- if (aa.getQName().equals( name ))
- {
- if (oldAttr == null)
+ if (aa.getQName().equals(name)) {
+ if (oldAttr == null) {
oldAttr = aa;
- else
- {
- removeNode( aa );
+ } else {
+ removeNode(aa);
c.toPrevAttr();
}
}
}
- if (oldAttr == null)
- {
- c.moveToDom( e );
+ if (oldAttr == null) {
+ c.moveToDom(e);
c.next();
- Cur.moveNode( (Xobj) a, c );
- }
- else
- {
- c.moveToDom( oldAttr );
- Cur.moveNode( (Xobj) a, c );
- removeNode( oldAttr );
+ Cur.moveNode((Xobj) a, c);
+ } else {
+ c.moveToDom(oldAttr);
+ Cur.moveNode((Xobj) a, c);
+ removeNode(oldAttr);
}
c.release();
@@ -3225,31 +3714,43 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Node _attributes_item ( Dom e, int index )
- {
+ public static Node _attributes_item(Dom e, int index) {
Locale l = e.locale();
Dom a;
- if (l.noSync()) { l.enter(); try { a = attributes_item( e, index ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { a = attributes_item( e, index ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ a = attributes_item(e, index);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ a = attributes_item(e, index);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Node) a;
}
- public static Dom attributes_item ( Dom e, int index )
- {
- if (index < 0)
+ public static Dom attributes_item(Dom e, int index) {
+ if (index < 0) {
return null;
+ }
Cur c = e.tempCur();
Dom a = null;
- while ( c.toNextAttr() )
- {
- if (index-- == 0)
- {
+ while (c.toNextAttr()) {
+ if (index-- == 0) {
a = c.getDom();
break;
}
@@ -3264,35 +3765,31 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _processingInstruction_getData ( Dom p )
- {
- return _node_getNodeValue( p );
+ public static String _processingInstruction_getData(Dom p) {
+ return _node_getNodeValue(p);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _processingInstruction_getTarget ( Dom p )
- {
- return _node_getNodeName( p );
+ public static String _processingInstruction_getTarget(Dom p) {
+ return _node_getNodeName(p);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _processingInstruction_setData ( Dom p, String data )
- {
- _node_setNodeValue( p, data );
+ public static void _processingInstruction_setData(Dom p, String data) {
+ _node_setNodeValue(p, data);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _attr_getSpecified ( Dom a )
- {
+ public static boolean _attr_getSpecified(Dom a) {
// Can't tell the difference
return true;
}
@@ -3301,24 +3798,36 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Element _attr_getOwnerElement ( Dom a )
- {
+ public static Element _attr_getOwnerElement(Dom a) {
Locale l = a.locale();
Dom e;
- if (l.noSync()) { l.enter(); try { e = attr_getOwnerElement( a ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { e = attr_getOwnerElement( a ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ e = attr_getOwnerElement(a);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ e = attr_getOwnerElement(a);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Element) e;
}
- public static Dom attr_getOwnerElement ( Dom n )
- {
+ public static Dom attr_getOwnerElement(Dom n) {
Cur c = n.tempCur();
- if (!c.toParentRaw())
- {
+ if (!c.toParentRaw()) {
c.release();
return null;
}
@@ -3334,85 +3843,12 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _characterData_appendData ( Dom cd, String arg )
- {
+ public static void _characterData_appendData(Dom cd, String arg) {
// TODO - fix this *really* cheesy/bad/lousy perf impl
// also fix all the funcitons which follow
- if (arg != null && arg.length() != 0)
- _node_setNodeValue( cd, _node_getNodeValue( cd ) + arg );
- }
-
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
-
- public static void _characterData_deleteData ( Dom c, int offset, int count )
- {
- String s = _characterData_getData( c );
-
- if (offset < 0 || offset > s.length() || count < 0)
- throw new IndexSizeError();
-
- if (offset + count > s.length())
- count = s.length() - offset;
-
- if (count > 0)
- _characterData_setData( c, s.substring( 0, offset ) + s.substring( offset + count ) );
- }
-
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
-
- public static String _characterData_getData ( Dom c )
- {
- return _node_getNodeValue( c );
- }
-
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
-
- public static int _characterData_getLength ( Dom c )
- {
- return _characterData_getData( c ).length();
- }
-
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
-
- public static void _characterData_insertData ( Dom c, int offset, String arg )
- {
- String s = _characterData_getData( c );
-
- if (offset < 0 || offset > s.length())
- throw new IndexSizeError();
-
- if (arg != null && arg.length() > 0)
- _characterData_setData( c, s.substring( 0, offset ) + arg + s.substring( offset ) );
- }
-
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
-
- public static void _characterData_replaceData ( Dom c, int offset, int count, String arg )
- {
- String s = _characterData_getData( c );
-
- if (offset < 0 || offset > s.length() || count < 0)
- throw new IndexSizeError();
-
- if (offset + count > s.length())
- count = s.length() - offset;
-
- if (count > 0)
- {
- _characterData_setData(
- c, s.substring( 0, offset ) + (arg == null ? "" : arg)
- + s.substring( offset + count ) );
+ if (arg != null && arg.length() != 0) {
+ _node_setNodeValue(cd, _node_getNodeValue(cd) + arg);
}
}
@@ -3420,52 +3856,125 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static void _characterData_setData ( Dom c, String data )
- {
- _node_setNodeValue( c, data );
- }
+ public static void _characterData_deleteData(Dom c, int offset, int count) {
+ String s = _characterData_getData(c);
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////
-
- public static String _characterData_substringData ( Dom c, int offset, int count )
- {
- String s = _characterData_getData( c );
-
- if (offset < 0 || offset > s.length() || count < 0)
+ if (offset < 0 || offset > s.length() || count < 0) {
throw new IndexSizeError();
+ }
- if (offset + count > s.length())
+ if (offset + count > s.length()) {
count = s.length() - offset;
+ }
- return s.substring( offset, offset + count );
+ if (count > 0) {
+ _characterData_setData(c, s.substring(0, offset) + s.substring(offset + count));
+ }
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Text _text_splitText ( Dom t, int offset )
- {
+ public static String _characterData_getData(Dom c) {
+ return _node_getNodeValue(c);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ public static int _characterData_getLength(Dom c) {
+ return _characterData_getData(c).length();
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ public static void _characterData_insertData(Dom c, int offset, String arg) {
+ String s = _characterData_getData(c);
+
+ if (offset < 0 || offset > s.length()) {
+ throw new IndexSizeError();
+ }
+
+ if (arg != null && arg.length() > 0) {
+ _characterData_setData(c, s.substring(0, offset) + arg + s.substring(offset));
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ public static void _characterData_replaceData(Dom c, int offset, int count, String arg) {
+ String s = _characterData_getData(c);
+
+ if (offset < 0 || offset > s.length() || count < 0) {
+ throw new IndexSizeError();
+ }
+
+ if (offset + count > s.length()) {
+ count = s.length() - offset;
+ }
+
+ if (count > 0) {
+ _characterData_setData(
+ c, s.substring(0, offset) + (arg == null ? "" : arg)
+ + s.substring(offset + count));
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ public static void _characterData_setData(Dom c, String data) {
+ _node_setNodeValue(c, data);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ public static String _characterData_substringData(Dom c, int offset, int count) {
+ String s = _characterData_getData(c);
+
+ if (offset < 0 || offset > s.length() || count < 0) {
+ throw new IndexSizeError();
+ }
+
+ if (offset + count > s.length()) {
+ count = s.length() - offset;
+ }
+
+ return s.substring(offset, offset + count);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////
+
+ public static Text _text_splitText(Dom t, int offset) {
assert t.nodeType() == TEXT;
- String s = _characterData_getData( t );
+ String s = _characterData_getData(t);
- if (offset < 0 || offset > s.length())
+ if (offset < 0 || offset > s.length()) {
throw new IndexSizeError();
+ }
- _characterData_deleteData( t, offset, s.length() - offset );
+ _characterData_deleteData(t, offset, s.length() - offset);
// Don't need to pass a doc here, any node will do..
- Dom t2 = (Dom) _document_createTextNode( t, s.substring( offset ) );
+ Dom t2 = (Dom) _document_createTextNode(t, s.substring(offset));
- Dom p = (Dom) _node_getParentNode( t );
+ Dom p = (Dom) _node_getParentNode(t);
- if (p != null)
- {
- _node_insertBefore( p, (Text) t2, _node_getNextSibling( t ) );
+ if (p != null) {
+ _node_insertBefore(p, (Text) t2, _node_getNextSibling(t));
t.locale().invalidateDomCaches(p);
}
@@ -3476,7 +3985,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static String _text_getWholeText ( Dom t ) {
+ public static String _text_getWholeText(Dom t) {
throw new DomLevel3NotImplemented();
}
@@ -3484,7 +3993,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static boolean _text_isElementContentWhitespace ( Dom t ) {
+ public static boolean _text_isElementContentWhitespace(Dom t) {
throw new DomLevel3NotImplemented();
}
@@ -3492,7 +4001,7 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static Text _text_replaceWholeText ( Dom t, String content ) {
+ public static Text _text_replaceWholeText(Dom t, String content) {
throw new DomLevel3NotImplemented();
}
@@ -3500,66 +4009,74 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static XMLStreamReader _getXmlStreamReader ( Dom n )
- {
+ public static XMLStreamReader _getXmlStreamReader(Dom n) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { return getXmlStreamReader( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return getXmlStreamReader( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return getXmlStreamReader(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return getXmlStreamReader(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static XMLStreamReader getXmlStreamReader ( Dom n )
- {
+ public static XMLStreamReader getXmlStreamReader(Dom n) {
XMLStreamReader xs;
- switch ( n.nodeType() )
- {
- case DOCUMENT :
- case DOCFRAG :
- case ATTR :
- case ELEMENT :
- case PROCINST :
- case COMMENT :
- {
- Cur c = n.tempCur();
- xs = Jsr173.newXmlStreamReader( c, null );
- c.release();
- break;
- }
-
- case TEXT :
- case CDATA :
- {
- CharNode cn = (CharNode) n;
-
- Cur c;
-
- if ((c = cn.tempCur()) == null)
- {
- c = n.locale().tempCur();
-
- xs = Jsr173.newXmlStreamReader( c, cn.getObject(), cn._off, cn._cch );
- }
- else
- {
- xs =
- Jsr173.newXmlStreamReader(
- c , c.getChars( cn._cch ), c._offSrc, c._cchSrc );
-
+ switch (n.nodeType()) {
+ case DOCUMENT:
+ case DOCFRAG:
+ case ATTR:
+ case ELEMENT:
+ case PROCINST:
+ case COMMENT: {
+ Cur c = n.tempCur();
+ xs = Jsr173.newXmlStreamReader(c, null);
+ c.release();
+ break;
}
- c.release();
+ case TEXT:
+ case CDATA: {
+ CharNode cn = (CharNode) n;
- break;
- }
+ Cur c;
- case ENTITYREF :
- case ENTITY :
- case DOCTYPE :
- case NOTATION :
- throw new RuntimeException( "Not impl" );
+ if ((c = cn.tempCur()) == null) {
+ c = n.locale().tempCur();
- default : throw new RuntimeException( "Unknown kind" );
+ xs = Jsr173.newXmlStreamReader(c, cn.getObject(), cn._off, cn._cch);
+ } else {
+ xs =
+ Jsr173.newXmlStreamReader(
+ c, c.getChars(cn._cch), c._offSrc, c._cchSrc);
+
+ }
+
+ c.release();
+
+ break;
+ }
+
+ case ENTITYREF:
+ case ENTITY:
+ case DOCTYPE:
+ case NOTATION:
+ throw new RuntimeException("Not impl");
+
+ default:
+ throw new RuntimeException("Unknown kind");
}
return xs;
@@ -3569,19 +4086,32 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static XmlCursor _getXmlCursor ( Dom n )
- {
+ public static XmlCursor _getXmlCursor(Dom n) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { return getXmlCursor( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return getXmlCursor( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return getXmlCursor(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return getXmlCursor(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static XmlCursor getXmlCursor ( Dom n )
- {
+ public static XmlCursor getXmlCursor(Dom n) {
Cur c = n.tempCur();
- Cursor xc = new Cursor( c );
+ Cursor xc = new Cursor(c);
c.release();
@@ -3592,16 +4122,29 @@
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
- public static XmlObject _getXmlObject ( Dom n )
- {
+ public static XmlObject _getXmlObject(Dom n) {
Locale l = n.locale();
- if (l.noSync()) { l.enter(); try { return getXmlObject( n ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return getXmlObject( n ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return getXmlObject(n);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return getXmlObject(n);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static XmlObject getXmlObject ( Dom n )
- {
+ public static XmlObject getXmlObject(Dom n) {
Cur c = n.tempCur();
XmlObject x = c.getObject();
@@ -3620,861 +4163,1950 @@
// Soap Text Node
//
- public static boolean _soapText_isComment ( Dom n )
- {
+ public static boolean _soapText_isComment(Dom n) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Text text = (org.apache.xmlbeans.impl.soap.Text) n;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapText_isComment( text ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapText_isComment( text ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapText_isComment(text);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapText_isComment(text);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Node
//
- public static void _soapNode_detachNode ( Dom n )
- {
+ public static void _soapNode_detachNode(Dom n) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Node node = (org.apache.xmlbeans.impl.soap.Node) n;
- if (l.noSync()) { l.enter(); try { l._saaj.soapNode_detachNode( node ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapNode_detachNode( node ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapNode_detachNode(node);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapNode_detachNode(node);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapNode_recycleNode ( Dom n )
- {
+ public static void _soapNode_recycleNode(Dom n) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Node node = (org.apache.xmlbeans.impl.soap.Node) n;
- if (l.noSync()) { l.enter(); try { l._saaj.soapNode_recycleNode( node ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapNode_recycleNode( node ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapNode_recycleNode(node);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapNode_recycleNode(node);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String _soapNode_getValue ( Dom n )
- {
+ public static String _soapNode_getValue(Dom n) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Node node = (org.apache.xmlbeans.impl.soap.Node) n;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapNode_getValue( node ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapNode_getValue( node ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapNode_getValue(node);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapNode_getValue(node);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapNode_setValue ( Dom n, String value )
- {
+ public static void _soapNode_setValue(Dom n, String value) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Node node = (org.apache.xmlbeans.impl.soap.Node) n;
- if (l.noSync()) { l.enter(); try { l._saaj.soapNode_setValue( node, value ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapNode_setValue( node, value ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapNode_setValue(node, value);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapNode_setValue(node, value);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapNode_getParentElement ( Dom n )
- {
+ public static SOAPElement _soapNode_getParentElement(Dom n) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Node node = (org.apache.xmlbeans.impl.soap.Node) n;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapNode_getParentElement( node ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapNode_getParentElement( node ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapNode_getParentElement(node);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapNode_getParentElement(node);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapNode_setParentElement ( Dom n, SOAPElement p )
- {
+ public static void _soapNode_setParentElement(Dom n, SOAPElement p) {
Locale l = n.locale();
org.apache.xmlbeans.impl.soap.Node node = (org.apache.xmlbeans.impl.soap.Node) n;
- if (l.noSync()) { l.enter(); try { l._saaj.soapNode_setParentElement( node, p ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapNode_setParentElement( node, p ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapNode_setParentElement(node, p);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapNode_setParentElement(node, p);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Element
//
- public static void _soapElement_removeContents ( Dom d )
- {
+ public static void _soapElement_removeContents(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapElement_removeContents( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapElement_removeContents( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapElement_removeContents(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapElement_removeContents(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String _soapElement_getEncodingStyle ( Dom d )
- {
+ public static String _soapElement_getEncodingStyle(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getEncodingStyle( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getEncodingStyle( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getEncodingStyle(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getEncodingStyle(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapElement_setEncodingStyle ( Dom d, String encodingStyle )
- {
+ public static void _soapElement_setEncodingStyle(Dom d, String encodingStyle) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapElement_setEncodingStyle( se, encodingStyle ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapElement_setEncodingStyle( se, encodingStyle ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapElement_setEncodingStyle(se, encodingStyle);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapElement_setEncodingStyle(se, encodingStyle);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static boolean _soapElement_removeNamespaceDeclaration ( Dom d, String prefix )
- {
+ public static boolean _soapElement_removeNamespaceDeclaration(Dom d, String prefix) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_removeNamespaceDeclaration( se, prefix ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_removeNamespaceDeclaration( se, prefix ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_removeNamespaceDeclaration(se, prefix);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_removeNamespaceDeclaration(se, prefix);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapElement_getAllAttributes ( Dom d )
- {
+ public static Iterator _soapElement_getAllAttributes(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getAllAttributes( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getAllAttributes( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getAllAttributes(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getAllAttributes(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapElement_getChildElements ( Dom d )
- {
+ public static Iterator _soapElement_getChildElements(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getChildElements( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getChildElements( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getChildElements(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getChildElements(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapElement_getNamespacePrefixes ( Dom d )
- {
+ public static Iterator _soapElement_getNamespacePrefixes(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getNamespacePrefixes( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getNamespacePrefixes( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getNamespacePrefixes(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getNamespacePrefixes(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addAttribute ( Dom d, Name name, String value ) throws SOAPException
- {
+ public static SOAPElement _soapElement_addAttribute(Dom d, Name name, String value) throws SOAPException {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addAttribute( se, name, value ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addAttribute( se, name, value ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addAttribute(se, name, value);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addAttribute(se, name, value);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addChildElement ( Dom d, SOAPElement oldChild ) throws SOAPException
- {
+ public static SOAPElement _soapElement_addChildElement(Dom d, SOAPElement oldChild) throws SOAPException {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, oldChild ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, oldChild ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, oldChild);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, oldChild);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addChildElement ( Dom d, Name name ) throws SOAPException
- {
+ public static SOAPElement _soapElement_addChildElement(Dom d, Name name) throws SOAPException {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addChildElement ( Dom d, String localName ) throws SOAPException
- {
+ public static SOAPElement _soapElement_addChildElement(Dom d, String localName) throws SOAPException {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, localName ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, localName ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, localName);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, localName);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addChildElement ( Dom d, String localName, String prefix ) throws SOAPException
- {
+ public static SOAPElement _soapElement_addChildElement(Dom d, String localName, String prefix) throws SOAPException {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, localName, prefix ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, localName, prefix ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, localName, prefix);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, localName, prefix);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addChildElement ( Dom d, String localName, String prefix, String uri ) throws SOAPException
- {
+ public static SOAPElement _soapElement_addChildElement(Dom d, String localName, String prefix, String uri) throws SOAPException {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, localName, prefix, uri ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addChildElement( se, localName, prefix, uri ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, localName, prefix, uri);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addChildElement(se, localName, prefix, uri);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addNamespaceDeclaration ( Dom d, String prefix, String uri )
- {
+ public static SOAPElement _soapElement_addNamespaceDeclaration(Dom d, String prefix, String uri) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addNamespaceDeclaration( se, prefix, uri ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addNamespaceDeclaration( se, prefix, uri ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addNamespaceDeclaration(se, prefix, uri);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addNamespaceDeclaration(se, prefix, uri);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPElement _soapElement_addTextNode ( Dom d, String data )
- {
+ public static SOAPElement _soapElement_addTextNode(Dom d, String data) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_addTextNode( se, data ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_addTextNode( se, data ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addTextNode(se, data);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_addTextNode(se, data);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String _soapElement_getAttributeValue ( Dom d, Name name )
- {
+ public static String _soapElement_getAttributeValue(Dom d, Name name) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getAttributeValue( se, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getAttributeValue( se, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getAttributeValue(se, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getAttributeValue(se, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapElement_getChildElements ( Dom d, Name name )
- {
+ public static Iterator _soapElement_getChildElements(Dom d, Name name) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getChildElements( se, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getChildElements( se, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getChildElements(se, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getChildElements(se, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Name _soapElement_getElementName ( Dom d )
- {
+ public static Name _soapElement_getElementName(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getElementName( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getElementName( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getElementName(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getElementName(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String _soapElement_getNamespaceURI ( Dom d, String prefix )
- {
+ public static String _soapElement_getNamespaceURI(Dom d, String prefix) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getNamespaceURI( se, prefix ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getNamespaceURI( se, prefix ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getNamespaceURI(se, prefix);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getNamespaceURI(se, prefix);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapElement_getVisibleNamespacePrefixes ( Dom d )
- {
+ public static Iterator _soapElement_getVisibleNamespacePrefixes(Dom d) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_getVisibleNamespacePrefixes( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_getVisibleNamespacePrefixes( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getVisibleNamespacePrefixes(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_getVisibleNamespacePrefixes(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static boolean _soapElement_removeAttribute ( Dom d, Name name )
- {
+ public static boolean _soapElement_removeAttribute(Dom d, Name name) {
Locale l = d.locale();
SOAPElement se = (SOAPElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapElement_removeAttribute( se, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapElement_removeAttribute( se, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_removeAttribute(se, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapElement_removeAttribute(se, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Envelope
//
- public static SOAPBody _soapEnvelope_addBody ( Dom d ) throws SOAPException
- {
+ public static SOAPBody _soapEnvelope_addBody(Dom d) throws SOAPException {
Locale l = d.locale();
SOAPEnvelope se = (SOAPEnvelope) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapEnvelope_addBody( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapEnvelope_addBody( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_addBody(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_addBody(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPBody _soapEnvelope_getBody ( Dom d ) throws SOAPException
- {
+ public static SOAPBody _soapEnvelope_getBody(Dom d) throws SOAPException {
Locale l = d.locale();
SOAPEnvelope se = (SOAPEnvelope) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapEnvelope_getBody( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapEnvelope_getBody( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_getBody(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_getBody(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPHeader _soapEnvelope_getHeader ( Dom d ) throws SOAPException
- {
+ public static SOAPHeader _soapEnvelope_getHeader(Dom d) throws SOAPException {
Locale l = d.locale();
SOAPEnvelope se = (SOAPEnvelope) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapEnvelope_getHeader( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapEnvelope_getHeader( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_getHeader(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_getHeader(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPHeader _soapEnvelope_addHeader ( Dom d ) throws SOAPException
- {
+ public static SOAPHeader _soapEnvelope_addHeader(Dom d) throws SOAPException {
Locale l = d.locale();
SOAPEnvelope se = (SOAPEnvelope) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapEnvelope_addHeader( se ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapEnvelope_addHeader( se ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_addHeader(se);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_addHeader(se);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Name _soapEnvelope_createName ( Dom d, String localName )
- {
+ public static Name _soapEnvelope_createName(Dom d, String localName) {
Locale l = d.locale();
SOAPEnvelope se = (SOAPEnvelope) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapEnvelope_createName( se, localName ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapEnvelope_createName( se, localName ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_createName(se, localName);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_createName(se, localName);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Name _soapEnvelope_createName ( Dom d, String localName, String prefix, String namespaceURI )
- {
+ public static Name _soapEnvelope_createName(Dom d, String localName, String prefix, String namespaceURI) {
Locale l = d.locale();
SOAPEnvelope se = (SOAPEnvelope) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapEnvelope_createName( se, localName, prefix, namespaceURI ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapEnvelope_createName( se, localName, prefix, namespaceURI ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_createName(se, localName, prefix, namespaceURI);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapEnvelope_createName(se, localName, prefix, namespaceURI);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Header
//
- public static Iterator soapHeader_examineAllHeaderElements ( Dom d )
- {
+ public static Iterator soapHeader_examineAllHeaderElements(Dom d) {
Locale l = d.locale();
SOAPHeader sh = (SOAPHeader) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeader_examineAllHeaderElements( sh ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeader_examineAllHeaderElements( sh ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_examineAllHeaderElements(sh);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_examineAllHeaderElements(sh);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator soapHeader_extractAllHeaderElements ( Dom d )
- {
+ public static Iterator soapHeader_extractAllHeaderElements(Dom d) {
Locale l = d.locale();
SOAPHeader sh = (SOAPHeader) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeader_extractAllHeaderElements( sh ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeader_extractAllHeaderElements( sh ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_extractAllHeaderElements(sh);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_extractAllHeaderElements(sh);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator soapHeader_examineHeaderElements ( Dom d, String actor )
- {
+ public static Iterator soapHeader_examineHeaderElements(Dom d, String actor) {
Locale l = d.locale();
SOAPHeader sh = (SOAPHeader) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeader_examineHeaderElements( sh, actor ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeader_examineHeaderElements( sh, actor ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_examineHeaderElements(sh, actor);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_examineHeaderElements(sh, actor);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator soapHeader_examineMustUnderstandHeaderElements ( Dom d, String mustUnderstandString )
- {
+ public static Iterator soapHeader_examineMustUnderstandHeaderElements(Dom d, String mustUnderstandString) {
Locale l = d.locale();
SOAPHeader sh = (SOAPHeader) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeader_examineMustUnderstandHeaderElements( sh, mustUnderstandString ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeader_examineMustUnderstandHeaderElements( sh, mustUnderstandString ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_examineMustUnderstandHeaderElements(sh, mustUnderstandString);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_examineMustUnderstandHeaderElements(sh, mustUnderstandString);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator soapHeader_extractHeaderElements ( Dom d, String actor )
- {
+ public static Iterator soapHeader_extractHeaderElements(Dom d, String actor) {
Locale l = d.locale();
SOAPHeader sh = (SOAPHeader) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeader_extractHeaderElements( sh, actor ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeader_extractHeaderElements( sh, actor ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_extractHeaderElements(sh, actor);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_extractHeaderElements(sh, actor);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPHeaderElement soapHeader_addHeaderElement ( Dom d, Name name )
- {
+ public static SOAPHeaderElement soapHeader_addHeaderElement(Dom d, Name name) {
Locale l = d.locale();
SOAPHeader sh = (SOAPHeader) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeader_addHeaderElement( sh, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeader_addHeaderElement( sh, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_addHeaderElement(sh, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeader_addHeaderElement(sh, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Body
//
- public static boolean soapBody_hasFault ( Dom d )
- {
+ public static boolean soapBody_hasFault(Dom d) {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_hasFault( sb ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_hasFault( sb ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_hasFault(sb);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_hasFault(sb);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPFault soapBody_addFault ( Dom d ) throws SOAPException
- {
+ public static SOAPFault soapBody_addFault(Dom d) throws SOAPException {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_addFault( sb ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_addFault( sb ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addFault(sb);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addFault(sb);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPFault soapBody_getFault ( Dom d )
- {
+ public static SOAPFault soapBody_getFault(Dom d) {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_getFault( sb ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_getFault( sb ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_getFault(sb);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_getFault(sb);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPBodyElement soapBody_addBodyElement ( Dom d, Name name )
- {
+ public static SOAPBodyElement soapBody_addBodyElement(Dom d, Name name) {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_addBodyElement( sb, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_addBodyElement( sb, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addBodyElement(sb, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addBodyElement(sb, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPBodyElement soapBody_addDocument ( Dom d, Document document )
- {
+ public static SOAPBodyElement soapBody_addDocument(Dom d, Document document) {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_addDocument( sb, document ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_addDocument( sb, document ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addDocument(sb, document);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addDocument(sb, document);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPFault soapBody_addFault ( Dom d, Name name, String s ) throws SOAPException
- {
+ public static SOAPFault soapBody_addFault(Dom d, Name name, String s) throws SOAPException {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_addFault( sb, name, s ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_addFault( sb, name, s ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addFault(sb, name, s);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addFault(sb, name, s);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPFault soapBody_addFault ( Dom d, Name faultCode, String faultString, java.util.Locale locale ) throws SOAPException
- {
+ public static SOAPFault soapBody_addFault(Dom d, Name faultCode, String faultString, java.util.Locale locale) throws SOAPException {
Locale l = d.locale();
SOAPBody sb = (SOAPBody) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapBody_addFault( sb, faultCode, faultString, locale ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapBody_addFault( sb, faultCode, faultString, locale ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addFault(sb, faultCode, faultString, locale);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapBody_addFault(sb, faultCode, faultString, locale);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Fault
//
- public static void soapFault_setFaultString ( Dom d, String faultString )
- {
+ public static void soapFault_setFaultString(Dom d, String faultString) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapFault_setFaultString( sf, faultString ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapFault_setFaultString( sf, faultString ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultString(sf, faultString);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultString(sf, faultString);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void soapFault_setFaultString ( Dom d, String faultString, java.util.Locale locale )
- {
+ public static void soapFault_setFaultString(Dom d, String faultString, java.util.Locale locale) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapFault_setFaultString( sf, faultString, locale ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapFault_setFaultString( sf, faultString, locale ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultString(sf, faultString, locale);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultString(sf, faultString, locale);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void soapFault_setFaultCode ( Dom d, Name faultCodeName ) throws SOAPException
- {
+ public static void soapFault_setFaultCode(Dom d, Name faultCodeName) throws SOAPException {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapFault_setFaultCode( sf, faultCodeName ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapFault_setFaultCode( sf, faultCodeName ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultCode(sf, faultCodeName);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultCode(sf, faultCodeName);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void soapFault_setFaultActor ( Dom d, String faultActorString )
- {
+ public static void soapFault_setFaultActor(Dom d, String faultActorString) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapFault_setFaultActor( sf, faultActorString ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapFault_setFaultActor( sf, faultActorString ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultActor(sf, faultActorString);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultActor(sf, faultActorString);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String soapFault_getFaultActor ( Dom d )
- {
+ public static String soapFault_getFaultActor(Dom d) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_getFaultActor( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_getFaultActor( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultActor(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultActor(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String soapFault_getFaultCode ( Dom d )
- {
+ public static String soapFault_getFaultCode(Dom d) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_getFaultCode( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_getFaultCode( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultCode(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultCode(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void soapFault_setFaultCode ( Dom d, String faultCode ) throws SOAPException
- {
+ public static void soapFault_setFaultCode(Dom d, String faultCode) throws SOAPException {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapFault_setFaultCode( sf, faultCode ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapFault_setFaultCode( sf, faultCode ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultCode(sf, faultCode);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapFault_setFaultCode(sf, faultCode);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static java.util.Locale soapFault_getFaultStringLocale ( Dom d )
- {
+ public static java.util.Locale soapFault_getFaultStringLocale(Dom d) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_getFaultStringLocale( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_getFaultStringLocale( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultStringLocale(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultStringLocale(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Name soapFault_getFaultCodeAsName ( Dom d )
- {
+ public static Name soapFault_getFaultCodeAsName(Dom d) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_getFaultCodeAsName( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_getFaultCodeAsName( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultCodeAsName(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultCodeAsName(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String soapFault_getFaultString ( Dom d )
- {
+ public static String soapFault_getFaultString(Dom d) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_getFaultString( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_getFaultString( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultString(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getFaultString(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Detail soapFault_addDetail ( Dom d ) throws SOAPException
- {
+ public static Detail soapFault_addDetail(Dom d) throws SOAPException {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_addDetail( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_addDetail( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_addDetail(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_addDetail(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Detail soapFault_getDetail ( Dom d )
- {
+ public static Detail soapFault_getDetail(Dom d) {
Locale l = d.locale();
SOAPFault sf = (SOAPFault) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapFault_getDetail( sf ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapFault_getDetail( sf ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getDetail(sf);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapFault_getDetail(sf);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Header Element
//
- public static void soapHeaderElement_setMustUnderstand ( Dom d, boolean mustUnderstand )
- {
+ public static void soapHeaderElement_setMustUnderstand(Dom d, boolean mustUnderstand) {
Locale l = d.locale();
SOAPHeaderElement she = (SOAPHeaderElement) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapHeaderElement_setMustUnderstand( she, mustUnderstand ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapHeaderElement_setMustUnderstand( she, mustUnderstand ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapHeaderElement_setMustUnderstand(she, mustUnderstand);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapHeaderElement_setMustUnderstand(she, mustUnderstand);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static boolean soapHeaderElement_getMustUnderstand ( Dom d )
- {
+ public static boolean soapHeaderElement_getMustUnderstand(Dom d) {
Locale l = d.locale();
SOAPHeaderElement she = (SOAPHeaderElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeaderElement_getMustUnderstand( she ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeaderElement_getMustUnderstand( she ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeaderElement_getMustUnderstand(she);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeaderElement_getMustUnderstand(she);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void soapHeaderElement_setActor ( Dom d, String actor )
- {
+ public static void soapHeaderElement_setActor(Dom d, String actor) {
Locale l = d.locale();
SOAPHeaderElement she = (SOAPHeaderElement) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapHeaderElement_setActor( she, actor ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapHeaderElement_setActor( she, actor ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapHeaderElement_setActor(she, actor);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapHeaderElement_setActor(she, actor);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String soapHeaderElement_getActor ( Dom d )
- {
+ public static String soapHeaderElement_getActor(Dom d) {
Locale l = d.locale();
SOAPHeaderElement she = (SOAPHeaderElement) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapHeaderElement_getActor( she ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapHeaderElement_getActor( she ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapHeaderElement_getActor(she);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapHeaderElement_getActor(she);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Header Element
//
- public static DetailEntry detail_addDetailEntry ( Dom d, Name name )
- {
+ public static DetailEntry detail_addDetailEntry(Dom d, Name name) {
Locale l = d.locale();
Detail detail = (Detail) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.detail_addDetailEntry( detail, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.detail_addDetailEntry( detail, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.detail_addDetailEntry(detail, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.detail_addDetailEntry(detail, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator detail_getDetailEntries ( Dom d )
- {
+ public static Iterator detail_getDetailEntries(Dom d) {
Locale l = d.locale();
Detail detail = (Detail) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.detail_getDetailEntries( detail ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.detail_getDetailEntries( detail ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.detail_getDetailEntries(detail);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.detail_getDetailEntries(detail);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Soap Header Element
//
- public static void _soapPart_removeAllMimeHeaders ( Dom d )
- {
+ public static void _soapPart_removeAllMimeHeaders(Dom d) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapPart_removeAllMimeHeaders( sp ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapPart_removeAllMimeHeaders( sp ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapPart_removeAllMimeHeaders(sp);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapPart_removeAllMimeHeaders(sp);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapPart_removeMimeHeader ( Dom d, String name )
- {
+ public static void _soapPart_removeMimeHeader(Dom d, String name) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapPart_removeMimeHeader( sp, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapPart_removeMimeHeader( sp, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapPart_removeMimeHeader(sp, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapPart_removeMimeHeader(sp, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapPart_getAllMimeHeaders ( Dom d )
- {
+ public static Iterator _soapPart_getAllMimeHeaders(Dom d) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapPart_getAllMimeHeaders( sp ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapPart_getAllMimeHeaders( sp ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getAllMimeHeaders(sp);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getAllMimeHeaders(sp);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static SOAPEnvelope _soapPart_getEnvelope ( Dom d )
- {
+ public static SOAPEnvelope _soapPart_getEnvelope(Dom d) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapPart_getEnvelope( sp ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapPart_getEnvelope( sp ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getEnvelope(sp);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getEnvelope(sp);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Source _soapPart_getContent ( Dom d )
- {
+ public static Source _soapPart_getContent(Dom d) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapPart_getContent( sp ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapPart_getContent( sp ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getContent(sp);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getContent(sp);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapPart_setContent ( Dom d, Source source )
- {
+ public static void _soapPart_setContent(Dom d, Source source) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapPart_setContent( sp, source ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapPart_setContent( sp, source ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapPart_setContent(sp, source);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapPart_setContent(sp, source);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static String[] _soapPart_getMimeHeader ( Dom d, String name )
- {
+ public static String[] _soapPart_getMimeHeader(Dom d, String name) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapPart_getMimeHeader( sp, name ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapPart_getMimeHeader( sp, name ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getMimeHeader(sp, name);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getMimeHeader(sp, name);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapPart_addMimeHeader ( Dom d, String name, String value )
- {
+ public static void _soapPart_addMimeHeader(Dom d, String name, String value) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapPart_addMimeHeader( sp, name, value ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapPart_addMimeHeader( sp, name, value ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapPart_addMimeHeader(sp, name, value);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapPart_addMimeHeader(sp, name, value);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void _soapPart_setMimeHeader ( Dom d, String name, String value )
- {
+ public static void _soapPart_setMimeHeader(Dom d, String name, String value) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { l._saaj.soapPart_setMimeHeader( sp, name, value ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { l._saaj.soapPart_setMimeHeader( sp, name, value ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ l._saaj.soapPart_setMimeHeader(sp, name, value);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ l._saaj.soapPart_setMimeHeader(sp, name, value);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapPart_getMatchingMimeHeaders ( Dom d, String[] names )
- {
+ public static Iterator _soapPart_getMatchingMimeHeaders(Dom d, String[] names) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapPart_getMatchingMimeHeaders( sp, names ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapPart_getMatchingMimeHeaders( sp, names ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getMatchingMimeHeaders(sp, names);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getMatchingMimeHeaders(sp, names);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Iterator _soapPart_getNonMatchingMimeHeaders ( Dom d, String[] names )
- {
+ public static Iterator _soapPart_getNonMatchingMimeHeaders(Dom d, String[] names) {
Locale l = d.locale();
SOAPPart sp = (SOAPPart) d;
- if (l.noSync()) { l.enter(); try { return l._saaj.soapPart_getNonMatchingMimeHeaders( sp, names ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return l._saaj.soapPart_getNonMatchingMimeHeaders( sp, names ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getNonMatchingMimeHeaders(sp, names);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return l._saaj.soapPart_getNonMatchingMimeHeaders(sp, names);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
//
// Saaj callback
//
- private static class SaajData
- {
+ private static class SaajData {
Object _obj;
}
- public static void saajCallback_setSaajData ( Dom d, Object o )
- {
+ public static void saajCallback_setSaajData(Dom d, Object o) {
Locale l = d.locale();
- if (l.noSync()) { l.enter(); try { impl_saajCallback_setSaajData( d, o ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { impl_saajCallback_setSaajData( d, o ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ impl_saajCallback_setSaajData(d, o);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ impl_saajCallback_setSaajData(d, o);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static void impl_saajCallback_setSaajData ( Dom d, Object o )
- {
+ public static void impl_saajCallback_setSaajData(Dom d, Object o) {
Locale l = d.locale();
Cur c = l.tempCur();
- c.moveToDom( d );
+ c.moveToDom(d);
SaajData sd = null;
- if (o != null)
- {
- sd = (SaajData) c.getBookmark( SaajData.class );
+ if (o != null) {
+ sd = (SaajData) c.getBookmark(SaajData.class);
- if (sd == null)
+ if (sd == null) {
sd = new SaajData();
+ }
sd._obj = o;
}
- c.setBookmark( SaajData.class, sd );
+ c.setBookmark(SaajData.class, sd);
c.release();
}
- public static Object saajCallback_getSaajData ( Dom d )
- {
+ public static Object saajCallback_getSaajData(Dom d) {
Locale l = d.locale();
- if (l.noSync()) { l.enter(); try { return impl_saajCallback_getSaajData( d ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return impl_saajCallback_getSaajData( d ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return impl_saajCallback_getSaajData(d);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return impl_saajCallback_getSaajData(d);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Object impl_saajCallback_getSaajData ( Dom d )
- {
+ public static Object impl_saajCallback_getSaajData(Dom d) {
Locale l = d.locale();
Cur c = l.tempCur();
- c.moveToDom( d );
+ c.moveToDom(d);
- SaajData sd = (SaajData) c.getBookmark( SaajData.class );
+ SaajData sd = (SaajData) c.getBookmark(SaajData.class);
Object o = sd == null ? null : sd._obj;
@@ -4483,23 +6115,36 @@
return o;
}
- public static Element saajCallback_createSoapElement ( Dom d, QName name, QName parentName )
- {
+ public static Element saajCallback_createSoapElement(Dom d, QName name, QName parentName) {
Locale l = d.locale();
Dom e;
- if (l.noSync()) { l.enter(); try { e = impl_saajCallback_createSoapElement( d, name, parentName ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { e = impl_saajCallback_createSoapElement( d, name, parentName ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ e = impl_saajCallback_createSoapElement(d, name, parentName);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ e = impl_saajCallback_createSoapElement(d, name, parentName);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Element) e;
}
- public static Dom impl_saajCallback_createSoapElement ( Dom d, QName name, QName parentName )
- {
+ public static Dom impl_saajCallback_createSoapElement(Dom d, QName name, QName parentName) {
Cur c = d.locale().tempCur();
- c.createElement( name, parentName );
+ c.createElement(name, parentName);
Dom e = c.getDom();
@@ -4508,40 +6153,66 @@
return e;
}
- public static Element saajCallback_importSoapElement (
- Dom d, Element elem, boolean deep, QName parentName )
- {
+ public static Element saajCallback_importSoapElement(
+ Dom d, Element elem, boolean deep, QName parentName) {
Locale l = d.locale();
Dom e;
- if (l.noSync()) { l.enter(); try { e = impl_saajCallback_importSoapElement( d, elem, deep, parentName ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { e = impl_saajCallback_importSoapElement( d, elem, deep, parentName ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ e = impl_saajCallback_importSoapElement(d, elem, deep, parentName);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ e = impl_saajCallback_importSoapElement(d, elem, deep, parentName);
+ } finally {
+ l.exit();
+ }
+ }
+ }
return (Element) e;
}
- public static Dom impl_saajCallback_importSoapElement (
- Dom d, Element elem, boolean deep, QName parentName )
- {
+ public static Dom impl_saajCallback_importSoapElement(
+ Dom d, Element elem, boolean deep, QName parentName) {
// TODO -- need to rewrite DomImpl.document_importNode to use an Xcur
// to create the new tree. Then, I can pass the parentName to the new
// fcn and use it to create the correct root parent
- throw new RuntimeException( "Not impl" );
+ throw new RuntimeException("Not impl");
}
- public static Text saajCallback_ensureSoapTextNode ( Dom d )
- {
+ public static Text saajCallback_ensureSoapTextNode(Dom d) {
Locale l = d.locale();
- if (l.noSync()) { l.enter(); try { return impl_saajCallback_ensureSoapTextNode( d ); } finally { l.exit(); } }
- else synchronized ( l ) { l.enter(); try { return impl_saajCallback_ensureSoapTextNode( d ); } finally { l.exit(); } }
+ if (l.noSync()) {
+ l.enter();
+ try {
+ return impl_saajCallback_ensureSoapTextNode(d);
+ } finally {
+ l.exit();
+ }
+ } else {
+ synchronized (l) {
+ l.enter();
+ try {
+ return impl_saajCallback_ensureSoapTextNode(d);
+ } finally {
+ l.exit();
+ }
+ }
+ }
}
- public static Text impl_saajCallback_ensureSoapTextNode ( Dom d )
- {
+ public static Text impl_saajCallback_ensureSoapTextNode(Dom d) {
// if (!(d instanceof Text))
// {
// Xcur x = d.tempCur();
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Locale.java b/src/main/java/org/apache/xmlbeans/impl/store/Locale.java
index 7cfdaf0..ef3fb67 100755
--- a/src/main/java/org/apache/xmlbeans/impl/store/Locale.java
+++ b/src/main/java/org/apache/xmlbeans/impl/store/Locale.java
@@ -112,7 +112,6 @@
_saaj = options.getSaaj();
if (_saaj != null) {
-
_saaj.setCallback(this);
}
}
@@ -121,7 +120,7 @@
//
//
- static Locale getLocale(SchemaTypeLoader stl, XmlOptions options) {
+ public static Locale getLocale(SchemaTypeLoader stl, XmlOptions options) {
if (stl == null) {
stl = XmlBeans.getContextTypeLoader();
}
@@ -136,31 +135,30 @@
Locale l;
- if (source instanceof Locale) {
- l = (Locale) source;
- } else if (source instanceof XmlTokenSource) {
- l = (Locale) ((XmlTokenSource) source).monitor();
- } else {
- throw new IllegalArgumentException(
- "Source locale not understood: " + source);
- }
+ if (source instanceof Locale) {
+ l = (Locale) source;
+ } else if (source instanceof XmlTokenSource) {
+ l = (Locale) ((XmlTokenSource) source).monitor();
+ } else {
+ throw new IllegalArgumentException("Source locale not understood: " + source);
+ }
- if (l._schemaTypeLoader != stl) {
- throw new IllegalArgumentException(
- "Source locale does not support same schema type loader");
- }
+ if (l._schemaTypeLoader != stl) {
+ throw new IllegalArgumentException(
+ "Source locale does not support same schema type loader");
+ }
if (l._saaj != null && l._saaj != options.getSaaj()) {
- throw new IllegalArgumentException(
- "Source locale does not support same saaj");
- }
+ throw new IllegalArgumentException(
+ "Source locale does not support same saaj");
+ }
- if (l._validateOnSet && !options.isValidateOnSet()) {
- throw new IllegalArgumentException(
- "Source locale does not support same validate on set");
- }
+ if (l._validateOnSet && !options.isValidateOnSet()) {
+ throw new IllegalArgumentException(
+ "Source locale does not support same validate on set");
+ }
- // TODO - other things to check?
+ // TODO - other things to check?
return l;
}
@@ -169,7 +167,7 @@
//
//
- static void associateSourceName(Cur c, XmlOptions options) {
+ public static void associateSourceName(Cur c, XmlOptions options) {
String sourceName = options == null ? null : options.getDocumentSourceName();
if (sourceName != null) {
@@ -181,8 +179,8 @@
//
//
- static void autoTypeDocument(Cur c, SchemaType requestedType,
- XmlOptions options)
+ public static void autoTypeDocument(Cur c, SchemaType requestedType,
+ XmlOptions options)
throws XmlException {
assert c.isRoot();
@@ -1193,7 +1191,7 @@
}
}
- void loadNode(Node n, LoadContext context) {
+ public void loadNode(Node n, LoadContext context) {
switch (n.getNodeType()) {
case Node.DOCUMENT_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
@@ -1280,7 +1278,6 @@
XmlOptions saxHandlerOptions = new XmlOptions(options);
saxHandlerOptions.setLoadUseLocaleCharUtil(true);
-
initSaxHandler(l, saxHandlerOptions);
}
@@ -1822,7 +1819,7 @@
return false;
}
- static boolean toFirstChildElement(Cur c) {
+ public static boolean toFirstChildElement(Cur c) {
// if (!pushToContainer(c))
// return false;
//
@@ -2010,7 +2007,7 @@
}
}
- static Map<String,String> getAllNamespaces(Cur c, Map<String,String> filleMe) {
+ static Map<String, String> getAllNamespaces(Cur c, Map<String, String> filleMe) {
assert c.isNode();
c.push();
@@ -2366,7 +2363,7 @@
return _charUtil;
}
- long version() {
+ public long version() {
return _versionAll;
}
@@ -2627,7 +2624,7 @@
// Loading/parsing
//
- static abstract class LoadContext {
+ public static abstract class LoadContext {
protected abstract void startDTD(String name, String publicId,
String systemId);
@@ -2637,7 +2634,7 @@
protected abstract void endElement();
- protected abstract void attr(QName name, String value);
+ public abstract void attr(QName name, String value);
protected abstract void attr(String local, String uri, String prefix,
String value);
@@ -2654,7 +2651,7 @@
protected abstract void text(String s);
- protected abstract Cur finish();
+ public abstract Cur finish();
protected abstract void abort();
@@ -3232,6 +3229,9 @@
parentName);
}
+ public SchemaTypeLoader getSchemaTypeLoader() {
+ return _schemaTypeLoader;
+ }
private static final class DefaultQNameFactory
implements QNameFactory {
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Path.java b/src/main/java/org/apache/xmlbeans/impl/store/Path.java
deleted file mode 100755
index 31b9bdf..0000000
--- a/src/main/java/org/apache/xmlbeans/impl/store/Path.java
+++ /dev/null
@@ -1,471 +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.store;
-
-import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
-import org.apache.xmlbeans.impl.common.XPath;
-import org.apache.xmlbeans.impl.common.XPath.XPathCompileException;
-import org.apache.xmlbeans.impl.common.XPathExecutionContext;
-import org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath;
-import org.w3c.dom.Node;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-
-// TODO - This class handled query *and* path ... rename it?
-
-public abstract class Path {
- public static final String PATH_DELEGATE_INTERFACE = "PATH_DELEGATE_INTERFACE";
- public static String _useDelegateForXpath = "use delegate for xpath";
- public static String _useXbeanForXpath = "use xbean for xpath";
-
- private static final int USE_XBEAN = 0x01;
- private static final int USE_DELEGATE = 0x04;
-
- private static final Map<String, WeakReference<Path>> _xbeanPathCache = new WeakHashMap<>();
-
-
- private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-
- protected final String _pathKey;
-
- Path(String key) {
- _pathKey = key;
- }
-
-
- interface PathEngine {
- void release();
-
- boolean next(Cur c);
- }
-
- abstract PathEngine execute(Cur c, XmlOptions options);
-
- //
- //
- //
-
- static String getCurrentNodeVar(XmlOptions options) {
- String currentNodeVar = "this";
-
- options = XmlOptions.maskNull(options);
-
- String cnv = options.getXqueryCurrentNodeVar();
- if (cnv != null) {
- currentNodeVar = cnv;
-
- if (currentNodeVar.startsWith("$")) {
- throw new IllegalArgumentException("Omit the '$' prefix for the current node variable");
- }
- }
-
- return currentNodeVar;
- }
-
- public static Path getCompiledPath(String pathExpr, XmlOptions options) {
- options = XmlOptions.maskNull(options);
-
- int force =
- options.isXPathUseDelegate() ? USE_DELEGATE
- : options.isXPathUseXmlBeans() ? USE_XBEAN
- : USE_XBEAN | USE_DELEGATE;
- String delIntfName = XBeansXPath.class.getName();
-
- return getCompiledPath(pathExpr, force, getCurrentNodeVar(options), delIntfName);
- }
-
- static Path getCompiledPath(String pathExpr, int force,
- String currentVar, String delIntfName) {
- Path path = null;
- WeakReference<Path> pathWeakRef = null;
- Map<String, String> namespaces = (force & USE_DELEGATE) != 0 ? new HashMap<>() : null;
- lock.readLock().lock();
- try {
- if ((force & USE_XBEAN) != 0) {
- pathWeakRef = _xbeanPathCache.get(pathExpr);
- }
-
- if (pathWeakRef != null) {
- path = pathWeakRef.get();
- }
- if (path != null) {
- return path;
- }
- } finally {
- lock.readLock().unlock();
- }
- lock.writeLock().lock();
- try {
- if ((force & USE_XBEAN) != 0) {
- pathWeakRef = _xbeanPathCache.get(pathExpr);
- if (pathWeakRef != null) {
- path = pathWeakRef.get();
- }
- if (path == null) {
- path = getCompiledPathXbean(pathExpr, currentVar, namespaces);
- }
- }
- if (path == null && (force & USE_DELEGATE) != 0) {
- path = getCompiledPathDelegate(pathExpr, currentVar, namespaces, delIntfName);
- }
- if (path == null) {
- StringBuilder errMessage = new StringBuilder();
- if ((force & USE_XBEAN) != 0) {
- errMessage.append(" Trying XBeans path engine...");
- }
- if ((force & USE_DELEGATE) != 0) {
- errMessage.append(" Trying delegated path engine...");
- }
-
- throw new RuntimeException(errMessage.toString() + " FAILED on " + pathExpr);
- }
- } finally {
- lock.writeLock().unlock();
- }
- return path;
- }
-
- static private Path getCompiledPathXbean(String pathExpr,
- String currentVar, Map<String, String> namespaces) {
- Path path = XbeanPath.create(pathExpr, currentVar, namespaces);
- if (path != null) {
- _xbeanPathCache.put(path._pathKey, new WeakReference<>(path));
- }
-
- return path;
- }
-
- static private Path getCompiledPathDelegate(String pathExpr, String currentVar, Map<String, String> namespaces, String delIntfName) {
- if (namespaces == null) {
- namespaces = new HashMap<>();
- }
-
- try {
- XPath.compileXPath(pathExpr, currentVar, namespaces);
- } catch (XPath.XPathCompileException e) {
- //do nothing, this function is only called to populate the namespaces map
- }
-
-
- int offset = Integer.parseInt(namespaces.getOrDefault(XPath._NS_BOUNDARY, "0"));
- namespaces.remove(XPath._NS_BOUNDARY);
-
- return DelegatePathImpl.create(delIntfName,
- pathExpr.substring(offset),
- currentVar,
- namespaces);
- }
-
-
- public static String compilePath(String pathExpr, XmlOptions options) {
- return getCompiledPath(pathExpr, options)._pathKey;
- }
-
- //
- // Xbean store specific implementation of compiled path
- //
-
- private static final class XbeanPath extends Path {
- static Path create(String pathExpr, String currentVar, Map<String, String> namespaces) {
- try {
- return new XbeanPath(pathExpr, currentVar,
- XPath.compileXPath(pathExpr, currentVar, namespaces));
- } catch (XPathCompileException e) {
- return null;
- }
- }
-
- private XbeanPath(String pathExpr, String currentVar, XPath xpath) {
- super(pathExpr);
-
- _currentVar = currentVar;
- _compiledPath = xpath;
- }
-
- PathEngine execute(Cur c, XmlOptions options) {
- options = XmlOptions.maskNull(options);
- String delIntfName = XBeansXPath.class.getName();
-
- // The builtin XPath engine works only on containers. Delegate to
- // xqrl otherwise. Also, if the path had a //. at the end, the
- // simple xpath engine can't do the generate case, it only handles
- // attrs and elements.
-
- if (!c.isContainer() || _compiledPath.sawDeepDot()) {
- int force = USE_DELEGATE;
- return getCompiledPath(_pathKey, force, _currentVar, delIntfName).execute(c, options);
- }
- return new XbeanPathEngine(_compiledPath, c);
- }
-
- private final String _currentVar;
- private final XPath _compiledPath;
- public Map<String, String> namespaces;
- }
-
- private static final class XbeanPathEngine
- extends XPathExecutionContext
- implements PathEngine {
- XbeanPathEngine(XPath xpath, Cur c) {
- assert c.isContainer();
-
- _version = c._locale.version();
- _cur = c.weakCur(this);
-
- _cur.push();
-
- init(xpath);
-
- int ret = start();
-
- if ((ret & HIT) != 0) {
- c.addToSelection();
- }
-
- doAttrs(ret, c);
-
- if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
- release();
- }
- }
-
- private void advance(Cur c) {
- assert _cur != null;
-
- if (_cur.isFinish()) {
- if (_cur.isAtEndOfLastPush()) {
- release();
- } else {
- end();
- _cur.next();
- }
- } else if (_cur.isElem()) {
- int ret = element(_cur.getName());
-
- if ((ret & HIT) != 0) {
- c.addToSelection(_cur);
- }
-
- doAttrs(ret, c);
-
- if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
- end();
- _cur.skip();
- }
- } else {
- do {
- _cur.next();
- }
- while (!_cur.isContainerOrFinish());
- }
- }
-
- private void doAttrs(int ret, Cur c) {
- assert _cur.isContainer();
-
- if ((ret & ATTRS) != 0) {
- if (_cur.toFirstAttr()) {
- do {
- if (attr(_cur.getName())) {
- c.addToSelection(_cur);
- }
- }
- while (_cur.toNextAttr());
-
- _cur.toParent();
- }
- }
- }
-
- public boolean next(Cur c) {
- if (_cur != null && _version != _cur._locale.version()) {
- throw new ConcurrentModificationException("Document changed during select");
- }
-
- int startCount = c.selectionCount();
-
- while (_cur != null) {
- advance(c);
-
- if (startCount != c.selectionCount()) {
- return true;
- }
- }
-
- return false;
- }
-
- public void release() {
- if (_cur != null) {
- _cur.release();
- _cur = null;
- }
- }
-
- private final long _version;
- private Cur _cur;
- }
-
- private static final class DelegatePathImpl
- extends Path {
- private PathDelegate.SelectPathInterface _xpathImpl;
-
- static Path create(String implClassName, String pathExpr, String currentNodeVar, Map namespaceMap) {
- assert !currentNodeVar.startsWith("$"); // cezar review with ericvas
-
- PathDelegate.SelectPathInterface impl =
- PathDelegate.createInstance(implClassName, pathExpr, currentNodeVar, namespaceMap);
- if (impl == null) {
- return null;
- }
-
- return new DelegatePathImpl(impl, pathExpr);
- }
-
-
- private DelegatePathImpl(PathDelegate.SelectPathInterface xpathImpl,
- String pathExpr) {
- super(pathExpr);
- _xpathImpl = xpathImpl;
- }
-
- protected PathEngine execute(Cur c, XmlOptions options) {
- return new DelegatePathEngine(_xpathImpl, c);
- }
-
- private static class DelegatePathEngine
- extends XPathExecutionContext
- implements PathEngine {
- // full datetime format: yyyy-MM-dd'T'HH:mm:ss'Z'
- private final DateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- DelegatePathEngine(PathDelegate.SelectPathInterface xpathImpl,
- Cur c) {
- _engine = xpathImpl;
- _version = c._locale.version();
- _cur = c.weakCur(this);
- }
-
- public boolean next(Cur c) {
- if (!_firstCall) {
- return false;
- }
-
- _firstCall = false;
-
- if (_cur != null && _version != _cur._locale.version()) {
- throw new ConcurrentModificationException("Document changed during select");
- }
-
- List resultsList;
-
- Object context_node = _cur.getDom();
- resultsList = _engine.selectPath(context_node);
-
- int i;
- for (i = 0; i < resultsList.size(); i++) {
- //simple type function results
- Object node = resultsList.get(i);
- Cur pos = null;
- if (!(node instanceof Node)) {
- Object obj = resultsList.get(i);
- String value;
- if (obj instanceof Date) {
- value = xmlDateFormat.format((Date) obj);
- } else if (obj instanceof BigDecimal) {
- value = ((BigDecimal) obj).toPlainString();
- } else {
- value = obj.toString();
- }
-
- //we cannot leave the cursor's locale, as
- //everything is done in the selections of this cursor
-
- Locale l = c._locale;
- try {
- pos = l.load("<xml-fragment/>").tempCur();
- pos.setValue(value);
- SchemaType type = getType(node);
- Locale.autoTypeDocument(pos, type, null);
- //move the cur to the actual text
- pos.next();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } else {
- assert (node instanceof DomImpl.Dom) :
- "New object created in XPATH!";
- pos = ((DomImpl.Dom) node).tempCur();
-
- }
- c.addToSelection(pos);
- pos.release();
- }
- release();
- _engine = null;
- return true;
- }
-
- private SchemaType getType(Object node) {
- SchemaType type;
- if (node instanceof Integer) {
- type = XmlInteger.type;
- } else if (node instanceof Double) {
- type = XmlDouble.type;
- } else if (node instanceof Long) {
- type = XmlLong.type;
- } else if (node instanceof Float) {
- type = XmlFloat.type;
- } else if (node instanceof BigDecimal) {
- type = XmlDecimal.type;
- } else if (node instanceof Boolean) {
- type = XmlBoolean.type;
- } else if (node instanceof String) {
- type = XmlString.type;
- } else if (node instanceof Date) {
- type = XmlDate.type;
- } else {
- type = XmlAnySimpleType.type;
- }
- return type;
- }
-
- public void release() {
- if (_cur != null) {
- _cur.release();
- _cur = null;
- }
- }
-
- private Cur _cur;
- private PathDelegate.SelectPathInterface _engine;
- private boolean _firstCall = true;
- private long _version;
- }
- }
-}
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/PathDelegate.java b/src/main/java/org/apache/xmlbeans/impl/store/PathDelegate.java
deleted file mode 100644
index f25a14d..0000000
--- a/src/main/java/org/apache/xmlbeans/impl/store/PathDelegate.java
+++ /dev/null
@@ -1,94 +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.store;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.lang.reflect.Constructor;
-
-import org.apache.xmlbeans.impl.common.XPath;
-
-public final class PathDelegate
-{
- private static HashMap _constructors = new HashMap();
-
- private PathDelegate()
- {}
-
- private static synchronized void init(String implClassName)
- {
- // default to Saxon
- if (implClassName == null)
- implClassName = "org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath";
- Class selectPathInterfaceImpl = null;
- boolean engineAvailable = true;
- try
- {
- selectPathInterfaceImpl = Class.forName(implClassName);
- }
- catch (ClassNotFoundException e)
- {
- engineAvailable = false;
- }
- catch (NoClassDefFoundError e)
- {
- engineAvailable = false;
- }
-
- if (engineAvailable)
- {
- try
- {
- Constructor constructor = selectPathInterfaceImpl.getConstructor(
- new Class[] {String.class, String.class, Map.class, String.class});
- _constructors.put(implClassName, constructor);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- }
-
- public static synchronized SelectPathInterface createInstance(String implClassName,
- String xpath, String contextVar, Map namespaceMap)
- {
- if (_constructors.get(implClassName) == null)
- init(implClassName);
-
- if (_constructors.get(implClassName) == null)
- return null;
-
- Constructor constructor = (Constructor)_constructors.get(implClassName);
- try
- {
- Object defaultNS = namespaceMap.get(XPath._DEFAULT_ELT_NS);
- if (defaultNS != null)
- namespaceMap.remove(XPath._DEFAULT_ELT_NS);
- return (SelectPathInterface)constructor.newInstance(
- new Object[] {xpath, contextVar, namespaceMap, (String)defaultNS});
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public static interface SelectPathInterface
- {
- public List selectPath(Object node);
- }
-}
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Public2.java b/src/main/java/org/apache/xmlbeans/impl/store/Public2.java
index 342bbda..6984028 100755
--- a/src/main/java/org/apache/xmlbeans/impl/store/Public2.java
+++ b/src/main/java/org/apache/xmlbeans/impl/store/Public2.java
@@ -15,42 +15,24 @@
package org.apache.xmlbeans.impl.store;
-import javax.xml.stream.XMLStreamReader;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Node;
-import org.w3c.dom.Document;
-
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlException;
-
-import java.io.PrintStream;
-
+import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.store.DomImpl.Dom;
-
import org.apache.xmlbeans.impl.store.Saver.TextSaver;
-
+import org.apache.xmlbeans.impl.values.NamespaceManager;
import org.apache.xmlbeans.impl.values.TypeStore;
import org.apache.xmlbeans.impl.values.TypeStoreUser;
import org.apache.xmlbeans.impl.values.TypeStoreVisitor;
-import org.apache.xmlbeans.impl.values.TypeStoreUserFactory;
-
-import org.apache.xmlbeans.SchemaType;
-
-import org.apache.xmlbeans.impl.values.NamespaceManager;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import javax.xml.namespace.QName;
-
-import org.apache.xmlbeans.SchemaField;
-
-import org.apache.xmlbeans.QNameSet;
+import javax.xml.stream.XMLStreamReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
public final class Public2
{
@@ -83,7 +65,7 @@
public static String compilePath ( String path, XmlOptions options )
{
- return Path.compilePath( path, options );
+ return XPathFactory.compilePath( path, options );
}
public static DOMImplementation getDomImplementation ( )
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Query.java b/src/main/java/org/apache/xmlbeans/impl/store/Query.java
deleted file mode 100644
index aa746b8..0000000
--- a/src/main/java/org/apache/xmlbeans/impl/store/Query.java
+++ /dev/null
@@ -1,289 +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.store;
-
-import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
-import org.apache.xmlbeans.impl.common.XPath;
-import org.apache.xmlbeans.impl.xquery.saxon.XBeansXQuery;
-import org.w3c.dom.Node;
-
-import javax.xml.namespace.QName;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public abstract class Query {
- public static final String QUERY_DELEGATE_INTERFACE = "QUERY_DELEGATE_INTERFACE";
- public static String _useDelegateForXQuery = "use delegate for xquery";
-
-
- abstract XmlObject[] objectExecute(Cur c, XmlOptions options);
-
- abstract XmlCursor cursorExecute(Cur c, XmlOptions options);
-
- //
- // Xqrl store specific implementation of compiled path/query
- //
-
- static XmlObject[] objectExecQuery(Cur c, String queryExpr, XmlOptions options) {
- return getCompiledQuery(queryExpr, options).objectExecute(c, options);
- }
-
- static XmlCursor cursorExecQuery(Cur c, String queryExpr, XmlOptions options) {
- return getCompiledQuery(queryExpr, options).cursorExecute(c, options);
- }
-
- public static synchronized Query getCompiledQuery(String queryExpr, XmlOptions options) {
- return getCompiledQuery(queryExpr, Path.getCurrentNodeVar(options), options);
- }
-
- static synchronized Query getCompiledQuery(String queryExpr, String currentVar, XmlOptions options) {
- assert queryExpr != null;
- options = XmlOptions.maskNull(options);
- Query query;
-
- //Parse the query via XBeans: need to figure out end of prolog
- //in order to bind $this...not good but...
- Map<String, String> boundary = new HashMap<>();
- int boundaryVal;
- try {
- XPath.compileXPath(queryExpr, currentVar, boundary);
- } catch (XPath.XPathCompileException e) {
- //don't care if it fails, just care about boundary
- } finally {
- boundaryVal = Integer.parseInt(boundary.getOrDefault(XPath._NS_BOUNDARY, "0"));
- }
-
-
- String delIntfName = XBeansXQuery.class.getName();
- query = DelegateQueryImpl.createDelegateCompiledQuery(delIntfName, queryExpr, currentVar, boundaryVal, options);
-
- if (query != null) {
- //_delegateQueryCache.put(queryExpr, query);
- return query;
- }
-
- throw new RuntimeException("No query engine found");
- }
-
- public static synchronized String compileQuery(String queryExpr, XmlOptions options) {
- getCompiledQuery(queryExpr, options);
- return queryExpr;
- }
-
-
-
-
- private static final class DelegateQueryImpl extends Query {
- private DelegateQueryImpl(QueryDelegate.QueryInterface xqueryImpl) {
- _xqueryImpl = xqueryImpl;
- }
-
- static Query createDelegateCompiledQuery(String delIntfName,
- String queryExpr,
- String currentVar,
- int boundary,
- XmlOptions xmlOptions) {
- assert !(currentVar.startsWith(".") || currentVar.startsWith(".."));
- QueryDelegate.QueryInterface impl =
- QueryDelegate.createInstance(delIntfName, queryExpr,
- currentVar, boundary, xmlOptions);
- if (impl == null) {
- return null;
- }
-
- return new DelegateQueryImpl(impl);
- }
-
- XmlObject[] objectExecute(Cur c, XmlOptions options) {
- return new DelegateQueryEngine(_xqueryImpl, c, options).objectExecute();
- }
-
- XmlCursor cursorExecute(Cur c, XmlOptions options) {
- return new DelegateQueryEngine(_xqueryImpl, c, options).cursorExecute();
- }
-
-
- private static class DelegateQueryEngine {
- public DelegateQueryEngine(QueryDelegate.QueryInterface xqImpl,
- Cur c, XmlOptions opt) {
-
- _engine = xqImpl;
- _version = c._locale.version();
- _cur = c.weakCur(this);
- _options = opt;
-
- }
-
- public XmlObject[] objectExecute() {
- if (_cur != null && _version != _cur._locale.version())
- //throw new ConcurrentModificationException
- // ("Document changed during select")
- {
- ;
- }
-
- Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
- List resultsList = _engine.execQuery(_cur.getDom(), bindings);
-
- XmlObject[] result = new XmlObject[resultsList.size()];
- int i;
- for (i = 0; i < resultsList.size(); i++) {
- //copy objects into the locale
- Locale l = Locale.getLocale(_cur._locale._schemaTypeLoader, _options);
-
- l.enter();
- Object node = resultsList.get(i);
- Cur res = null;
- try {
- //typed function results of XQuery
- if (!(node instanceof Node)) {
- //TODO: exact same code as Path.java
- //make a common super-class and pull this--what to name that
- //superclass???
- res = l.load("<xml-fragment/>").tempCur();
- res.setValue(node.toString());
- SchemaType type = getType(node);
- Locale.autoTypeDocument(res, type, null);
- result[i] = res.getObject();
- } else {
- res = loadNode(l, (Node) node);
- }
- result[i] = res.getObject();
- } catch (XmlException e) {
- throw new RuntimeException(e);
- } finally {
- l.exit();
- }
- res.release();
- }
- release();
- _engine = null;
- return result;
- }
-
- private SchemaType getType(Object node) {
- SchemaType type;
- if (node instanceof Integer) {
- type = XmlInteger.type;
- } else if (node instanceof Double) {
- type = XmlDouble.type;
- } else if (node instanceof Long) {
- type = XmlLong.type;
- } else if (node instanceof Float) {
- type = XmlFloat.type;
- } else if (node instanceof BigDecimal) {
- type = XmlDecimal.type;
- } else if (node instanceof Boolean) {
- type = XmlBoolean.type;
- } else if (node instanceof String) {
- type = XmlString.type;
- } else if (node instanceof Date) {
- type = XmlDate.type;
- } else {
- type = XmlAnySimpleType.type;
- }
- return type;
- }
-
- public XmlCursor cursorExecute() {
- if (_cur != null && _version != _cur._locale.version())
- //throw new ConcurrentModificationException
- // ("Document changed during select")
- {
- ;
- }
-
- Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
- List resultsList = _engine.execQuery(_cur.getDom(), bindings);
-
- int i;
- _engine = null;
-
- Locale locale = Locale.getLocale(_cur._locale._schemaTypeLoader, _options);
- locale.enter();
- Locale.LoadContext _context = new Cur.CurLoadContext(locale, _options);
- Cursor resultCur = null;
- try {
- for (i = 0; i < resultsList.size(); i++) {
- loadNodeHelper(locale, (Node) resultsList.get(i), _context);
- }
- Cur c = _context.finish();
- Locale.associateSourceName(c, _options);
- Locale.autoTypeDocument(c, null, _options);
- resultCur = new Cursor(c);
- } catch (Exception e) {
- } finally {
- locale.exit();
- }
- release();
- return resultCur;
- }
-
-
- public void release() {
- if (_cur != null) {
- _cur.release();
- _cur = null;
- }
- }
-
-
- private Cur loadNode(Locale locale, Node node) {
- Locale.LoadContext context = new Cur.CurLoadContext(locale, _options);
-
- try {
- loadNodeHelper(locale, node, context);
- Cur c = context.finish();
- Locale.associateSourceName(c, _options);
- Locale.autoTypeDocument(c, null, _options);
- return c;
- } catch (Exception e) {
- throw new XmlRuntimeException(e.getMessage(), e);
- }
- }
-
- private void loadNodeHelper(Locale locale, Node node, Locale.LoadContext context) {
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- QName attName = new QName(node.getNamespaceURI(),
- node.getLocalName(),
- node.getPrefix());
- context.attr(attName, node.getNodeValue());
- } else {
- locale.loadNode(node, context);
- }
-
- }
-
-
- private Cur _cur;
- private QueryDelegate.QueryInterface _engine;
- private long _version;
- private XmlOptions _options;
- }
-
- private QueryDelegate.QueryInterface _xqueryImpl;
- }
-
-}
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/QueryDelegate.java b/src/main/java/org/apache/xmlbeans/impl/store/QueryDelegate.java
deleted file mode 100644
index 6a184ee..0000000
--- a/src/main/java/org/apache/xmlbeans/impl/store/QueryDelegate.java
+++ /dev/null
@@ -1,76 +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.store;
-
-import org.apache.xmlbeans.XmlOptions;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.lang.reflect.Constructor;
-
-public final class QueryDelegate {
- private static final Map<String, Constructor<? extends QueryInterface>> _constructors =
- new HashMap<String, Constructor<? extends QueryInterface>>();
-
- private QueryDelegate() {
- }
-
- private static synchronized void init(String implClassName) {
- // default to Saxon
- if (implClassName == null)
- implClassName = "org.apache.xmlbeans.impl.xquery.saxon.XBeansXQuery";
- Class<? extends QueryInterface> queryInterfaceImpl = null;
- boolean engineAvailable = true;
- try {
- //noinspection unchecked
- queryInterfaceImpl = (Class<? extends QueryInterface>) Class.forName(implClassName);
- } catch (ClassNotFoundException e) {
- engineAvailable = false;
- } catch (NoClassDefFoundError e) {
- engineAvailable = false;
- }
-
- if (engineAvailable) {
- try {
- Constructor<? extends QueryInterface> constructor = queryInterfaceImpl.getConstructor(
- String.class, String.class, Integer.class, XmlOptions.class);
- _constructors.put(implClassName, constructor);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- public static synchronized QueryInterface createInstance(String implClassName,
- String query, String contextVar, int boundary, XmlOptions xmlOptions) {
- if (_constructors.get(implClassName) == null)
- init(implClassName);
-
- if (_constructors.get(implClassName) == null)
- return null;
-
- Constructor<? extends QueryInterface> constructor = _constructors.get(implClassName);
- try {
- return constructor.newInstance(query, contextVar, boundary, xmlOptions);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public interface QueryInterface {
- List execQuery(Object node, Map variableBindings);
- }
-}
diff --git a/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java b/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java
index 83c03c6..0c9c847 100644
--- a/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java
+++ b/src/main/java/org/apache/xmlbeans/impl/store/Xobj.java
@@ -24,6 +24,7 @@
import org.apache.xmlbeans.impl.values.TypeStoreUser;
import org.apache.xmlbeans.impl.values.TypeStoreUserFactory;
import org.apache.xmlbeans.impl.values.TypeStoreVisitor;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
import javax.xml.namespace.QName;
import java.io.PrintStream;
@@ -2473,7 +2474,7 @@
try {
Cur c = tempCur();
- XmlObject[] result = Query.objectExecQuery(c, queryExpr, options);
+ XmlObject[] result = XPathFactory.objectExecQuery(c, queryExpr, options);
c.release();
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java b/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java
new file mode 100755
index 0000000..b59eccd
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/Path.java
@@ -0,0 +1,24 @@
+/* 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.xpath;
+
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+
+
+public interface Path {
+ XPathEngine execute(Cur c, XmlOptions options);
+}
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XPath.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java
similarity index 82%
rename from src/main/java/org/apache/xmlbeans/impl/common/XPath.java
rename to src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java
index 4ba2f68..8110066 100644
--- a/src/main/java/org/apache/xmlbeans/impl/common/XPath.java
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XPath.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlException;
@@ -38,21 +38,18 @@
}
public static XPath compileXPath(String xpath, String currentNodeVar)
- throws XPathCompileException {
+ throws XPathCompileException {
return compileXPath(xpath, currentNodeVar, null);
}
public static XPath compileXPath(String xpath, Map<String, String> namespaces)
- throws XPathCompileException {
+ throws XPathCompileException {
return compileXPath(xpath, "$this", namespaces);
}
- public static XPath compileXPath(
- String xpath, String currentNodeVar, Map<String, String> namespaces)
- throws XPathCompileException {
- return
- new XPathCompilationContext(namespaces, currentNodeVar).
- compile(xpath);
+ public static XPath compileXPath(String xpath, String currentNodeVar, Map<String, String> namespaces)
+ throws XPathCompileException {
+ return new XPathCompilationContext(namespaces, currentNodeVar).compile(xpath);
}
static final class Selector {
@@ -63,10 +60,6 @@
final XPathStep[] _paths;
}
- //
- //
- //
-
XPath(Selector selector, boolean sawDeepDot) {
_selector = selector;
_sawDeepDot = sawDeepDot;
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java
similarity index 93%
rename from src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java
rename to src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java
index 0e03a5d..76f8e61 100644
--- a/src/main/java/org/apache/xmlbeans/impl/common/XPathCompilationContext.java
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathCompilationContext.java
@@ -13,16 +13,17 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import org.apache.xmlbeans.XmlError;
+import org.apache.xmlbeans.impl.common.XMLChar;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import static org.apache.xmlbeans.impl.common.XPath._NS_BOUNDARY;
+import static org.apache.xmlbeans.impl.xpath.XPath._NS_BOUNDARY;
class XPathCompilationContext {
private String _expr;
@@ -42,7 +43,7 @@
XPathCompilationContext(Map<String, String> namespaces, String currentNodeVar) {
// TODO: checkme
-// assert (_currentNodeVar == null || _currentNodeVar.startsWith("$"));
+ // assert (_currentNodeVar == null || _currentNodeVar.startsWith("$"));
_currentNodeVar = (currentNodeVar == null) ? "$this" : currentNodeVar;
@@ -144,22 +145,22 @@
switch (prefix != null ? prefix : "") {
case "xml":
- return "http://www.w3.org/XML/1998/namespace";
+ return "http://www.w3.org/XML/1998/namespace";
case "xs":
- return "http://www.w3.org/2001/XMLSchema";
+ return "http://www.w3.org/2001/XMLSchema";
case "xsi":
- return "http://www.w3.org/2001/XMLSchema-instance";
+ return "http://www.w3.org/2001/XMLSchema-instance";
case "fn":
- return "http://www.w3.org/2002/11/xquery-functions";
+ return "http://www.w3.org/2002/11/xquery-functions";
case "xdt":
- return "http://www.w3.org/2003/11/xpath-datatypes";
+ return "http://www.w3.org/2003/11/xpath-datatypes";
case "local":
- return "http://www.w3.org/2003/11/xquery-local-functions";
+ return "http://www.w3.org/2003/11/xquery-local-functions";
}
throw newError("Undefined prefix: " + prefix);
@@ -187,15 +188,15 @@
for (String s : tokens) {
assert (s != null && !s.isEmpty());
- while (isWhitespace(offset)) {
- offset++;
- }
+ while (isWhitespace(offset)) {
+ offset++;
+ }
- if (!startsWith(s, offset)) {
- return false;
- }
+ if (!startsWith(s, offset)) {
+ return false;
+ }
- offset += s.length();
+ offset += s.length();
}
advance(offset);
@@ -332,10 +333,10 @@
} else {
tokenize("child", "::");
name = tokenizeQName();
- 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
- }
+ 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;
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java
new file mode 100644
index 0000000..e7dc9d1
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathEngine.java
@@ -0,0 +1,24 @@
+/* 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.xpath;
+
+import org.apache.xmlbeans.impl.store.Cur;
+
+public interface XPathEngine {
+ void release();
+
+ boolean next(Cur c);
+}
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java
similarity index 98%
rename from src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java
rename to src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java
index b5b38f7..a60744a 100644
--- a/src/main/java/org/apache/xmlbeans/impl/common/XPathExecutionContext.java
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathExecutionContext.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import javax.xml.namespace.QName;
import java.util.ArrayList;
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java
new file mode 100644
index 0000000..29029e9
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathFactory.java
@@ -0,0 +1,189 @@
+/* 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.xpath;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.xpath.saxon.SaxonXPath;
+import org.apache.xmlbeans.impl.xpath.saxon.SaxonXQuery;
+import org.apache.xmlbeans.impl.xpath.xmlbeans.XmlbeansXPath;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class XPathFactory {
+ private static final int USE_XMLBEANS = 0x01;
+ private static final int USE_SAXON = 0x04;
+
+ private static final Map<String, WeakReference<Path>> _xmlbeansPathCache = new WeakHashMap<>();
+ private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+ static String getCurrentNodeVar(XmlOptions options) {
+ String currentNodeVar = "this";
+
+ options = XmlOptions.maskNull(options);
+
+ String cnv = options.getXqueryCurrentNodeVar();
+ if (cnv != null) {
+ currentNodeVar = cnv;
+
+ if (currentNodeVar.startsWith("$")) {
+ throw new IllegalArgumentException("Omit the '$' prefix for the current node variable");
+ }
+ }
+
+ return currentNodeVar;
+ }
+
+ public static Path getCompiledPath(String pathExpr, XmlOptions options) {
+ options = XmlOptions.maskNull(options);
+ return getCompiledPath(pathExpr, options, getCurrentNodeVar(options));
+ }
+
+ public static Path getCompiledPath(String pathExpr, XmlOptions options, String currentVar) {
+ int force =
+ options.isXPathUseSaxon() ? USE_SAXON
+ : options.isXPathUseXmlBeans() ? USE_XMLBEANS
+ : USE_XMLBEANS | USE_SAXON;
+
+ Path path = null;
+ WeakReference<Path> pathWeakRef = null;
+ Map<String, String> namespaces = (force & USE_SAXON) != 0 ? new HashMap<>() : null;
+ lock.readLock().lock();
+ try {
+ if ((force & USE_XMLBEANS) != 0) {
+ pathWeakRef = _xmlbeansPathCache.get(pathExpr);
+ }
+ if (pathWeakRef != null) {
+ path = pathWeakRef.get();
+ }
+ if (path != null) {
+ return path;
+ }
+ } finally {
+ lock.readLock().unlock();
+ }
+ lock.writeLock().lock();
+ try {
+ if ((force & USE_XMLBEANS) != 0) {
+ pathWeakRef = _xmlbeansPathCache.get(pathExpr);
+ if (pathWeakRef != null) {
+ path = pathWeakRef.get();
+ }
+ if (path == null) {
+ path = getCompiledPathXmlBeans(pathExpr, currentVar, namespaces);
+ }
+ }
+ if (path == null && (force & USE_SAXON) != 0) {
+ path = getCompiledPathSaxon(pathExpr, currentVar, namespaces);
+ }
+ if (path == null) {
+ StringBuilder errMessage = new StringBuilder();
+ if ((force & USE_XMLBEANS) != 0) {
+ errMessage.append(" Trying XmlBeans path engine...");
+ }
+ if ((force & USE_SAXON) != 0) {
+ errMessage.append(" Trying Saxon path engine...");
+ }
+
+ throw new RuntimeException(errMessage.toString() + " FAILED on " + pathExpr);
+ }
+ } finally {
+ lock.writeLock().unlock();
+ }
+ return path;
+ }
+
+ private static Path getCompiledPathXmlBeans(String pathExpr, String currentVar, Map<String, String> namespaces) {
+ try {
+ Path path = new XmlbeansXPath(pathExpr, currentVar,
+ XPath.compileXPath(pathExpr, currentVar, namespaces));
+ _xmlbeansPathCache.put(pathExpr, new WeakReference<>(path));
+ return path;
+ } catch (XPath.XPathCompileException ignored) {
+ return null;
+ }
+ }
+
+ public static Path getCompiledPathSaxon(String pathExpr, String currentVar, Map<String, String> namespaces) {
+ if (namespaces == null) {
+ namespaces = new HashMap<>();
+ }
+
+ try {
+ XPath.compileXPath(pathExpr, currentVar, namespaces);
+ } catch (XPath.XPathCompileException e) {
+ //do nothing, this function is only called to populate the namespaces map
+ }
+
+
+ int offset = Integer.parseInt(namespaces.getOrDefault(XPath._NS_BOUNDARY, "0"));
+ namespaces.remove(XPath._NS_BOUNDARY);
+
+ return new SaxonXPath(pathExpr.substring(offset), currentVar, namespaces);
+ }
+
+
+ public static String compilePath(String pathExpr, XmlOptions options) {
+ getCompiledPath(pathExpr, options);
+ return pathExpr;
+ }
+
+ //
+ // Xqrl store specific implementation of compiled path/query
+ //
+
+ public static XmlObject[] objectExecQuery(Cur c, String queryExpr, XmlOptions options) {
+ return getCompiledQuery(queryExpr, options).objectExecute(c, options);
+ }
+
+ public static XmlCursor cursorExecQuery(Cur c, String queryExpr, XmlOptions options) {
+ return getCompiledQuery(queryExpr, options).cursorExecute(c, options);
+ }
+
+ public static synchronized XQuery getCompiledQuery(String queryExpr, XmlOptions options) {
+ return getCompiledQuery(queryExpr, XPathFactory.getCurrentNodeVar(options), options);
+ }
+
+ static synchronized XQuery getCompiledQuery(String queryExpr, String currentVar, XmlOptions options) {
+ assert queryExpr != null;
+ options = XmlOptions.maskNull(options);
+
+ //Parse the query via XmlBeans: need to figure out end of prolog
+ //in order to bind $this...not good but...
+ Map<String, String> boundary = new HashMap<>();
+ int boundaryVal;
+ try {
+ XPath.compileXPath(queryExpr, currentVar, boundary);
+ } catch (XPath.XPathCompileException e) {
+ //don't care if it fails, just care about boundary
+ } finally {
+ boundaryVal = Integer.parseInt(boundary.getOrDefault(XPath._NS_BOUNDARY, "0"));
+ }
+
+ return new SaxonXQuery(queryExpr, currentVar, boundaryVal, options);
+ }
+
+ public static synchronized String compileQuery(String queryExpr, XmlOptions options) {
+ getCompiledQuery(queryExpr, options);
+ return queryExpr;
+ }
+}
diff --git a/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java
similarity index 97%
rename from src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java
rename to src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java
index 4426f3f..ca2ef4c 100644
--- a/src/main/java/org/apache/xmlbeans/impl/common/XPathStep.java
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XPathStep.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.common;
+package org.apache.xmlbeans.impl.xpath;
import javax.xml.namespace.QName;
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java b/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java
new file mode 100644
index 0000000..9aae59b
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/XQuery.java
@@ -0,0 +1,27 @@
+/* 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.xpath;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+
+public interface XQuery {
+ XmlObject[] objectExecute(Cur c, XmlOptions options);
+
+ XmlCursor cursorExecute(Cur c, XmlOptions options);
+}
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java b/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java
similarity index 89%
rename from src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
rename to src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java
index c92e6bb..be56ca0 100644
--- a/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/XBeansXPath.java
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPath.java
@@ -22,7 +22,11 @@
import net.sf.saxon.om.SequenceTool;
import net.sf.saxon.sxpath.*;
import net.sf.saxon.tree.wrapper.VirtualNode;
-import org.apache.xmlbeans.impl.store.PathDelegate;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.xpath.Path;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
import org.w3c.dom.Node;
import javax.xml.transform.TransformerException;
@@ -33,9 +37,8 @@
import java.util.Map;
@SuppressWarnings("WeakerAccess")
-public class XBeansXPath
- implements PathDelegate.SelectPathInterface {
- private final Map<String, String> namespaceMap = new HashMap<String, String>();
+public class SaxonXPath implements Path {
+ private final Map<String, String> namespaceMap = new HashMap<>();
private String path;
private String contextVar;
private String defaultNS;
@@ -46,16 +49,20 @@
* @param path The XPath expression
* @param contextVar The name of the context variable
* @param namespaceMap a map of prefix/uri bindings for NS support
- * @param defaultNS the uri for the default element NS, if any
*/
- public XBeansXPath(String path, String contextVar,
- Map<String, String> namespaceMap, String defaultNS) {
+ public SaxonXPath(String path, String contextVar, Map<String, String> namespaceMap) {
this.path = path;
this.contextVar = contextVar;
- this.defaultNS = defaultNS;
+ this.defaultNS = namespaceMap.get(XPath._DEFAULT_ELT_NS);
this.namespaceMap.putAll(namespaceMap);
+ this.namespaceMap.remove(XPath._DEFAULT_ELT_NS);
}
+ public XPathEngine execute(Cur c, XmlOptions options) {
+ return new SaxonXPathEngine(this, c);
+ }
+
+
/**
* Select all nodes that are selectable by this XPath
* expression. If multiple nodes match, multiple nodes
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java b/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java
new file mode 100644
index 0000000..ba64c5e
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXPathEngine.java
@@ -0,0 +1,138 @@
+/* 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.xpath.saxon;
+
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.store.DomImpl;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathExecutionContext;
+import org.w3c.dom.Node;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ConcurrentModificationException;
+import java.util.Date;
+import java.util.List;
+
+public class SaxonXPathEngine extends XPathExecutionContext implements XPathEngine {
+ // full datetime format: yyyy-MM-dd'T'HH:mm:ss'Z'
+ private final DateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ private Cur _cur;
+ private SaxonXPath _engine;
+ private boolean _firstCall = true;
+ private final long _version;
+
+
+ SaxonXPathEngine(SaxonXPath xpathImpl, Cur c) {
+ _engine = xpathImpl;
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+ }
+
+ public boolean next(Cur c) {
+ if (!_firstCall) {
+ return false;
+ }
+
+ _firstCall = false;
+
+ if (_cur != null && _version != _cur.getLocale().version()) {
+ throw new ConcurrentModificationException("Document changed during select");
+ }
+
+ List resultsList = _engine.selectPath(_cur.getDom());
+
+ int i;
+ for (i = 0; i < resultsList.size(); i++) {
+ //simple type function results
+ Object node = resultsList.get(i);
+ Cur pos = null;
+ if (!(node instanceof Node)) {
+ Object obj = resultsList.get(i);
+ String value;
+ if (obj instanceof Date) {
+ value = xmlDateFormat.format((Date) obj);
+ } else if (obj instanceof BigDecimal) {
+ value = ((BigDecimal) obj).toPlainString();
+ } else {
+ value = obj.toString();
+ }
+
+ //we cannot leave the cursor's locale, as
+ //everything is done in the selections of this cursor
+
+ org.apache.xmlbeans.impl.store.Locale l = c.getLocale();
+ try {
+ pos = l.load("<xml-fragment/>").tempCur();
+ pos.setValue(value);
+ SchemaType type = getType(node);
+ Locale.autoTypeDocument(pos, type, null);
+ //move the cur to the actual text
+ pos.next();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ assert (node instanceof DomImpl.Dom) :
+ "New object created in XPATH!";
+ pos = ((DomImpl.Dom) node).tempCur();
+
+ }
+ c.addToSelection(pos);
+ pos.release();
+ }
+ release();
+ _engine = null;
+ return true;
+ }
+
+ private SchemaType getType(Object node) {
+ SchemaType type;
+ if (node instanceof Integer) {
+ type = XmlInteger.type;
+ } else if (node instanceof Double) {
+ type = XmlDouble.type;
+ } else if (node instanceof Long) {
+ type = XmlLong.type;
+ } else if (node instanceof Float) {
+ type = XmlFloat.type;
+ } else if (node instanceof BigDecimal) {
+ type = XmlDecimal.type;
+ } else if (node instanceof Boolean) {
+ type = XmlBoolean.type;
+ } else if (node instanceof String) {
+ type = XmlString.type;
+ } else if (node instanceof Date) {
+ type = XmlDate.type;
+ } else {
+ type = XmlAnySimpleType.type;
+ }
+ return type;
+ }
+
+ public void release() {
+ if (_cur != null) {
+ _cur.release();
+ _cur = null;
+ }
+ }
+
+
+}
diff --git a/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java b/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
similarity index 61%
rename from src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
rename to src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
index bfce95c..212b47b 100644
--- a/src/main/java/org/apache/xmlbeans/impl/xquery/saxon/XBeansXQuery.java
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/saxon/SaxonXQuery.java
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-package org.apache.xmlbeans.impl.xquery.saxon;
+package org.apache.xmlbeans.impl.xpath.saxon;
import net.sf.saxon.Configuration;
import net.sf.saxon.dom.DocumentWrapper;
@@ -27,10 +27,11 @@
import net.sf.saxon.query.XQueryExpression;
import net.sf.saxon.type.BuiltInAtomicType;
import net.sf.saxon.value.*;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlRuntimeException;
-import org.apache.xmlbeans.XmlTokenSource;
-import org.apache.xmlbeans.impl.store.QueryDelegate;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.store.Cursor;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.xpath.XQuery;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -43,15 +44,20 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
+import java.util.Date;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
-public class XBeansXQuery
- implements QueryDelegate.QueryInterface {
- private XQueryExpression xquery;
- private String contextVar;
- private Configuration config;
+public class SaxonXQuery implements XQuery {
+ private final XQueryExpression xquery;
+ private final String contextVar;
+ private final Configuration config;
+
+ private Cur _cur;
+ private long _version;
+ private XmlOptions _options;
+
/**
* Construct given an XQuery expression string.
@@ -60,7 +66,12 @@
* @param contextVar The name of the context variable
* @param boundary The offset of the end of the prolog
*/
- public XBeansXQuery(final String query, String contextVar, Integer boundary, XmlOptions xmlOptions) {
+ public SaxonXQuery(final String query, String contextVar, Integer boundary, XmlOptions xmlOptions) {
+ assert !(contextVar.startsWith(".") || contextVar.startsWith(".."));
+
+ _options = xmlOptions;
+
+
config = new Configuration();
StaticQueryContext sc = config.newStaticQueryContext();
Map<String, String> nsMap = xmlOptions.getLoadAdditionalNamespaces();
@@ -78,6 +89,22 @@
}
}
+
+ public XmlObject[] objectExecute(Cur c, XmlOptions options) {
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+ this._options = options;
+ return objectExecute();
+ }
+
+ public XmlCursor cursorExecute(Cur c, XmlOptions options) {
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+ this._options = options;
+ return cursorExecute();
+ }
+
+
public List execQuery(Object node, Map variableBindings) {
try {
Node contextNode = (Node) node;
@@ -206,4 +233,144 @@
return new ObjectValue(value);
}
}
+
+
+ public XmlObject[] objectExecute() {
+ if (_cur != null && _version != _cur.getLocale().version())
+ //throw new ConcurrentModificationException
+ // ("Document changed during select")
+ {
+ ;
+ }
+
+ Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
+ List resultsList = execQuery(_cur.getDom(), bindings);
+
+ XmlObject[] result = new XmlObject[resultsList.size()];
+ int i;
+ for (i = 0; i < resultsList.size(); i++) {
+ //copy objects into the locale
+ Locale l = Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
+
+ l.enter();
+ Object node = resultsList.get(i);
+ Cur res = null;
+ try {
+ //typed function results of XQuery
+ if (!(node instanceof Node)) {
+ //TODO: exact same code as Path.java
+ //make a common super-class and pull this--what to name that
+ //superclass???
+ res = l.load("<xml-fragment/>").tempCur();
+ res.setValue(node.toString());
+ SchemaType type = getType(node);
+ Locale.autoTypeDocument(res, type, null);
+ result[i] = res.getObject();
+ } else {
+ res = loadNode(l, (Node) node);
+ }
+ result[i] = res.getObject();
+ } catch (XmlException e) {
+ throw new RuntimeException(e);
+ } finally {
+ l.exit();
+ }
+ res.release();
+ }
+ release();
+ return result;
+ }
+
+ private SchemaType getType(Object node) {
+ SchemaType type;
+ if (node instanceof Integer) {
+ type = XmlInteger.type;
+ } else if (node instanceof Double) {
+ type = XmlDouble.type;
+ } else if (node instanceof Long) {
+ type = XmlLong.type;
+ } else if (node instanceof Float) {
+ type = XmlFloat.type;
+ } else if (node instanceof BigDecimal) {
+ type = XmlDecimal.type;
+ } else if (node instanceof Boolean) {
+ type = XmlBoolean.type;
+ } else if (node instanceof String) {
+ type = XmlString.type;
+ } else if (node instanceof Date) {
+ type = XmlDate.type;
+ } else {
+ type = XmlAnySimpleType.type;
+ }
+ return type;
+ }
+
+ public XmlCursor cursorExecute() {
+ if (_cur != null && _version != _cur.getLocale().version())
+ //throw new ConcurrentModificationException
+ // ("Document changed during select")
+ {
+ ;
+ }
+
+ Map<String, Object> bindings = XmlOptions.maskNull(_options).getXqueryVariables();
+ List resultsList = execQuery(_cur.getDom(), bindings);
+
+ int i;
+
+ Locale locale = Locale.getLocale(_cur.getLocale().getSchemaTypeLoader(), _options);
+ locale.enter();
+ Locale.LoadContext _context = new Cur.CurLoadContext(locale, _options);
+ Cursor resultCur = null;
+ try {
+ for (i = 0; i < resultsList.size(); i++) {
+ loadNodeHelper(locale, (Node) resultsList.get(i), _context);
+ }
+ Cur c = _context.finish();
+ Locale.associateSourceName(c, _options);
+ Locale.autoTypeDocument(c, null, _options);
+ resultCur = new Cursor(c);
+ } catch (Exception e) {
+ } finally {
+ locale.exit();
+ }
+ release();
+ return resultCur;
+ }
+
+
+ public void release() {
+ if (_cur != null) {
+ _cur.release();
+ _cur = null;
+ }
+ }
+
+
+ private Cur loadNode(Locale locale, Node node) {
+ Locale.LoadContext context = new Cur.CurLoadContext(locale, _options);
+
+ try {
+ loadNodeHelper(locale, node, context);
+ Cur c = context.finish();
+ Locale.associateSourceName(c, _options);
+ Locale.autoTypeDocument(c, null, _options);
+ return c;
+ } catch (Exception e) {
+ throw new XmlRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ private void loadNodeHelper(Locale locale, Node node, Locale.LoadContext context) {
+ if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ QName attName = new QName(node.getNamespaceURI(),
+ node.getLocalName(),
+ node.getPrefix());
+ context.attr(attName, node.getNodeValue());
+ } else {
+ locale.loadNode(node, context);
+ }
+
+ }
+
}
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java b/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java
new file mode 100644
index 0000000..3ef314d
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPath.java
@@ -0,0 +1,56 @@
+/* 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.xpath.xmlbeans;
+
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.xpath.Path;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathFactory;
+
+//
+// XmlBeans store specific implementation of compiled path
+//
+
+public class XmlbeansXPath implements Path {
+ private final String _pathKey;
+ private final String _currentVar;
+ private final XPath _compiledPath;
+
+ public XmlbeansXPath(String pathExpr, String currentVar, XPath xpath) {
+ _pathKey = pathExpr;
+
+ _currentVar = currentVar;
+ _compiledPath = xpath;
+ }
+
+ public XPathEngine execute(Cur c, XmlOptions options) {
+ options = XmlOptions.maskNull(options);
+
+ // The builtin XPath engine works only on containers. Delegate to
+ // saxon otherwise. Also, if the path had a //. at the end, the
+ // simple xpath engine can't do the generate case, it only handles
+ // attrs and elements.
+ if (!c.isContainer() || _compiledPath.sawDeepDot()) {
+ Path xpe = XPathFactory.getCompiledPathSaxon(_pathKey, _currentVar, null);
+ return xpe.execute(c, options);
+ } else {
+ return new XmlbeansXPathEngine(_compiledPath, c);
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java b/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java
new file mode 100644
index 0000000..82c583f
--- /dev/null
+++ b/src/main/java/org/apache/xmlbeans/impl/xpath/xmlbeans/XmlbeansXPathEngine.java
@@ -0,0 +1,126 @@
+/* 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.xpath.xmlbeans;
+
+import org.apache.xmlbeans.impl.store.Cur;
+import org.apache.xmlbeans.impl.store.Locale;
+import org.apache.xmlbeans.impl.xpath.XPath;
+import org.apache.xmlbeans.impl.xpath.XPathEngine;
+import org.apache.xmlbeans.impl.xpath.XPathExecutionContext;
+
+import java.util.ConcurrentModificationException;
+
+class XmlbeansXPathEngine extends XPathExecutionContext implements XPathEngine {
+ XmlbeansXPathEngine(XPath xpath, Cur c) {
+ assert c.isContainer();
+
+ _version = c.getLocale().version();
+ _cur = c.weakCur(this);
+
+ _cur.push();
+
+ init(xpath);
+
+ int ret = start();
+
+ if ((ret & HIT) != 0) {
+ c.addToSelection();
+ }
+
+ doAttrs(ret, c);
+
+ if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
+ release();
+ }
+ }
+
+ private void advance(Cur c) {
+ assert _cur != null;
+
+ if (_cur.isFinish()) {
+ if (_cur.isAtEndOfLastPush()) {
+ release();
+ } else {
+ end();
+ _cur.next();
+ }
+ } else if (_cur.isElem()) {
+ int ret = element(_cur.getName());
+
+ if ((ret & HIT) != 0) {
+ c.addToSelection(_cur);
+ }
+
+ doAttrs(ret, c);
+
+ if ((ret & DESCEND) == 0 || !Locale.toFirstChildElement(_cur)) {
+ end();
+ _cur.skip();
+ }
+ } else {
+ do {
+ _cur.next();
+ }
+ while (!_cur.isContainerOrFinish());
+ }
+ }
+
+ private void doAttrs(int ret, Cur c) {
+ assert _cur.isContainer();
+
+ if ((ret & ATTRS) != 0) {
+ if (_cur.toFirstAttr()) {
+ do {
+ if (attr(_cur.getName())) {
+ c.addToSelection(_cur);
+ }
+ }
+ while (_cur.toNextAttr());
+
+ _cur.toParent();
+ }
+ }
+ }
+
+ public boolean next(Cur c) {
+ if (_cur != null && _version != _cur.getLocale().version()) {
+ throw new ConcurrentModificationException("Document changed during select");
+ }
+
+ int startCount = c.selectionCount();
+
+ while (_cur != null) {
+ advance(c);
+
+ if (startCount != c.selectionCount()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void release() {
+ if (_cur != null) {
+ _cur.release();
+ _cur = null;
+ }
+ }
+
+ private final long _version;
+ private Cur _cur;
+}
+
diff --git a/src/main/multimodule/java9/module-info.class b/src/main/multimodule/java9/module-info.class
index 058d152..55af511 100644
--- a/src/main/multimodule/java9/module-info.class
+++ b/src/main/multimodule/java9/module-info.class
Binary files differ
diff --git a/src/main/multimodule/java9/module-info.java b/src/main/multimodule/java9/module-info.java
index 321bf12..5861eb2 100644
--- a/src/main/multimodule/java9/module-info.java
+++ b/src/main/multimodule/java9/module-info.java
@@ -30,12 +30,11 @@
exports org.apache.xmlbeans.impl.repackage;
exports org.apache.xmlbeans.impl.common;
exports org.apache.xmlbeans.impl.config;
- // exports org.apache.xmlbeans.impl.xquery;
- exports org.apache.xmlbeans.impl.xquery.saxon;
exports org.apache.xmlbeans.impl.richParser;
exports org.apache.xmlbeans.impl.soap;
- // exports org.apache.xmlbeans.impl.xpath;
+ exports org.apache.xmlbeans.impl.xpath;
exports org.apache.xmlbeans.impl.xpath.saxon;
+ exports org.apache.xmlbeans.impl.xpath.xmlbeans;
exports org.apache.xmlbeans.impl.regex;
exports org.apache.xmlbeans.impl.tool;
exports org.apache.xmlbeans.impl.schema;