com.ibm.sensorevent.model.generic
Class GenericAttribute

java.lang.Object
  extended by com.ibm.sensorevent.model.generic.GenericAttribute
All Implemented Interfaces:
IGenericAttribute, java.io.Serializable

public class GenericAttribute
extends java.lang.Object
implements IGenericAttribute, java.io.Serializable

GenericAttribute represents a data value (an attribute) managed by the even model. All attributes have a name, value, and type. The name uniquely identifies each attribute within a GenericGroup. The value is any single Java Object or arrays of Java Objects. Primitive values are managed using the standard wrapper classes. The type indicates the type of data stored in the value field and whether the value represent a single value or an array of values.

The interface associated with this class is IGenericAttribute.

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
           
protected  java.lang.String name
          The attribute's name
protected  int type
          The attribute's type as defined in IGenericType.
protected  java.lang.Object[] value
          The attribute's value
 
Constructor Summary
protected GenericAttribute()
          Constructs a new GenericAttribute
protected GenericAttribute(java.lang.String name)
          Constructs a new GenericAttribute with the specified name
 
Method Summary
 java.lang.Object[] getArrayValue()
          Returns the attribute's values as an Object array
 boolean[] getBooleanArrayValue()
          Returns the attribute's values as a boolean array
 boolean getBooleanValue()
          Returns the attribute's value as a boolean
 byte[] getByteArrayValue()
          Returns the attribute's values as a byte array
 byte getByteValue()
          Returns the attribute's value as a byte
 java.util.Date[] getDateArrayValue()
          Returns the attribute's value as a java.util.Date array
 long[] getDateArrayValueAsLong()
          Returns the attribute's java.util.Date values as an array of long millisecond values
 java.util.Date getDateValue()
          Returns the attribute's value as a java.util.Date
 long getDateValueAsLong()
          Returns the attribute's java.util.Date value as a long millisecond value
 double[] getDoubleArrayValue()
          Returns the attribute's values as a double array
 double getDoubleValue()
          Returns the attribute's value as a double
 float[] getFloatArrayValue()
          Returns the attribute's values as a float array
 float getFloatValue()
          Returns the attribute's value as a float
 byte[] getHexValue()
          Returns the attribute's value as an array of hex bytes.
 java.lang.String getHexValueAsString()
          Returns the attribute's hex byte array value as a String
static IGenericAttribute getInstance(java.lang.String name)
          Factory method to create a IGenericAttribute instance
 int[] getIntArrayValue()
          Returns the attribute's values as an int array
 int getIntValue()
          Returns the attribute's value as an int
 long[] getLongArrayValue()
          Returns the attribute's values as a long array
 long getLongValue()
          Returns the attribute's value as a long
 java.lang.String getName()
          Returns the attribute's name
static int getObjectDataType(java.lang.Object obj)
          Returns the IGenericType describing the object's data type.
 short[] getShortArrayValue()
          Returns the attribute's values as a short array
 short getShortValue()
          Returns the attribute's value as a short
 java.lang.String[] getStringArrayValue()
          Returns the attribute's values as a String array
 java.lang.String getStringValue()
          Returns the attribute's value as a String
 int getType()
          Returns the type of this attribute
 java.lang.Object getValue()
          Returns the attribute's value as an Object or an Object[]
 void setArrayValue(java.lang.Object[] value)
          Sets the value of this attribute to an Object array
 void setBooleanArrayValue(boolean[] b)
          Sets the value of this attribute to a boolean array
 void setBooleanValue(boolean b)
          Sets the value of this attribute to a single boolean value
 void setByteArrayValue(byte[] b)
          Sets the value of this attribute to a byte array
 void setByteValue(byte b)
          Sets the value of this attribute to a single byte value
 void setDateArrayValue(java.util.Date[] d)
          Sets the value of this attribute to a java.util.Date array
 void setDateArrayValueAsLong(long[] l)
          Sets the value of this attribute to a java.util.Date array converted from the long milliseconds array values
 void setDateValue(java.util.Date d)
          Sets the value of this attribute to a single java.util.Date value
 void setDateValueAsLong(long l)
          Sets the value of this attribute to a single java.util.Date value converted from the given long milliseconds value
 void setDoubleArrayValue(double[] d)
          Sets the value of this attribute to a double array
 void setDoubleValue(double d)
          Sets the value of this attribute to a single double value
 void setFloatArrayValue(float[] f)
          Sets the value of this attribute to a float array
 void setFloatValue(float f)
          Sets the value of this attribute to a single float value
 void setHexValue(byte[] b)
          Sets the value of this attribute to a single HexBinary string converted from the given byte array.
 void setHexValue(java.lang.String s)
          Sets the value of this attribute to a single HexBinary string converted from the given byte array.
 void setIntArrayValue(int[] i)
          Sets the value of this attribute to an int array
 void setIntValue(int i)
          Sets the value of this attribute to a single int value
 void setLongArrayValue(long[] l)
          Sets the value of this attribute to a long array
 void setLongValue(long l)
          Sets the value of this attribute to a single long value
 void setName(java.lang.String name)
          Sets the name of this attribute
 void setShortArrayValue(short[] s)
          Sets the value of this attribute to a short array
 void setShortValue(short s)
          Sets the value of this attribute to a single short value
 void setStringArrayValue(java.lang.String[] s)
          Sets the value of this attribute to a String array
 void setStringValue(java.lang.String s)
          Sets the value of this attribute to a single String value
 void setType(int type)
          Sets the type of this attribute
 void setValue(java.lang.Object value)
          Sets the value of this attribute; value may be a single Object or an Object[]
 java.lang.String toString()
          Returns a string representation of this attribute (for debug purposes)
 java.lang.String valueAsString()
          Returns a string representation of this attribute's value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

