Skip navigation links

Oracle® Coherence Java API Reference
v3.5

E14977-01


com.tangosol.run.xml
Class PropertyAdapter

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.BitHelper
          extended by com.tangosol.util.ExternalizableHelper
              extended by com.tangosol.run.xml.PropertyAdapter

All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
IterableAdapter, SerializableAdapter, SimpleAdapter, XmlElementAdapter, XmlSerializableAdapter

public abstract class PropertyAdapter
extends ExternalizableHelper
implements java.io.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

Field Summary
protected  java.lang.Class m_clzType
          The type of the property.
protected  boolean m_fAttribute
          True if the property is stored in an attribute instead of an XML element.
protected  XmlBean.BeanInfo m_infoBean
          The BeanInfo object that contains this PropertyAdapter.
protected  java.lang.reflect.Method m_methodClone
          The "public Object clone()" method for the property type, if available.
protected  java.lang.reflect.Method m_methodGet
          The property "accessor" method.
protected  java.lang.reflect.Method m_methodSet
          The property "mutator" method.
protected  java.lang.String m_sName
          The property name.
protected  java.lang.String m_sNmsPrefix
          The namespace prefix for this property.
protected  java.lang.String m_sNmsUri
          The namespace URI for this property.
protected  java.lang.String m_sXml
          The XML element name used to store this property.
protected static java.lang.Class[] NOPARAMS
          Parameters for finding no-parameter methods.

 

Constructor Summary
protected PropertyAdapter(XmlBean.BeanInfo infoBean, java.lang.Class clzType, java.lang.String sName, java.lang.String sXml, XmlElement xml)
          Construct a PropertyAdapter.

 

Method Summary
 java.lang.Object clone(java.lang.Object o)
          Make a clone of the passed object.
 boolean equalsValue(java.lang.Object o1, java.lang.Object o2)
          Compare the two passed objects for equality.
 XmlValue findAttribute(XmlElement xml)
          Find an attribute of the specified XmlElement that represents a value for a property represented by this adapter.
 XmlElement findElement(XmlElement xml)
          Find a child element of the specified XmlElement that represents a value for a property represented by this adapter.
 java.lang.Object fromUri(java.lang.String sUri)
          Deserialize an object from a URI element.
 java.lang.Object fromXml(XmlElement xml)
          Deserialize an object from an XML element.
 java.lang.Object get(XmlBean bean)
          Extract the property value from the passed bean reference.
 java.lang.reflect.Method getAccessor()
          Obtain the Method object that is used to call the property accessor.
 XmlBean.BeanInfo getBeanInfo()
          Obtain the containing BeanInfo object.
 java.lang.reflect.Method getCloner()
          Obtain the Method object that is used to deep-clone the property value.
 java.util.Iterator getElements(XmlElement xml)
          Get an iterator of child elements of the specified XmlElement that represent values for a property represented by this adapter.
 java.lang.String getLocalXmlName()
          Determine the "local" XML element name that will be used to hold the property value.
 java.lang.reflect.Method getMutator()
          Obtain the Method object that is used to call the property mutator.
 java.lang.String getName()
          Obtain the name of the property that this PropertyAdapter handles.
 java.lang.String getNamespacePrefix()
          Determine the default namespace prefix for the property.
 java.lang.String getNamespaceUri()
          Determine the namespace URI for the property.
 java.lang.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).
 java.lang.String getXmlName()
          Return the XML element name used to generate an XML.
 int hash(java.lang.Object o)
          Compute a hash code for the passed object.
 boolean isAnonymous()
          Determine if this property does not have a designated element name.
 boolean isAttribute()
          Determine if the property is stored in an XML attribute instead of an XML element.
abstract  boolean isCloneRequired()
          Determine if the property value must be deep-cloned.
 boolean isElementMatch(XmlElement xml)
          Check whether or not the passed element matches to the property's local name and Namespace URI.
 boolean isEmpty(java.lang.Object o)
          Determine if the specified value is empty.
 java.lang.Object readExternal(java.io.DataInput in)
          Read a value from the passed DataInput object.
 java.lang.Object readXml(XmlElement xml)
          Deserialize an object from XML.
 void set(XmlBean bean, java.lang.Object o)
          Store the property value in the passed bean.
 void setNamespacePrefix(java.lang.String sPrefix)
          Set the default Namespace prefix for this property.
 java.lang.String toString()
          Debugging support.
 java.lang.String toUri(java.lang.Object o)
          Serialize an object into a URI element.
 XmlElement toXml(java.lang.Object o)
          Serialize an object into an XML element.
 void writeExternal(java.io.DataOutput out, java.lang.Object o)
          Write the specified data to the passed DataOutput object.
 void writeXml(XmlElement xml, java.lang.Object o)
          Serialize an object into an XML element.

 

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

 

