Agent System POND 1.2 (28.2.2002)

FIM.Util.XML
Class XMLByteArray

java.lang.Object
  |
  +--FIM.Util.XML.XMLByteArray
All Implemented Interfaces:
Serializable, XMLEncodeable

public class XMLByteArray
extends Object
implements XMLEncodeable, Serializable

Encodes a byte array as an XML element. The name of the element is always "XMLByteArray".

Version:
1.0
Author:
Michael Sonntag
See Also:
Serialized Form

Constructor Summary
XMLByteArray()
          Create an empty XMLByteArray object.
XMLByteArray(byte[] data)
          Creates a new XMLByteArray object from a byte array.
XMLByteArray(Element elem)
          Creates a new XMLByteArray object from an element.
 
Method Summary
 void decodeXMLElement(Element elem)
          Restores the contained string from an element.
 boolean equals(Object obj)
          Compares two XMLByteArray objects
 Serializable getAsSerializable()
          Retrieve the byte array as a Serializable.
 Element getAsXMLElement(Document doc)
          Returns the string encoded as an XML element with the name "XMLString".
 byte[] getBytes()
          Retrieve the contained data as a byte arra.
 void setBytes(byte[] data)
          Set the contained data to a new value.
 String toString()
          Retrieve the contained string.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XMLByteArray

public XMLByteArray()
Create an empty XMLByteArray object.

XMLByteArray

public XMLByteArray(byte[] data)
Creates a new XMLByteArray object from a byte array.
Parameters:
data - the content of the XMLString

XMLByteArray

public XMLByteArray(Element elem)
Creates a new XMLByteArray object from an element.
Parameters:
data - the element to parse
Method Detail

getBytes

public byte[] getBytes()
Retrieve the contained data as a byte arra.
Returns:
the contained data

setBytes

public void setBytes(byte[] data)
Set the contained data to a new value. The old value will be overwritten and is lost.
Parameters:
data - the data to set

getAsSerializable

public Serializable getAsSerializable()
Retrieve the byte array as a Serializable.
Specified by:
getAsSerializable in interface XMLEncodeable
Returns:
the byte array as a serializable

getAsXMLElement

public Element getAsXMLElement(Document doc)
Returns the string encoded as an XML element with the name "XMLString". The string itself can be everything, as it is contained in a CDATA section (and "]]>" is escaped, so it may also be contained).
Specified by:
getAsXMLElement in interface XMLEncodeable
Returns:
the string encoded in an XML element

decodeXMLElement

public void decodeXMLElement(Element elem)
                      throws IllegalArgumentException
Restores the contained string from an element.
Specified by:
decodeXMLElement in interface XMLEncodeable
Parameters:
elem - the element containing the string
Throws:
IllegalArgumentException - if the element is wrong or ill-formed (tag name not "XMLString" or does not contain only a CDATASection)

toString

public String toString()
Retrieve the contained string.
Specified by:
toString in interface XMLEncodeable
Overrides:
toString in class Object
Returns:
the contained string

equals

public boolean equals(Object obj)
Compares two XMLByteArray objects
Overrides:
equals in class Object
Parameters:
obj - the object to compare to this one

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.