| Method from org.apache.xmlbeans.impl.store.Locale Detail: |
static void applyNamespaces(Cur c,
Map namespaces) {
assert c.isContainer();
java.util.Iterator i = namespaces.keySet().iterator();
while (i.hasNext())
{
String prefix = (String) i.next();
// Usually, this is the predefined xml namespace
if (!prefix.toLowerCase().startsWith("xml"))
{
if (c.namespaceForPrefix(prefix, false) == null)
{
c.push();
c.next();
c.createAttr(c._locale.createXmlns(prefix));
c.next();
c.insertString((String) namespaces.get(prefix));
c.pop();
}
}
}
}
|
static String applyWhiteSpaceRule(String s,
int wsr) {
int l = s == null ? 0 : s.length();
if (l == 0 || wsr == WS_PRESERVE)
return s;
char ch;
if (wsr == WS_REPLACE)
{
for (int i = 0; i < l; i++)
if ((ch = s.charAt(i)) == '\n" || ch == '\r" || ch == '\t")
return processWhiteSpaceRule(s, wsr);
}
else if (wsr == Locale.WS_COLLAPSE)
{
if (CharUtil.isWhiteSpace(s.charAt(0)) ||
CharUtil.isWhiteSpace(s.charAt(l - 1)))
return processWhiteSpaceRule(s, wsr);
boolean lastWasWhite = false;
for (int i = 1; i < l; i++)
{
boolean isWhite = CharUtil.isWhiteSpace(s.charAt(i));
if (isWhite && lastWasWhite)
return processWhiteSpaceRule(s, wsr);
lastWasWhite = isWhite;
}
}
return s;
}
|
static void associateSourceName(Cur c,
XmlOptions options) {
String sourceName = (String) XmlOptions.safeGet(options,
XmlOptions.DOCUMENT_SOURCE_NAME);
if (sourceName != null)
getDocProps(c, true).setSourceName(sourceName);
}
|
static void autoTypeDocument(Cur c,
SchemaType requestedType,
XmlOptions options) throws XmlException {
assert c.isRoot();
// The type in the options overrides all sniffing
options = XmlOptions.maskNull(options);
SchemaType optionType = (SchemaType) options.get(
XmlOptions.DOCUMENT_TYPE);
if (optionType != null)
{
c.setType(optionType);
return;
}
SchemaType type = null;
// An xsi:type can be used to pick a type out of the loader, or used to refine
// a type with a name.
if (requestedType == null || requestedType.getName() != null)
{
QName xsiTypeName = c.getXsiTypeName();
SchemaType xsiSchemaType =
xsiTypeName == null ?
null : c._locale._schemaTypeLoader.findType(xsiTypeName);
if (requestedType == null ||
requestedType.isAssignableFrom(xsiSchemaType))
type = xsiSchemaType;
}
// Look for a document element to establish type
if (type == null &&
(requestedType == null || requestedType.isDocumentType()))
{
assert c.isRoot();
c.push();
QName docElemName =
!c.hasAttrs() && Locale.toFirstChildElement(c) &&
!Locale.toNextSiblingElement(c)
? c.getName() : null;
c.pop();
if (docElemName != null)
{
type =
c._locale._schemaTypeLoader.findDocumentType(docElemName);
if (type != null && requestedType != null)
{
QName requesteddocElemNameName = requestedType.getDocumentElementName();
if (!requesteddocElemNameName.equals(docElemName) &&
!requestedType.isValidSubstitution(docElemName))
{
throw
new XmlException("Element " +
QNameHelper.pretty(docElemName) +
" is not a valid " +
QNameHelper.pretty(requesteddocElemNameName) +
" document or a valid substitution.");
}
}
}
}
if (type == null && requestedType == null)
{
c.push();
type =
Locale.toFirstNormalAttr(c) && !Locale.toNextNormalAttr(c)
?
c._locale._schemaTypeLoader.findAttributeType(c.getName()) :
null;
c.pop();
}
if (type == null)
type = requestedType;
if (type == null)
type = XmlBeans.NO_TYPE;
c.setType(type);
if (requestedType != null)
{
if (type.isDocumentType())
verifyDocumentType(c, type.getDocumentElementName());
else if (type.isAttributeType())
verifyAttributeType(c, type.getAttributeTypeAttributeName());
}
}
|
static boolean beginsWithXml(String name) {
if (name.length() < 3)
return false;
char ch;
if (((ch = name.charAt(0)) == 'x" || ch == 'X") &&
((ch = name.charAt(1)) == 'm" || ch == 'M") &&
((ch = name.charAt(2)) == 'l" || ch == 'L"))
{
return true;
}
return false;
}
|
int count(Xobj parent,
QName name,
QNameSet set) {
int n = 0;
for (Xobj x = findNthChildElem(parent, name, set, 0);
x != null; x = x._nextSibling)
{
if (x.isElem())
{
if (set == null)
{
if (x._name.equals(name))
n++;
}
else if (set.contains(x._name))
n++;
}
}
return n;
}
|
CdataNode createCdataNode() {
return _saaj == null ?
new CdataNode(this) : new SaajCdataNode(this);
}
|
public Document createDocument(String uri,
String qname,
DocumentType doctype) {
return DomImpl._domImplementation_createDocument(this, uri, qname,
doctype);
}
|
public DocumentType createDocumentType(String qname,
String publicId,
String systemId) {
throw new RuntimeException("Not implemented");
// return DomImpl._domImplementation_createDocumentType( this, qname, publicId, systemId );
}
|
public Element createSoapElement(QName name,
QName parentName) {
assert _ownerDoc != null;
return DomImpl.saajCallback_createSoapElement(_ownerDoc, name,
parentName);
}
|
TextNode createTextNode() {
return _saaj == null ? new TextNode(this) : new SaajTextNode(this);
}
|
QName createXmlns(String prefix) {
if (prefix == null)
prefix = "";
return
prefix.length() == 0
? makeQName(_xmlnsUri, "xmlns", "")
: makeQName(_xmlnsUri, prefix, "xmlns");
}
|
int domLength(Dom parent) {
if (parent == null)
return 0;
int da = _domNthCache_A.distance( parent, 0 );
int db = _domNthCache_B.distance( parent, 0 );
int len =
da < = db
? _domNthCache_A.length( parent )
: _domNthCache_B.length( parent );
if (da == db)
{
domNthCache temp = _domNthCache_A;
_domNthCache_A = _domNthCache_B;
_domNthCache_B = temp;
}
return len;
}
|
void embedCurs() {
for (Cur c; (c = _registered) != null;)
{
assert c._xobj != null;
_registered = c.listRemove(_registered);
c._xobj._embedded = c.listInsert(c._xobj._embedded);
c._state = Cur.EMBEDDED;
}
}
|
public void enter() {
assert _numTempFramesLeft >= 0;
if (--_numTempFramesLeft < = 0)
{
Cur[] newTempFrames = new Cur[(_numTempFramesLeft =
_tempFrames.length) *
2];
System.arraycopy(_tempFrames, 0, newTempFrames, 0,
_tempFrames.length);
_tempFrames = newTempFrames;
}
if (++_entryCount > 1000)
{
pollQueue();
_entryCount = 0;
}
}
|
public void enter(Locale otherLocale) {
enter();
if (otherLocale != this)
otherLocale.enter();
}
|
boolean entered() {
return _tempFrames.length - _numTempFramesLeft > 0;
}
|
public void exit() {
// assert _numTempFramesLeft >= 0;
//asserts computed frame fits between 0 and _tempFrames.length
assert _numTempFramesLeft >= 0 &&
(_numTempFramesLeft < = _tempFrames.length - 1):
" Temp frames mismanaged. Impossible stack frame. Unsynchronized: " +
noSync();
int frame = _tempFrames.length - ++_numTempFramesLeft;
while (_tempFrames[frame] != null)
_tempFrames[frame].release();
}
|
public void exit(Locale otherLocale) {
exit();
if (otherLocale != this)
otherLocale.exit();
}
|
Dom findDomNthChild(Dom parent,
int n) {
assert n >= 0;
if (parent == null)
return null;
int da = _domNthCache_A.distance(parent, n);
int db = _domNthCache_B.distance(parent, n);
// the "better" cache should never walk more than 1/2 len
Dom x = null;
boolean bInvalidate = (db - _domNthCache_B._len / 2 > 0) &&
(db - _domNthCache_B._len / 2 - domNthCache.BLITZ_BOUNDARY > 0);
boolean aInvalidate = (da - _domNthCache_A._len / 2 > 0) &&
(da - _domNthCache_A._len / 2 - domNthCache.BLITZ_BOUNDARY > 0);
if (da < = db)
if (!aInvalidate)
x = _domNthCache_A.fetch(parent, n);
else
{
_domNthCache_B._version = -1;//blitz the cache
x = _domNthCache_B.fetch(parent, n);
}
else if (!bInvalidate)
x = _domNthCache_B.fetch(parent, n);
else
{
_domNthCache_A._version = -1;//blitz the cache
x = _domNthCache_A.fetch(parent, n);
}
if (da == db)
{
domNthCache temp = _domNthCache_A;
_domNthCache_A = _domNthCache_B;
_domNthCache_B = temp;
}
return x;
}
|
Xobj findNthChildElem(Xobj parent,
QName name,
QNameSet set,
int n) {
// only one of (set or name) is not null
// or both are null for a wildcard
assert (name == null || set == null);
assert n >= 0;
if (parent == null)
return null;
int da = _nthCache_A.distance(parent, name, set, n);
int db = _nthCache_B.distance(parent, name, set, n);
Xobj x =
da < = db
? _nthCache_A.fetch(parent, name, set, n)
: _nthCache_B.fetch(parent, name, set, n);
if (da == db)
{
nthCache temp = _nthCache_A;
_nthCache_A = _nthCache_B;
_nthCache_B = temp;
}
return x;
}
|
static Map getAllNamespaces(Cur c,
Map filleMe) {
assert c.isNode();
c.push();
if (!c.isContainer())
c.toParent();
assert c.isContainer();
do
{
QName cName = c.getName();
while (c.toNextAttr())
{
if (c.isXmlns())
{
String prefix = c.getXmlnsPrefix();
String uri = c.getXmlnsUri();
// Here I check to see if there is a default namespace
// mapping which is not empty on a non root container which
// is in a namespace. This this case, I do not want to add
// this mapping because it could not be persisted out this
// way.
if (prefix.length() == 0 && uri.length() > 0 &&
cName != null &&
cName.getNamespaceURI().length() > 0)
{
continue;
}
if (filleMe == null)
filleMe = new HashMap();
if (!filleMe.containsKey(prefix))
filleMe.put(prefix, uri);
}
}
if (!c.isContainer())
c.toParentRaw();
}
while (c.toParentRaw());
c.pop();
return filleMe;
}
|
CharUtil getCharUtil() {
//
//
//
if (_charUtil == null)
_charUtil = new CharUtil(1024);
return _charUtil;
}
|
Cur getCur() {
assert _curPool == null || _curPoolCount > 0;
Cur c;
if (_curPool == null)
c = new Cur(this);
else
{
_curPool = _curPool.listRemove(c = _curPool);
_curPoolCount--;
}
assert c._state == Cur.POOLED;
assert c._prev == null && c._next == null;
assert c._xobj == null && c._pos == Cur.NO_POS;
assert c._ref == null;
_registered = c.listInsert(_registered);
c._state = Cur.REGISTERED;
return c;
}
|
static XmlDocumentProperties getDocProps(Cur c,
boolean ensure) {
c.push();
while (c.toParent())
;
DocProps props = (DocProps) c.getBookmark(DocProps.class);
if (props == null && ensure)
c.setBookmark(DocProps.class, props = new DocProps());
c.pop();
return props;
}
|
public Object getFeature(String feature,
String version) {
throw new RuntimeException("DOM Level 3 Not implemented");
}
|
static Locale getLocale(SchemaTypeLoader stl,
XmlOptions options) {
if (stl == null)
stl = XmlBeans.getContextTypeLoader();
options = XmlOptions.maskNull(options);
Locale l = null;
if (options.hasOption(USE_SAME_LOCALE))
{
Object source = options.get(USE_SAME_LOCALE);
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._saaj != null && l._saaj != options.get(Saaj.SAAJ_IMPL))
throw new IllegalArgumentException(
"Source locale does not support same saaj");
if (l._validateOnSet &&
!options.hasOption(XmlOptions.VALIDATE_ON_SET))
throw new IllegalArgumentException(
"Source locale does not support same validate on set");
// TODO - other things to check?
}
else
l = new Locale(stl, options);
return l;
}
|
public Object getSaajData(Node n) {
assert n instanceof Dom;
return DomImpl.saajCallback_getSaajData((Dom) n);
}
|
static Locale.ScrubBuffer getScrubBuffer(int wsr) {
SoftReference softRef = (SoftReference) tl_scrubBuffer.get();
ScrubBuffer scrubBuffer = (ScrubBuffer) (softRef).get();
if (scrubBuffer == null)
{
scrubBuffer = new ScrubBuffer();
tl_scrubBuffer.set(new SoftReference(scrubBuffer));
}
scrubBuffer.init(wsr);
return scrubBuffer;
}
|
static String getTextValue(Cur c) {
assert c.isNode();
if (!c.hasChildren())
return c.getValueAsString();
StringBuffer sb = new StringBuffer();
c.push();
for (c.next(); !c.isAtEndOfLastPush(); c.next())
if (c.isText())
{
if ( (c._xobj.isComment() || c._xobj.isProcinst() ) && c._pos< c._xobj._cchValue )
continue;
CharUtil.getString(sb, c.getChars(-1), c._offSrc, c._cchSrc);
}
c.pop();
return sb.toString();
}
|
static int getTextValue(Cur c,
int wsr,
char[] chars,
int off,
int maxCch) {
// TODO - hack impl for now ... improve
assert c.isNode();
String s = c._xobj.getValueAsString(wsr);
int n = s.length();
if (n > maxCch)
n = maxCch;
if (n < = 0)
return 0;
s.getChars(0, n, chars, off);
return n;
}
|
public boolean hasFeature(String feature,
String version) {
return DomImpl._domImplementation_hasFeature(this, feature, version);
}
|
public Element importSoapElement(Document doc,
Element elem,
boolean deep,
QName parentName) {
assert doc instanceof Dom;
return DomImpl.saajCallback_importSoapElement((Dom) doc, elem, deep,
parentName);
}
|
void invalidateDomCaches(Dom d) {
if (_domNthCache_A._parent == d)
_domNthCache_A._version = -1;
if (_domNthCache_B._parent == d)
_domNthCache_B._version = -1;
}
|
boolean isDomCached(Dom d) {
return _domNthCache_A._parent == d || _domNthCache_B._parent == d;
}
|
static boolean isFragment(Cur start,
Cur end) {
assert !end.isAttr();
start.push();
end.push();
int numDocElems = 0;
boolean isFrag = false;
while (!start.isSamePos(end))
{
int k = start.kind();
if (k == ATTR)
break;
if (k == TEXT && !isWhiteSpace(start.getCharsAsString(-1)))
{
isFrag = true;
break;
}
if (k == ELEM && ++numDocElems > 1)
{
isFrag = true;
break;
}
// Move to next token
assert k != ATTR;
if (k != TEXT)
start.toEnd();
start.next();
}
start.pop();
end.pop();
return isFrag || numDocElems != 1;
}
|
static boolean isFragmentQName(QName name) {
return name.equals(Locale._openuriFragment) ||
name.equals(Locale._xmlFragment);
}
|
static final boolean isWhiteSpace(String s) {
int l = s.length();
while (l-- > 0)
if (!CharUtil.isWhiteSpace(s.charAt(l)))
return false;
return true;
}
|
static final boolean isWhiteSpace(StringBuffer sb) {
int l = sb.length();
while (l-- > 0)
if (!CharUtil.isWhiteSpace(sb.charAt(l)))
return false;
return true;
}
|
static boolean isXmlns(QName name) {
String prefix = name.getPrefix();
if (prefix.equals("xmlns"))
return true;
return prefix.length() == 0 && name.getLocalPart().equals("xmlns");
}
|
public Dom load(Reader r) throws XmlException, IOException {
return load(r, null);
}
|
public Dom load(InputStream in) throws XmlException, IOException {
return load(in, null);
}
|
public Dom load(String s) throws XmlException {
return load(s, null);
}
|
public Dom load(Reader r,
XmlOptions options) throws XmlException, IOException {
return load(new InputSource(r), options);
}
|
public Dom load(InputStream in,
XmlOptions options) throws XmlException, IOException {
return load(new InputSource(in), options);
}
|
public Dom load(String s,
XmlOptions options) throws XmlException {
Reader r = new StringReader(s);
try
{
return load(r, options);
}
catch (IOException e)
{
assert false: "StringReader should not throw IOException";
throw new XmlException(e.getMessage(), e);
}
finally
{
try
{
r.close();
}
catch (IOException e)
{
}
}
}
|
void loadNode(Node n,
Locale.LoadContext context) {
switch (n.getNodeType())
{
case Node.DOCUMENT_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.ENTITY_REFERENCE_NODE:
{
loadNodeChildren(n, context);
break;
}
case Node.ELEMENT_NODE:
{
context.startElement(
makeQualifiedQName(n.getNamespaceURI(), n.getNodeName()));
NamedNodeMap attrs = n.getAttributes();
for (int i = 0; i < attrs.getLength(); i++)
{
Node a = attrs.item(i);
String attrName = a.getNodeName();
String attrValue = a.getNodeValue();
if (attrName.toLowerCase().startsWith("xmlns"))
{
if (attrName.length() == 5)
context.xmlns(null, attrValue);
else
context.xmlns(attrName.substring(6), attrValue);
}
else
context.attr(
makeQualifiedQName(a.getNamespaceURI(), attrName),
attrValue);
}
loadNodeChildren(n, context);
context.endElement();
break;
}
case Node.TEXT_NODE:
case Node.CDATA_SECTION_NODE:
{
context.text(n.getNodeValue());
break;
}
case Node.COMMENT_NODE:
{
context.comment(n.getNodeValue());
break;
}
case Node.PROCESSING_INSTRUCTION_NODE:
{
context.procInst(n.getNodeName(), n.getNodeValue());
break;
}
case Node.DOCUMENT_TYPE_NODE:
case Node.ENTITY_NODE:
case Node.NOTATION_NODE:
case Node.ATTRIBUTE_NODE:
{
throw new RuntimeException("Unexpected node");
}
}
}
|
QName makeQName(String uri,
String localPart) {
assert localPart != null && localPart.length() > 0;
// TODO - make sure name is a well formed name?
return _qnameFactory.getQName(uri, localPart);
}
|
QName makeQName(String uri,
String local,
String prefix) {
return _qnameFactory.getQName(uri, local, prefix == null ? "" : prefix);
}
|
QName makeQNameNoCheck(String uri,
String localPart) {
return _qnameFactory.getQName(uri, localPart);
}
|
QName makeQualifiedQName(String uri,
String qname) {
if (qname == null)
qname = "";
int i = qname.indexOf(':");
return i < 0
?
_qnameFactory.getQName(uri, qname)
:
_qnameFactory.getQName(uri, qname.substring(i + 1),
qname.substring(0, i));
}
|
public static DOMImplementation newDomImplementation(SchemaTypeLoader stl,
XmlOptions options) {
return (DOMImplementation) getLocale(stl, options);
}
|
public static XmlObject newInstance(SchemaTypeLoader stl,
SchemaType type,
XmlOptions options) {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.newInstance(type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.newInstance(type, options);
}
finally
{
l.exit();
}
}
}
|
public XmlSaxHandler newSaxHandler(SchemaType type,
XmlOptions options) {
return new XmlSaxHandlerImpl(this, type, options);
}
|
public static XmlSaxHandler newSaxHandler(SchemaTypeLoader stl,
SchemaType type,
XmlOptions options) {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.newSaxHandler(type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.newSaxHandler(type, options);
}
finally
{
l.exit();
}
}
}
|
public boolean noSync() {
return _noSync;
}
|
public static XmlCursor nodeToCursor(Node n) {
return DomImpl._getXmlCursor(checkNode(n));
}
|
public static XmlObject nodeToXmlObject(Node n) {
return DomImpl._getXmlObject(checkNode(n));
}
|
public static XMLStreamReader nodeToXmlStream(Node n) {
return DomImpl._getXmlStreamReader(checkNode(n));
}
|
void notifyChange() {
// First, notify the registered listeners ...
while (_changeListeners != null)
{
_changeListeners.notifyChange();
if (_changeListeners.getNextChangeListener() == _changeListeners)
_changeListeners.setNextChangeListener(null);
ChangeListener next = _changeListeners.getNextChangeListener();
_changeListeners.setNextChangeListener(null);
_changeListeners = next;
}
// Then, prepare for the change in a locale specific way. Need to create real Curs for
// 'virtual' Curs in Locations
_locations.notifyChange();
}
|
Cur parse(String s,
SchemaType type,
XmlOptions options) throws XmlException {
Reader r = new StringReader(s);
try
{
Cur c = getSaxLoader(options).load(this, new InputSource(r),
options);
autoTypeDocument(c, type, options);
return c;
}
catch (IOException e)
{
assert false: "StringReader should not throw IOException";
throw new XmlException(e.getMessage(), e);
}
finally
{
try
{
r.close();
}
catch (IOException e)
{
}
}
}
|
public XmlObject parseToXmlObject(XMLInputStream xis,
SchemaType type,
XmlOptions options) throws XmlException, XMLStreamException {
Cur c;
try
{
c = loadXMLInputStream(xis, options);
}
catch (org.apache.xmlbeans.xml.stream.XMLStreamException e)
{
throw new XmlException(e.getMessage(), e);
}
autoTypeDocument(c, type, options);
XmlObject x = (XmlObject) c.getUser();
c.release();
return x;
} Deprecated! XMLInputStream - was deprecated by XMLStreamReader from STaX - jsr173 API.
|
public XmlObject parseToXmlObject(XMLStreamReader xsr,
SchemaType type,
XmlOptions options) throws XmlException {
Cur c;
try
{
c = loadXMLStreamReader(xsr, options);
}
catch (XMLStreamException e)
{
throw new XmlException(e.getMessage(), e);
}
autoTypeDocument(c, type, options);
XmlObject x = (XmlObject) c.getUser();
c.release();
return x;
}
|
public XmlObject parseToXmlObject(Node node,
SchemaType type,
XmlOptions options) throws XmlException {
LoadContext context = new Cur.CurLoadContext(this, options);
loadNode(node, context);
Cur c = context.finish();
associateSourceName(c, options);
autoTypeDocument(c, type, options);
XmlObject x = (XmlObject) c.getUser();
c.release();
return x;
}
|
public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
String xmlText,
SchemaType type,
XmlOptions options) throws XmlException {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.parseToXmlObject(xmlText, type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.parseToXmlObject(xmlText, type, options);
}
finally
{
l.exit();
}
}
}
|
public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
XMLInputStream xis,
SchemaType type,
XmlOptions options) throws XmlException, XMLStreamException {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.parseToXmlObject(xis, type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.parseToXmlObject(xis, type, options);
}
finally
{
l.exit();
}
}
} Deprecated! XMLInputStream - was deprecated by XMLStreamReader from STaX - jsr173 API.
|
public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
XMLStreamReader xsr,
SchemaType type,
XmlOptions options) throws XmlException {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.parseToXmlObject(xsr, type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.parseToXmlObject(xsr, type, options);
}
finally
{
l.exit();
}
}
}
|
public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
InputStream is,
SchemaType type,
XmlOptions options) throws XmlException, IOException {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.parseToXmlObject(is, type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.parseToXmlObject(is, type, options);
}
finally
{
l.exit();
}
}
}
|
public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
Reader reader,
SchemaType type,
XmlOptions options) throws XmlException, IOException {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.parseToXmlObject(reader, type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.parseToXmlObject(reader, type, options);
}
finally
{
l.exit();
}
}
}
|
public static XmlObject parseToXmlObject(SchemaTypeLoader stl,
Node node,
SchemaType type,
XmlOptions options) throws XmlException {
Locale l = getLocale(stl, options);
if (l.noSync())
{
l.enter();
try
{
return l.parseToXmlObject(node, type, options);
}
finally
{
l.exit();
}
}
else
synchronized (l)
{
l.enter();
try
{
return l.parseToXmlObject(node, type, options);
}
finally
{
l.exit();
}
}
}
|
static String processWhiteSpaceRule(String s,
int wsr) {
ScrubBuffer sb = getScrubBuffer(wsr);
sb.scrub(s, 0, s.length());
return sb.getResultAsString();
}
|
static boolean pushToContainer(Cur c) {
c.push();
for (; ;)
{
switch (c.kind())
{
case ROOT:
case ELEM:
return true;
case -ROOT:
case -ELEM:
c.pop();
return false;
case COMMENT:
case PROCINST:
c.skip();
break;
default :
c.nextWithAttrs();
break;
}
}
}
|
final ReferenceQueue refQueue() {
if (_refQueue == null)
_refQueue = new ReferenceQueue();
return _refQueue;
}
|
void registerForChange(Locale.ChangeListener listener) {
if (listener.getNextChangeListener() == null)
{
if (_changeListeners == null)
listener.setNextChangeListener(listener);
else
listener.setNextChangeListener(_changeListeners);
_changeListeners = listener;
}
}
|
public void setSaajData(Node n,
Object o) {
assert n instanceof Dom;
DomImpl.saajCallback_setSaajData((Dom) n, o);
}
|
public static Node streamToNode(XMLStreamReader xs) {
return Jsr173.nodeFromStream(xs);
}
|
public boolean sync() {
return !_noSync;
}
|
Cur tempCur() {
return tempCur(null);
}
|
Cur tempCur(String id) {
Cur c = getCur();
assert c._tempFrame == -1;
assert _numTempFramesLeft < _tempFrames.length : "Temp frame not pushed";
int frame = _tempFrames.length - _numTempFramesLeft - 1;
assert frame >= 0 && frame < _tempFrames.length;
Cur next = _tempFrames[frame];
c._nextTemp = next;
assert c._prevTemp == null;
if (next != null)
{
assert next._prevTemp == null;
next._prevTemp = c;
}
_tempFrames[frame] = c;
c._tempFrame = frame;
c._id = id;
return c;
}
|
static boolean toChild(Cur c,
QName name,
int n) {
if (n >= 0 && pushToContainer(c))
{
Xobj x = c._locale.findNthChildElem(c._xobj, name, null, n);
c.pop();
if (x != null)
{
c.moveTo(x);
return true;
}
}
return false;
}
|
static boolean toFirstChildElement(Cur c) {
// if (!pushToContainer(c))
// return false;
//
// if (!c.toFirstChild() || (!c.isElem() && !toNextSiblingElement(c)))
// {
// c.pop();
// return false;
// }
//
// c.popButStay();
//
// return true;
Xobj originalXobj = c._xobj;
int originalPos = c._pos;
loop:
for (; ;)
{
switch (c.kind())
{
case ROOT:
case ELEM:
break loop;
case -ROOT:
case -ELEM:
c.moveTo(originalXobj, originalPos);
return false;
case COMMENT:
case PROCINST:
c.skip();
break;
default:
c.nextWithAttrs();
break;
}
}
if (!c.toFirstChild() || (!c.isElem() && !toNextSiblingElement(c)))
{
c.moveTo(originalXobj, originalPos);
return false;
}
return true;
}
|
static boolean toFirstNormalAttr(Cur c) {
c.push();
if (c.toFirstAttr())
{
do
{
if (!c.isXmlns())
{
c.popButStay();
return true;
}
}
while (c.toNextAttr());
}
c.pop();
return false;
}
|
static boolean toLastChildElement(Cur c) {
if (!pushToContainer(c))
return false;
if (!c.toLastChild() || (!c.isElem() && !toPrevSiblingElement(c)))
{
c.pop();
return false;
}
c.popButStay();
return true;
}
|
static boolean toNextNormalAttr(Cur c) {
c.push();
while (c.toNextAttr())
{
if (!c.isXmlns())
{
c.popButStay();
return true;
}
}
c.pop();
return false;
}
|
static boolean toNextSiblingElement(Cur c) {
if (!c.hasParent())
return false;
c.push();
int k = c.kind();
if (k == ATTR)
{
c.toParent();
c.next();
}
else if (k == ELEM)
c.skip();
while ((k = c.kind()) >= 0)
{
if (k == ELEM)
{
c.popButStay();
return true;
}
if (k > 0)
c.toEnd();
c.next();
}
c.pop();
return false;
}
|
static boolean toNextSiblingElement(Cur c,
Xobj parent) {
Xobj originalXobj = c._xobj;
int originalPos = c._pos;
int k = c.kind();
if (k == ATTR)
{
c.moveTo(parent);
c.next();
}
else if (k == ELEM)
c.skip();
while ((k = c.kind()) >= 0)
{
if (k == ELEM)
{
return true;
}
if (k > 0)
c.toEnd();
c.next();
}
c.moveTo(originalXobj, originalPos);
return false;
}
|
static boolean toPrevNormalAttr(Cur c) {
if (c.isAttr())
{
c.push();
for (; ;)
{
assert c.isAttr();
// See if I can move backward. If I'm at the first attr, prev must return
// false and not move.
if (!c.prev())
break;
// Skip past the text value or attr begin
c.prev();
// I might have skipped over text above
if (!c.isAttr())
c.prev();
if (c.isNormalAttr())
{
c.popButStay();
return true;
}
}
c.pop();
}
return false;
}
|
static boolean toPrevSiblingElement(Cur cur) {
if (!cur.hasParent())
return false;
Cur c = cur.tempCur();
boolean moved = false;
int k = c.kind();
if (k != ATTR)
{
for (; ;)
{
if (!c.prev())
break;
k = c.kind();
if (k == ROOT || k == ELEM)
break;
if (c.kind() == -ELEM)
{
c.toParent();
cur.moveToCur(c);
moved = true;
break;
}
}
}
c.release();
return moved;
}
|
long version() {
return _versionAll;
}
|
Cur weakCur(Object o) {
assert o != null && !(o instanceof Ref);
Cur c = getCur();
assert c._tempFrame == -1;
assert c._ref == null;
c._ref = new Ref(c, o);
return c;
}
|
static String xmlnsPrefix(QName name) {
return name.getPrefix().equals("xmlns") ? name.getLocalPart() : "";
}
|