Package com.tangosol.run.xml
Class SimpleDocument
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.BitHelper
com.tangosol.util.ExternalizableHelper
com.tangosol.run.xml.SimpleValue
com.tangosol.run.xml.SimpleElement
com.tangosol.run.xml.SimpleDocument
- All Implemented Interfaces:
ExternalizableLite
,PortableObject
,XmlDocument
,XmlElement
,XmlSerializable
,XmlValue
,Externalizable
,Serializable
,Cloneable
A simple implementation of the XmlElement interface. Protected methods are
provided to support inheriting classes.
- Author:
- cp 2000.10.20
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.run.xml.SimpleElement
SimpleElement.AttributeMap, SimpleElement.ElementIterator, SimpleElement.ElementList
Nested classes/interfaces inherited from class com.tangosol.util.ExternalizableHelper
ExternalizableHelper.DecoratedMultiBufferReadBuffer, ExternalizableHelper.DefaultObjectStreamFactory, ExternalizableHelper.FormatAwareCompressor, ExternalizableHelper.IntDecoratedObject, ExternalizableHelper.Shielded, ExternalizableHelper.ShieldedDataOutputStream, ExternalizableHelper.ShieldedInputStream, ExternalizableHelper.ShieldedObjectOutputStream, ExternalizableHelper.ShieldedOutputStream, ExternalizableHelper.SimpleXmlBeanClassCache, ExternalizableHelper.Stats, ExternalizableHelper.XmlBeanClassCache
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Fields inherited from class com.tangosol.util.ExternalizableHelper
BINARY_SIZE, CHUNK_SIZE, CHUNK_THRESHOLD, CONVERTER_FROM_BINARY, CONVERTER_STRIP_INTDECO, CONVERTER_TO_BINARY, DECO_APP_1, DECO_APP_2, DECO_APP_3, DECO_BACKUP, DECO_CUSTOM, DECO_EXPIRY, DECO_ID_MAX, DECO_ID_MIN, DECO_JCACHE, DECO_JCACHE_SYNTHETIC, DECO_MEMCACHED, DECO_PUSHREP, DECO_QUEUE_METADATA, DECO_RSVD_1, DECO_STORE, DECO_TX, DECO_VALUE, DECO_WLS, EMPTY_BINARY_ARRAY, FMT_B_ARRAY, FMT_BIN_DECO, FMT_BIN_EXT_DECO, FMT_BINARY, FMT_BOOLEAN, FMT_BYTE, FMT_DECIMAL, FMT_DOUBLE, FMT_EXT, FMT_FLOAT, FMT_IDO, FMT_INT, FMT_INTEGER, FMT_LONG, FMT_NONE, FMT_NULL, FMT_OBJ_EXT, FMT_OBJ_SER, FMT_OPT, FMT_OPT_DOUBLE, FMT_OPT_INT, FMT_OPT_LONG, FMT_SHORT, FMT_STRING, FMT_UNKNOWN, FMT_XML_BEAN, FMT_XML_SER, FORCE_RESOLVING_STREAMS, LAMBDA_SERIALIZATION, MAX_DECO_HEADER_BYTES, PACKED_INT_SIZE, PACKED_LONG_SIZE, PROPERTY_CONFIG, s_streamfactory, TRINT_DOMAIN_SPAN, TRINT_MAX_VALUE, TRINT_MAX_VARIANCE, USE_POF_STREAMS, USE_XMLBEAN_CLASS_CACHE, XMLBEAN_CLASS_CACHE
Fields inherited from class com.tangosol.util.Base
LOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
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
ConstructorDescriptionConstruct an empty SimpleDocument.SimpleDocument
(String sName) Construct a SimpleDocument.SimpleDocument
(String sName, String sDtdUri, String sDtdName) Construct a SimpleDocument. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Validates that the document is mutable, otherwise throws an UnsupportedOperationException.clone()
Creates and returns a copy of this XmlDocument.boolean
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.Get the XML comment that appears outside of the root element.Get the public identifier of the DTD (DOCTYPE) for the document.Get the URI of the DTD (DOCTYPE) for the document.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
Restore the contents of a user type instance by reading its state using the specified PofReader object.void
Restore the contents of this object by loading the object's state from the passed DataInput object.void
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
setDocumentComment
(String sComment) Set the XML comment that appears outside of the root element.void
setDtdName
(String sName) Set the public identifier of the DTD (DOCTYPE) for the document.void
Set the URI of the DTD (DOCTYPE) for the document.void
setEncoding
(String sEncoding) Set the encoding string for the XML document.toXml()
Serialize the object into an XmlElement.void
writeExternal
(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.void
writeExternal
(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.void
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
writeXml
(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, getQualifiedName, 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.ExternalizableHelper
asBinary, calculatePackedLength, calculatePackedLength, checkObjectInputFilter, checkObjectInputFilter, checkObjectInputFilter, convertUTF, decodeExpiry, decorate, decorate, decorate, decorate, decorate, decorateBinary, encodeExpiry, ensureSerializer, extractIntDecoration, fromBinary, fromBinary, fromBinary, fromBinary, fromBinary, fromBinary, fromByteArray, fromByteArray, getClass, getConfigSerialFilter, getConfigSerialFilterFactory, getDecoration, getDecoration, getDecorations, getDeltaCompressor, getInputStream, getNewObjectInput, getObjectInput, getObjectInputFilter, getObjectOutput, getObjectStreamFactory, getOutputStream, getShieldedOutputStream, getStreamFormat, getUndecorated, getUndecorated, isDecorated, isDecorated, isIntDecorated, isIntDecorated, isResolving, isSerializable, isSerializerCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, loadClass, loadResource, main, makeTrint, readBigDecimal, readBigInteger, readBooleanArray, readBooleanArray, readByteArray, readCharArray, readCharArray, readCollection, readDate, readDoubleArray, readDoubleArray, readExternalizableLite, readExternalizableLite, readFloatArray, readFloatArray, readInt, readInt, readIntArray, readIntArray, readIntArray2d, readLargeBooleanArray, readLargeByteArray, readLargeCharArray, readLargeDoubleArray, readLargeFloatArray, readLargeIntArray, readLargeLongArray, readLargeObjectArray, readLargeStringArray, readLong, readLong, readLongArray, readLongArray, readMap, readMap, readObject, readObject, readObjectArray, readObjectArray, readSafeUTF, readSafeUTF, readSerializable, readSerializable, readStringArray, readStringArray, readTime, readTimestamp, readTrint, readUnsignedTrint, readUTF, readXmlBean, readXmlSerializable, readXmlSerializable, realize, removeIntDecoration, removeIntDecoration, replace, reportIncompatibleSerializers, setObjectStreamFactory, toBinary, toBinary, toBinary, toByteArray, toByteArray, toByteArray, toLiteBinary, toLong, undecorate, undecorate, validateBufferSize, validateLoadArray, validateLoadClass, writeBigDecimal, writeBigInteger, writeBooleanArray, writeByteArray, writeCollection, writeDate, writeDoubleArray, writeExternalizableLite, writeFloatArray, writeInt, writeInt, writeIntArray2d, writeLong, writeLong, writeMap, writeObject, writeSafeUTF, writeSafeUTF, writeSerializable, writeStringArray, writeTime, writeTimestamp, writeTrint, writeTrint, writeUTF, writeXmlBean, writeXmlSerializable
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, toBytes, toBytes, toBytes, toBytes, toInt, toInt, toLong
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
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, getQualifiedName, 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 Details
-
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
Construct a SimpleDocument.- Parameters:
sName
- the name of the root element
-
SimpleDocument
Construct a SimpleDocument.- Parameters:
sName
- the name of the root elementsDtdUri
- the URI of the DTD (system identifier)sDtdName
- the name of the DTD (public identifier); may be null
-
-
Method Details
-
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 interfaceXmlDocument
- Returns:
- the document type URI
-
setDtdUri
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 interfaceXmlDocument
- Parameters:
sUri
- the document type URI
-
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 interfaceXmlDocument
- Returns:
- the DTD public identifier
-
setDtdName
Set the public identifier of the DTD (DOCTYPE) for the document.- Specified by:
setDtdName
in interfaceXmlDocument
- Parameters:
sName
- the DTD public identifier
-
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 interfaceXmlDocument
- Returns:
- the encoding set for the document
-
setEncoding
Set the encoding string for the XML document.- Specified by:
setEncoding
in interfaceXmlDocument
- Parameters:
sEncoding
- the encoding that the document will use
-
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 interfaceXmlDocument
- Returns:
- the document comment
-
setDocumentComment
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 interfaceXmlDocument
- Parameters:
sComment
- the document comment
-
writeXml
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 interfaceXmlDocument
- Specified by:
writeXml
in interfaceXmlElement
- Overrides:
writeXml
in classSimpleElement
- Parameters:
out
- a PrintWriter object to use to write tofPretty
- 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:- the hashCode from the root element
- the hashCode from the document type (uri and optional name)
- Specified by:
hashCode
in interfaceXmlDocument
- Specified by:
hashCode
in interfaceXmlElement
- Specified by:
hashCode
in interfaceXmlValue
- Overrides:
hashCode
in classSimpleElement
- Returns:
- the hash value for this XML document
-
equals
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 interfaceXmlDocument
- Specified by:
equals
in interfaceXmlElement
- Specified by:
equals
in interfaceXmlValue
- Overrides:
equals
in classSimpleElement
- Returns:
- true if the documents are equal, false otherwise
-
clone
Creates and returns a copy of this XmlDocument.- Specified by:
clone
in interfaceXmlDocument
- Specified by:
clone
in interfaceXmlElement
- Specified by:
clone
in interfaceXmlValue
- Overrides:
clone
in classSimpleElement
- Returns:
- a clone of this instance.
-
writeExternal
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 interfaceExternalizable
- Parameters:
out
- the stream to write the object to- Throws:
IOException
- Includes any I/O exceptions that may occur
-
readExternal
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 interfaceExternalizable
- Parameters:
in
- the stream to read data from in order to restore the object- Throws:
IOException
- if I/O errors occurClassNotFoundException
- If the class for an object being restored cannot be found.
-
readExternal
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in interfaceExternalizableLite
- Overrides:
readExternal
in classSimpleElement
- Parameters:
in
- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Overrides:
writeExternal
in classSimpleElement
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-
readExternal
Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternal
in interfacePortableObject
- Overrides:
readExternal
in classSimpleElement
- Parameters:
in
- the PofReader from which to read the object's state- Throws:
IOException
- if an I/O error occurs
-
writeExternal
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternal
in interfacePortableObject
- Overrides:
writeExternal
in classSimpleElement
- Parameters:
out
- the PofWriter to which to write the object's state- Throws:
IOException
- if an I/O error occurs
-
toXml
Serialize the object into an XmlElement.- Specified by:
toXml
in interfaceXmlSerializable
- Overrides:
toXml
in classSimpleElement
- Returns:
- an XmlElement that contains the serialized form of the object
-
fromXml
Deserialize the object from an XmlElement. This method can throw one of several RuntimeExceptions.- Specified by:
fromXml
in interfaceXmlSerializable
- Overrides:
fromXml
in classSimpleElement
- Parameters:
xml
- an XmlElement that contains the serialized form of the object- Throws:
UnsupportedOperationException
- if this element is immutable
-
checkMutable
protected void checkMutable()Validates that the document is mutable, otherwise throws an UnsupportedOperationException.- Overrides:
checkMutable
in classSimpleElement
- Throws:
UnsupportedOperationException
- if the document is immutable
-