name

protected volatile java.lang.String name
The attribute's name


value

protected volatile java.lang.Object[] value
The attribute's value


type

protected volatile int type
The attribute's type as defined in IGenericType. The type indicates whether the value fields represents one value or an array of values.

Constructor Detail

GenericAttribute

protected GenericAttribute()
Constructs a new GenericAttribute


GenericAttribute

protected GenericAttribute(java.lang.String name)
                    throws SensorEventException
Constructs a new GenericAttribute with the specified name

Parameters:
name - the name of the attribute
Throws:
SensorEventException
Method Detail

getInstance

public static IGenericAttribute getInstance(java.lang.String name)
                                     throws SensorEventException
Factory method to create a IGenericAttribute instance

Parameters:
name - the name of the attribute
Throws:
SensorEventException

getName

public java.lang.String getName()
Returns the attribute's name

Specified by:
getName in interface IGenericAttribute

getValue

public java.lang.Object getValue()
Returns the attribute's value as an Object or an Object[]

Specified by:
getValue in interface IGenericAttribute

getBooleanValue

public boolean getBooleanValue()
                        throws SensorEventException
Returns the attribute's value as a boolean

Specified by:
getBooleanValue in interface IGenericAttribute
Throws:
SensorEventException

getByteValue

public byte getByteValue()
                  throws SensorEventException
Returns the attribute's value as a byte

Specified by:
getByteValue in interface IGenericAttribute
Throws:
SensorEventException

getDateValue

public java.util.Date getDateValue()
                            throws SensorEventException
Returns the attribute's value as a java.util.Date

Specified by:
getDateValue in interface IGenericAttribute
Throws:
SensorEventException

getDateValueAsLong

public long getDateValueAsLong()
                        throws SensorEventException
Returns the attribute's java.util.Date value as a long millisecond value

Specified by:
getDateValueAsLong in interface IGenericAttribute
Throws:
SensorEventException

getDoubleValue

public double getDoubleValue()
                      throws SensorEventException
Returns the attribute's value as a double

Specified by:
getDoubleValue in interface IGenericAttribute
Throws:
SensorEventException

getFloatValue

public float getFloatValue()
                    throws SensorEventException
Returns the attribute's value as a float

Specified by:
getFloatValue in interface IGenericAttribute
Throws:
SensorEventException

getHexValue

public byte[] getHexValue()
                   throws SensorEventException
Returns the attribute's value as an array of hex bytes. The byte values have been decoded using the HexBinary algorithm.

Specified by:
getHexValue in interface IGenericAttribute
Throws:
SensorEventException

getHexValueAsString

public java.lang.String getHexValueAsString()
                                     throws SensorEventException
Returns the attribute's hex byte array value as a String

Specified by:
getHexValueAsString in interface IGenericAttribute
Throws:
SensorEventException

getIntValue

public int getIntValue()
                throws SensorEventException
