|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthomegear.HomeGearArray
public class HomeGearArray
Representation of the homegear RPC arrays and structs.
A Usage demonstration is given in main(String[])
.
Field Summary | |
---|---|
protected byte[] |
data
|
protected int |
length
|
protected int |
offs
|
static int |
TYPE_ARRAY
Array identifier |
static int |
TYPE_BASE64
BASE64 identifier |
static int |
TYPE_BOOL
Boolean identifier |
static int |
TYPE_FLOAT
Float identifier |
static int |
TYPE_INT
Integer identifier |
static int |
TYPE_STRING
String identifier |
static int |
TYPE_STRUCT
Struct identifier |
Constructor Summary | |
---|---|
HomeGearArray(boolean struct,
byte[] data_,
int offs_)
Constructs an array or struct from a raw data. |
|
HomeGearArray(java.lang.Object... vals)
Constructs an array from a list of variables. |
|
HomeGearArray(java.lang.String[] names,
java.lang.Object[] vals)
Constructs an array or a struct from a list of variables |
Method Summary | |
---|---|
boolean |
boolValue(int idx)
Returns a boolean element. |
HomeGearArray |
child(int idx)
Returns child array or struct. |
protected void |
compress(byte[] data_,
int offs_)
Replaces data buffer and releases duplicate buffers of children. |
HomeGearArray |
copy()
This makes a copy of the instance. |
double |
doubleValue(int idx)
Returns value of a float or integer object. |
int |
find(java.lang.String name)
Returns the index of a element identified by field name. |
protected int |
intEncode(int pos)
Encodes integer from data at a given position. |
int |
intValue(int idx)
Returns a integer element. |
boolean |
isStruct()
Returns true if it is a struct, i.e. if elements have names. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
name(int idx)
Returns the name of an element or null if its an array. |
int |
size()
Returns number of elements. |
java.lang.String |
stringValue(java.lang.String lb,
int idx)
Returns a string representation of a element. |
java.lang.String |
toString()
Returns a string representation. |
java.lang.String |
toString(java.lang.String lb)
Returns a string representation. |
int |
type(int idx)
Returns the type of an element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected byte[] data
protected int offs
protected int length
public static final int TYPE_INT
public static final int TYPE_BOOL
public static final int TYPE_STRING
public static final int TYPE_FLOAT
public static final int TYPE_BASE64
public static final int TYPE_ARRAY
public static final int TYPE_STRUCT
Constructor Detail |
---|
public HomeGearArray(java.lang.String[] names, java.lang.Object[] vals) throws java.lang.IllegalArgumentException, java.io.IOException
names
- The field names. If length of names is > 0 and names != null its a struct, otherwise an array.vals
- Values of the struct or array.
java.lang.IllegalArgumentException
- if a parameter is invalid.
java.io.IOException
- if an I/O error occurs.public HomeGearArray(java.lang.Object... vals) throws java.lang.IllegalArgumentException, java.io.IOException
vals
- Values of the array.
java.lang.IllegalArgumentException
- if a parameter is invalid.
java.io.IOException
- if an I/O error occurs.public HomeGearArray(boolean struct, byte[] data_, int offs_) throws java.lang.IllegalArgumentException
struct
- True if it is a struct.data_
- Buffer containing data.offs_
- Offset of data.
java.lang.IllegalArgumentException
- if a parameter is invalid.Method Detail |
---|
public HomeGearArray copy()
protected void compress(byte[] data_, int offs_)
data_
- New data buffer.offs_
- New offset.public int size()
public boolean isStruct()
protected int intEncode(int pos) throws java.lang.IllegalArgumentException
pos
- The position.
java.lang.IllegalArgumentException
- if Index is out of bounds.public int find(java.lang.String name) throws java.io.UnsupportedEncodingException
name
- The name of the field.
java.io.UnsupportedEncodingException
- if your computer does not support ASCII.public int type(int idx) throws java.lang.IndexOutOfBoundsException
idx
- The element index.
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.public boolean boolValue(int idx) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException
idx
- The element index.
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.
java.lang.IllegalArgumentException
- if element type is invalid.public int intValue(int idx) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException
idx
- The element index.
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.
java.lang.IllegalArgumentException
- if element type is invalid.public double doubleValue(int idx) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException
idx
- The element index.
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.
java.lang.IllegalArgumentException
- if element type is invalid.public HomeGearArray child(int idx) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException
idx
- the element index.
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.
java.lang.IllegalArgumentException
- if element type is invalid.public java.lang.String stringValue(java.lang.String lb, int idx) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
idx
- the element index.lb
- line break string (including indent).
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.
java.lang.IllegalArgumentException
- if element type is invalid.
java.io.UnsupportedEncodingException
- if your computer does not support ASCII.public java.lang.String name(int idx) throws java.lang.IndexOutOfBoundsException, java.io.UnsupportedEncodingException
idx
- the element index.
java.lang.IndexOutOfBoundsException
- if Index is out of bounds.
java.io.UnsupportedEncodingException
- if your computer does not support ASCII.public java.lang.String toString(java.lang.String lb)
lb
- line break string (including indent).
public java.lang.String toString()
toString
in class java.lang.Object
java.lang.IllegalArgumentException
- if data is corrupt.public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |