| Method from org.apache.xmlbeans.impl.values.XmlObjectBase Detail: |
public final XmlObject _copy() {
return _copy(null);
}
Same as copy() but unsynchronized.
Warning: Using this method in mutithreaded environment can cause invalid states. |
public final XmlObject _copy(XmlOptions xmlOptions) {
// immutable objects don't get copied. They're immutable
if (isImmutable())
return this;
check_orphaned();
SchemaTypeLoader stl = get_store().get_schematypeloader();
XmlObject result = (XmlObject)get_store().copy(stl, schemaType(), xmlOptions);
return result;
}
Same as copy() but unsynchronized.
If Locale.COPY_USE_NEW_LOCALE is set in the options, a new locale will be created for the copy.
Warning: Using this method in mutithreaded environment can cause invalid states. |
protected boolean _isComplexContent() {
return (_flags & FLAG_COMPLEXCONTENT) != 0;
}
|
protected boolean _isComplexType() {
return (_flags & FLAG_COMPLEXTYPE) != 0;
}
|
public final XmlObject _set(XmlObject src) {
if (isImmutable())
throw new IllegalStateException("Cannot set the value of an immutable XmlObject");
XmlObjectBase obj = underlying(src);
TypeStoreUser newObj = this;
if (obj == null)
{
setNil();
return this;
}
if (obj.isImmutable())
set(obj.stringValue());
else
newObj = setterHelper( obj );
return (XmlObject) newObj;
}
Same as set() but unsynchronized.
Warning: Using this method in mutithreaded environment can cause invalid states. |
protected boolean _validateOnSet() {
return (_flags & FLAG_VALIDATE_ON_SET) != 0;
}
|
public final void attach_store(TypeStore store) {
_textsource = store;
if ((_flags & FLAG_IMMUTABLE) != 0)
throw new IllegalStateException();
_flags |= FLAG_STORE | FLAG_VALUE_DATED | FLAG_NIL_DATED | FLAG_ELEMENT_DATED;
if (store.is_attribute())
_flags |= FLAG_ATTRIBUTE;
if (store.validate_on_set())
_flags |= FLAG_VALIDATE_ON_SET;
}
Called to initialize the TypeStore associated with this XmlObject
implementation. If not called, this is a free-floating value holder.
When a value is first attached, it is put in a completely invalidated
state. |
public BigDecimal bigDecimalValue() {
return getBigDecimalValue();
} Deprecated! replaced - with #getBigDecimalValue
|
public BigInteger bigIntegerValue() {
return getBigIntegerValue();
} Deprecated! replaced - with #getBigIntegerValue
|
public boolean booleanValue() {
return getBooleanValue();
} Deprecated! replaced - with #getBooleanValue
|
static final XmlOptions buildInnerPrettyOptions() {
XmlOptions options = new XmlOptions();
options.put( XmlOptions.SAVE_INNER );
options.put( XmlOptions.SAVE_PRETTY_PRINT );
options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
options.put( XmlOptions.SAVE_USE_DEFAULT_NAMESPACE );
return options;
}
|
public boolean build_nil() {
assert((_flags & FLAG_STORE) != 0);
assert((_flags & FLAG_VALUE_DATED) == 0);
return (_flags & FLAG_NIL) != 0;
}
A store will call back on build_nil after we've called invalidate_nil
and it needs to know what the nil value is. |
public final String build_text(NamespaceManager nsm) {
assert((_flags & FLAG_STORE) != 0);
assert((_flags & FLAG_VALUE_DATED) == 0);
if ((_flags & (FLAG_NIL | FLAG_ISDEFAULT)) != 0)
return "";
return compute_text(
nsm == null ? has_store() ? get_store() : null : nsm);
}
Called by a TypeStore to pull out the most reasonable
text value from us. This is done after we have invalidated
the store (typically when our value has been set). |
public byte[] byteArrayValue() {
return getByteArrayValue();
} Deprecated! replaced - with #getByteArrayValue
|
public byte byteValue() {
return getByteValue();
} Deprecated! replaced - with #getByteValue
|
public Calendar calendarValue() {
return getCalendarValue();
} Deprecated! replaced - with #getCalendarValue
|
public XmlObject changeType(SchemaType type) {
if (type == null)
throw new IllegalArgumentException( "Invalid type (null)" );
if ((_flags & FLAG_STORE) == 0)
{
throw
new IllegalStateException(
"XML Value Objects cannot have thier type changed" );
}
synchronized (monitor())
{
check_orphaned();
return (XmlObject) get_store().change_type( type );
}
}
|
public final void check_dated() {
if ((_flags & FLAGS_DATED) != 0)
{
if ((_flags & FLAG_ORPHANED) != 0)
throw new XmlValueDisconnectedException();
assert((_flags & FLAG_STORE) != 0);
check_element_dated();
if ((_flags & FLAG_ELEMENT_DATED) != 0)
{
int eltflags = get_store().compute_flags();
_flags &= ~(FLAGS_ELEMENT | FLAG_ELEMENT_DATED);
_flags |= eltflags;
}
boolean nilled = false;
if ((_flags & FLAG_NIL_DATED) != 0)
{
if (get_store().find_nil())
{
if ((_flags & FLAG_NILLABLE) == 0 &&
(_flags & FLAG_VALIDATE_ON_SET) != 0)
throw new XmlValueOutOfRangeException(); // nil not allowed
// let the implementation know that we're nil now
set_nil();
_flags |= FLAG_NIL;
nilled = true;
}
else
{
_flags &= ~FLAG_NIL;
}
_flags &= ~FLAG_NIL_DATED;
}
if (!nilled)
{
String text;
if ((_flags & FLAG_COMPLEXCONTENT) != 0 || (text = get_wscanon_text()) == null)
update_from_complex_content();
else
{
NamespaceContext.push(new NamespaceContext(get_store()));
try { update_from_wscanon_text(text); }
finally { NamespaceContext.pop(); }
}
}
_flags &= ~FLAG_VALUE_DATED;
}
}
Called prior to every get operation, to ensure
that the value being read is valid. If the value
has been invalidated, it is re-read from the underlying
text store, and this may cause an out of range exception.
This method deals with nils, nillability, defaults, etc. |
protected final void check_orphaned() {
if (is_orphaned())
throw new XmlValueDisconnectedException();
}
Called before every getter and setter on the strongly
typed classes to ensure that the object has not been
orphaned. |
public final int compareTo(Object obj) {
int result = compareValue((XmlObject)obj); // can throw ClassCast
if (result == 2)
throw new ClassCastException();
return result;
}
Implements Comparable. This compareTo is inconsistent with
equals unless isImmutable() is true. |
public final int compareValue(XmlObject xmlobj) {
if (xmlobj == null)
return 2;
boolean acquired = false;
try
{
if (isImmutable())
{
if (xmlobj.isImmutable())
{
return compareValueImpl(xmlobj);
}
else
{
synchronized (xmlobj.monitor())
{
return compareValueImpl(xmlobj);
}
}
}
else
{
if (xmlobj.isImmutable() || monitor() == xmlobj.monitor())
{
synchronized (monitor())
{
return compareValueImpl(xmlobj);
}
}
else
{
GlobalLock.acquire();
acquired = true;
synchronized (monitor())
{
synchronized (xmlobj.monitor())
{
GlobalLock.release();
acquired = false;
return compareValueImpl(xmlobj);
}
}
}
}
}
catch (InterruptedException e)
{
throw new XmlRuntimeException(e);
}
finally
{
if (acquired)
GlobalLock.release();
}
}
|
protected int compare_to(XmlObject xmlobj) {
if (equal_to(xmlobj))
return 0;
return 2;
}
This implementation of compare_to is allowed to do two
unusual things:
(1) it can assume that the xmlobj passed has a primitive
type underlying the instance type that matches the
current instance, and that neither is nil.
(2) it is allowed to return 2 for "incomparable";
it should not throw an exception. |
abstract protected String compute_text(NamespaceManager nsm)
This should return the canonical string value of the primitive.
Only called when non-nil. |
public final XmlObject copy() {
if (preCheck())
return _copy();
else
synchronized (monitor())
{
return _copy();
}
}
|
public TypeStoreUser create_attribute_user(QName attrName) {
return (TypeStoreUser)((SchemaTypeImpl)schemaType()).createAttributeType(attrName, get_store().get_schematypeloader());
}
A typestore user can create a new TypeStoreUser instance for
a given attribute child, based on the attribute name.
Returns null if there is no strongly typed information for that
given attributes. |
public TypeStoreUser create_element_user(QName eltName,
QName xsiType) {
return
(TypeStoreUser)
((SchemaTypeImpl) schemaType()).createElementType(
eltName, xsiType, get_store().get_schematypeloader() );
/*
SchemaTypeImpl stype = (SchemaTypeImpl)schemaType().getElementType(eltName, xsiType, get_store().get_schematypeloader());
if (stype == null)
return null;
return (TypeStoreUser)stype.createUnattachedNode();
*/
}
A typestore user can create a new TypeStoreUser instance for
a given element child name as long as you also pass the
qname contained by the xsi:type attribute, if any.
Note that we will ignore the xsiType if it turns out to be invalid.
Returns null if there is no strongly typed information for that
given element (which implies, recusively, no strongly typed information
downwards). |
public Date dateValue() {
return getDateValue();
} Deprecated! replaced - with #getDateValue
|
public void disconnect_store() {
assert((_flags & FLAG_STORE) != 0);
_flags |= FLAGS_DATED | FLAG_ORPHANED;
// do NOT null out _textsource, because we need it non-null for synchronization
}
A store calls back here in order to force a disconnect.
After this is done, the object should be considered invalid.
Any attempt to access or set a value should result in an
exception.
Note that this is how we handle deletions and xsi:type changes. |
public XmlDocumentProperties documentProperties() {
XmlCursor cur = newCursorForce(); try { return cur.documentProperties(); } finally { cur.dispose(); }
}
|
public double doubleValue() {
return getDoubleValue();
} Deprecated! replaced - with #getDoubleValue
|
public void dump() {
XmlCursor cur = newCursorForce(); try { cur.dump(); } finally { cur.dispose(); }
}
|
protected int elementFlags() {
check_element_dated();
return (_flags & FLAGS_ELEMENT);
}
Used for situations where these flags must be passed on to
chained values. (See XmlAnySimpleType (allSimpleValue), union
implementations). |
public StringEnumAbstractBase enumValue() {
return getEnumValue();
} Deprecated! replaced - with #getEnumValue
|
abstract protected boolean equal_to(XmlObject xmlobj)
|
public final boolean equals(Object obj) {
if (!isImmutable())
return super.equals(obj);
if (!(obj instanceof XmlObject))
return false;
XmlObject xmlobj = (XmlObject)obj;
if (!xmlobj.isImmutable())
return false;
return valueEquals(xmlobj);
}
|
public XmlObject[] execQuery(String path) {
return execQuery( path, null );
}
|
public XmlObject[] execQuery(String queryExpr,
XmlOptions options) {
synchronized (monitor())
{
TypeStore typeStore = get_store();
if (typeStore == null)
{
throw
new XmlRuntimeException(
"Cannot do XQuery on XML Value Objects" );
}
try
{
return _typedArray(typeStore.exec_query( queryExpr, options ));
}
catch (XmlException e)
{
throw new XmlRuntimeException( e );
}
}
}
|
public float floatValue() {
return getFloatValue();
} Deprecated! replaced - with #getFloatValue
|
public GDate gDateValue() {
return getGDateValue();
} Deprecated! replaced - with #getGDateValue
|
public GDuration gDurationValue() {
return getGDurationValue();
} Deprecated! replaced - with #getGDurationValue
|
public BigDecimal getBigDecimalValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "numeric"});
}
|
public BigInteger getBigIntegerValue() {
BigDecimal bd = bigDecimalValue(); return bd == null ? null : bd.toBigInteger();
}
|
public boolean getBooleanValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "boolean"});
}
|
public byte[] getByteArrayValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "byte[]"});
}
|
public byte getByteValue() {
long l = getIntValue();
if (l > Byte.MAX_VALUE) throw new XmlValueOutOfRangeException();
if (l < Byte.MIN_VALUE) throw new XmlValueOutOfRangeException();
return (byte)l;
}
|
public Calendar getCalendarValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "Calendar"});
}
|
public Date getDateValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "Date"});
}
|
public Node getDomNode() {
XmlCursor cur = newCursorForce(); try { return cur.getDomNode(); } finally { cur.dispose(); }
}
|
public double getDoubleValue() {
BigDecimal bd = getBigDecimalValue(); return bd == null ? 0.0 : bd.doubleValue();
}
|
public StringEnumAbstractBase getEnumValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "enum"});
}
|
public float getFloatValue() {
BigDecimal bd = getBigDecimalValue(); return bd == null ? 0.0f : bd.floatValue();
}
|
public GDate getGDateValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "Date"});
}
|
public GDuration getGDurationValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "Duration"});
}
|
public int getIntValue() {
long l = getLongValue();
if (l > Integer.MAX_VALUE) throw new XmlValueOutOfRangeException();
if (l < Integer.MIN_VALUE) throw new XmlValueOutOfRangeException();
return (int)l;
}
|
public List getListValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "List"});
}
|
public long getLongValue() {
BigInteger b = getBigIntegerValue();
if (b == null) return 0L;
if (b.compareTo(_max) >= 0) throw new XmlValueOutOfRangeException();
if (b.compareTo(_min) < = 0) throw new XmlValueOutOfRangeException();
return b.longValue();
}
|
public Object getObjectValue() {
return java_value(this);
}
|
public QName getQNameValue() {
throw new XmlValueNotSupportedException(XmlErrorCodes.EXCEPTION_VALUE_NOT_SUPPORTED_S2J,
new Object[] {getPrimitiveTypeName(), "QName"});
}
|
public short getShortValue() {
long l = getIntValue();
if (l > Short.MAX_VALUE) throw new XmlValueOutOfRangeException();
if (l < Short.MIN_VALUE) throw new XmlValueOutOfRangeException();
return (short)l;
}
|
public String getStringValue() {
if (isImmutable())
{
if ((_flags & FLAG_NIL) != 0)
return null;
return compute_text(null);
}
// Since complex-content types don't have a "natural" string value, we
// emit the deeply concatenated, tag-removed content of the tag.
synchronized (monitor())
{
if (_isComplexContent())
return get_store().fetch_text(TypeStore.WS_PRESERVE);
check_dated();
if ((_flags & FLAG_NIL) != 0)
return null;
return compute_text(has_store() ? get_store() : null);
}
}
|
public final XmlLocale getXmlLocale() {
return get_store().get_locale();
}
|
public SchemaField get_attribute_field(QName attrName) {
SchemaAttributeModel model = schemaType().getAttributeModel();
if (model == null)
return null;
return model.getAttribute(attrName);
}
|
public SchemaType get_attribute_type(QName attrName) {
return schemaType().getAttributeType(
attrName, get_store().get_schematypeloader() );
}
|
public int get_attributeflags(QName attrName) {
if (!_isComplexType())
return 0;
SchemaProperty prop = schemaType().getAttributeProperty(attrName);
if (prop == null)
return 0;
return
(prop.hasDefault() == SchemaProperty.NEVER ? 0 : TypeStore.HASDEFAULT) |
(prop.hasFixed() == SchemaProperty.NEVER ? 0 : TypeStore.FIXED);
// BUGBUG: todo: hook up required?
}
Returns the flags for the given attribute. |
public String get_default_attribute_text(QName attrName) {
assert(_isComplexType());
if (!_isComplexType())
throw new IllegalStateException();
SchemaProperty prop = schemaType().getAttributeProperty(attrName);
if (prop == null)
return "";
return prop.getDefaultText();
}
Returns the default attribute text for the attribute with
the given name, or null if no default. |
protected XmlAnySimpleType get_default_attribute_value(QName name) {
SchemaType sType = schemaType();
SchemaAttributeModel aModel = sType.getAttributeModel();
if (aModel == null)
return null;
SchemaLocalAttribute sAttr = aModel.getAttribute(name);
if (sAttr == null)
return null;
return sAttr.getDefaultValue();
}
Called by code generated code to get the default attribute value
for a given attribute name, or null if none. |
public String get_default_element_text(QName eltName) {
assert(_isComplexContent());
if (!_isComplexContent())
throw new IllegalStateException();
SchemaProperty prop = schemaType().getElementProperty(eltName);
if (prop == null)
return "";
return prop.getDefaultText();
}
Returns the default element text, if it's consistent. If it's
not consistent, returns null, and requires a visitor walk.
Also returns null if there is no default at all (although
that can also be discovered via get_elementflags without
doing a walk). |
public final QNameSet get_element_ending_delimiters(QName eltname) {
SchemaProperty prop = schemaType().getElementProperty(eltname);
if (prop == null)
return null;
return prop.getJavaSetterDelimiter();
}
Inserting a new element is always unambiguous except in one
situation: when adding an element after the last one with
that name (or the first one if there are none).
In that case, add the element at the first possible slot
BEFORE any element whose qname is contained in the QNameSet
given. (If the QNameSet is empty, that means add the new
element at the very end.)
If the returned QNameSet is null, treat it as if the QNameSet
contained all QNames, i.e., add the new element at the very
first position possible (adjacent to the last element of the
same name, or at the very first slot if it is the first elt
with that name). |
public SchemaType get_element_type(QName eltName,
QName xsiType) {
return schemaType().getElementType(
eltName, xsiType, get_store().get_schematypeloader() );
}
|
public int get_elementflags(QName eltName) {
if (!_isComplexContent())
return 0;
SchemaProperty prop = schemaType().getElementProperty(eltName);
if (prop == null)
return 0;
if (prop.hasDefault() == SchemaProperty.VARIABLE ||
prop.hasFixed() == SchemaProperty.VARIABLE ||
prop.hasNillable() == SchemaProperty.VARIABLE)
return -1;
return
(prop.hasDefault() == SchemaProperty.NEVER ? 0 : TypeStore.HASDEFAULT) |
(prop.hasFixed() == SchemaProperty.NEVER ? 0 : TypeStore.FIXED) |
(prop.hasNillable() == SchemaProperty.NEVER ? 0 : TypeStore.NILLABLE);
}
Returns the elementflags, if they're consistent. If they're
not, returns -1, and requires a vistor walk. |
public SchemaType get_schema_type() {
return schemaType();
}
|
public final TypeStore get_store() {
assert((_flags & FLAG_STORE) != 0);
return (TypeStore)_textsource;
}
Used by the ComplexTypeImpl subclass to get direct access
to the store. |
protected int get_wscanon_rule() {
return SchemaType.WS_COLLAPSE;
}
Returns the whitespace rule that will be applied before
building a string to pass to get_text().
Overridden by subclasses that don't need their text
for set_text canonicalized; perhaps they already implement
scanners that can deal with whitespace, and they know
they have no regex pattern restrictions. |
public final String get_wscanon_text() {
if ((_flags & FLAG_STORE) == 0)
{
return apply_wscanon((String)_textsource);
}
else return get_store().fetch_text(get_wscanon_rule());
}
Grabs the undelying litral representation, applying the
implementation's wscanon rule.
Null if not simple content. |
protected final boolean has_store() {
return (_flags & FLAG_STORE) != 0;
}
|
public final int hashCode() {
if (!isImmutable())
return super.hashCode();
synchronized (monitor())
{
if (isNil())
return 0;
return value_hash_code();
}
}
|
protected void initComplexType(boolean complexType,
boolean complexContent) {
_flags |= (complexType ? FLAG_COMPLEXTYPE : 0) |
(complexContent ? FLAG_COMPLEXCONTENT : 0);
}
Called by restriction subclasses within their constructors to enable
complex type support. |
public void init_flags(SchemaProperty prop) {
if (prop == null) return;
if (prop.hasDefault() == SchemaProperty.VARIABLE ||
prop.hasFixed() == SchemaProperty.VARIABLE ||
prop.hasNillable() == SchemaProperty.VARIABLE)
return;
_flags &= ~FLAGS_ELEMENT;
_flags |=
(prop.hasDefault() == SchemaProperty.NEVER ? 0 : TypeStore.HASDEFAULT) |
(prop.hasFixed() == SchemaProperty.NEVER ? 0 : TypeStore.FIXED) |
(prop.hasNillable() == SchemaProperty.NEVER ? 0 : TypeStore.NILLABLE) |
(FLAG_NOT_VARIABLE);
}
|
public SchemaType instanceType() {
synchronized (monitor()) { return isNil() ? null : schemaType(); }
}
|
public int intValue() {
return getIntValue();
} Deprecated! replaced - with #getIntValue
|
public final void invalidate_element_order() {
assert((_flags & FLAG_STORE) != 0);
_flags |= FLAG_VALUE_DATED | FLAG_NIL_DATED | FLAG_ELEMENT_DATED;
}
Called by a TypeStore to indicate that the element's default
value, nillability, fixedness, etc, may have changed by
virtue of the element order changing (and xsi:nil and the
text may have changed too); so the store should be consulted
next time any setter or getter is called. |
public final void invalidate_nilvalue() {
assert((_flags & FLAG_STORE) != 0);
_flags |= FLAG_VALUE_DATED | FLAG_NIL_DATED;
}
Called by a TypeStore to indicate that the xsi:nil attribute
on the containing element (and possibly the text) has been
invalidated and both should be consulted next time the value
is needed. |
public final void invalidate_value() {
assert((_flags & FLAG_STORE) != 0);
_flags |= FLAG_VALUE_DATED;
}
Called by a TypeStore to indicate that the text has been
invalidated and should be fetched next time the value is
needed. |
public final boolean isDefault() {
check_dated();
return ((_flags & FLAG_ISDEFAULT) != 0);
}
True if the value is currently defaulted. |
public final boolean isDefaultable() {
check_element_dated();
return ((_flags & FLAG_HASDEFAULT) != 0);
}
True if the value is currently defaulted. |
public final boolean isFixed() {
check_element_dated();
return ((_flags & FLAG_FIXED) != 0);
}
True if the value is fixed. |
public boolean isImmutable() {
return (_flags & FLAG_IMMUTABLE) != 0;
}
Is this instance an immutable value? |
public boolean isInstanceOf(SchemaType type) {
SchemaType myType;
if (type.getSimpleVariety() != SchemaType.UNION)
{
for (myType = instanceType(); myType != null; myType = myType.getBaseType())
if (type == myType)
return true;
return false;
}
else
{
Set ctypes = new HashSet(Arrays.asList(type.getUnionConstituentTypes()));
for (myType = instanceType(); myType != null; myType = myType.getBaseType())
if (ctypes.contains(myType))
return true;
return false;
}
}
|
public final boolean isNil() {
synchronized (monitor())
{
check_dated();
return ((_flags & FLAG_NIL) != 0);
}
}
True if the value is nilled. |
public final boolean isNillable() {
check_element_dated();
return ((_flags & FLAG_NILLABLE) != 0);
}
True if the value is allowed to be nil. |
public boolean is_child_element_order_sensitive() {
if (!_isComplexType())
return false;
return schemaType().isOrderSensitive();
}
Returns false if child elements are insensitive to order;
if it returns true, you're required to call invalidate_element_order
on children to the right of any child order rearrangement. |
protected boolean is_defaultable_ws(String v) {
return true;
}
Types should return false if they don't treat the given
whitespace as a default value. |
protected final boolean is_orphaned() {
return (_flags & FLAG_ORPHANED) != 0;
}
Describes the orphaned status of this object. |
protected static Object java_value(XmlObject obj) {
if (obj.isNil())
return null;
if (!(obj instanceof XmlAnySimpleType))
return obj;
SchemaType instanceType = ((SimpleValue)obj).instanceType();
assert(instanceType != null) : "Nil case should have been handled above";
// handle lists
if (instanceType.getSimpleVariety() == SchemaType.LIST)
return ((SimpleValue)obj).getListValue();
SimpleValue base = (SimpleValue)obj;
switch (instanceType.getPrimitiveType().getBuiltinTypeCode())
{
case SchemaType.BTC_BOOLEAN:
return base.getBooleanValue() ? Boolean.TRUE : Boolean.FALSE;
case SchemaType.BTC_BASE_64_BINARY:
case SchemaType.BTC_HEX_BINARY:
return base.getByteArrayValue();
case SchemaType.BTC_QNAME:
return base.getQNameValue();
case SchemaType.BTC_FLOAT:
return new Float(base.getFloatValue());
case SchemaType.BTC_DOUBLE:
return new Double(base.getDoubleValue());
case SchemaType.BTC_DECIMAL:
{
switch (instanceType.getDecimalSize())
{
case SchemaType.SIZE_BYTE:
return new Byte(base.getByteValue());
case SchemaType.SIZE_SHORT:
return new Short(base.getShortValue());
case SchemaType.SIZE_INT:
return new Integer(base.getIntValue());
case SchemaType.SIZE_LONG:
return new Long(base.getLongValue());
case SchemaType.SIZE_BIG_INTEGER:
return base.getBigIntegerValue();
default:
assert(false) : "invalid numeric bit count";
// fallthrough
case SchemaType.SIZE_BIG_DECIMAL:
return base.getBigDecimalValue();
}
}
case SchemaType.BTC_ANY_URI:
return base.getStringValue();
case SchemaType.BTC_DURATION:
return base.getGDurationValue();
case SchemaType.BTC_DATE_TIME:
case SchemaType.BTC_TIME:
case SchemaType.BTC_DATE:
case SchemaType.BTC_G_YEAR_MONTH:
case SchemaType.BTC_G_YEAR:
case SchemaType.BTC_G_MONTH_DAY:
case SchemaType.BTC_G_DAY:
case SchemaType.BTC_G_MONTH:
return base.getCalendarValue();
default:
assert(false) : "encountered nonprimitive type.";
// fallthrough
// NB: for string enums we just do java.lang.String
// when in the context of unions. It's easier on users.
case SchemaType.BTC_NOTATION:
case SchemaType.BTC_STRING:
case SchemaType.BTC_ANY_SIMPLE:
// return base.getStringValue();
return base.getStringValue();
}
}
|
public List listValue() {
return getListValue();
} Deprecated! replaced - with #getListValue
|
public long longValue() {
return getLongValue();
} Deprecated! replaced - with #getLongValue
|
public final Object monitor() {
// for serialization
if (has_store())
return get_store().get_locale();
return this;
}
|
public XmlCursor newCursor() {
if ((_flags & FLAG_STORE) == 0)
throw new IllegalStateException("XML Value Objects cannot create cursors");
check_orphaned();
// Note that new_cursor does not really need sync ....
XmlLocale l = getXmlLocale();
if (l.noSync()) { l.enter(); try { return get_store().new_cursor(); } finally { l.exit(); } }
else synchronized ( l ) { l.enter(); try { return get_store().new_cursor(); } finally { l.exit(); } }
}
|
public XmlCursor newCursorForce() {
synchronized (monitor())
{
return ensureStore().newCursor();
}
}
|
public Node newDomNode() {
return newDomNode(null);
}
|
public Node newDomNode(XmlOptions options) {
XmlCursor cur = newCursorForce(); try { return cur.newDomNode(makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public InputStream newInputStream() {
return newInputStream(null);
}
|
public InputStream newInputStream(XmlOptions options) {
XmlCursor cur = newCursorForce(); try { return cur.newInputStream(makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public Reader newReader() {
return newReader(null);
}
|
public Reader newReader(XmlOptions options) {
XmlCursor cur = newCursorForce(); try { return cur.newReader(makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public XMLInputStream newXMLInputStream() {
return newXMLInputStream(null);
} Deprecated! XMLInputStream - was deprecated by XMLStreamReader from STaX - jsr173 API.
|
public XMLInputStream newXMLInputStream(XmlOptions options) {
XmlCursor cur = newCursorForce(); try { return cur.newXMLInputStream(makeInnerOptions(options)); } finally { cur.dispose(); }
} Deprecated! XMLInputStream - was deprecated by XMLStreamReader from STaX - jsr173 API.
|
public XMLStreamReader newXMLStreamReader() {
return newXMLStreamReader(null);
}
|
public XMLStreamReader newXMLStreamReader(XmlOptions options) {
XmlCursor cur = newCursorForce(); try { return cur.newXMLStreamReader(makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public TypeStoreVisitor new_visitor() {
if (!_isComplexContent())
return null;
return new SchemaTypeVisitorImpl(schemaType().getContentModel());
}
A typestore user can return a visitor that is used to compute
default text and elementflags for an arbitrary element. |
public void objectSet(Object obj) {
setObjectValue(obj);
} Deprecated! replaced - with #setObjectValue
|
public Object objectValue() {
return getObjectValue();
} Deprecated! replaced - with #getObjectValue
|
public QName qNameValue() {
return getQNameValue();
} Deprecated! replaced - with #getQNameValue
|
public void save(File file) throws IOException {
save( file, null );
}
|
public void save(OutputStream os) throws IOException {
save( os, null );
}
|
public void save(Writer w) throws IOException {
save( w, null );
}
|
public void save(File file,
XmlOptions options) throws IOException {
XmlCursor cur = newCursorForce(); try { cur.save(file, makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public void save(OutputStream os,
XmlOptions options) throws IOException {
XmlCursor cur = newCursorForce(); try { cur.save(os, makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public void save(Writer w,
XmlOptions options) throws IOException {
XmlCursor cur = newCursorForce(); try { cur.save(w, makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
public void save(ContentHandler ch,
LexicalHandler lh) throws SAXException {
save( ch, lh, null );
}
|
public void save(ContentHandler ch,
LexicalHandler lh,
XmlOptions options) throws SAXException {
XmlCursor cur = newCursorForce(); try { cur.save(ch, lh, makeInnerOptions(options)); } finally { cur.dispose(); }
}
|
abstract public SchemaType schemaType()
|
public XmlObject selectAttribute(QName attributeName) {
XmlCursor xc = this.newCursor();
try
{
if (!xc.isContainer())
return null;
if (xc.toFirstAttribute())
{
//look for attributes
do
{
if (xc.getName().equals(attributeName))
{
return xc.getObject();
}
}
while (xc.toNextAttribute());
}
return null;
}
finally
{
xc.dispose();
}
}
Selects the content of the attribute with the given name. |
public XmlObject selectAttribute(String attributeUri,
String attributeLocalName) {
return selectAttribute(new QName(attributeUri, attributeLocalName));
}
Selects the content of the attribute with the given name. |
public XmlObject[] selectAttributes(QNameSet attributeNameSet) {
if (attributeNameSet==null)
throw new IllegalArgumentException();
XmlCursor xc = this.newCursor();
try
{
if (!xc.isContainer())
return EMPTY_RESULT;
List result = new ArrayList();
if (xc.toFirstAttribute())
{
//look for attributes
do
{
if (attributeNameSet.contains(xc.getName()))
{
result.add(xc.getObject());
}
}
while (xc.toNextAttribute());
}
if (result.size() == 0)
return EMPTY_RESULT;
else
return (XmlObject[]) result.toArray(EMPTY_RESULT);
}
finally
{
xc.dispose();
}
}
Selects the contents of the attributes that are contained in the elementNameSet. |
public XmlObject[] selectChildren(QName elementName) {
XmlCursor xc = this.newCursor();
try
{
if (!xc.isContainer())
return EMPTY_RESULT;
List result = new ArrayList();
if (xc.toChild(elementName))
{
// look for elements
do
{
result.add(xc.getObject());
}
while (xc.toNextSibling(elementName));
}
if (result.size() == 0)
return EMPTY_RESULT;
else
return (XmlObject[]) result.toArray(EMPTY_RESULT);
}
finally
{
xc.dispose();
}
}
Selects the contents of the children elements with the given name. |
public XmlObject[] selectChildren(QNameSet elementNameSet) {
if (elementNameSet==null)
throw new IllegalArgumentException();
XmlCursor xc = this.newCursor();
try
{
if (!xc.isContainer())
return EMPTY_RESULT;
List result = new ArrayList();
if (xc.toFirstChild())
{
// look for elements
do
{
assert xc.isContainer();
if (elementNameSet.contains(xc.getName()))
{
result.add(xc.getObject());
}
}
while (xc.toNextSibling());
}
if (result.size() == 0)
return EMPTY_RESULT;
else
return (XmlObject[]) result.toArray(EMPTY_RESULT);
}
finally
{
xc.dispose();
}
}
Selects the contents of the children elements that are contained in the elementNameSet. |
public XmlObject[] selectChildren(String elementUri,
String elementLocalName) {
return selectChildren(new QName(elementUri, elementLocalName));
}
Selects the contents of the children elements with the given name. |
public XmlObject[] selectPath(String path) {
return selectPath( path, null );
}
|
public XmlObject[] selectPath(String path,
XmlOptions options) {
XmlObject [] selections;
// all user-level code; doesn't need to be synchronized
XmlCursor c = newCursor();
if (c == null)
throw new XmlValueDisconnectedException();
try
{
c.selectPath( path, options );
if (!c.hasNextSelection())
selections = EMPTY_RESULT;
else
{
selections = new XmlObject [ c.getSelectionCount() ];
for (int i = 0 ; c.toNextSelection() ; i++)
{
if ((selections[ i ] = c.getObject()) == null)
{
if ( !c.toParent() || (selections[ i ] = c.getObject()) == null )
throw
new XmlRuntimeException(
"Path must select only elements " +
"and attributes" );
}
}
}
}
finally
{
c.dispose();
}
return _typedArray(selections);
}
|
public void set(String obj) {
setStringValue(obj);
} Deprecated! replaced - with #setStringValue
|
public void set(boolean v) {
setBooleanValue(v);
} Deprecated! replaced - with #setBooleanValue
|
public void set(byte v) {
setByteValue(v);
} Deprecated! replaced - with #setByteValue
|
public void set(short v) {
setShortValue(v);
} Deprecated! replaced - with #setShortValue
|
public void set(int v) {
setIntValue(v);
} Deprecated! replaced - with #setIntValue
|
public void set(long v) {
setLongValue(v);
} Deprecated! replaced - with #setLongValue
|
public void set(BigInteger obj) {
setBigIntegerValue(obj);
} Deprecated! replaced - with #setBigIntegerValue
|
public void set(BigDecimal obj) {
setBigDecimalValue(obj);
} Deprecated! replaced - with #setBigDecimalValue
|
public void set(float v) {
setFloatValue(v);
} Deprecated! replaced - with #setFloatValue
|
public void set(double v) {
setDoubleValue(v);
} Deprecated! replaced - with #setDoubleValue
|
public void set(byte[] obj) {
setByteArrayValue(obj);
} Deprecated! replaced - with #setByteArrayValue
|
public void set(StringEnumAbstractBase obj) {
setEnumValue(obj);
} Deprecated! replaced - with #setEnumValue
|
public void set(Calendar obj) {
setCalendarValue(obj);
} Deprecated! replaced - with #setCalendarValue
|
public void set(Date obj) {
setDateValue(obj);
} Deprecated! replaced - with #setDateValue
|
public void set(GDateSpecification obj) {
setGDateValue(obj);
} Deprecated! replaced - with #setGDateValue
|
public void set(GDurationSpecification obj) {
setGDurationValue(obj);
} Deprecated! replaced - with #setGDurationValue
|
public void set(QName obj) {
setQNameValue(obj);
} Deprecated! replaced - with #setQNameValue
|
public void set(List obj) {
setListValue(obj);
} Deprecated! replaced - with #setListValue
|
public final XmlObject set(XmlObject src) {
if (isImmutable())
throw new IllegalStateException("Cannot set the value of an immutable XmlObject");
XmlObjectBase obj = underlying(src);
TypeStoreUser newObj = this;
if (obj == null)
{
setNil();
return this;
}
if (obj.isImmutable())
set(obj.stringValue());
else
{
boolean noSyncThis = preCheck();
boolean noSyncObj = obj.preCheck();
if (monitor() == obj.monitor()) // both are in the same locale
{
if (noSyncThis) // the locale is not sync
newObj = setterHelper( obj );
else // the locale is sync
{
synchronized (monitor()) {
newObj = setterHelper( obj );
}
}
}
else // on different locale's
{
if (noSyncThis)
{
if (noSyncObj) // both unsync
{
newObj = setterHelper( obj );
}
else // only obj is sync
{
synchronized (obj.monitor()) {
newObj = setterHelper( obj );
}
}
}
else
{
if (noSyncObj) // only this is sync
{
synchronized (monitor()) {
newObj = setterHelper( obj );
}
|