Returns the attribute's value as an int

Specified by:
getIntValue in interface IGenericAttribute
Throws:
SensorEventException

getLongValue

public long getLongValue()
                  throws SensorEventException
Returns the attribute's value as a long

Specified by:
getLongValue in interface IGenericAttribute
Throws:
SensorEventException

getShortValue

public short getShortValue()
                    throws SensorEventException
Returns the attribute's value as a short

Specified by:
getShortValue in interface IGenericAttribute
Throws:
SensorEventException

getStringValue

public java.lang.String getStringValue()
                                throws SensorEventException
Returns the attribute's value as a String

Specified by:
getStringValue in interface IGenericAttribute
Throws:
SensorEventException

getArrayValue

public java.lang.Object[] getArrayValue()
                                 throws SensorEventException
Returns the attribute's values as an Object array

Specified by:
getArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getBooleanArrayValue

public boolean[] getBooleanArrayValue()
                               throws SensorEventException
Returns the attribute's values as a boolean array

Specified by:
getBooleanArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getByteArrayValue

public byte[] getByteArrayValue()
                         throws SensorEventException
Returns the attribute's values as a byte array

Specified by:
getByteArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getDateArrayValue

public java.util.Date[] getDateArrayValue()
                                   throws SensorEventException
Returns the attribute's value as a java.util.Date array

Specified by:
getDateArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getDateArrayValueAsLong

public long[] getDateArrayValueAsLong()
                               throws SensorEventException
Returns the attribute's java.util.Date values as an array of long millisecond values

Specified by:
getDateArrayValueAsLong in interface IGenericAttribute
Throws:
SensorEventException

getDoubleArrayValue

public double[] getDoubleArrayValue()
                             throws SensorEventException
Returns the attribute's values as a double array

Specified by:
getDoubleArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getFloatArrayValue

public float[] getFloatArrayValue()
                           throws SensorEventException
Returns the attribute's values as a float array

Specified by:
getFloatArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getIntArrayValue

public int[] getIntArrayValue()
                       throws SensorEventException
Returns the attribute's values as an int array

Specified by:
getIntArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getLongArrayValue

public long[] getLongArrayValue()
                         throws SensorEventException
Returns the attribute's values as a long array

Specified by:
getLongArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getShortArrayValue

public short[] getShortArrayValue()
                           throws SensorEventException
Returns the attribute's values as a short array

Specified by:
getShortArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getStringArrayValue

public java.lang.String[] getStringArrayValue()
                                       throws SensorEventException
Returns the attribute's values as a String array

Specified by:
getStringArrayValue in interface IGenericAttribute
Throws:
SensorEventException

getType

public int getType()
Returns the type of this attribute

Specified by:
getType in interface IGenericAttribute
See Also:
IGenericType

setName

public void setName(java.lang.String name)
             throws SensorEventException
Sets the name of this attribute

Specified by:
setName in interface IGenericAttribute
Throws:
SensorEventException

setValue

public void setValue(java.lang.Object value)
              throws SensorEventException
Sets the value of this attribute; value may be a single Object or an Object[]

Specified by:
setValue in interface IGenericAttribute
Throws:
SensorEventException

setBooleanValue

public void setBooleanValue(boolean b)
                     throws SensorEventException
Sets the value of this attribute to a single boolean value

Specified by:
setBooleanValue in interface IGenericAttribute
Throws:
SensorEventException

setByteValue

public void setByteValue(byte b)
                  throws SensorEventException
Sets the value of this attribute to a single byte value

Specified by:
setByteValue in interface IGenericAttribute
Throws:
SensorEventException

setDateValue

public void setDateValue(java.util.Date d)
                  throws SensorEventException
Sets the value of this attribute to a single java.util.Date value

Specified by:
setDateValue in interface IGenericAttribute
Throws:
SensorEventException

setDateValueAsLong

public void setDateValueAsLong(long l)
                        throws SensorEventException
Sets the value of this attribute to a single java.util.Date value converted from the given long milliseconds value

Specified by:
setDateValueAsLong in interface IGenericAttribute
Throws:
SensorEventException

setDoubleValue

public void setDoubleValue(double d)
                    throws SensorEventException
Sets the value of this attribute to a single double value

Specified by:
setDoubleValue in interface IGenericAttribute
Throws:
SensorEventException

