Package cern.dip.implementation
Class DipDataImp
- java.lang.Object
-
- cern.dip.implementation.DipDataImp
-
- All Implemented Interfaces:
DipData
,java.io.Serializable
- Direct Known Subclasses:
MockDipData
public class DipDataImp extends java.lang.Object implements DipData, java.io.Serializable
Interface for DIP data. DipData objects are created by DipFactoryInterfaces and returned to DipSubscriptionListeners.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FIELD_NAME_WHEN_PRMITIVE
-
Fields inherited from interface cern.dip.DipData
TYPE_BOOLEAN, TYPE_BOOLEAN_ARRAY, TYPE_BYTE, TYPE_BYTE_ARRAY, TYPE_DOUBLE, TYPE_DOUBLE_ARRAY, TYPE_FLOAT, TYPE_FLOAT_ARRAY, TYPE_INT, TYPE_INT_ARRAY, TYPE_LONG, TYPE_LONG_ARRAY, TYPE_NULL, TYPE_SHORT, TYPE_SHORT_ARRAY, TYPE_STRING, TYPE_STRING_ARRAY
-
-
Constructor Summary
Constructors Constructor Description DipDataImp()
Data object created with a default data quality of good
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(java.lang.String tag)
Returnstrue
if this object contains an entry with the specified tag.boolean
extractBoolean()
Returns theboolean
stored in the default data entry.boolean
extractBoolean(java.lang.String tag)
Returns theboolean
stored in the specified data entry.boolean[]
extractBooleanArray()
Returns theboolean
array stored in the default data entry.boolean[]
extractBooleanArray(java.lang.String tag)
Returns theboolean
array stored in the specified data entry.byte
extractByte()
Returns thebyte
stored in the default data entry.byte
extractByte(java.lang.String tag)
Returns thebyte
stored in the specified data entry.byte[]
extractByteArray()
Returns thebyte
array stored in the default data entry.byte[]
extractByteArray(java.lang.String tag)
Returns thebyte
array stored in the specified data entry.int
extractDataQuality()
Returns the data quality value of this DipData object as an int.DipQualityEnum
extractDataQualityEnum()
DipTimestamp
extractDipTime()
Returns theDipTimestamp
of this DipData object.double
extractDouble()
Returns thefloat
array stored in the default data entry.double
extractDouble(java.lang.String tag)
Returns thefloat
array stored in the default data entry.double[]
extractDoubleArray()
Returns thedouble
array stored in the default data entry.double[]
extractDoubleArray(java.lang.String tag)
Returns thedouble
array stored in the specified data entry.float
extractFloat()
Extracts the default value from the DipData object as a float.float
extractFloat(java.lang.String tag)
Returns thefloat
stored in the specified data entry.float[]
extractFloatArray()
Returns thedouble
stored in the default data entry.float[]
extractFloatArray(java.lang.String tag)
Returns thefloat
array stored in the specified data entry.int
extractInt()
Returns theint
stored in the default data entry.int
extractInt(java.lang.String tag)
Returns theint
stored in the specified data entry.int[]
extractIntArray()
Returns theint
array stored in the default data entry.int[]
extractIntArray(java.lang.String tag)
Returns theint
array stored in the specified data entry.long
extractLong()
Returns thelong
stored in the default data entry.long
extractLong(java.lang.String tag)
Returns thelong
stored in the specified data entry.long[]
extractLongArray()
Returns thelong
array stored in the default data entry.long[]
extractLongArray(java.lang.String tag)
Returns thelong
array stored in the specified data entry.java.lang.String
extractQualityString()
Extracts the string that describes the reason for the quality.short
extractShort()
Returns theshort
stored in the default data entry.short
extractShort(java.lang.String tag)
Returns theshort
stored in the specified data entry.short[]
extractShortArray()
Returns theshort
array stored in the default data entry.short[]
extractShortArray(java.lang.String tag)
Returns theshort
array stored in the specified data entry.java.lang.String
extractString()
Returns theString
stored in the default data entry.java.lang.String
extractString(java.lang.String tag)
Returns theString
stored in the specified data entry.java.lang.String[]
extractStringArray()
Returns theString
array stored in the default data entry.java.lang.String[]
extractStringArray(java.lang.String tag)
Returns theString
array stored in the specified data entry.protected int
getCByteSize()
calc how many bytes it would take to store the data.java.util.Optional<java.lang.Object>
getPrimitiveValueAsObject()
Returns the primitive DipData value as a Java Object.java.lang.String[]
getTags()
Returns an unordered String array that contains tags of all entries.static int
getTypeSize(int dipType)
returns size in bytes of DIP type in bytes If type is array it will return the size of one of its elementsjava.util.Map<java.lang.String,java.lang.Object>
getValueAsMap()
Returns the contents of the DipData as a field name / value map.int
getValueType()
Returns type code for the value contained in the default entry.int
getValueType(java.lang.String tag)
Returns type code for the value contained in the specified entry.void
insert(boolean value)
Inserts a boolean as default value into the DipData object.void
insert(boolean[] value)
Inserts a double array as default value into the DipData object.void
insert(byte value)
Inserts a byte as default value into the DipData object.void
insert(byte[] value)
Inserts a byte array as default value into the DipData object.void
insert(double value)
Inserts a double as default value into the DipData object.void
insert(double[] value)
Inserts a double array as default value into the DipData object.void
insert(float value)
Inserts a float as default value into the DipData object.void
insert(float[] value)
Inserts a float array as default value into the DipData object.void
insert(int value)
Inserts an int as default value into the DipData object.void
insert(int[] value)
Inserts an int array as default value into the DipData object.void
insert(long value)
Inserts a long as default value into the DipData object.void
insert(long[] value)
Inserts a long array as default value into the DipData object.void
insert(short value)
Inserts a short as default value into the DipData object.void
insert(short[] value)
Inserts an short array as default value into the DipData object.void
insert(java.lang.String value)
Inserts a String as default value into the DipData object.void
insert(java.lang.String[] value)
Inserts a String array as default value into the DipData object.void
insert(java.lang.String tag, boolean value)
Inserts a named boolean entry into the DipData object.void
insert(java.lang.String tag, boolean[] value)
Inserts a named boolean array entry into the DipData object.void
insert(java.lang.String tag, byte value)
Inserts a named byte entry into the DipData object.void
insert(java.lang.String tag, byte[] value)
Inserts a named byte array entry into the DipData object.void
insert(java.lang.String tag, double value)
Inserts a named double entry into the DipData object.void
insert(java.lang.String tag, double[] value)
Inserts a named double array entry into the DipData object.void
insert(java.lang.String tag, float value)
Inserts a named float entry into the DipData object.void
insert(java.lang.String tag, float[] value)
Inserts a named float array entry into the DipData object.void
insert(java.lang.String tag, int value)
Inserts a named int entry into the DipData object.void
insert(java.lang.String tag, int[] value)
Inserts a named int array entry into the DipData object.void
insert(java.lang.String tag, long value)
Inserts a named long entry into the DipData object.void
insert(java.lang.String tag, long[] value)
Inserts a named long array entry into the DipData object.void
insert(java.lang.String tag, short value)
Inserts a named short entry into the DipData object.void
insert(java.lang.String tag, short[] value)
Inserts a named short array entry into the DipData object.void
insert(java.lang.String tag, java.lang.String value)
Inserts a named String entry into the DipData object.void
insert(java.lang.String tag, java.lang.String[] value)
Inserts a named String array entry into the DipData object.boolean
isEmpty()
Returnstrue
if this DipData contains no entries;false
otherwise.boolean
isPrimitive()
Indicates whether the DipData package only carries a single value (as opposed to one or more fields, a.k.a.protected void
readInFromBuffer(java.nio.ByteBuffer dataBuffer, java.lang.String format)
Read data into this object from a ByteBuffer.protected void
setDataQuality(int dataQuality)
protected void
setDipTime(DipTimestamp time)
protected void
setQualityString(java.lang.String reason)
int
size()
Returns the number of entries in this object.protected java.lang.String
writeDataToBuffer(java.nio.ByteBuffer buffer)
Writes the usr data contained in the object to the start of the supplied Data buffer.
-
-
-
Field Detail
-
FIELD_NAME_WHEN_PRMITIVE
public static final java.lang.String FIELD_NAME_WHEN_PRMITIVE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCByteSize
protected int getCByteSize()
calc how many bytes it would take to store the data. Strings take size() bytes + 1
-
writeDataToBuffer
protected java.lang.String writeDataToBuffer(java.nio.ByteBuffer buffer)
Writes the usr data contained in the object to the start of the supplied Data buffer. The format string has the following structure : name|type|cardinality|- Parameters:
buffer
- - it is up to the caller to make sure this has sufficient capacity- Returns:
- format - the format string describing how the data is packed
-
readInFromBuffer
protected void readInFromBuffer(java.nio.ByteBuffer dataBuffer, java.lang.String format) throws TypeMismatch
Read data into this object from a ByteBuffer. The format string desribes the structure of the data in the buffer- Throws:
TypeMismatch
-
insert
public void insert(float value) throws TypeMismatch
Description copied from interface:DipData
Inserts a float as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(float[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a float array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(double value) throws TypeMismatch
Inserts a double as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(double[] value) throws TypeMismatch
Inserts a double array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(short value) throws TypeMismatch
Inserts a short as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(short[] value) throws TypeMismatch
Inserts an short array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(int value) throws TypeMismatch
Inserts an int as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(int[] value) throws TypeMismatch
Inserts an int array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(long value) throws TypeMismatch
Inserts a long as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(long[] value) throws TypeMismatch
Inserts a long array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(byte value) throws TypeMismatch
Inserts a byte as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(byte[] value) throws TypeMismatch
Inserts a byte array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(boolean value) throws TypeMismatch
Inserts a boolean as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(boolean[] value) throws TypeMismatch
Inserts a double array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(java.lang.String value) throws TypeMismatch
Inserts a String as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
insert
public void insert(java.lang.String[] value) throws TypeMismatch
Inserts a String array as default value into the DipData object. If the default value already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
value
- - the value to be written- Throws:
TypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.
-
extractString
public java.lang.String extractString() throws TypeMismatch
Description copied from interface:DipData
Returns theString
stored in the default data entry.- Specified by:
extractString
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractBoolean
public boolean extractBoolean() throws TypeMismatch
Description copied from interface:DipData
Returns theboolean
stored in the default data entry.- Specified by:
extractBoolean
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractByte
public byte extractByte() throws TypeMismatch
Description copied from interface:DipData
Returns thebyte
stored in the default data entry.- Specified by:
extractByte
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractShort
public short extractShort() throws TypeMismatch
Description copied from interface:DipData
Returns theshort
stored in the default data entry.- Specified by:
extractShort
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractInt
public int extractInt() throws TypeMismatch
Description copied from interface:DipData
Returns theint
stored in the default data entry.- Specified by:
extractInt
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractFloat
public float extractFloat() throws TypeMismatch
Description copied from interface:DipData
Extracts the default value from the DipData object as a float.- Specified by:
extractFloat
in interfaceDipData
- Throws:
TypeMismatch
-
extractDouble
public double extractDouble() throws TypeMismatch
Description copied from interface:DipData
Returns thefloat
array stored in the default data entry.- Specified by:
extractDouble
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractLong
public long extractLong() throws TypeMismatch
Description copied from interface:DipData
Returns thelong
stored in the default data entry.- Specified by:
extractLong
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractBooleanArray
public boolean[] extractBooleanArray() throws TypeMismatch
Description copied from interface:DipData
Returns theboolean
array stored in the default data entry.- Specified by:
extractBooleanArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractByteArray
public byte[] extractByteArray() throws TypeMismatch
Description copied from interface:DipData
Returns thebyte
array stored in the default data entry.- Specified by:
extractByteArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractShortArray
public short[] extractShortArray() throws TypeMismatch
Description copied from interface:DipData
Returns theshort
array stored in the default data entry.- Specified by:
extractShortArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractIntArray
public int[] extractIntArray() throws TypeMismatch
Description copied from interface:DipData
Returns theint
array stored in the default data entry.- Specified by:
extractIntArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractFloatArray
public float[] extractFloatArray() throws TypeMismatch
Description copied from interface:DipData
Returns thedouble
stored in the default data entry.- Specified by:
extractFloatArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractDoubleArray
public double[] extractDoubleArray() throws TypeMismatch
Description copied from interface:DipData
Returns thedouble
array stored in the default data entry.- Specified by:
extractDoubleArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractLongArray
public long[] extractLongArray() throws TypeMismatch
Description copied from interface:DipData
Returns thelong
array stored in the default data entry.- Specified by:
extractLongArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractStringArray
public java.lang.String[] extractStringArray() throws TypeMismatch
Description copied from interface:DipData
Returns theString
array stored in the default data entry.- Specified by:
extractStringArray
in interfaceDipData
- Throws:
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.
-
extractDataQuality
public int extractDataQuality()
Description copied from interface:DipData
Returns the data quality value of this DipData object as an int. The data quality can be one of:- Specified by:
extractDataQuality
in interfaceDipData
- See Also:
DipQuality.DIP_QUALITY_BAD
,DipQuality.DIP_QUALITY_GOOD
,DipQuality.DIP_QUALITY_UNCERTAIN
-
extractDataQualityEnum
public DipQualityEnum extractDataQualityEnum()
- Specified by:
extractDataQualityEnum
in interfaceDipData
-
setDataQuality
protected void setDataQuality(int dataQuality)
-
extractDipTime
public DipTimestamp extractDipTime()
Description copied from interface:DipData
Returns theDipTimestamp
of this DipData object. This should represent the time at which the value(s) contained in this object were obtained.- Specified by:
extractDipTime
in interfaceDipData
-
setDipTime
protected void setDipTime(DipTimestamp time)
-
extractQualityString
public java.lang.String extractQualityString()
Extracts the string that describes the reason for the quality.- Specified by:
extractQualityString
in interfaceDipData
-
setQualityString
protected void setQualityString(java.lang.String reason)
-
contains
public boolean contains(java.lang.String tag)
Description copied from interface:DipData
Returnstrue
if this object contains an entry with the specified tag.
-
extractBoolean
public boolean extractBoolean(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theboolean
stored in the specified data entry.- Specified by:
extractBoolean
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than aboolean
, or nothing.
-
extractBooleanArray
public boolean[] extractBooleanArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theboolean
array stored in the specified data entry.- Specified by:
extractBooleanArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than aboolean
array, or nothing.
-
extractByte
public byte extractByte(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thebyte
stored in the specified data entry.- Specified by:
extractByte
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than abyte
, or nothing.
-
extractByteArray
public byte[] extractByteArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thebyte
array stored in the specified data entry.- Specified by:
extractByteArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than abyte
array, or nothing.
-
extractDouble
public double extractDouble(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thefloat
array stored in the default data entry.- Specified by:
extractDouble
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than adouble
array, or nothing.
-
extractDoubleArray
public double[] extractDoubleArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thedouble
array stored in the specified data entry.- Specified by:
extractDoubleArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than adouble
array, or nothing.
-
extractFloat
public float extractFloat(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thefloat
stored in the specified data entry.- Specified by:
extractFloat
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than afloat
, or nothing.
-
extractFloatArray
public float[] extractFloatArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thefloat
array stored in the specified data entry.- Specified by:
extractFloatArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than afloat
array, or nothing.
-
extractInt
public int extractInt(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theint
stored in the specified data entry.- Specified by:
extractInt
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than aint
, or nothing.
-
extractIntArray
public int[] extractIntArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theint
array stored in the specified data entry.- Specified by:
extractIntArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than aint
array, or nothing.
-
extractLong
public long extractLong(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thelong
stored in the specified data entry.- Specified by:
extractLong
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than along
, or nothing.
-
extractLongArray
public long[] extractLongArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns thelong
array stored in the specified data entry.- Specified by:
extractLongArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than along
array, or nothing.
-
extractShort
public short extractShort(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theshort
stored in the specified data entry.- Specified by:
extractShort
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than ashort
, or nothing.
-
extractShortArray
public short[] extractShortArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theshort
array stored in the specified data entry.- Specified by:
extractShortArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than ashort
array, or nothing.
-
extractString
public java.lang.String extractString(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theString
stored in the specified data entry.- Specified by:
extractString
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than aString
, or nothing.
-
extractStringArray
public java.lang.String[] extractStringArray(java.lang.String tag) throws BadParameter, TypeMismatch
Description copied from interface:DipData
Returns theString
array stored in the specified data entry.- Specified by:
extractStringArray
in interfaceDipData
- Throws:
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than aString
array, or nothing.
-
getTags
public java.lang.String[] getTags()
Description copied from interface:DipData
Returns an unordered String array that contains tags of all entries. Returns a zero length array if this object is empty.
-
getValueType
public int getValueType()
Description copied from interface:DipData
Returns type code for the value contained in the default entry. The return value can be one of the TYPE_X constants defined in this interface.- Specified by:
getValueType
in interfaceDipData
- See Also:
DipData.TYPE_NULL
,DipData.TYPE_BOOLEAN
,DipData.TYPE_BOOLEAN_ARRAY
,DipData.TYPE_BYTE
,DipData.TYPE_BYTE_ARRAY
,DipData.TYPE_SHORT
,DipData.TYPE_SHORT_ARRAY
,DipData.TYPE_INT
,DipData.TYPE_INT_ARRAY
,DipData.TYPE_LONG
,DipData.TYPE_LONG_ARRAY
,DipData.TYPE_FLOAT
,DipData.TYPE_FLOAT_ARRAY
,DipData.TYPE_DOUBLE
,DipData.TYPE_DOUBLE_ARRAY
,DipData.TYPE_STRING
,Will return TYPE_NULL if the object is holding complex data (tag/value pairs)
-
getValueType
public int getValueType(java.lang.String tag)
Description copied from interface:DipData
Returns type code for the value contained in the specified entry. The return value can be one of the TYPE_X constants defined in this interface. Will return TYPE_NULL if the tag name passed does not exist.- Specified by:
getValueType
in interfaceDipData
- Parameters:
tag
- - the name of the field this method is to find the type of.- See Also:
DipData.getValueType()
-
getTypeSize
public static int getTypeSize(int dipType)
returns size in bytes of DIP type in bytes If type is array it will return the size of one of its elements
-
insert
public void insert(java.lang.String tag, boolean value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named boolean entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, boolean[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named boolean array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, byte value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named byte entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, byte[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named byte array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, double value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named double entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, double[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named double array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, float value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named float entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, float[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named float array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, int value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named int entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, int[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named int array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, long value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named long entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, long[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named long array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, short value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named short entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, short[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named short array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, java.lang.String value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named String entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
insert
public void insert(java.lang.String tag, java.lang.String[] value) throws TypeMismatch
Description copied from interface:DipData
Inserts a named String array entry into the DipData object. If the entry already exists, it will be overwritten.- Specified by:
insert
in interfaceDipData
- Parameters:
tag
- - name of the 'field' the value belongs to.value
- - the value to be written- Throws:
TypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.
-
isEmpty
public boolean isEmpty()
Description copied from interface:DipData
Returnstrue
if this DipData contains no entries;false
otherwise.
-
size
public int size()
Description copied from interface:DipData
Returns the number of entries in this object.
-
getValueAsMap
public java.util.Map<java.lang.String,java.lang.Object> getValueAsMap() throws java.lang.Exception
Description copied from interface:DipData
Returns the contents of the DipData as a field name / value map.- Specified by:
getValueAsMap
in interfaceDipData
- Returns:
- A map associating the field name to its value.
- Throws:
java.lang.Exception
-
getPrimitiveValueAsObject
public java.util.Optional<java.lang.Object> getPrimitiveValueAsObject()
Description copied from interface:DipData
Returns the primitive DipData value as a Java Object.- Specified by:
getPrimitiveValueAsObject
in interfaceDipData
- Returns:
- the primitive value or an empty
Optional
if the data payload is not a carrying a single value.
-
isPrimitive
public boolean isPrimitive()
Description copied from interface:DipData
Indicates whether the DipData package only carries a single value (as opposed to one or more fields, a.k.a. key/value pairs)- Specified by:
isPrimitive
in interfaceDipData
- Returns:
true
if the DipData package carries a single value with a default field name.
-
-