Class EncodedInteger
- java.lang.Object
-
- java.lang.Number
-
- EncodedInteger
-
- All Implemented Interfaces:
DataObject
,Immutable
,Serializable
public abstract class EncodedInteger extends Number implements DataObject, Immutable
An immutable integer that uses an IntegerCodec to encode/decode to a network form. Each subclass of EncodedInteger should include a constructor which takes an int value as it's only parameter.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EncodedInteger(IntegerCodec codec, byte[] data)
protected
EncodedInteger(IntegerCodec codec, byte[] data, int start, int len)
protected
EncodedInteger(IntegerCodec codec, int value)
protected
EncodedInteger(DataInput input)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
byteValue()
Object
clone()
Perform a deep copy of this object.double
doubleValue()
boolean
equals(Object o)
float
floatValue()
int
hashCode()
int
intValue()
boolean
isReadOnly()
Check if this object has been set read-only.long
longValue()
void
setReadOnly()
Set this object to be "read-only".short
shortValue()
void
toStream(DataOutput out)
String
toString()
-
-
-
Constructor Detail
-
EncodedInteger
protected EncodedInteger(DataInput input) throws IOException
- Throws:
IOException
-
EncodedInteger
protected EncodedInteger(IntegerCodec codec, int value) throws EncodeException
- Throws:
EncodeException
-
EncodedInteger
protected EncodedInteger(IntegerCodec codec, byte[] data)
-
EncodedInteger
protected EncodedInteger(IntegerCodec codec, byte[] data, int start, int len)
-
-
Method Detail
-
toStream
public void toStream(DataOutput out) throws IOException
- Throws:
IOException
-
shortValue
public final short shortValue()
- Overrides:
shortValue
in classNumber
-
floatValue
public final float floatValue()
- Specified by:
floatValue
in classNumber
-
doubleValue
public final double doubleValue()
- Specified by:
doubleValue
in classNumber
-
clone
public Object clone()
Description copied from interface:DataObject
Perform a deep copy of this object. Read-only state of the object is not copied; the new object will be read-write by default.Inherently immutable objects may optionally return the same object without modification from clone(), rather than constructing a new instance.
- Specified by:
clone
in interfaceDataObject
- Overrides:
clone
in classObject
- Returns:
- a new object that is a deep copy of this object; for immutable objects, the same object may optionally be returned.
-
setReadOnly
public void setReadOnly()
Description copied from interface:DataObject
Set this object to be "read-only". Any subsequent attempt to modify this object will throw IllegalStateException. Once an object has been made read-only, it cannot be later set to read-write - this is a "one-way" operation.Note that a read-only object is not necessarily immutable; if reference types are returned from accessors, then callers could theoretically mutate those objects even if the top-level object is marked as read-only. The ability to make objects read-only is intended to catch programming errors (e.g. attempting to modify a data object passed as part of a SLEE event), not to provide an absolute guarantee of immutability.
Calling setReadOnly() on an object that is already read-only is a no-op.
Some DataObject implementations may be inherently immutable. In those cases, they are considered always read-only.
- Specified by:
setReadOnly
in interfaceDataObject
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:DataObject
Check if this object has been set read-only.- Specified by:
isReadOnly
in interfaceDataObject
- Returns:
- true if the object is read-only or inherently immutable
- See Also:
DataObject.setReadOnly()
-
-