Package com.tangosol.run.xml
Class SimpleElement
- 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
-
- All Implemented Interfaces:
ExternalizableLite
,PortableObject
,XmlElement
,XmlSerializable
,XmlValue
,Serializable
,Cloneable
- Direct Known Subclasses:
SimpleDocument
public class SimpleElement extends SimpleValue implements XmlElement, XmlSerializable
A simple implementation of the XmlElement interface. Protected methods are provided to support inheriting classes.- Author:
- cp 2000.10.20
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SimpleElement.AttributeMap
A Map implementation using a list that can be a read-only map that supports only Strings for keys and XmlValue for values.protected class
SimpleElement.ElementIterator
Provides an Iterator implementation that exposes only those Elements from the Element list that match a certain name.protected class
SimpleElement.ElementList
An implementation of List that only supports XmlElements as the content of the List.-
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
Constructors Constructor Description SimpleElement()
Construct an empty SimpleElement.SimpleElement(String sName)
Construct a SimpleElement.SimpleElement(String sName, Object oValue)
Construct a SimpleElement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XmlValue
addAttribute(String sName)
Provides a means to add a new attribute value.XmlElement
addElement(String sName)
Create a new element and add it as a child element to this element.protected void
checkMutable()
Validates that the element is mutable, otherwise throws an UnsupportedOperationException.Object
clone()
Creates and returns a copy of this SimpleElement.XmlElement
ensureElement(String sPath)
Ensure that a child element exists.boolean
equals(Object o)
Compare this XML element and all of its contained information with another XML element for equality.XmlElement
findElement(String sPath)
Find a child element with the specified '/'-delimited path.void
fromXml(XmlElement xml)
Deserialize the object from an XmlElement.String
getAbsolutePath()
Get the '/'-delimited path of the element starting from the root element.XmlValue
getAttribute(String sName)
Get an attribute value.Map
getAttributeMap()
Get the map of all attributes.String
getComment()
Get the text of any comments that are in the XML element.XmlElement
getElement(String sName)
Get a child element.List
getElementList()
Get the list of all child elements.Iterator
getElements(String sName)
Get an iterator of child elements that have a specific name.String
getName()
Get the name of the element.QualifiedName
getQualifiedName()
Obtains theQualifiedName
of theXmlElement
.XmlElement
getRoot()
Get the root element.XmlValue
getSafeAttribute(String sName)
Get an attribute value, and return a temporary value if the attribute does not exist.XmlElement
getSafeElement(String sPath)
Return the specified child element using the same path notation as supported by findElement, but return a read-only element if the specified element does not exist.int
hashCode()
Provide a hash value for this XML element and all of its contained information.protected XmlValue
instantiateAttribute()
Instantiate an XmlValue implementation for an attribute value.protected Map
instantiateAttributeMap()
Instantiate a Map implementation that will support the name to value map used to hold attributes.protected XmlElement
instantiateElement(String sName, Object oValue)
Instantiate an XmlElement implementation for an element.protected List
instantiateElementList()
Instantiate a List implementation that will hold child elements.protected boolean
isNameMutable()
Determine if the name can be changed.void
readExternal(PofReader in)
Restore the contents of a user type instance by reading its state using the specified PofReader object.void
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from the passed DataInput object.void
setAttribute(String sName, XmlValue val)
Set an attribute value.void
setComment(String sComment)
Set the text of this element's comment.void
setName(String sName)
Set the Name of the element.String
toString()
Format the XML element and all its contained information into a String in a display format.String
toString(boolean fPretty)
Format the XML element and all its contained information into a String in a display format.XmlElement
toXml()
Serialize the object into an XmlElement.protected void
writeAttributes(PrintWriter out, boolean fPretty)
Write the attributes as part of a start tag.protected void
writeChildren(PrintWriter out, boolean fPretty)
Write the element as it will appear in XML.protected void
writeComment(PrintWriter out, boolean fPretty)
Write the element as it will appear in XML.protected void
writeEmptyTag(PrintWriter out, boolean fPretty)
Write the element as a combined start/end tag.protected void
writeEndTag(PrintWriter out, boolean fPretty)
Write the element's end tag.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.protected void
writeStartTag(PrintWriter out, boolean fPretty)
Write the element's start tag.void
writeValue(PrintWriter out, boolean fPretty)
Write the value as it will appear in XML.void
writeXml(PrintWriter out, boolean fPretty)
Write the element as it will appear in XML.-
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, isPatchCompatible, isPatchCompatible, isResolving, isSerializable, isSerializerCompatible, isVersionCompatible, isVersionCompatible, 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.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
-
-
-
-
Constructor Detail
-
SimpleElement
public SimpleElement()
Construct an empty SimpleElement. Note: this constructor is needed only to comply with the requirements for the Externalizable and ExternalizableLite interfaces.
-
SimpleElement
public SimpleElement(String sName)
Construct a SimpleElement.- Parameters:
sName
- the name of the element
-
-
Method Detail
-
getName
public String getName()
Get the name of the element.- Specified by:
getName
in interfaceXmlElement
- Returns:
- the element name
-
setName
public void setName(String sName)
Set the Name of the element. This method is intended primarily to be utilized to configure a newly instantiated element before adding it as a child element to another element. Implementations of this interface that support read-only documents are expected to throw UnsupportedOperationException from this method if the document (or this element) is in a read-only state. If this XmlElement has a parent XmlElement, then the implementation of this interface is permitted to throw UnsupportedOperationException from this method. This results from typical document implementations in which the name of an element that is a child of another element is immutable; the W3C DOM interfaces are one example.- Specified by:
setName
in interfaceXmlElement
- Parameters:
sName
- the new element name- Throws:
IllegalArgumentException
- if the name is null or if the name is not a legal XML tag nameUnsupportedOperationException
- if the element cannot be renamed
-
getQualifiedName
public QualifiedName getQualifiedName()
Obtains theQualifiedName
of theXmlElement
.- Specified by:
getQualifiedName
in interfaceXmlElement
- Returns:
- the
QualifiedName
-
getRoot
public XmlElement getRoot()
Get the root element. This is a convenience method. Parent element is retrived using getParent().- Specified by:
getRoot
in interfaceXmlElement
- Returns:
- the root element for this element
-
getAbsolutePath
public String getAbsolutePath()
Get the '/'-delimited path of the element starting from the root element. This is a convenience method. Elements are retrieved by simple name using getName().- Specified by:
getAbsolutePath
in interfaceXmlElement
- Returns:
- the element path
-
getElementList
public List getElementList()
Get the list of all child elements. The contents of the list implement the XmlValue interface. If this XmlElement is mutable, then the list returned from this method is expected to be mutable as well. An element should be fully configured before it is added to the list:- The List implementation is permitted (and most implementations are expected) to instantiate its own copy of any XmlElement objects added to it.
- Certain properties of an element (such as Name) may not be settable once the element has been added. (See the comments for the setName method.)
- Specified by:
getElementList
in interfaceXmlElement
- Returns:
- a List containing all elements of this XmlElement
-
getElement
public XmlElement getElement(String sName)
Get a child element. This is a convenience method. Elements are accessed and manipulated via the list returned from getElementList(). If multiple child elements exist that have the specified name, then the behavior of this method is undefined, and it is permitted to return any one of the matching elements, to return null, or to throw an arbitrary runtime exception.- Specified by:
getElement
in interfaceXmlElement
- Parameters:
sName
- the specified name- Returns:
- the specified element as an object implementing XmlElement, or null if the specified child element does not exist
-
getElements
public Iterator getElements(String sName)
Get an iterator of child elements that have a specific name. This is a convenience method. Elements are accessed and manipulated via the list returned from getElementList().- Specified by:
getElements
in interfaceXmlElement
- Parameters:
sName
- the specified name- Returns:
- an iterator containing all child elements of the specified name
-
addElement
public XmlElement addElement(String sName)
Create a new element and add it as a child element to this element. This is a convenience method. Elements are accessed and manipulated via the list returned from getElementList().- Specified by:
addElement
in interfaceXmlElement
- Parameters:
sName
- the name for the new element- Returns:
- the new XmlElement object
- Throws:
IllegalArgumentException
- if the name is null or if the name is not a legal XML tag nameUnsupportedOperationException
- if this element is immutable or otherwise cannot add a child element
-
findElement
public XmlElement findElement(String sPath)
Find a child element with the specified '/'-delimited path. This is based on a subset of the XPath specification, supporting:- Leading '/' to specify root
- Use of '/' as a path delimiter
- Use of '..' to specify parent
- Specified by:
findElement
in interfaceXmlElement
- Parameters:
sPath
- element path- Returns:
- the specified element as an object implementing XmlElement, or null if the specified child element does not exist
-
getSafeElement
public XmlElement getSafeElement(String sPath)
Return the specified child element using the same path notation as supported by findElement, but return a read-only element if the specified element does not exist. This method never returns null. This is a convenience method. Elements are accessed and manipulated via the list returned from getElementList(). If multiple child elements exist that have the specified name, then the behavior of this method is undefined, and it is permitted to return any one of the matching elements, to return null, or to throw an arbitrary runtime exception.- Specified by:
getSafeElement
in interfaceXmlElement
- Parameters:
sPath
- element path- Returns:
- the specified element (never null) as an object implementing XmlElement for read-only use
-
ensureElement
public XmlElement ensureElement(String sPath)
Ensure that a child element exists. This is a convenience method. It combines the functionality of findElement() and addElement(). If any part of the path does not exist create new child elements to match the path.- Specified by:
ensureElement
in interfaceXmlElement
- Parameters:
sPath
- element path- Returns:
- the existing or new XmlElement object
- Throws:
IllegalArgumentException
- if the name is null or if any part of the path is not a legal XML tag nameUnsupportedOperationException
- if any element in the path is immutable or otherwise cannot add a child element- See Also:
findElement(java.lang.String)
-
getAttributeMap
public Map getAttributeMap()
Get the map of all attributes. The map is keyed by attribute names. The corresponding values are non-null objects that implement the XmlValue interface.- Specified by:
getAttributeMap
in interfaceXmlElement
- Returns:
- a Map containing all attributes of this XmlElement; the return value will never be null, although it may be an empty map
-
getAttribute
public XmlValue getAttribute(String sName)
Get an attribute value. This is a convenience method. Attributes are accessed and manipulated via the map returned from getAttributeMap.- Specified by:
getAttribute
in interfaceXmlElement
- Parameters:
sName
- the name of the attribute- Returns:
- the value of the specified attribute, or null if the attribute does not exist or does not have a value
-
setAttribute
public void setAttribute(String sName, XmlValue val)
Set an attribute value. If the attribute does not already exist, and the new value is non-null, then the attribute is added and its value is set to the passed value. If the attribute does exist, and the new value is non-null, then the attribute's value is updated to the passed value. If the attribute does exist, but the new value is null, then the attribute and its corresponding value are removed. This is a convenience method. Attributes are accessed and manipulated via the map returned from getAttributeMap.- Specified by:
setAttribute
in interfaceXmlElement
- Parameters:
sName
- the name of the attributeval
- the new value for the attribute; null indicates that the attribute should be removed
-
addAttribute
public XmlValue addAttribute(String sName)
Provides a means to add a new attribute value. If the attribute of the same name already exists, it is returned, otherwise a new value is created and added as an attribute. This is a convenience method. Attributes are accessed and manipulated via the map returned from getAttributeMap.- Specified by:
addAttribute
in interfaceXmlElement
- Parameters:
sName
- the name of the attribute- Returns:
- a XmlValue of the same name if it already exists
-
getSafeAttribute
public XmlValue getSafeAttribute(String sName)
Get an attribute value, and return a temporary value if the attribute does not exist. This is a convenience method. Attributes are accessed and manipulated via the map returned from getAttributeMap.- Specified by:
getSafeAttribute
in interfaceXmlElement
- Parameters:
sName
- the name of the attribute- Returns:
- the value of the specified attribute, or a temporary value if the attribute does not exist
-
getComment
public String getComment()
Get the text of any comments that are in the XML element. An element can contain many comments interspersed randomly with textual values and child elements. In reality, comments are rarely used. The purpose of this method and the corresponding mutator are to ensure that if comments do exist, that their text will be accessible through this interface and not lost through a transfer from one instance of this interface to another.- Specified by:
getComment
in interfaceXmlElement
- Returns:
- the comment text from this element (not including the "") or null if there was no comment
-
setComment
public void setComment(String sComment)
Set the text of this element's comment. This interface allows a single comment to be associated with the element. The XML specification does not allow a comment to contain the String "--".- Specified by:
setComment
in interfaceXmlElement
- Parameters:
sComment
- the comment text- Throws:
IllegalArgumentException
- if the comment contains "--"
-
writeXml
public void writeXml(PrintWriter out, boolean fPretty)
Write the element as it will appear in XML.- Specified by:
writeXml
in interfaceXmlElement
- 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
-
writeValue
public void writeValue(PrintWriter out, boolean fPretty)
Write the value as it will appear in XML.- Specified by:
writeValue
in interfaceXmlValue
- Overrides:
writeValue
in classSimpleValue
- 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
-
toXml
public XmlElement toXml()
Serialize the object into an XmlElement.- Specified by:
toXml
in interfaceXmlSerializable
- 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 interfaceXmlSerializable
- Parameters:
xml
- an XmlElement that contains the serialized form of the object- Throws:
UnsupportedOperationException
- if this element is immutable
-
readExternal
public void readExternal(DataInput in) throws IOException
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 classSimpleValue
- 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 occursNotActiveException
- if the object is not in its initial state, and therefore cannot be deserialized into
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
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 classSimpleValue
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-
readExternal
public void readExternal(PofReader in) throws IOException
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 classSimpleValue
- Parameters:
in
- the PofReader from which to read the object's state- Throws:
IOException
- if an I/O error occurs
-
writeExternal
public void writeExternal(PofWriter out) throws IOException
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 classSimpleValue
- Parameters:
out
- the PofWriter to which to write the object's state- Throws:
IOException
- if an I/O error occurs
-
checkMutable
protected void checkMutable()
Validates that the element is mutable, otherwise throws an UnsupportedOperationException.- Throws:
UnsupportedOperationException
- if the document is immutable
-
isNameMutable
protected boolean isNameMutable()
Determine if the name can be changed. The default implementation allows a name to be changed. This can be overridden by inheriting implementations.- Returns:
- true if the name can be changed
-
instantiateElementList
protected List instantiateElementList()
Instantiate a List implementation that will hold child elements.- Returns:
- a List that supports XmlElements
-
instantiateElement
protected XmlElement instantiateElement(String sName, Object oValue)
Instantiate an XmlElement implementation for an element.- Parameters:
sName
- element nameoValue
- element value- Returns:
- a new XmlElement to be used as an element
-
instantiateAttributeMap
protected Map instantiateAttributeMap()
Instantiate a Map implementation that will support the name to value map used to hold attributes.- Returns:
- a Map that supports String keys and XmlValue values
-
instantiateAttribute
protected XmlValue instantiateAttribute()
Instantiate an XmlValue implementation for an attribute value.- Returns:
- a new XmlValue to be used as an attribute value
-
writeEmptyTag
protected void writeEmptyTag(PrintWriter out, boolean fPretty)
Write the element as a combined start/end tag.- 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
-
writeStartTag
protected void writeStartTag(PrintWriter out, boolean fPretty)
Write the element's start tag.- 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
-
writeEndTag
protected void writeEndTag(PrintWriter out, boolean fPretty)
Write the element's end tag.- 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
-
writeAttributes
protected void writeAttributes(PrintWriter out, boolean fPretty)
Write the attributes as part of a start tag.- 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
-
writeComment
protected void writeComment(PrintWriter out, boolean fPretty)
Write the element as it will appear in XML.- 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
-
writeChildren
protected void writeChildren(PrintWriter out, boolean fPretty)
Write the element as it will appear in XML.- 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
-
toString
public String toString()
Format the XML element and all its contained information into a String in a display format. Note that this overrides the contract of the toString method in the super interface XmlValue.- Specified by:
toString
in interfaceXmlElement
- Specified by:
toString
in interfaceXmlValue
- Overrides:
toString
in classSimpleValue
- Returns:
- a String representation of the XML element
-
toString
public String toString(boolean fPretty)
Format the XML element and all its contained information into a String in a display format.- Parameters:
fPretty
- true to specify that the output is intended to be as human readable as possible- Returns:
- a String representation of the XML element
-
hashCode
public int hashCode()
Provide a hash value for this XML element and all of its contained information. Note that this overrides the contract of the hashCode method in the super interface XmlValue. The hash value is defined as a xor of the following:- the hashCode from the element's value (i.e. super.hashCode())
- the hashCode from each attribute name
- the hashCode from each attribute value
- the hashCode from each sub-element
- Specified by:
hashCode
in interfaceXmlElement
- Specified by:
hashCode
in interfaceXmlValue
- Overrides:
hashCode
in classSimpleValue
- Returns:
- the hash value for this XML element
-
equals
public boolean equals(Object o)
Compare this XML element and all of its contained information with another XML element for equality. Note that this overrides the contract of the equals method in the super interface XmlValue.- Specified by:
equals
in interfaceXmlElement
- Specified by:
equals
in interfaceXmlValue
- Overrides:
equals
in classSimpleValue
- Returns:
- true if the elements are equal, false otherwise
-
clone
public Object clone()
Creates and returns a copy of this SimpleElement. The returned copy is a deep clone of this SimpleElement "unlinked" from the parent and mutable- Specified by:
clone
in interfaceXmlElement
- Specified by:
clone
in interfaceXmlValue
- Overrides:
clone
in classSimpleValue
- Returns:
- a clone of this instance.
-
-