Class PrimitiveArrayAdapter

    • Constructor Detail

      • PrimitiveArrayAdapter

        public PrimitiveArrayAdapter​(XmlBean.BeanInfo infoBean,
                                     Class clzType,
                                     String sName,
                                     String sXml,
                                     XmlElement xml)
        Construct a PrimitiveArrayAdapter.
        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

      • isStringable

        public boolean isStringable()
        Returns:
        true if the adapter can format the array of primitive values to/from a single value (e.g. char[], byte[])
      • hash

        public abstract int hash​(Object o)
        compute a hash code for the passed object.
        Overrides:
        hash in class PropertyAdapter
        Parameters:
        o - the object to compute a hash code for
        Returns:
        an integer hash code
      • equalsValue

        public abstract boolean equalsValue​(Object o1,
                                            Object o2)
        Compare the two passed objects for equality.
        Overrides:
        equalsValue in class PropertyAdapter
        Parameters:
        o1 - the first object
        o2 - the second object
        Returns:
        true if the two objects are equal
      • clone

        public abstract Object clone​(Object o)
        Make a clone of the passed object.
        Overrides:
        clone in class PropertyAdapter
        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.
        Overrides:
        fromXml in class IterableAdapter
        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.
        Overrides:
        toXml in class IterableAdapter
        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.
        Overrides:
        readXml in class PropertyAdapter
        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.
        Overrides:
        writeXml in class PropertyAdapter
        Parameters:
        xml - the XML element containing the XML elements to serialize to
        o - the object to serialize (may be null)
      • readElements

        protected Object readElements​(XmlElement xml)
        Specified by:
        readElements in class IterableAdapter
        Parameters:
        xml - the XML element containing the XML elements to deserialize from
        Returns:
        the object deserialized from the XML (not null)
      • writeElements

        protected void writeElements​(XmlElement xml,
                                     Object o)
        Specified by:
        writeElements in class IterableAdapter
        Parameters:
        xml - the XML element to which the iterable elements are written
        o - the object to serialize (not null)
      • fromXmlString

        public Object fromXmlString​(XmlElement xml)
        Deserialize a primitive array from a single XML element.
        Parameters:
        xml - the XML element to deserialize from (not null)
        Returns:
        the object deserialized from the XML element
        Throws:
        UnsupportedOperationException - if the property cannot be read from a single XML element
      • toXmlString

        public XmlElement toXmlString​(Object o)
        Serialize a primitive array into a single XML element.
        Parameters:
        o - the object to serialize (not null)
        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
      • readSparseArray

        public abstract Object readSparseArray​(Iterator iter,
                                               int c)
        Read a sparse array of primitive values.
        Parameters:
        iter - the iterator of XmlElement objects
        c - the size of the array
        Returns:
        an array of primitive values
      • readArray

        public abstract Object readArray​(Iterator iter,
                                         XmlElement xml,
                                         boolean fNested)
        Read an array of primitive values.
        Parameters:
        iter - the iterator of XmlElement objects
        xml - the XmlElement from which the iterator was obtained
        fNested - true if the array is nested under an array tag
        Returns:
        an array of primitive values
      • writeSparseArray

        public abstract void writeSparseArray​(XmlElement xml,
                                              Object o,
                                              String sElement)
        Write a sparse array of primitive values.
        Parameters:
        xml - the XmlElement that will contain the array
        o - the primitive array
        sElement - the name of the element containing an element value
      • writeArray

        public abstract void writeArray​(XmlElement xml,
                                        Object o,
                                        String sElement)
        Write a sparse array of primitive values.
        Parameters:
        xml - the XmlElement that will contain the array elements
        o - the primitive array
        sElement - the name of the element containing an element value