setFloatValue

public void setFloatValue(float f)
                   throws SensorEventException
Sets the value of this attribute to a single float value

Specified by:
setFloatValue in interface IGenericAttribute
Throws:
SensorEventException

setHexValue

public void setHexValue(byte[] b)
                 throws SensorEventException
Sets the value of this attribute to a single HexBinary string converted from the given byte array. The string is created by encoding the given byte array using the HexBinary algorithm.

Specified by:
setHexValue in interface IGenericAttribute
Throws:
SensorEventException

setHexValue

public void setHexValue(java.lang.String s)
                 throws SensorEventException
Sets the value of this attribute to a single HexBinary string converted from the given byte array.

Specified by:
setHexValue in interface IGenericAttribute
Throws:
SensorEventException

setIntValue

public void setIntValue(int i)
                 throws SensorEventException
Sets the value of this attribute to a single int value

Specified by:
setIntValue in interface IGenericAttribute
Throws:
SensorEventException

setLongValue

public void setLongValue(long l)
                  throws SensorEventException
Sets the value of this attribute to a single long value

Specified by:
setLongValue in interface IGenericAttribute
Throws:
SensorEventException

setShortValue

public void setShortValue(short s)
                   throws SensorEventException
Sets the value of this attribute to a single short value

Specified by:
setShortValue in interface IGenericAttribute
Throws:
SensorEventException

setStringValue

public void setStringValue(java.lang.String s)
                    throws SensorEventException
Sets the value of this attribute to a single String value

Specified by:
setStringValue in interface IGenericAttribute
Throws:
SensorEventException

setArrayValue

public void setArrayValue(java.lang.Object[] value)
                   throws SensorEventException
Sets the value of this attribute to an Object array

Specified by:
setArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setBooleanArrayValue

public void setBooleanArrayValue(boolean[] b)
                          throws SensorEventException
Sets the value of this attribute to a boolean array

Specified by:
setBooleanArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setByteArrayValue

public void setByteArrayValue(byte[] b)
                       throws SensorEventException
Sets the value of this attribute to a byte array

Specified by:
setByteArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setDateArrayValue

public void setDateArrayValue(java.util.Date[] d)
                       throws SensorEventException
Sets the value of this attribute to a java.util.Date array

Specified by:
setDateArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setDateArrayValueAsLong

public void setDateArrayValueAsLong(long[] l)
                             throws SensorEventException
Sets the value of this attribute to a java.util.Date array converted from the long milliseconds array values

Specified by:
setDateArrayValueAsLong in interface IGenericAttribute
Throws:
SensorEventException

setDoubleArrayValue

public void setDoubleArrayValue(double[] d)
                         throws SensorEventException
Sets the value of this attribute to a double array

Specified by:
setDoubleArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setFloatArrayValue

public void setFloatArrayValue(float[] f)
                        throws SensorEventException
Sets the value of this attribute to a float array

Specified by:
setFloatArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setIntArrayValue

public void setIntArrayValue(int[] i)
                      throws SensorEventException
Sets the value of this attribute to an int array

Specified by:
setIntArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setLongArrayValue

public void setLongArrayValue(long[] l)
                       throws SensorEventException
Sets the value of this attribute to a long array

Specified by:
setLongArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setShortArrayValue

public void setShortArrayValue(short[] s)
                        throws SensorEventException
Sets the value of this attribute to a short array

Specified by:
setShortArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setStringArrayValue

public void setStringArrayValue(java.lang.String[] s)
                         throws SensorEventException
Sets the value of this attribute to a String array

Specified by:
setStringArrayValue in interface IGenericAttribute
Throws:
SensorEventException

setType

public void setType(int type)
Sets the type of this attribute

Specified by:
setType in interface IGenericAttribute
See Also:
IGenericType

getObjectDataType

public static int getObjectDataType(java.lang.Object obj)
                             throws SensorEventException
Returns the IGenericType describing the object's data type.

Throws:
SensorEventException

toString

public java.lang.String toString()
Returns a string representation of this attribute (for debug purposes)

Overrides:
toString in class java.lang.Object

valueAsString

public java.lang.String valueAsString()
Returns a string representation of this attribute's value

Specified by:
valueAsString in interface IGenericAttribute


Copyright © 2005 - 2009 IBM Corp. All Rights Reserved.