Oracle® Coherence Java API Reference
v3.5.3

E15583-01

com.tangosol.run.xml
Class SimpleDocument

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.SimpleValue
                  extended by com.tangosol.run.xml.SimpleElement
                      extended by com.tangosol.run.xml.SimpleDocument
All Implemented Interfaces:
ExternalizableLite, PortableObject, XmlDocument, XmlElement, XmlSerializable, XmlValue, java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class SimpleDocument
extends SimpleElement
implements XmlDocument, java.io.Externalizable

A simple implementation of the XmlElement interface. Protected methods are provided to support inheriting classes.

Author:
cp 2000.10.20

Nested Class Summary
 
Nested classes/interfaces inherited from class com.tangosol.run.xml.SimpleElement
SimpleElement.AttributeMap, SimpleElement.ElementIterator, SimpleElement.ElementList
 
Field Summary
 
Fields inherited from interface com.tangosol.run.xml.XmlValue
TYPE_BINARY, TYPE_BOOLEAN, TYPE_DATE, TYPE_DATETIME, TYPE_DECIMAL, TYPE_DOUBLE, TYPE_INT, TYPE_LONG, TYPE_STRING, TYPE_TIME
 
Constructor Summary
SimpleDocument()
          Construct an empty SimpleDocument.
SimpleDocument(java.lang.String sName)
          Construct a SimpleDocument.
SimpleDocument(java.lang.String sName, java.lang.String sDtdUri, java.lang.String sDtdName)
          Construct a SimpleDocument.
 
Method Summary
protected  void checkMutable()
          Validates that the document is mutable, otherwise throws an UnsupportedOperationException.
 java.lang.Object clone()
          Creates and returns a copy of this XmlDocument.
 boolean equals(java.lang.Object o)
          Compare this XML document and all of its contained information with another XML document for equality.
 void fromXml(XmlElement xml)
          Deserialize the object from an XmlElement.
 java.lang.String getDocumentComment()
          Get the XML comment that appears outside of the root element.
 java.lang.String getDtdName()
          Get the public identifier of the DTD (DOCTYPE) for the document.
 java.lang.String getDtdUri()
          Get the URI of the DTD (DOCTYPE) for the document.
 java.lang.String getEncoding()
          Get the encoding string for the XML document.
 int hashCode()
          Provide a hash value for this XML document and all of its contained information.
 void readExternal(java.io.DataInput in)
          Restore the contents of this object by loading the object's state from the passed DataInput object.
 void readExternal(java.io.ObjectInput in)
          The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
 void readExternal(PofReader in)
          Restore the contents of a user type instance by reading its state using the specified PofReader object.
 void setDocumentComment(java.lang.String sComment)
          Set the XML comment that appears outside of the root element.
 void setDtdName(java.lang.String sName)
          Set the public identifier of the DTD (DOCTYPE) for the document.
 void setDtdUri(java.lang.String sUri)
          Set the URI of the DTD (DOCTYPE) for the document.
 void setEncoding(java.lang.String sEncoding)
          Set the encoding string for the XML document.
 XmlElement toXml()
          Serialize the object into an XmlElement.
 void writeExternal(java.io.DataOutput out)
          Save the contents of this object by storing the object's state into the passed DataOutput object.
 void writeExternal(java.io.ObjectOutput out)
          The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
 void writeExternal(PofWriter out)
          Save the contents of a POF user type instance by writing its state using the specified PofWriter object.
 void writeXml(java.io.PrintWriter out, boolean fPretty)
          Write the XML document, including an XML header and DOCTYPE if one exists.
 
Methods inherited from class com.tangosol.run.xml.SimpleElement
addAttribute, addElement, ensureElement, findElement, getAbsolutePath, getAttribute, getAttributeMap, getComment, getElement, getElementList, getElements, getName, getRoot, getSafeAttribute, getSafeElement, instantiateAttribute, instantiateAttributeMap, instantiateElement, instantiateElementList, isNameMutable, setAttribute, setComment, setName, toString, toString, writeAttributes, writeChildren, writeComment, writeEmptyTag, writeEndTag, writeStartTag, writeValue
 
