|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FudgeFieldContainer
A container of Fudge fields providing simple access to principal types.
The Fudge specification is built around messages containing a list of fields
.
This interface is the high-level representation of the list of fields.
Each field may be referenced by a name or by an ordinal. All four combinations are possible - from both present to both absent. Methods provide the ability to lookup a field by both name or ordinal.
Applications working with messages should use this interface rather than
FudgeMsg
directly where possible for flexibility.
This interface makes no guarantees about the mutability or thread-safety of implementations.
Method Summary | ||
---|---|---|
List<FudgeField> |
getAllByName(String name)
Gets the list of all fields with the given name. |
|
List<FudgeField> |
getAllByOrdinal(int ordinal)
Gets the list of all fields with the given ordinal. |
|
Set<String> |
getAllFieldNames()
Gets the set of all unique field names in this container. |
|
List<FudgeField> |
getAllFields()
Gets the list of all the fields in this container. |
|
Boolean |
getBoolean(int ordinal)
Gets the value of the first field with the given ordinal as a Boolean . |
|
Boolean |
getBoolean(String name)
Gets the value of the first field with the given name as a Boolean . |
|
FudgeField |
getByIndex(int index)
Gets the field in the container with the given index offset. |
|
FudgeField |
getByName(String name)
Gets the first field with the given name. |
|
FudgeField |
getByOrdinal(int ordinal)
Gets the first field with the given ordinal. |
|
Byte |
getByte(int ordinal)
Gets the value of the first field with the given ordinal as a Byte . |
|
Byte |
getByte(String name)
Gets the value of the first field with the given name as a Byte . |
|
Double |
getDouble(int ordinal)
Gets the value of the first field with the given ordinal as a Double . |
|
Double |
getDouble(String name)
Gets the value of the first field with the given name as a Double . |
|
|
getFieldValue(Class<T> clazz,
FudgeField field)
Gets the value of a field converted to a specific type. |
|
Float |
getFloat(int ordinal)
Gets the value of the first field with the given ordinal as a Float . |
|
Float |
getFloat(String name)
Gets the value of the first field with the given name as a Float . |
|
Integer |
getInt(int ordinal)
Gets the value of the first field with the given ordinal as an Integer . |
|
Integer |
getInt(String name)
Gets the value of the first field with the given name as an Integer . |
|
Long |
getLong(int ordinal)
Gets the value of the first field with the given ordinal as a Long . |
|
Long |
getLong(String name)
Gets the value of the first field with the given name as a Long . |
|
FudgeFieldContainer |
getMessage(int ordinal)
Gets the value of the first field with the given ordinal as a FudgeFieldContainer . |
|
FudgeFieldContainer |
getMessage(String name)
Gets the value of the first field with the given name as a FudgeFieldContainer . |
|
short |
getNumFields()
Gets the size of the container. |
|
Short |
getShort(int ordinal)
Gets the value of the first field with the given ordinal as a Short . |
|
Short |
getShort(String name)
Gets the value of the first field with the given name as a Short . |
|
String |
getString(int ordinal)
Gets the value of the first field with the given ordinal as a String . |
|
String |
getString(String name)
Gets the value of the first field with the given name as a String . |
|
|
getValue(Class<T> clazz,
int ordinal)
Gets the value of the first field with the given ordinal. |
|
|
getValue(Class<T> clazz,
String name)
Gets the value of the first field with the given name. |
|
Object |
getValue(int ordinal)
Gets the value of the first field with the given ordinal as an Object . |
|
Object |
getValue(String name)
Gets the value of the first field with the given name as an Object . |
|
boolean |
hasField(int ordinal)
Checks whether this container has any field which matches the given ordinal. |
|
boolean |
hasField(String name)
Checks whether this container has any field which matches the given name. |
|
boolean |
isEmpty()
Checks if the container is empty. |
|
Iterator<FudgeField> |
iterator()
Gets an iterator over the list of fields in this container. |
Method Detail |
---|
short getNumFields()
This returns the total number of fields.
boolean isEmpty()
This checks to see if there are any fields present.
Iterator<FudgeField> iterator()
A container is ordered and the returned iterator reflects that order.
iterator
in interface Iterable<FudgeField>
List<FudgeField> getAllFields()
A container is ordered and the returned list reflects that order.
Set<String> getAllFieldNames()
FudgeField getByIndex(int index)
index
- the zero-based offset into the message of the field, valid
IndexOutOfBoundsException
- if the index is invalidboolean hasField(String name)
name
- the field name to check, null returns false
List<FudgeField> getAllByName(String name)
A container is ordered and may contain multiple fields with the same name. This method returns all matching fields in the order of the container.
name
- the field name, null matches fields without a name
FudgeField getByName(String name)
A container is ordered and may contain multiple fields with the same name. This method returns the first that matches.
name
- the field name, null matches fields without a name
boolean hasField(int ordinal)
ordinal
- the field ordinal to check
List<FudgeField> getAllByOrdinal(int ordinal)
A container is ordered and may contain multiple fields with the same ordinal. This method returns all matching fields in the order of the container.
ordinal
- the field ordinal
FudgeField getByOrdinal(int ordinal)
A container is ordered and may contain multiple fields with the same ordinal. This method returns the first that matches.
ordinal
- the field ordinal
<T> T getFieldValue(Class<T> clazz, FudgeField field)
This attempts to convert the given field to a specific value type.
Depending on the underlying implementation this may use a FudgeTypeDictionary
.
This conversion logic is at the message level as the field itself does not contain sufficient information.
For example, the underlying FudgeFieldType
may be shared between a number of encoding strategies.
If an implementation does not have the ability to convert, it must return null
for a null
field value and the field value unchanged if it is assignable to the type requested.
T
- the class to convert toclazz
- the type to convert to, not nullfield
- the field whose data to convert, null returns null
IllegalArgumentException
- if the requested target class is not appropriate for the field<T> T getValue(Class<T> clazz, String name)
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches.
T
- the class to convert toclazz
- the type to convert to, not nullname
- the field name, null matches fields without a name
<T> T getValue(Class<T> clazz, int ordinal)
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches.
T
- the class to convert toclazz
- the type to convert to, not nullordinal
- the field ordinal
IllegalArgumentException
- if the requested target class is not appropriate for the fieldObject getValue(String name)
Object
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches.
name
- the field name, null matches fields without a name
Object getValue(int ordinal)
Object
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches.
ordinal
- the field ordinal
Double getDouble(String name)
Double
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a double.
name
- the field name, null matches fields without a name
Double getDouble(int ordinal)
Double
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a double.
ordinal
- the field ordinal
Float getFloat(String name)
Float
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a float.
name
- the field name, null matches fields without a name
Float getFloat(int ordinal)
Float
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a float.
ordinal
- the field ordinal
Long getLong(String name)
Long
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a long.
name
- the field name, null matches fields without a name
Long getLong(int ordinal)
Long
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a long.
ordinal
- the field ordinal
Integer getInt(String name)
Integer
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to an integer.
name
- the field name, null matches fields without a name
Integer getInt(int ordinal)
Integer
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to an integer.
ordinal
- the field ordinal
Short getShort(String name)
Short
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a short.
name
- the field name, null matches fields without a name
Short getShort(int ordinal)
Short
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a short.
ordinal
- the field ordinal
Byte getByte(String name)
Byte
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a byte.
name
- the field name, null matches fields without a name
Byte getByte(int ordinal)
Byte
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a byte.
ordinal
- the field ordinal
String getString(String name)
String
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a string.
name
- the field name, null matches fields without a name
String getString(int ordinal)
String
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a string.
ordinal
- the field ordinal
Boolean getBoolean(String name)
Boolean
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a boolean.
name
- the field name, null matches fields without a name
Boolean getBoolean(int ordinal)
Boolean
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a boolean.
ordinal
- the field ordinal
FudgeFieldContainer getMessage(String name)
FudgeFieldContainer
.
A container is ordered and may contain multiple fields with the same name. This method returns the value of the first that matches with a type that can be converted to a message.
name
- the field name, null matches fields without a name
FudgeFieldContainer getMessage(int ordinal)
FudgeFieldContainer
.
A container is ordered and may contain multiple fields with the same ordinal. This method returns the value of the first that matches with a type that can be converted to a message.
ordinal
- the field ordinal
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |