Package com.tangosol.run.xml
Class PropertyAdapter
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.BitHelper
-
- com.tangosol.util.ExternalizableHelper
-
- com.tangosol.run.xml.PropertyAdapter
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
IterableAdapter,SerializableAdapter,SimpleAdapter,XmlElementAdapter,XmlSerializableAdapter
public abstract class PropertyAdapter extends ExternalizableHelper implements Serializable
The PropertyAdapter is the base class for handling the operations that can occur on any property.<property> <name>People</name> <xml-name>people</xml-name> <!-- optional, empty name indicates anonymous element --> <adapter>...</adapter> <!-- optional --> <type>...</type> <!-- defaults via reflection --> <class>...</class> <!-- defaults to <type> --> <property>- Version:
- 1.00 2001.03.06
- Author:
- cp
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.ExternalizableHelper
ExternalizableHelper.DecoratedMultiBufferReadBuffer, ExternalizableHelper.DefaultObjectStreamFactory, ExternalizableHelper.FormatAwareCompressor, ExternalizableHelper.IntDecoratedObject, ExternalizableHelper.Shielded, ExternalizableHelper.ShieldedDataOutputStream, ExternalizableHelper.ShieldedInputStream, ExternalizableHelper.ShieldedObjectOutputStream, ExternalizableHelper.ShieldedOutputStream, ExternalizableHelper.SimpleXmlBeanClassCache, ExternalizableHelper.Stats, ExternalizableHelper.XmlBeanClassCache
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected Classm_clzTypeThe type of the property.protected booleanm_fAttributeTrue if the property is stored in an attribute instead of an XML element.protected XmlBean.BeanInfom_infoBeanThe BeanInfo object that contains this PropertyAdapter.protected Methodm_methodCloneThe "public Object clone()" method for the property type, if available.protected Methodm_methodGetThe property "accessor" method.protected Methodm_methodSetThe property "mutator" method.protected Stringm_sNameThe property name.protected Stringm_sNmsPrefixThe namespace prefix for this property.protected Stringm_sNmsUriThe namespace URI for this property.protected Stringm_sXmlThe XML element name used to store this property.protected static Class[]NOPARAMSParameters for finding no-parameter methods.-
Fields inherited from class com.tangosol.util.ExternalizableHelper
BINARY_SIZE, CHUNK_SIZE, CHUNK_THRESHOLD, CONVERTER_FROM_BINARY, CONVERTER_STRIP_INTDECO, CONVERTER_TO_BINARY, DECO_APP_1, DECO_APP_2, DECO_APP_3, DECO_BACKUP, 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_STORE, 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, LAMBDA_SERIALIZATION, MAX_DECO_HEADER_BYTES, PACKED_INT_SIZE, PACKED_LONG_SIZE, PROPERTY_CONFIG, s_streamfactory, TRINT_DOMAIN_SPAN, TRINT_MAX_VALUE, TRINT_MAX_VARIANCE, USE_POF_STREAMS, USE_XMLBEAN_CLASS_CACHE, XMLBEAN_CLASS_CACHE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPropertyAdapter(XmlBean.BeanInfo infoBean, Class clzType, String sName, String sXml, XmlElement xml)Construct a PropertyAdapter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Objectclone(Object o)Make a clone of the passed object.booleanequalsValue(Object o1, Object o2)Compare the two passed objects for equality.XmlValuefindAttribute(XmlElement xml)Find an attribute of the specified XmlElement that represents a value for a property represented by this adapter.XmlElementfindElement(XmlElement xml)Find a child element of the specified XmlElement that represents a value for a property represented by this adapter.ObjectfromUri(String sUri)Deserialize an object from a URI element.ObjectfromXml(XmlElement xml)Deserialize an object from an XML element.Objectget(XmlBean bean)Extract the property value from the passed bean reference.MethodgetAccessor()Obtain the Method object that is used to call the property accessor.XmlBean.BeanInfogetBeanInfo()Obtain the containing BeanInfo object.MethodgetCloner()Obtain the Method object that is used to deep-clone the property value.IteratorgetElements(XmlElement xml)Get an iterator of child elements of the specified XmlElement that represent values for a property represented by this adapter.StringgetLocalXmlName()Determine the "local" XML element name that will be used to hold the property value.MethodgetMutator()Obtain the Method object that is used to call the property mutator.StringgetName()Obtain the name of the property that this PropertyAdapter handles.StringgetNamespacePrefix()Determine the default namespace prefix for the property.StringgetNamespaceUri()Determine the namespace URI for the property.ClassgetType()Obtain the type of the property (the class of the object declared as being returned by the accessor and passed to the mutator).StringgetXmlName()Return the XML element name used to generate an XML.inthash(Object o)compute a hash code for the passed object.booleanisAnonymous()Determine if this property does not have a designated element name.booleanisAttribute()Determine if the property is stored in an XML attribute instead of an XML element.abstract booleanisCloneRequired()Determine if the property value must be deep-cloned.booleanisElementMatch(XmlElement xml)Check whether or not the passed element matches to the property's local name and Namespace URI.booleanisEmpty(Object o)Determine if the specified value is empty.ObjectreadExternal(DataInput in)Read a value from the passed DataInput object.ObjectreadXml(XmlElement xml)Deserialize an object from XML.voidset(XmlBean bean, Object o)Store the property value in the passed bean.voidsetNamespacePrefix(String sPrefix)Set the default Namespace prefix for this property.StringtoString()Debugging support.StringtoUri(Object o)Serialize an object into a URI element.XmlElementtoXml(Object o)Serialize an object into an XML element.voidwriteExternal(DataOutput out, Object o)Write the specified data to the passed DataOutput object.voidwriteXml(XmlElement xml, Object o)Serialize an object into an XML element.-
Methods inherited from class com.tangosol.util.ExternalizableHelper
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, isPatchCompatible, isPatchCompatible, isResolving, isSerializable, isSerializerCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, 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
-
Methods inherited from class com.tangosol.util.BitHelper
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
-
Methods inherited from class com.tangosol.util.Base
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, getProcessRandom, 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, newHashMap, newHashMap, newHashSet, newHashSet, 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
-
-
-
-
Field Detail
-
NOPARAMS
protected static final Class[] NOPARAMS
Parameters for finding no-parameter methods.
-
m_infoBean
protected XmlBean.BeanInfo m_infoBean
The BeanInfo object that contains this PropertyAdapter.
-
m_sName
protected String m_sName
The property name.
-
m_sXml
protected String m_sXml
The XML element name used to store this property.
-
m_fAttribute
protected boolean m_fAttribute
True if the property is stored in an attribute instead of an XML element.
-
m_clzType
protected Class m_clzType
The type of the property.
-
m_methodGet
protected Method m_methodGet
The property "accessor" method.
-
m_methodSet
protected Method m_methodSet
The property "mutator" method.
-
m_methodClone
protected Method m_methodClone
The "public Object clone()" method for the property type, if available.
-
m_sNmsUri
protected String m_sNmsUri
The namespace URI for this property.
-
m_sNmsPrefix
protected String m_sNmsPrefix
The namespace prefix for this property.
-
-
Constructor Detail
-
PropertyAdapter
protected PropertyAdapter(XmlBean.BeanInfo infoBean, Class clzType, String sName, String sXml, XmlElement xml)
Construct a PropertyAdapter.Note: This constructor may narrow the specified property type to match the declared property accessor return type; therefore, subclasses should not assume that the specified property type will be equal to that returned by the
getType()method.- Parameters:
infoBean- BeanInfo for a bean containing this propertyclzType- the type of the propertysName- the property namesXml- the XML tag namexml- additional XML information
-
-
Method Detail
-
getBeanInfo
public XmlBean.BeanInfo getBeanInfo()
Obtain the containing BeanInfo object.- Returns:
- the BeanInfo that describes an XML bean containing this property
-
getName
public String getName()
Obtain the name of the property that this PropertyAdapter handles.- Returns:
- the property name
-
getLocalXmlName
public String getLocalXmlName()
Determine the "local" XML element name that will be used to hold the property value.- Returns:
- the local XML element name for the property value
-
getXmlName
public String getXmlName()
Return the XML element name used to generate an XML.- Returns:
- the outgoing XML element name for the property value
-
isElementMatch
public boolean isElementMatch(XmlElement xml)
Check whether or not the passed element matches to the property's local name and Namespace URI.- Parameters:
xml- the XML element- Returns:
- true if the specified element represents a value for a property represented by this adapter
-
findElement
public XmlElement findElement(XmlElement xml)
Find a child element of the specified XmlElement that represents a value for a property represented by this adapter.- Parameters:
xml- the parent XmlElement- Returns:
- an element that can be processed by this adapther; null if none could be found
-
getElements
public Iterator getElements(XmlElement xml)
Get an iterator of child elements of the specified XmlElement that represent values for a property represented by this adapter.- Parameters:
xml- the parent XmlElement- Returns:
- an iterator containing all child elements that can be processed by this adapther
-
findAttribute
public XmlValue findAttribute(XmlElement xml)
Find an attribute of the specified XmlElement that represents a value for a property represented by this adapter.- Parameters:
xml- the parent XmlElement- Returns:
- an attribute that can be processed by this adapther; null if none could be found
-
getNamespaceUri
public String getNamespaceUri()
Determine the namespace URI for the property.- Returns:
- the URI that qualifies the Namespace for this property
-
getNamespacePrefix
public String getNamespacePrefix()
Determine the default namespace prefix for the property.- Returns:
- the default Namespace prefix for this property
-
setNamespacePrefix
public void setNamespacePrefix(String sPrefix)
Set the default Namespace prefix for this property.- Parameters:
sPrefix- the new default namespace for this property
-
getType
public Class getType()
Obtain the type of the property (the class of the object declared as being returned by the accessor and passed to the mutator).- Returns:
- the property type
-
getAccessor
public Method getAccessor()
Obtain the Method object that is used to call the property accessor.- Returns:
- the accessor (getter) method for the property
-
getMutator
public Method getMutator()
Obtain the Method object that is used to call the property mutator.- Returns:
- the mutator (setter) method for the property or null if the property is not settable
-
getCloner
public Method getCloner()
Obtain the Method object that is used to deep-clone the property value.- Returns:
- the clone method for the property or null if none is applicable or available
-
isAnonymous
public boolean isAnonymous()
Determine if this property does not have a designated element name.- Returns:
- true if the property doesn't have an associated XmlElement
-
isAttribute
public boolean isAttribute()
Determine if the property is stored in an XML attribute instead of an XML element.- Returns:
- true if the property is attribute bound
-
isCloneRequired
public abstract boolean isCloneRequired()
Determine if the property value must be deep-cloned. Typically, a property value must be deep-cloned if it is a mutable reference type, e.g. StringBuffer, Date, byte[].- Returns:
- true if the property value must be "deep" cloned when the containing object is cloned
-
get
public Object get(XmlBean bean)
Extract the property value from the passed bean reference.- Parameters:
bean- the XML bean object to obtain the property value from- Returns:
- the property value
-
isEmpty
public boolean isEmpty(Object o)
Determine if the specified value is empty.- Parameters:
o- the value- Returns:
- true if the object is considered to be empty for persistence and XML-generation purposes
-
set
public void set(XmlBean bean, Object o)
Store the property value in the passed bean.- Parameters:
bean- the XML bean object to store the property value intoo- the property value
-
hash
public int hash(Object o)
compute a hash code for the passed object.- Parameters:
o- the object to compute a hash code for- Returns:
- an integer hash code
-
equalsValue
public boolean equalsValue(Object o1, Object o2)
Compare the two passed objects for equality.- Parameters:
o1- the first objecto2- the second object- Returns:
- true if the two objects are equal
-
clone
public Object clone(Object o)
Make a clone of the passed object.- Parameters:
o- the object to clone- Returns:
- a clone of the passed object
-
fromXml
public Object fromXml(XmlElement xml)
Deserialize an object from an XML element.- Parameters:
xml- the XML element to deserialize from- Returns:
- the object deserialized from the XML element
- Throws:
UnsupportedOperationException- if the property cannot be read from a single XML element
-
toXml
public XmlElement toXml(Object o)
Serialize an object into an XML element.- Parameters:
o- the object to serialize- Returns:
- the XML element representing the serialized form of the passed object
- Throws:
UnsupportedOperationException- if the property cannot be written to a single XML element
-
readXml
public Object readXml(XmlElement xml)
Deserialize an object from XML. Note that the parent element is the one passed to this method; this method is responsible for finding all of the necessarily elements within the parent element. This method is intended to allow collection properties to read their data from multiple XML elements.- Parameters:
xml- the XML element containing the XML elements to deserialize from- Returns:
- the object deserialized from the XML (may be null)
-
writeXml
public void writeXml(XmlElement xml, Object o)
Serialize an object into an XML element. Note that the parent element is the one passed to this method; this method is responsible for creating the necessarily elements within the parent element. This method is intended to allow collection properties to write their data to multiple XML elements.- Parameters:
xml- the XML element containing the XML elements to serialize too- the object to serialize (may be null)
-
fromUri
public Object fromUri(String sUri)
Deserialize an object from a URI element.- Parameters:
sUri- the URI element to deserialize from- Returns:
- the object deserialized from the URI element
- Throws:
UnsupportedOperationException- if the property cannot be read from a URI element
-
toUri
public String toUri(Object o)
Serialize an object into a URI element.- Parameters:
o- the object to serialize- Returns:
- the URI element representing the serialized form of the passed object
- Throws:
UnsupportedOperationException- if the property cannot be written to a URI element
-
readExternal
public Object readExternal(DataInput in) throws IOException
Read a value from the passed DataInput object.- Parameters:
in- the DataInput stream to read property data from- Returns:
- the data read from the DataInput; never null
- Throws:
IOException- if an I/O exception occurs
-
writeExternal
public void writeExternal(DataOutput out, Object o) throws IOException
Write the specified data to the passed DataOutput object.- Parameters:
out- the DataOutput stream to write too- the data to write to the DataOutput; never null- Throws:
IOException- if an I/O exception occurs
-
-