public abstract class XmlBean extends ExternalizableHelper implements Cloneable, Externalizable, ExternalizableLite, XmlSerializable
The following property types are supported using standard property adapters:
1) XmlValue types: TYPE_BOOLEAN - boolean, java.lang.Boolean TYPE_INT - byte, char, short, int, java.lang.Byte, java.lang.Character, java.lang.Short, java.lang.Integer TYPE_LONG - long, java.lang.Long TYPE_DOUBLE - float, double, java.lang.Float, java.lang.Double TYPE_DECIMAL - java.math.BigDecimal, java.math.BigInteger TYPE_STRING - java.lang.String TYPE_BINARY - com.tangosol.util.Binary, byte[] TYPE_DATE - java.sql.Date TYPE_TIME - java.sql.Time TYPE_DATETIME - java.sql.Timestamp, java.util.Date 2) Objects implementing XmlSerializable (including XmlBean subclasses) 3) Objects implementing Serializable 4) Collections of any of the above: Java arrays java.util.Collection java.util.Set java.util.List java.util.Map java.util.SortedSet java.util.SortedMapEach XmlBean must have a corresponding XML declaration file that provides the necessary information to parse XML into the XML bean and to format the XML bean into XML. The declaration file should be located in the same package (directory) as the class itself.
For example, here is an XmlBean subclass with an int property "Id" and a String property "Name":
public class Person extends XmlBean {
public Person(int nId, String sName) {...}
public int getId() {...}
public void setId(int nId) {...}
public String getName() {...}
public void setName(String sName) {...}
}
The Person XML bean example above would have an XML declaration file that
resembles the following:
<xml-bean>
<name>person</name>
<property>
<name>Id</name>
<xml-name>person-id</xml-name>
</property>
<property>
<name>Name</name>
<xml-name>full-name</xml-name>
</property>
</xml-bean>
Consider the following code:
System.out.println(new Person(15, "John Smith").toString());
The output would be:
<person>
<person-id>15</person-id>
<full-name>John Smith</full-name>
</person>
To specify namespace information for an XML bean, add an "xmlns" element to
the bean's descriptor:
<xml-bean>
<name>person</name>
<xmlns>
<uri>the-schema-URI-goes-here</uri>
<prefix>the-default-namespace-prefix-goes-here</prefix>
<xmlns>
<property>
...
</property>
</xml-bean>
Modifier and Type | Class and Description |
---|---|
static class |
XmlBean.BeanInfo
A BeanInfo contains information about the XML bean and its properties.
|
ExternalizableHelper.DecoratedMultiBufferReadBuffer, ExternalizableHelper.DefaultObjectStreamFactory, ExternalizableHelper.FormatAwareCompressor, ExternalizableHelper.IntDecoratedObject, ExternalizableHelper.Shielded, ExternalizableHelper.ShieldedDataOutputStream, ExternalizableHelper.ShieldedInputStream, ExternalizableHelper.ShieldedObjectOutputStream, ExternalizableHelper.ShieldedOutputStream, ExternalizableHelper.SimpleXmlBeanClassCache, ExternalizableHelper.Stats, ExternalizableHelper.XmlBeanClassCache
Base.LoggingWriter, Base.StackFrame
CHUNK_SIZE, CHUNK_THRESHOLD, CONVERTER_FROM_BINARY, CONVERTER_STRIP_INTDECO, CONVERTER_TO_BINARY, DECO_APP_1, DECO_APP_2, DECO_APP_3, DECO_CUSTOM, DECO_EXPIRY, DECO_ID_MAX, DECO_ID_MIN, DECO_JCACHE, DECO_JCACHE_SYNTHETIC, DECO_MEMCACHED, DECO_PUSHREP, DECO_QUEUE_METADATA, DECO_RSVD_1, DECO_RSVD_2, DECO_STORE, DECO_TOPLINK, DECO_TX, DECO_VALUE, DECO_WLS, EMPTY_BINARY_ARRAY, FMT_B_ARRAY, FMT_BIN_DECO, FMT_BIN_EXT_DECO, FMT_BINARY, FMT_BOOLEAN, FMT_BYTE, FMT_DECIMAL, FMT_DOUBLE, FMT_EXT, FMT_FLOAT, FMT_IDO, FMT_INT, FMT_INTEGER, FMT_LONG, FMT_NONE, FMT_NULL, FMT_OBJ_EXT, FMT_OBJ_SER, FMT_OPT, FMT_OPT_DOUBLE, FMT_OPT_INT, FMT_OPT_LONG, FMT_SHORT, FMT_STRING, FMT_UNKNOWN, FMT_XML_BEAN, FMT_XML_SER, FORCE_RESOLVING_STREAMS, MAX_DECO_HEADER_BYTES, PROPERTY_CONFIG, s_streamfactory, TRINT_DOMAIN_SPAN, TRINT_MAX_VALUE, TRINT_MAX_VARIANCE, USE_POF_STREAMS, USE_XMLBEAN_CLASS_CACHE, XMLBEAN_CLASS_CACHE
Modifier | Constructor and Description |
---|---|
protected |
XmlBean()
Construct a value object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adopt(Collection coll)
Helper to adopt a Collection of XmlBean objects.
|
protected void |
adopt(Iterator iter)
Helper to adopt a collection of XmlBean objects.
|
protected void |
adopt(Map map)
Helper to adopt a Map of XmlBean objects.
|
protected void |
adopt(Object[] ao)
Helper to adopt a collection of XmlBean objects.
|
protected void |
adopt(XmlBean child)
When an XmlBean adds a contained XmlBean, it should invoke this method
to relate the contained XmlBean with this XmlBean.
|
protected void |
checkMutable()
Verify that this XmlBean is mutable.
|
Object |
clone()
Clone the value object.
|
XmlBean |
ensureMutable()
Make sure that this XML bean is mutable.
|
void |
ensureReadOnly()
Make sure that this value is read-only (immutable).
|
boolean |
equals(Object o)
Determine if this value object is equal to the passed value object.
|
void |
fromXml(XmlElement xml)
Deserialize the object from an XmlElement.
|
PropertyAdapter[] |
getAdapters()
Obtain the PropertyAdapter objects for this XmlBean.
|
XmlBean.BeanInfo |
getBeanInfo()
Obtain the BeanInfo for this XmlBean object, or create and configure
a BeanInfo if one does not exist.
|
protected int |
getHashCode()
Get the cached hash code.
|
XmlBean |
getParentXmlBean()
Obtain the XmlBean that contains this XmlBean.
|
int |
hashCode()
Determine a hash code for this value object.
|
protected static void |
init(Class clz,
String sName,
String[] asProp)
For backwards compatibility only - loads reflection info.
|
protected XmlBean.BeanInfo |
initBeanInfo()
Initialize the Object, loading the XML Bean design information if
necessary.
|
boolean |
isMutable()
Determine if this value can be modified.
|
void |
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from
the passed DataInput object.
|
void |
readExternal(ObjectInput in)
The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays.
|
protected void |
setHashCode(int nHash)
Set the cached hash code.
|
protected void |
setMutable(boolean fMutable)
Specify whether this value can be modified or not.
|
protected void |
setParentXmlBean(XmlBean parent)
Specify the XmlBean that contains this XmlBean.
|
String |
toString()
To assist in debugging, provide a clear indication of the key's
state.
|
XmlElement |
toXml()
Serialize the object into an XmlElement.
|
void |
writeExternal(DataOutput out)
Save the contents of this object by storing the object's state into
the passed DataOutput object.
|
void |
writeExternal(ObjectOutput out)
The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings,
and arrays.
|
asBinary, calculatePackedLength, calculatePackedLength, checkObjectInputFilter, checkObjectInputFilter, checkObjectInputFilter, convertUTF, decodeExpiry, decorate, decorate, decorate, decorate, decorate, decorateBinary, encodeExpiry, ensureSerializer, extractIntDecoration, fromBinary, fromBinary, fromBinary, fromBinary, fromBinary, fromBinary, fromByteArray, fromByteArray, getClass, getConfigSerialFilter, getConfigSerialFilterFactory, getDecoration, getDecoration, getDecorations, getDeltaCompressor, getInputStream, getNewObjectInput, getObjectInput, getObjectInputFilter, getObjectOutput, getObjectStreamFactory, getOutputStream, getShieldedOutputStream, getStreamFormat, getUndecorated, getUndecorated, isDecorated, isDecorated, isIntDecorated, isIntDecorated, isResolving, isSerializable, isSerializerCompatible, isVersionCompatible, isVersionCompatible, loadClass, loadResource, main, makeTrint, readBigDecimal, readBigInteger, readBooleanArray, readBooleanArray, readByteArray, readCharArray, readCharArray, readCollection, readDate, readDoubleArray, readDoubleArray, readExternalizableLite, readExternalizableLite, readFloatArray, readFloatArray, readInt, readInt, readIntArray, readIntArray, readIntArray2d, readLargeBooleanArray, readLargeByteArray, readLargeCharArray, readLargeDoubleArray, readLargeFloatArray, readLargeIntArray, readLargeLongArray, readLargeObjectArray, readLargeStringArray, readLong, readLong, readLongArray, readLongArray, readMap, readMap, readObject, readObject, readObjectArray, readObjectArray, readSafeUTF, readSafeUTF, readSerializable, readSerializable, readStringArray, readStringArray, readTime, readTimestamp, readTrint, readUnsignedTrint, readUTF, readXmlBean, readXmlSerializable, readXmlSerializable, realize, removeIntDecoration, removeIntDecoration, replace, reportIncompatibleSerializers, setObjectStreamFactory, toBinary, toBinary, toBinary, toByteArray, toByteArray, toByteArray, toLiteBinary, toLong, undecorate, undecorate, validateBufferSize, validateLoadArray, validateLoadClass, writeBigDecimal, writeBigInteger, writeBooleanArray, writeByteArray, writeCollection, writeDate, writeDoubleArray, writeExternalizableLite, writeFloatArray, writeInt, writeInt, writeIntArray2d, writeLong, writeLong, writeMap, writeObject, writeSafeUTF, writeSafeUTF, writeSerializable, writeStringArray, writeTime, writeTimestamp, writeTrint, writeTrint, writeUTF, writeXmlBean, writeXmlSerializable
countBits, countBits, countBits, indexOfLSB, indexOfLSB, indexOfLSB, indexOfMSB, indexOfMSB, indexOfMSB, rotateLeft, rotateLeft, rotateLeft, rotateRight, rotateRight, rotateRight, toBitString, toBitString, toBitString, toBytes, toBytes, toBytes, toBytes, toInt, toInt, toLong
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
public XmlBean getParentXmlBean()
protected void setParentXmlBean(XmlBean parent)
parent
- the XmlBean that contains this XmlBeanprotected void adopt(Map map)
map
- a Map that may contain keys and/or values that are XmlBeansprotected void adopt(Collection coll)
coll
- a Collection that may contain XmlBeansprotected void adopt(Iterator iter)
iter
- an Iterator that may contain XmlBeansprotected void adopt(Object[] ao)
ao
- an array that may contain XmlBeansprotected void adopt(XmlBean child)
child
- the XmlBean that is being contained within this XmlBeanpublic boolean isMutable()
protected void setMutable(boolean fMutable)
fMutable
- true to allow this value to be modified, otherwise false
to indicate that this value is read-onlypublic XmlBean ensureMutable()
public void ensureReadOnly()
protected void checkMutable()
protected int getHashCode()
protected void setHashCode(int nHash)
nHash
- the hash codepublic XmlBean.BeanInfo getBeanInfo()
public PropertyAdapter[] getAdapters()
public boolean equals(Object o)
public int hashCode()
public String toString()
public Object clone()
public XmlElement toXml()
toXml
in interface XmlSerializable
public void fromXml(XmlElement xml)
fromXml
in interface XmlSerializable
xml
- an XmlElement that contains the serialized form of the
objectUnsupportedOperationException
- if the operation is not supportedIllegalStateException
- if this is not an appropriate stateIllegalArgumentException
- if there is an illegal argumentpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
in
- the stream to read data from in order to restore the objectIOException
- if I/O errors occurClassNotFoundException
- if the class for an object being
restored cannot be found.public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
out
- the stream to write the object toIOException
- includes any I/O exceptions that may occurpublic void readExternal(DataInput in) throws IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore
the state of this objectIOException
- if an I/O exception occursNotActiveException
- if the object is not in its initial
state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object toIOException
- if an I/O exception occursprotected static void init(Class clz, String sName, String[] asProp)
clz
- the class to initializesName
- the name of the value objectasProp
- the property names that make up the value objectprotected XmlBean.BeanInfo initBeanInfo()