Methods inherited from class com.tangosol.run.xml.SimpleValue
convert, ensureType, getBinary, getBinary, getBoolean, getBoolean, getDate, getDate, getDateTime, getDateTime, getDecimal, getDecimal, getDouble, getDouble, getInt, getInt, getInternalValue, getLong, getLong, getParent, getString, getString, getTime, getTime, getValue, isAttribute, isContent, isEmpty, isMutable, setAttribute, setBinary, setBoolean, setDate, setDateTime, setDecimal, setDouble, setInt, setInternalValue, setLong, setMutable, setParent, setString, setTime
 
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
 
Methods inherited from interface com.tangosol.run.xml.XmlDocument
toString
 
Methods inherited from interface com.tangosol.run.xml.XmlElement
addAttribute, addElement, ensureElement, findElement, getAbsolutePath, getAttribute, getAttributeMap, getComment, getElement, getElementList, getElements, getName, getRoot, getSafeAttribute, getSafeElement, setAttribute, setComment, setName
 
Methods inherited from interface com.tangosol.run.xml.XmlValue
getBinary, getBinary, getBoolean, getBoolean, getDate, getDate, getDateTime, getDateTime, getDecimal, getDecimal, getDouble, getDouble, getInt, getInt, getLong, getLong, getParent, getString, getString, getTime, getTime, getValue, isAttribute, isContent, isEmpty, isMutable, setBinary, setBoolean, setDate, setDateTime, setDecimal, setDouble, setInt, setLong, setParent, setString, setTime, writeValue
 

Constructor Detail

SimpleDocument

public SimpleDocument()
Construct an empty SimpleDocument. Note: this constructor is needed only to comply with the requirements for the Externalizable and ExternalizableLite interfaces.


SimpleDocument

public SimpleDocument(java.lang.String sName)
Construct a SimpleDocument.

Parameters:
sName - the name of the root element

SimpleDocument

public SimpleDocument(java.lang.String sName,
                      java.lang.String sDtdUri,
                      java.lang.String sDtdName)
Construct a SimpleDocument.

Parameters:
sName - the name of the root element
sDtdUri - the URI of the DTD (system identifier)
sDtdName - the name of the DTD (public identifier); may be null
Method Detail

getDtdUri

public java.lang.String getDtdUri()
Get the URI of the DTD (DOCTYPE) for the document. This is referred to as the System Identifier by the XML specification. For example: http://java.sun.com/j2ee/dtds/web-app_2_2.dtd

Specified by:
getDtdUri in interface XmlDocument
Returns:
the document type URI

setDtdUri

public void setDtdUri(java.lang.String sUri)
Set the URI of the DTD (DOCTYPE) for the document. This is referred to as the System Identifier by the XML specification.

Specified by:
setDtdUri in interface XmlDocument
Parameters:
sUri - the document type URI

getDtdName

public java.lang.String getDtdName()
Get the public identifier of the DTD (DOCTYPE) for the document. For example: -//Sun Microsystems, Inc.//DTD Web Application 1.2//EN

Specified by:
getDtdName in interface XmlDocument
Returns:
the DTD public identifier

setDtdName

public void setDtdName(java.lang.String sName)
Set the public identifier of the DTD (DOCTYPE) for the document.

Specified by:
setDtdName in interface XmlDocument
Parameters:
sName - the DTD public identifier

getEncoding

public java.lang.String getEncoding()
Get the encoding string for the XML document. Documents that are parsed may or may not have the encoding string from the persistent form of the document.

Specified by:
getEncoding in interface XmlDocument
Returns:
the encoding set for the document

setEncoding

public void setEncoding(java.lang.String sEncoding)
Set the encoding string for the XML document.

Specified by:
setEncoding in interface XmlDocument
Parameters:
sEncoding - the encoding that the document will use

getDocumentComment

public java.lang.String getDocumentComment()
Get the XML comment that appears outside of the root element. This differs from the Comment property of this object, which refers to the comment within the root element.

Specified by:
getDocumentComment in interface XmlDocument
Returns:
the document comment

setDocumentComment

public void setDocumentComment(java.lang.String sComment)
Set the XML comment that appears outside of the root element. This differs from the Comment property of this object, which refers to the comment within the root element.