Field Detail

NOPARAMS

protected static final java.lang.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 java.lang.String m_sName
The property name.

m_sXml

protected java.lang.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 java.lang.Class m_clzType
The type of the property.

m_methodGet

protected java.lang.reflect.Method m_methodGet
The property "accessor" method.

m_methodSet

protected java.lang.reflect.Method m_methodSet
The property "mutator" method.

m_methodClone

protected java.lang.reflect.Method m_methodClone
The "public Object clone()" method for the property type, if available.

m_sNmsUri

protected java.lang.String m_sNmsUri
The namespace URI for this property.

m_sNmsPrefix

protected java.lang.String m_sNmsPrefix
The namespace prefix for this property.

Constructor Detail

PropertyAdapter

protected PropertyAdapter(XmlBean.BeanInfo infoBean,
                          java.lang.Class clzType,
                          java.lang.String sName,
                          java.lang.String sXml,
                          XmlElement xml)
Construct a PropertyAdapter. <p/> 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 property
clzType - the type of the property
sName - the property name
sXml - the XML tag name
xml - 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 java.lang.String getName()
Obtain the name of the property that this PropertyAdapter handles.
Returns:
the property name

getLocalXmlName

public java.lang.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 java.lang.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.
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 java.util.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 java.lang.String getNamespaceUri()
Determine the namespace URI for the property.
Returns:
the URI that qualifies the Namespace for this property

getNamespacePrefix

public java.lang.String getNamespacePrefix()
Determine the default namespace prefix for the property.
Returns:
the default Namespace prefix for this property

setNamespacePrefix

public void setNamespacePrefix(java.lang.String sPrefix)
Set the default Namespace prefix for this property.
Parameters:
sPrefix - the new default namespace for this property

getType

public java.lang.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 java.lang.reflect.Method getAccessor()
Obtain the Method object that is used to call the property accessor.
Returns:
the accessor (getter) method for the property

getMutator

public java.lang.reflect.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 java.lang.reflect.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 java.lang.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(java.lang.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,
                java.lang.Object o)
Store the property value in the passed bean.
Parameters:
bean - the XML bean object to store the property value into
o - the property value

hash

public int hash(java.lang.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(java.lang.Object o1,
                           java.lang.Object o2)
Compare the two passed objects for equality.
Parameters:
o1 - the first object
o2 - the second object
Returns:
true if the two objects are equal

clone

public java.lang.Object clone(java.lang.Object o)
Make a clone of the passed object.
Parameters:
o - the object to clone
Returns:
a clone of the passed object

fromXml

public java.lang.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:
java.lang.UnsupportedOperationException - if the property cannot be read from a single XML element

toXml

public XmlElement toXml(java.lang.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:
java.lang.UnsupportedOperationException - if the property cannot be written to a single XML element

readXml

public java.lang.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,
                     java.lang.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 to
o - the object to serialize (may be null)

fromUri

public java.lang.Object fromUri(java.lang.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:
java.lang.UnsupportedOperationException - if the property cannot be read from a URI element

toUri

public java.lang.String toUri(java.lang.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:
java.lang.UnsupportedOperationException - if the property cannot be written to a URI element

readExternal

public java.lang.Object readExternal(java.io.DataInput in)
                              throws java.io.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:
java.io.IOException - if an I/O exception occurs

writeExternal

public void writeExternal(java.io.DataOutput out,
                          java.lang.Object o)
                   throws java.io.IOException
Write the specified data to the passed DataOutput object.
Parameters:
out - the DataOutput stream to write to
o - the data to write to the DataOutput; never null
Throws:
java.io.IOException - if an I/O exception occurs

toString

public java.lang.String toString()
Debugging support.
Returns:
a String description of this PropertyAdapter object

Skip navigation links

Oracle® Coherence Java API Reference
v3.5

E14977-01


Copyright © 2000, 2009, Oracle. All rights reserved.