Package com.tangosol.run.xml
Class SimpleValue
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.BitHelper
-
- com.tangosol.util.ExternalizableHelper
-
- com.tangosol.run.xml.SimpleValue
-
- All Implemented Interfaces:
ExternalizableLite,PortableObject,XmlValue,Serializable,Cloneable
- Direct Known Subclasses:
SimpleElement
public class SimpleValue extends ExternalizableHelper implements XmlValue, Cloneable, ExternalizableLite, PortableObject
A simple implementation of the XmlValue interface. Protected methods are provided to support inheriting classes.- Author:
- cp 2000.10.18
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
DEFAULT_LOAD_FACTOR, 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 SimpleValue()Construct an empty SimpleValue.SimpleValue(Object oValue)Construct a SimpleValue.SimpleValue(Object oValue, boolean fAttribute)Construct a SimpleValue.SimpleValue(Object oValue, boolean fAttribute, boolean fReadOnly)Construct a SimpleValue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Creates and returns a copy of this SimpleValue.protected Objectconvert(Object o, int nType)Convert the passed Object to the specified type.protected ObjectensureType(int nType)Change the type of the internal representation of the XmlValue.booleanequals(Object o)Compare this XML value with another XML value for equality.BinarygetBinary()Get the value as binary.BinarygetBinary(Binary binDefault)Get the value as binary.booleangetBoolean()Get the value as a boolean.booleangetBoolean(boolean fDefault)Get the value as a boolean.DategetDate()Get the value as a Date.DategetDate(Date dtDefault)Get the value as a Date.TimestampgetDateTime()Get the value as a Timestamp.TimestampgetDateTime(Timestamp dtDefault)Get the value as a Timestamp.BigDecimalgetDecimal()Get the value as a decimal.BigDecimalgetDecimal(BigDecimal decDefault)Get the value as a decimal.doublegetDouble()Get the value as a double.doublegetDouble(double dflDefault)Get the value as a double.intgetInt()Get the value as an int.intgetInt(int nDefault)Get the value as an int.protected ObjectgetInternalValue()Get the internal value of this XmlValue.longgetLong()Get the value as a long.longgetLong(long lDefault)Get the value as a long.XmlElementgetParent()Get the parent element of this element.StringgetString()Get the value as a String.StringgetString(String sDefault)Get the value as a String.TimegetTime()Get the value as a Time.TimegetTime(Time dtDefault)Get the value as a Time.ObjectgetValue()Get the value as an Object.inthashCode()Provide a hash value for this XML value.booleanisAttribute()Determine if this value is an element attribute.booleanisContent()Determine if this value is an element's content.booleanisEmpty()Determine if the value is empty.booleanisMutable()Determine if this value can be modified.voidreadExternal(PofReader in)Restore the contents of a user type instance by reading its state using the specified PofReader object.voidreadExternal(DataInput in)Restore the contents of this object by loading the object's state from the passed DataInput object.protected voidsetAttribute(boolean fAttribute)Specify that this value is an element attribute.voidsetBinary(Binary binVal)Set the binary value.voidsetBoolean(boolean fVal)Set the boolean value.voidsetDate(Date dtVal)Set the Date value.voidsetDateTime(Timestamp dtVal)Set the Timestamp value.voidsetDecimal(BigDecimal decVal)Set the dcimal value.voidsetDouble(double dflVal)Set the double value.voidsetInt(int nVal)Set the int value.protected voidsetInternalValue(Object oValue)Update the internal representation of the XmlValue.voidsetLong(long lVal)Set the long value.protected voidsetMutable(boolean fMutable)Specify whether this value can be modified or not.voidsetParent(XmlElement element)Set the parent element of this value.voidsetString(String sVal)Set the String value.voidsetTime(Time dtVal)Set the Time value.StringtoString()Format the XML value into a String in a display format.voidwriteExternal(PofWriter out)Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(DataOutput out)Save the contents of this object by storing the object's state into the passed DataOutput object.voidwriteValue(PrintWriter out, boolean fPretty)Write the value as it will appear in XML.-
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, newHashMap, newHashMap, newHashSet, newHashSet, 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
-
-
-
-
Constructor Detail
-
SimpleValue
public SimpleValue()
Construct an empty SimpleValue. Also used by the ExternalizableLite implementation.
-
SimpleValue
public SimpleValue(Object oValue)
Construct a SimpleValue. This form constructs an element's content value from the passed Object value. If the Object is a String, then the String should be un-escaped by this point; it must not still be in the form of the CDATA construct.- Parameters:
oValue- the initial value for this SimpleValue- Throws:
IllegalArgumentException- if the String value is illegal
-
SimpleValue
public SimpleValue(Object oValue, boolean fAttribute)
Construct a SimpleValue. This form constructs an element's content or attribute value from the passed String value. The String should be un-escaped by this point; it must not still be in the form of the CDATA construct.- Parameters:
oValue- the initial value for this SimpleValuefAttribute- true if this SimpleValue is an element attribute value; false if an element's content's value- Throws:
IllegalArgumentException- if the String value is illegal
-
SimpleValue
public SimpleValue(Object oValue, boolean fAttribute, boolean fReadOnly)
Construct a SimpleValue. This form constructs an element's content or attribute value from the passed String value, and also allows the caller to specify that the value is immutable. The String should be un-escaped by this point; it must not still be in the form of the CDATA construct.- Parameters:
oValue- the initial value for this SimpleValuefAttribute- true if this SimpleValue is an element attribute value; false if an element's content's valuefReadOnly- true if this SimpleValue is intended to be read- only once the constructor has finished- Throws:
IllegalArgumentException- if the String value is illegal
-
-
Method Detail
-
getBoolean
public boolean getBoolean()
Get the value as a boolean.- Specified by:
getBooleanin interfaceXmlValue- Returns:
- the value as a boolean
-
getBoolean
public boolean getBoolean(boolean fDefault)
Get the value as a boolean.- Specified by:
getBooleanin interfaceXmlValue- Parameters:
fDefault- the default return value if the internal value can not be translated into a legal value of type boolean- Returns:
- the value as a boolean
-
setBoolean
public void setBoolean(boolean fVal)
Set the boolean value.- Specified by:
setBooleanin interfaceXmlValue- Parameters:
fVal- a new value of type boolean
-
getInt
public int getInt()
Get the value as an int.
-
getInt
public int getInt(int nDefault)
Get the value as an int.
-
setInt
public void setInt(int nVal)
Set the int value.
-
getLong
public long getLong()
Get the value as a long.
-
getLong
public long getLong(long lDefault)
Get the value as a long.
-
setLong
public void setLong(long lVal)
Set the long value.
-
getDouble
public double getDouble()
Get the value as a double.
-
getDouble
public double getDouble(double dflDefault)
Get the value as a double.
-
setDouble
public void setDouble(double dflVal)
Set the double value.
-
getDecimal
public BigDecimal getDecimal()
Get the value as a decimal.- Specified by:
getDecimalin interfaceXmlValue- Returns:
- the value as a BigDecimal
-
getDecimal
public BigDecimal getDecimal(BigDecimal decDefault)
Get the value as a decimal.- Specified by:
getDecimalin interfaceXmlValue- Parameters:
decDefault- the default return value if the internal value can not be translated into a legal value of type decimal- Returns:
- the value as a decimal
-
setDecimal
public void setDecimal(BigDecimal decVal)
Set the dcimal value.- Specified by:
setDecimalin interfaceXmlValue- Parameters:
decVal- a new value of type BigDecimal
-
getString
public String getString()
Get the value as a String.
-
setString
public void setString(String sVal)
Set the String value.- Specified by:
setStringin interfaceXmlValue- Parameters:
sVal- a new value of type String- Throws:
IllegalArgumentException- if the String value is null
-
getBinary
public Binary getBinary()
Get the value as binary. The XML format is expected to be Base64.
-
getBinary
public Binary getBinary(Binary binDefault)
Get the value as binary. The XML format is expected to be Base64.
-
setBinary
public void setBinary(Binary binVal)
Set the binary value.- Specified by:
setBinaryin interfaceXmlValue- Parameters:
binVal- a new value of type Binary- Throws:
IllegalArgumentException- if the binary value is null
-
getDate
public Date getDate()
Get the value as a Date.
-
setDate
public void setDate(Date dtVal)
Set the Date value.
-
getTime
public Time getTime()
Get the value as a Time.
-
setTime
public void setTime(Time dtVal)
Set the Time value.
-
getDateTime
public Timestamp getDateTime()
Get the value as a Timestamp.- Specified by:
getDateTimein interfaceXmlValue- Returns:
- the value as a Timestamp
-
getDateTime
public Timestamp getDateTime(Timestamp dtDefault)
Get the value as a Timestamp.- Specified by:
getDateTimein interfaceXmlValue- Parameters:
dtDefault- the default return value if the internal value can not be translated into a legal value of type Timestamp- Returns:
- the value as a Timestamp
-
setDateTime
public void setDateTime(Timestamp dtVal)
Set the Timestamp value.- Specified by:
setDateTimein interfaceXmlValue- Parameters:
dtVal- a new value of type Timestamp
-
getValue
public Object getValue()
Get the value as an Object. The following types are supported: Boolean Integer Long Double BigDecimal String Binary Date Time Timestamp It is always legal for an implementation to return the value as a String, for example returning a binary value in a base64 encoding. This method exists to allow one value to copy from another value.
-
getParent
public XmlElement getParent()
Get the parent element of this element.
-
setParent
public void setParent(XmlElement element)
Set the parent element of this value. The parent cannot be modified once set.- Specified by:
setParentin interfaceXmlValue- Parameters:
element- the parent element- Throws:
IllegalArgumentException- thrown if the specified parent is nullIllegalStateException- throw if the parent is already set
-
isEmpty
public boolean isEmpty()
Determine if the value is empty.
-
isAttribute
public boolean isAttribute()
Determine if this value is an element attribute.- Specified by:
isAttributein interfaceXmlValue- Returns:
- true if this value is an element attribute, otherwise false
-
isContent
public boolean isContent()
Determine if this value is an element's content.
-
isMutable
public boolean isMutable()
Determine if this value can be modified. If the value cannot be modified, all mutating methods are required to throw an UnsupportedOperationException.
-
writeValue
public void writeValue(PrintWriter out, boolean fPretty)
Write the value as it will appear in XML.- Specified by:
writeValuein interfaceXmlValue- 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
-
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:
readExternalin interfaceExternalizableLite- 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:
writeExternalin interfaceExternalizableLite- 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:
readExternalin interfacePortableObject- 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:
writeExternalin interfacePortableObject- Parameters:
out- the PofWriter to which to write the object's state- Throws:
IOException- if an I/O error occurs
-
getInternalValue
protected Object getInternalValue()
Get the internal value of this XmlValue. This method acts as a single point to which all accessor calls route. As such, it is intended to be extended by inheriting implementations.- Returns:
- the current value of this SimpleValue object or null
-
setInternalValue
protected void setInternalValue(Object oValue)
Update the internal representation of the XmlValue. This method acts as a single point to which all mutator calls route. As such, it is intended to be extended by inheriting implementations.- Parameters:
oValue- the new value for this SimpleValue object- Throws:
UnsupportedOperationException- if this XmlValue is not mutable
-
ensureType
protected Object ensureType(int nType)
Change the type of the internal representation of the XmlValue. A failed conversion will leave the value as null.- Parameters:
nType- the enumerated type to convert to- Returns:
- the current value of this SimpleValue object as the specified type or null
-
convert
protected Object convert(Object o, int nType)
Convert the passed Object to the specified type.- Parameters:
o- the object valuenType- the enumerated type to convert to- Returns:
- an object of the specified type
-
setAttribute
protected void setAttribute(boolean fAttribute)
Specify that this value is an element attribute.- Parameters:
fAttribute- true if this value is an element attribute, false if this value is an element's content
-
setMutable
protected void setMutable(boolean fMutable)
Specify whether this value can be modified or not.- Parameters:
fMutable- pass true to allow this value to be modified, otherwise false to indicate that this value is read-only
-
toString
public String toString()
Format the XML value into a String in a display format.
-
hashCode
public int hashCode()
Provide a hash value for this XML value. The hash value is defined as one of the following:- 0 if getValue() returns null
- otherwise the hash value is the hashCode() of the string representation of the value
-
equals
public boolean equals(Object o)
Compare this XML value with another XML value for equality.
-
-