Specified by:
setDocumentComment in interface XmlDocument
Parameters:
sComment - the document comment

writeXml

public void writeXml(java.io.PrintWriter out,
                     boolean fPretty)
Write the XML document, including an XML header and DOCTYPE if one exists. This overrides the contract of the XmlElement super interface.

Specified by:
writeXml in interface XmlDocument
Specified by:
writeXml in interface XmlElement
Overrides:
writeXml in class SimpleElement
Parameters:
out - a PrintWriter object to use to write to
fPretty - true to specify that the output is intended to be as human readable as possible

hashCode

public int hashCode()
Provide a hash value for this XML document and all of its contained information. Note that this overrides the contract of the hashCode method in the super interface XmlElement. The hash value is defined as a xor of the following:
  1. the hashCode from the root element
  2. the hashCode from the document type (uri and optional name)

Specified by:
hashCode in interface XmlDocument
Specified by:
hashCode in interface XmlElement
Specified by:
hashCode in interface XmlValue
Overrides:
hashCode in class SimpleElement
Returns:
the hash value for this XML document

equals

public boolean equals(java.lang.Object o)
Compare this XML document and all of its contained information with another XML document for equality. Note that this overrides the contract of the equals method in the super interface XmlElement.

Specified by:
equals in interface XmlDocument
Specified by:
equals in interface XmlElement
Specified by:
equals in interface XmlValue
Overrides:
equals in class SimpleElement
Returns:
true if the documents are equal, false otherwise

clone

public java.lang.Object clone()
Creates and returns a copy of this XmlDocument.

Specified by:
clone in interface XmlDocument
Specified by:
clone in interface XmlElement
Specified by:
clone in interface XmlValue
Overrides:
clone in class SimpleElement
Returns:
a clone of this instance.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the stream to write the object to
Throws:
java.io.IOException - Includes any I/O exceptions that may occur

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
java.io.IOException - if I/O errors occur
java.lang.ClassNotFoundException - If the class for an object being restored cannot be found.

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException
Restore the contents of this object by loading the object's state from the passed DataInput object.

Specified by:
readExternal in interface ExternalizableLite
Overrides:
readExternal in class SimpleElement
Parameters:
in - the DataInput stream to read data from in order to restore the state of this object
Throws:
java.io.IOException - if an I/O exception occurs
java.io.NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Save the contents of this object by storing the object's state into the passed DataOutput object.

Specified by:
writeExternal in interface ExternalizableLite
Overrides:
writeExternal in class SimpleElement
Parameters:
out - the DataOutput stream to write the state of this object to
Throws:
java.io.IOException - if an I/O exception occurs

readExternal

public void readExternal(PofReader in)
                  throws java.io.IOException
Restore the contents of a user type instance by reading its state using the specified PofReader object.

Specified by:
readExternal in interface PortableObject
Overrides:
readExternal in class SimpleElement
Parameters:
in - the PofReader from which to read the object's state
Throws:
java.io.IOException - if an I/O error occurs

writeExternal

public void writeExternal(PofWriter out)
                   throws java.io.IOException
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.

Specified by:
writeExternal in interface PortableObject
Overrides:
writeExternal in class SimpleElement
Parameters:
out - the PofWriter to which to write the object's state
Throws:
java.io.IOException - if an I/O error occurs

toXml

public XmlElement toXml()
Serialize the object into an XmlElement.

Specified by:
toXml in interface XmlSerializable
Overrides:
toXml in class SimpleElement
Returns:
an XmlElement that contains the serialized form of the object

fromXml

public void fromXml(XmlElement xml)
Deserialize the object from an XmlElement. This method can throw one of several RuntimeExceptions.

Specified by:
fromXml in interface XmlSerializable
Overrides:
fromXml in class SimpleElement
Parameters:
xml - an XmlElement that contains the serialized form of the object
Throws:
java.lang.UnsupportedOperationException - if this element is immutable

checkMutable

protected void checkMutable()
Validates that the document is mutable, otherwise throws an UnsupportedOperationException.

Overrides:
checkMutable in class SimpleElement
Throws:
java.lang.UnsupportedOperationException

Oracle® Coherence Java API Reference
v3.5.3

E15583-01

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