public class DipDataImp extends Object implements DipData, Serializable
Modifier and Type | Field and Description |
---|---|
protected static String |
fieldNameWhenPrimitive |
protected HashMap |
fields |
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 and Description |
---|
DipDataImp()
Data object created with a default data quality of good
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String tag)
Returns
true if this object contains an entry with the
specified tag. |
boolean |
extractBoolean()
Returns the
boolean stored in the default data entry. |
boolean |
extractBoolean(String tag)
Returns the
boolean stored in the specified data entry. |
boolean[] |
extractBooleanArray()
Returns the
boolean array stored in the default data entry. |
boolean[] |
extractBooleanArray(String tag)
Returns the
boolean array stored in the specified data entry. |
byte |
extractByte()
Returns the
byte stored in the default data entry. |
byte |
extractByte(String tag)
Returns the
byte stored in the specified data entry. |
byte[] |
extractByteArray()
Returns the
byte array stored in the default data entry. |
byte[] |
extractByteArray(String tag)
Returns the
byte 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 the
DipTimestamp of this DipData object. |
double |
extractDouble()
Returns the
float array stored in the default data entry. |
double |
extractDouble(String tag)
Returns the
float array stored in the default data entry. |
double[] |
extractDoubleArray()
Returns the
double array stored in the default data entry. |
double[] |
extractDoubleArray(String tag)
Returns the
double array stored in the specified data entry. |
float |
extractFloat()
Extracts the default value from the DipData object as a float.
|
float |
extractFloat(String tag)
Returns the
float stored in the specified data entry. |
float[] |
extractFloatArray()
Returns the
double stored in the default data entry. |
float[] |
extractFloatArray(String tag)
Returns the
float array stored in the specified data entry. |
int |
extractInt()
Returns the
int stored in the default data entry. |
int |
extractInt(String tag)
Returns the
int stored in the specified data entry. |
int[] |
extractIntArray()
Returns the
int array stored in the default data entry. |
int[] |
extractIntArray(String tag)
Returns the
int array stored in the specified data entry. |
long |
extractLong()
Returns the
long stored in the default data entry. |
long |
extractLong(String tag)
Returns the
long stored in the specified data entry. |
long[] |
extractLongArray()
Returns the
long array stored in the default data entry. |
long[] |
extractLongArray(String tag)
Returns the
long array stored in the specified data entry. |
String |
extractQualityString()
Extracts the string that describes the reason for the quality.
|
short |
extractShort()
Returns the
short stored in the default data entry. |
short |
extractShort(String tag)
Returns the
short stored in the specified data entry. |
short[] |
extractShortArray()
Returns the
short array stored in the default data entry. |
short[] |
extractShortArray(String tag)
Returns the
short array stored in the specified data entry. |
String |
extractString()
Returns the
String stored in the default data entry. |
String |
extractString(String tag)
Returns the
String stored in the specified data entry. |
String[] |
extractStringArray()
Returns the
String array stored in the default data entry. |
String[] |
extractStringArray(String tag)
Returns the
String array stored in the specified data entry. |
protected int |
getCByteSize()
calc how many bytes it would take to store the data.
|
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 elements
|
Map<String,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(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(String value)
Inserts a String as default value into the DipData object.
|
void |
insert(String[] value)
Inserts a String array as default value into the DipData object.
|
void |
insert(String tag,
boolean value)
Inserts a named boolean entry into the DipData object.
|
void |
insert(String tag,
boolean[] value)
Inserts a named boolean array entry into the DipData object.
|
void |
insert(String tag,
byte value)
Inserts a named byte entry into the DipData object.
|
void |
insert(String tag,
byte[] value)
Inserts a named byte array entry into the DipData object.
|
void |
insert(String tag,
double value)
Inserts a named double entry into the DipData object.
|
void |
insert(String tag,
double[] value)
Inserts a named double array entry into the DipData object.
|
void |
insert(String tag,
float value)
Inserts a named float entry into the DipData object.
|
void |
insert(String tag,
float[] value)
Inserts a named float array entry into the DipData object.
|
void |
insert(String tag,
int value)
Inserts a named int entry into the DipData object.
|
void |
insert(String tag,
int[] value)
Inserts a named int array entry into the DipData object.
|
void |
insert(String tag,
long value)
Inserts a named long entry into the DipData object.
|
void |
insert(String tag,
long[] value)
Inserts a named long array entry into the DipData object.
|
void |
insert(String tag,
short value)
Inserts a named short entry into the DipData object.
|
void |
insert(String tag,
short[] value)
Inserts a named short array entry into the DipData object.
|
void |
insert(String tag,
String value)
Inserts a named String entry into the DipData object.
|
void |
insert(String tag,
String[] value)
Inserts a named String array entry into the DipData object.
|
boolean |
isEmpty()
Returns
true if this DipData contains no entries;
false otherwise. |
protected void |
readInFromBuffer(ByteBuffer dataBuffer,
String format)
Read data into this object from a ByteBuffer.
|
protected void |
setDataQuality(int dataQuality) |
protected void |
setDipTime(DipTimestamp time) |
protected void |
setQualityString(String reason) |
int |
size()
Returns the number of entries in this object.
|
protected String |
writeDataToBuffer(ByteBuffer buffer)
Writes the usr data contained in the object to the start of
the supplied Data buffer.
|
protected static final String fieldNameWhenPrimitive
protected HashMap fields
public DipDataImp()
protected int getCByteSize()
protected String writeDataToBuffer(ByteBuffer buffer)
buffer
- - it is up to the caller to make sure this has sufficient capacityprotected void readInFromBuffer(ByteBuffer dataBuffer, String format) throws TypeMismatch
TypeMismatch
public void insert(float value) throws TypeMismatch
DipData
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(float[] value) throws TypeMismatch
DipData
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(double value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(double[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(short value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(short[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(int value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(int[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(long value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(long[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(byte value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(byte[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(boolean value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(boolean[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(String value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public void insert(String[] value) throws TypeMismatch
insert
in interface DipData
value
- - the value to be writtenTypeMismatch
- if entry is complex or contains a default value which is not of the same type as value.public String extractString() throws TypeMismatch
DipData
String
stored in the default data entry.extractString
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public boolean extractBoolean() throws TypeMismatch
DipData
boolean
stored in the default data entry.extractBoolean
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public byte extractByte() throws TypeMismatch
DipData
byte
stored in the default data entry.extractByte
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public short extractShort() throws TypeMismatch
DipData
short
stored in the default data entry.extractShort
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public int extractInt() throws TypeMismatch
DipData
int
stored in the default data entry.extractInt
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public float extractFloat() throws TypeMismatch
DipData
extractFloat
in interface DipData
TypeMismatch
public double extractDouble() throws TypeMismatch
DipData
float
array stored in the default data entry.extractDouble
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public long extractLong() throws TypeMismatch
DipData
long
stored in the default data entry.extractLong
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public boolean[] extractBooleanArray() throws TypeMismatch
DipData
boolean
array stored in the default data entry.extractBooleanArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public byte[] extractByteArray() throws TypeMismatch
DipData
byte
array stored in the default data entry.extractByteArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public short[] extractShortArray() throws TypeMismatch
DipData
short
array stored in the default data entry.extractShortArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public int[] extractIntArray() throws TypeMismatch
DipData
int
array stored in the default data entry.extractIntArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public float[] extractFloatArray() throws TypeMismatch
DipData
double
stored in the default data entry.extractFloatArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public double[] extractDoubleArray() throws TypeMismatch
DipData
double
array stored in the default data entry.extractDoubleArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public long[] extractLongArray() throws TypeMismatch
DipData
long
array stored in the default data entry.extractLongArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public String[] extractStringArray() throws TypeMismatch
DipData
String
array stored in the default data entry.extractStringArray
in interface DipData
TypeMismatch
- if 1) the object is holding complex data or 2) the value held is not of the required type.public int extractDataQuality()
DipData
extractDataQuality
in interface DipData
DipQuality.DIP_QUALITY_BAD
,
DipQuality.DIP_QUALITY_GOOD
,
DipQuality.DIP_QUALITY_UNCERTAIN
public DipQualityEnum extractDataQualityEnum()
extractDataQualityEnum
in interface DipData
protected void setDataQuality(int dataQuality)
public DipTimestamp extractDipTime()
DipData
DipTimestamp
of this DipData object. This should represent the time at which the
value(s) contained in this object were obtained.extractDipTime
in interface DipData
protected void setDipTime(DipTimestamp time)
public String extractQualityString()
extractQualityString
in interface DipData
protected void setQualityString(String reason)
public boolean contains(String tag)
DipData
true
if this object contains an entry with the
specified tag.public boolean extractBoolean(String tag) throws BadParameter, TypeMismatch
DipData
boolean
stored in the specified data entry.extractBoolean
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a boolean
,
or nothing.public boolean[] extractBooleanArray(String tag) throws BadParameter, TypeMismatch
DipData
boolean
array stored in the specified data entry.extractBooleanArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a boolean
array,
or nothing.public byte extractByte(String tag) throws BadParameter, TypeMismatch
DipData
byte
stored in the specified data entry.extractByte
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a byte
,
or nothing.public byte[] extractByteArray(String tag) throws BadParameter, TypeMismatch
DipData
byte
array stored in the specified data entry.extractByteArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a byte
array,
or nothing.public double extractDouble(String tag) throws BadParameter, TypeMismatch
DipData
float
array stored in the default data entry.extractDouble
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a double
array,
or nothing.public double[] extractDoubleArray(String tag) throws BadParameter, TypeMismatch
DipData
double
array stored in the specified data entry.extractDoubleArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a double
array,
or nothing.public float extractFloat(String tag) throws BadParameter, TypeMismatch
DipData
float
stored in the specified data entry.extractFloat
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a float
,
or nothing.public float[] extractFloatArray(String tag) throws BadParameter, TypeMismatch
DipData
float
array stored in the specified data entry.extractFloatArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a float
array,
or nothing.public int extractInt(String tag) throws BadParameter, TypeMismatch
DipData
int
stored in the specified data entry.extractInt
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a int
,
or nothing.public int[] extractIntArray(String tag) throws BadParameter, TypeMismatch
DipData
int
array stored in the specified data entry.extractIntArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a int
array,
or nothing.public long extractLong(String tag) throws BadParameter, TypeMismatch
DipData
long
stored in the specified data entry.extractLong
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a long
,
or nothing.public long[] extractLongArray(String tag) throws BadParameter, TypeMismatch
DipData
long
array stored in the specified data entry.extractLongArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a long
array,
or nothing.public short extractShort(String tag) throws BadParameter, TypeMismatch
DipData
short
stored in the specified data entry.extractShort
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a short
,
or nothing.public short[] extractShortArray(String tag) throws BadParameter, TypeMismatch
DipData
short
array stored in the specified data entry.extractShortArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a short
array,
or nothing.public String extractString(String tag) throws BadParameter, TypeMismatch
DipData
String
stored in the specified data entry.extractString
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a String
,
or nothing.public String[] extractStringArray(String tag) throws BadParameter, TypeMismatch
DipData
String
array stored in the specified data entry.extractStringArray
in interface DipData
BadParameter
- if this DipData does not contain the specified entryTypeMismatch
- if the entry contains something other than a String
array,
or nothing.public String[] getTags()
DipData
public int getValueType()
DipData
getValueType
in interface DipData
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)
public int getValueType(String tag)
DipData
getValueType
in interface DipData
tag
- - the name of the field this method is to find the type of.DipData.getValueType()
public static int getTypeSize(int dipType)
public void insert(String tag, boolean value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, boolean[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, byte value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, byte[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, double value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, double[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, float value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, float[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, int value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, int[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, long value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, long[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, short value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, short[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, String value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public void insert(String tag, String[] value) throws TypeMismatch
DipData
insert
in interface DipData
tag
- - name of the 'field' the value belongs to.value
- - the value to be writtenTypeMismatch
- if entry is simple or contains a tag already exists and its corresponding data is not of the same type as value.public boolean isEmpty()
DipData
true
if this DipData contains no entries;
false
otherwise.public int size()
DipData
public Map<String,Object> getValueAsMap() throws Exception
DipData
getValueAsMap
in interface DipData
Exception
Copyright © 2008–2017 CERN. All rights reserved.