Agent System POND 1.2 (28.2.2002)

FIM.Util.XML
Class XMLString

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

public class XMLString
extends Object
implements XMLEncodeable, Serializable

Encodes a string as an XML element. The name of the element is always "XMLString".

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

Constructor Summary
XMLString()
          Create an empty XMLString object.
XMLString(Element elem)
          Creates a new XMLString object from an element.
XMLString(String str)
          Creates a new XMLString object from a string.
 
Method Summary
 void decodeXMLElement(Element elem)
          Restores the contained string from an element.
 boolean equals(Object obj)
          Compares two XMLString objects
 Serializable getAsSerializable()
          Retrieve the string as a Serializable.
 Element getAsXMLElement(Document doc)
          Returns the string encoded as an XML element with the name "XMLString".
 String getString()
          Retrieve the contained string.
 void setString(String str)
          Set the contained string 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

XMLString

public XMLString()
Create an empty XMLString object.

XMLString

public XMLString(String str)
Creates a new XMLString object from a string.
Parameters:
str - the content of the XMLString (may not be null)

XMLString

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

getString

public String getString()
Retrieve the contained string.
Returns:
the contained string

setString

public void setString(String str)
Set the contained string to a new value. The old value will be overwritten and is lost.
Parameters:
str - the string to set

getAsSerializable

public Serializable getAsSerializable()
Retrieve the string as a Serializable.
Specified by:
getAsSerializable in interface XMLEncodeable
Returns:
the string 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 XMLString 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.