|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.inspirel.yami.Parameters
public final class Parameters
Collection of message parameters.
A collection of message parameters is a list of typed {name, value} pairs.
Each entry in this collection has a unique name and can have
one of the following types:
boolean
or boolean
arrayint
or int
arraylong
or long
arraydouble
or double
arrayString
or String
arraybyte[]
buffers or their arraysParameters
objects or their arrays,
which provides its own scope for naming.The names of entries are searched for using case-sensitive comparisons.
Note: The instances of this class should not be used from multiple threads without synchronization; it is safe to use separate instances in separate threads.
Note:
The entries are ordered - the order in which they are created
influences the final serialized form of the message payload.
Newly created entries are appended to the end of the collection unless
there is an existing empty slot that can be reused - the appropriate
slot is searched for from the beginning to the end of the collection
and if no free slot is found the collection is extended at the end.
The above guarantee concerns the user code that relies on
predictable serialization.
Nested Class Summary | |
---|---|
static class |
Parameters.Entry
Class representing a single entry in the collection. |
static class |
Parameters.EntryIterator
Iterator class for visiting all entries in the collection. |
static class |
Parameters.EntryType
Enumeration defining all possible entry types. |
Constructor Summary | |
---|---|
Parameters()
Default constructor, creates an empty collection of parameters. |
Method Summary | |
---|---|
void |
clear()
Removes all entries from the collection. |
void |
deserialize(java.util.List<byte[]> buffers)
Deserializes from the given list of buffers. |
Parameters.Entry |
find(java.lang.String name)
Finds the entry by name. |
byte[] |
getBinary(java.lang.String name)
Gets the byte[] value from the given entry. |
byte[][] |
getBinaryArray(java.lang.String name)
Gets the array of byte[] buffers
from the given entry. |
boolean |
getBoolean(java.lang.String name)
Gets the boolean value from the given entry. |
boolean[] |
getBooleanArray(java.lang.String name)
Gets the boolean array from the given entry. |
double |
getDouble(java.lang.String name)
Gets the double value from the given entry. |
double[] |
getDoubleArray(java.lang.String name)
Gets the double array from the given entry. |
int |
getInteger(java.lang.String name)
Gets the int value from the given entry. |
int[] |
getIntegerArray(java.lang.String name)
Gets the int array from the given entry. |
long |
getLong(java.lang.String name)
Gets the long value from the given entry. |
long[] |
getLongArray(java.lang.String name)
Gets the long array from the given entry. |
Parameters[] |
getNestedArray(java.lang.String name)
Gets the nested Parameters array from the given entry. |
Parameters |
getNestedParameters(java.lang.String name)
Gets the nested Parameters object from the given entry. |
java.lang.String |
getString(java.lang.String name)
Gets the String value from the given entry. |
java.lang.String[] |
getStringArray(java.lang.String name)
Gets the String array from the given entry. |
Parameters.EntryType |
getType(java.lang.String name)
Gets the type of the given entry. |
java.util.Iterator<Parameters.Entry> |
iterator()
Gets the iterator over the list of entries. |
void |
remove(java.lang.String name)
Removes the given entry from the collection. |
java.util.List<byte[]> |
serialize(int chunkSize)
Serializes the content of the whole collection. |
void |
setBinary(java.lang.String name,
byte[] value)
Sets a byte[] value with the given name. |
void |
setBinaryArray(java.lang.String name,
byte[][] array)
Sets the byte[] array (note: array of byte arrays)
with the given name. |
void |
setBoolean(java.lang.String name,
boolean value)
Sets a boolean value with the given name. |
void |
setBooleanArray(java.lang.String name,
boolean[] array)
Sets the boolean array with the given name. |
void |
setDouble(java.lang.String name,
double value)
Sets a double value with the given name. |
void |
setDoubleArray(java.lang.String name,
double[] array)
Sets the double array with the given name. |
void |
setInteger(java.lang.String name,
int value)
Sets an int value with the given name. |
void |
setIntegerArray(java.lang.String name,
int[] array)
Sets the int array with the given name. |
void |
setLong(java.lang.String name,
long value)
Sets a long value with the given name. |
void |
setLongArray(java.lang.String name,
long[] array)
Sets the long array with the given name. |
void |
setNestedArray(java.lang.String name,
Parameters[] nested)
Sets the nested Parameters array with the given name. |
void |
setNestedParameters(java.lang.String name,
Parameters nested)
Sets the nested Parameters object with the given name. |
void |
setString(java.lang.String name,
java.lang.String value)
Sets a String value with the given name. |
void |
setStringArray(java.lang.String name,
java.lang.String[] array)
Sets the String array with the given name. |
int |
size()
Gets the current size of the collection. |
java.lang.String |
toString()
Returns a string representation of the content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Parameters()
Method Detail |
---|
public void setBoolean(java.lang.String name, boolean value)
boolean
value with the given name.
name
- name of the new entry or the entry to be replacedvalue
- value to be setpublic boolean getBoolean(java.lang.String name)
boolean
value from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain boolean
value
NoSuchNameException
- if the given name is not foundpublic void setInteger(java.lang.String name, int value)
int
value with the given name.
name
- name of the new entry or the entry to be replacedvalue
- value to be setpublic int getInteger(java.lang.String name)
int
value from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain int
value
NoSuchNameException
- if the given name is not foundpublic void setLong(java.lang.String name, long value)
long
value with the given name.
name
- name of the new entry or the entry to be replacedvalue
- value to be setpublic long getLong(java.lang.String name)
long
value from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain long
value
NoSuchNameException
- if the given name is not foundpublic void setDouble(java.lang.String name, double value)
double
value with the given name.
name
- name of the new entry or the entry to be replacedvalue
- value to be setpublic double getDouble(java.lang.String name)
double
value from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain double
value
NoSuchNameException
- if the given name is not foundpublic void setString(java.lang.String name, java.lang.String value)
String
value with the given name.
name
- name of the new entry or the entry to be replacedvalue
- value to be setpublic java.lang.String getString(java.lang.String name)
String
value from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain String
value
NoSuchNameException
- if the given name is not foundpublic void setBinary(java.lang.String name, byte[] value)
byte[]
value with the given name.
name
- name of the new entry or the entry to be replacedvalue
- value to be setpublic byte[] getBinary(java.lang.String name)
byte[]
value from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain byte[]
value
NoSuchNameException
- if the given name is not foundpublic void setBooleanArray(java.lang.String name, boolean[] array)
boolean
array with the given name.
Note: the array is not copied internally.
name
- name of the new entry or the entry to be replacedarray
- value to be setpublic boolean[] getBooleanArray(java.lang.String name)
boolean
array from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain boolean
array
NoSuchNameException
- if the given name is not foundpublic void setIntegerArray(java.lang.String name, int[] array)
int
array with the given name.
Note: the array is not copied internally.
name
- name of the new entry or the entry to be replacedarray
- value to be setpublic int[] getIntegerArray(java.lang.String name)
int
array from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain int
array
NoSuchNameException
- if the given name is not foundpublic void setLongArray(java.lang.String name, long[] array)
long
array with the given name.
Note: the array is not copied internally.
name
- name of the new entry or the entry to be replacedarray
- value to be setpublic long[] getLongArray(java.lang.String name)
long
array from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain long
array
NoSuchNameException
- if the given name is not foundpublic void setDoubleArray(java.lang.String name, double[] array)
double
array with the given name.
Note: the array is not copied internally.
name
- name of the new entry or the entry to be replacedarray
- value to be setpublic double[] getDoubleArray(java.lang.String name)
double
array from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain long
array
NoSuchNameException
- if the given name is not foundpublic void setStringArray(java.lang.String name, java.lang.String[] array)
String
array with the given name.
Note: the array is not copied internally.
name
- name of the new entry or the entry to be replacedarray
- value to be setpublic java.lang.String[] getStringArray(java.lang.String name)
String
array from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain String
array
NoSuchNameException
- if the given name is not foundpublic void setBinaryArray(java.lang.String name, byte[][] array)
byte[]
array (note: array of byte arrays)
with the given name.
Note: the arrays are not copied internally.
name
- name of the new entry or the entry to be replacedarray
- value to be setpublic byte[][] getBinaryArray(java.lang.String name)
byte[]
buffers
from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain byte[]
array
NoSuchNameException
- if the given name is not foundpublic void setNestedParameters(java.lang.String name, Parameters nested)
Parameters
object with the given name.
Note: the nested object is not cloned internally.
name
- name of the new entry or the entry to be replacednested
- object to nestpublic Parameters getNestedParameters(java.lang.String name)
Parameters
object from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain nested
Parameters
object
NoSuchNameException
- if the given name is not foundpublic void setNestedArray(java.lang.String name, Parameters[] nested)
Parameters
array with the given name.
Note: the nested objects are not cloned internally.
name
- name of the new entry or the entry to be replacednested
- array of objects to nestpublic Parameters[] getNestedArray(java.lang.String name)
Parameters
array from the given entry.
name
- name of the entry to be inspected
BadTypeException
- if the given entry does not contain nested
Parameters
array
NoSuchNameException
- if the given name is not foundpublic void remove(java.lang.String name)
Note: The removed entry leaves a hole (empty slot) in the collection that can be reused by newly added entries.
name
- the name of the entry to be removedpublic void clear()
public int size()
public Parameters.EntryType getType(java.lang.String name)
name
- name of the given entry
NoSuchNameException
- if the given name is not foundpublic java.util.Iterator<Parameters.Entry> iterator()
The iterator visits only those entries which are used (in other words, it skips unused slots).
iterator
in interface java.lang.Iterable<Parameters.Entry>
public Parameters.Entry find(java.lang.String name)
name
- the name of entry
Entry
or null
if the given name was not foundpublic java.util.List<byte[]> serialize(int chunkSize)
The content is serialized into chunks of the given size, after serialization only the last chunk can be smaller than the requested size.
serialize
in interface YAMISerializable
chunkSize
- chunk size, should be a multiple of 4
or Integer.MAX_VALUE
java.lang.IllegalArgumentException
- if requested chunk size
is not a multiple of 4 and is not
Integer.MAX_VALUE
public void deserialize(java.util.List<byte[]> buffers)
Note: The current content of this object is not cleared
before attempting deserialization and each retrieved data element
is merged into the current content as if done by individual
calls to appropriate setXYZ
functions.
In most cases deserialization will be performed to the empty
Parameters
object
(to reconstruct it to the form that was used
for serialization), but deserialization onto non-empty object
might be occasionally useful as a way of merging two collections.
buffers
- each buffer should have a size that is multiple of 4
java.lang.IllegalArgumentException
- if any of the given
buffers has a size that is not a multiple of 4
or when the given data cannot be properly deserializedpublic java.lang.String toString()
This function is supposed to be used by unit tests and for simple debugging.
toString
in class java.lang.Object
String
representation of the collection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |