public class TupleEntry extends Object
Tuple
instance and its declaring Fields
instance to be used as a single object.
Once a TupleEntry is created, its Fields cannot be changed, but the Tuple instance it holds can be replaced or
modified. The managed Tuple should not have elements added or removed, as this will break the relationship with
the associated Fields instance.
If type information is provided on the Fields instance, all setters on this class will use that information to
coerce the given object to the expected type.
For example, if position is is of type long
, then entry.setString(0, "9" )
will coerce the "9" to a
long 9
. Thus, entry.getObject(0) == 9l
.
No coercion is performed with the getObject(Comparable)
and getObject(int)
methods.
To set a value without coercion, see the setRaw(Comparable, Object)
and setRaw(int, Object)
methods.Modifier and Type | Field and Description |
---|---|
static TupleEntry |
NULL
An EMPTY TupleEntry instance for use as a stand in instead of a
null . |
Constructor and Description |
---|
TupleEntry()
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(boolean isUnmodifiable)
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(Fields fields)
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(Fields fields,
boolean isUnmodifiable)
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(Fields fields,
Tuple tuple)
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(Fields fields,
Tuple tuple,
boolean isUnmodifiable)
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(Tuple tuple)
Constructor TupleEntry creates a new TupleEntry instance.
|
TupleEntry(TupleEntry tupleEntry)
Constructor TupleEntry creates a new TupleEntry instance that is a safe copy of the given tupleEntry.
|
Modifier and Type | Method and Description |
---|---|
TupleEntry |
appendNew(TupleEntry entry)
Method appendNew appends the given TupleEntry instance to this instance.
|
<T> Iterable<T> |
asIterableOf(Class<T> type)
Method asIterableOf returns an
Iterable instance that will coerce all Tuple elements
into the given type parameter. |
boolean |
equals(Object object) |
boolean |
getBoolean(Comparable fieldName)
Method getBoolean returns the element for the given field name or position as a boolean.
|
Tuple |
getCoercedTuple(Type[] types)
Method getCoercedTuple is a helper method for copying the current tuple elements into a new Tuple,
of the same size, as the requested coerced types.
|
Tuple |
getCoercedTuple(Type[] types,
Tuple into)
Method getCoercedTuple is a helper method for copying the current tuple elements into the new Tuple,
of the same size, as the requested coerced types.
|
double |
getDouble(Comparable fieldName)
Method getDouble returns the element for the given field name or position as a double.
|
Fields |
getFields()
Method getFields returns the fields of this TupleEntry object.
|
float |
getFloat(Comparable fieldName)
Method getFloat returns the element for the given field name or position as a float.
|
int |
getInteger(Comparable fieldName)
Method getInteger returns the element for the given field name or position as an int.
|
long |
getLong(Comparable fieldName)
Method getLong returns the element for the given field name or position as a long.
|
Object |
getObject(Comparable fieldName)
Method getObject returns the value in the given field or position.
|
Object |
getObject(Comparable fieldName,
Type type)
Method getObject returns the value in the given field or position as the requested type.
|
Object |
getObject(int pos)
Method getObject returns the value in the given position pos.
|
Object |
getObject(int pos,
Type type)
Method getObject returns the value in the given field or position as the requested type.
|
short |
getShort(Comparable fieldName)
Method getShort returns the element for the given field name or position as a short.
|
String |
getString(Comparable fieldName)
Method getString returns the element for the given field name or position as a String.
|
Tuple |
getTuple()
Method getTuple returns the tuple of this TupleEntry object.
|
Tuple |
getTupleCopy()
Method getTupleCopy returns a copy of the tuple of this TupleEntry object.
|
int |
hashCode() |
boolean |
hasTypes()
Returns true if there are types associated with this instance.
|
boolean |
isUnmodifiable()
Method isUnmodifiable returns true if this TupleEntry is unmodifiable.
|
static Tuple |
select(Fields selector,
TupleEntry... entries)
Method select will select a new Tuple instance from the given set of entries.
|
TupleEntry |
selectEntry(Fields selector)
Method selectEntry selects the fields specified in the selector from this instance.
|
TupleEntry |
selectEntryCopy(Fields selector)
Method selectEntry selects the fields specified in selector from this instance.
|
Tuple |
selectInto(Fields selector,
Tuple tuple)
Method selectInto selects the fields specified in the selector from this instance and copies
them into the given tuple argument.
|
Tuple |
selectTuple(Fields selector)
Method selectTuple selects the fields specified in the selector from this instance.
|
Tuple |
selectTupleCopy(Fields selector)
Method selectTupleCopy selects the fields specified in selector from this instance.
|
void |
set(TupleEntry tupleEntry)
Method set sets the values from the given tupleEntry into this TupleEntry instance based on the given
tupleEntry field names.
|
void |
setBoolean(Comparable fieldName,
boolean value)
Method setBoolean sets the value in the given field or position.
|
void |
setCanonicalTuple(Tuple tuple)
Method setCanonicalTuple replaces each value of the current tuple with the given tuple elements after
they are coerced.
|
void |
setCanonicalValues(Object[] values)
Method setCanonicalValues replaces each value of the current tuple with th give Object[]
after they are coerced.
|
void |
setDouble(Comparable fieldName,
double value)
Method setDouble sets the value in the given field or position.
|
void |
setFloat(Comparable fieldName,
float value)
Method setFloat sets the value in the given field or position.
|
void |
setInteger(Comparable fieldName,
int value)
Method setInteger sets the value in the given field or position.
|
void |
setLong(Comparable fieldName,
long value)
Method setLong sets the value in the given field or position.
|
void |
setObject(Comparable fieldName,
Object value)
Method set sets the value in the given field or position.
|
void |
setRaw(Comparable fieldName,
Object value)
Method set sets the value in the given field or position.
|
void |
setRaw(int pos,
Object value)
Method set sets the value in the given position.
|
void |
setShort(Comparable fieldName,
short value)
Method setShort sets the value in the given field or position.
|
void |
setString(Comparable fieldName,
String value)
Method setString sets the value in the given field or position.
|
void |
setTuple(Fields selector,
Tuple tuple)
Method setTuple sets the values specified by the selector to the values given by the given tuple, the given
values will always be copied into this TupleEntry.
|
void |
setTuple(Tuple tuple)
Method setTuple sets the tuple of this TupleEntry object, no copy will be performed.
|
int |
size()
Method size returns the number of values in this instance.
|
String |
toString() |
public static final TupleEntry NULL
null
.public TupleEntry()
@ConstructorProperties(value="isUnmodifiable") public TupleEntry(boolean isUnmodifiable)
isUnmodifiable
- of type boolean@ConstructorProperties(value="fields") public TupleEntry(Fields fields)
fields
- of type Fields@ConstructorProperties(value={"fields","isUnmodifiable"}) public TupleEntry(Fields fields, boolean isUnmodifiable)
fields
- of type FieldsisUnmodifiable
- of type boolean@ConstructorProperties(value={"fields","tuple","isUnmodifiable"}) public TupleEntry(Fields fields, Tuple tuple, boolean isUnmodifiable)
fields
- of type Fieldstuple
- of type TupleisUnmodifiable
- of type boolean@ConstructorProperties(value={"fields","tuple"}) public TupleEntry(Fields fields, Tuple tuple)
fields
- of type Fieldstuple
- of type Tuple@ConstructorProperties(value="tupleEntry") public TupleEntry(TupleEntry tupleEntry)
tupleEntry
- of type TupleEntry@ConstructorProperties(value="tuple") public TupleEntry(Tuple tuple)
tuple
- of type Tuplepublic static Tuple select(Fields selector, TupleEntry... entries)
selector
- of type Fieldsentries
- of type TupleEntrypublic boolean isUnmodifiable()
public Fields getFields()
public boolean hasTypes()
public Tuple getTuple()
public Tuple getTupleCopy()
public Tuple getCoercedTuple(Type[] types)
types
- of type Type[]public Tuple getCoercedTuple(Type[] types, Tuple into)
types
- of type Type[]into
- of type Tuplepublic void setTuple(Tuple tuple)
Tuple.isUnmodifiable() == true
) and this TupleEntry is
not "unmodifiable", an exception will be thrown.
Unmodifiable tuples are generally owned by the system and cannot be be changed and must not be cached.tuple
- the tuple of this TupleEntry object.public void setCanonicalTuple(Tuple tuple)
null
, the current tuple will be set to null
.tuple
- to replace the current wrapped Tuple instancepublic void setCanonicalValues(Object[] values)
values
- to replace the current wrapped tuple instance valuespublic int size()
public Object getObject(int pos)
pos
- position of the element to return.public Object getObject(int pos, Type type)
pos
- position of the element to return.public Object getObject(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.
No coercion is performed if there is an associated coercible type.fieldName
- field name or position to returnpublic Object getObject(Comparable fieldName, Type type)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.
Coercion is performed to the given type.fieldName
- field name or position to returnpublic void setRaw(int pos, Object value)
pos
- position to setvalue
- of type Comparablepublic void setRaw(Comparable fieldName, Object value)
fieldName
- field name or position to setvalue
- of type Comparablepublic void setObject(Comparable fieldName, Object value)
fieldName
- field name or position to setvalue
- of type Comparablepublic void setBoolean(Comparable fieldName, boolean value)
fieldName
- field name or position to setvalue
- of type booleanpublic void setShort(Comparable fieldName, short value)
fieldName
- field name or position to setvalue
- of type shortpublic void setInteger(Comparable fieldName, int value)
fieldName
- field name or position to setvalue
- of type intpublic void setLong(Comparable fieldName, long value)
fieldName
- field name or position to setvalue
- of type longpublic void setFloat(Comparable fieldName, float value)
fieldName
- field name or position to setvalue
- of type floatpublic void setDouble(Comparable fieldName, double value)
fieldName
- field name or position to setvalue
- of type doublepublic void setString(Comparable fieldName, String value)
fieldName
- field name or position to setvalue
- of type Stringpublic String getString(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic float getFloat(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic double getDouble(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic int getInteger(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic long getLong(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic short getShort(Comparable fieldName)
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic boolean getBoolean(Comparable fieldName)
true
value will be returned. false
if null.
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.fieldName
- field name or position to returnpublic TupleEntry selectEntry(Fields selector)
Fields.ALL
or the
same fields as declared are given, this
will be returned.
The returned TupleEntry will be either modifiable or unmodifiable, depending on the state of this TupleEntry instance.
See selectEntryCopy(Fields)
to guarantee a copy suitable for modifying or caching/storing in a collection.
Note this is a bug fix and change from 2.0 and 2.1. In previous versions the modifiable state was dependent
on the given selector.selector
- Fields selector that selects the values to returnpublic TupleEntry selectEntryCopy(Fields selector)
selector
- Fields selector that selects the values to returnpublic Tuple selectTuple(Fields selector)
Fields.ALL
or the
same fields as declared are given, this.getTuple()
will be returned.
The returned Tuple will be either modifiable or unmodifiable, depending on the state of this TupleEntry instance.
See selectTupleCopy(Fields)
to guarantee a copy suitable for modifying or caching/storing in a collection.
Note this is a bug fix and change from 2.0 and 2.1. In previous versions the modifiable state was dependent
on the given selector.selector
- Fields selector that selects the values to returnpublic Tuple selectTupleCopy(Fields selector)
selector
- Fields selector that selects the values to returnpublic Tuple selectInto(Fields selector, Tuple tuple)
selector
- of type Fieldstuple
- of type Tuplepublic void setTuple(Fields selector, Tuple tuple)
selector
- of type Fieldstuple
- of type Tuplepublic void set(TupleEntry tupleEntry)
tupleEntry
- of type TupleEntrypublic TupleEntry appendNew(TupleEntry entry)
entry
- of type TupleEntrypublic <T> Iterable<T> asIterableOf(Class<T> type)
Iterable
instance that will coerce all Tuple elements
into the given type
parameter.
This method honors any CoercibleType
instances on the internal
Fields instance for the specified Tuple element.type
- of type ClassCopyright © 2007-2015 Concurrent, Inc. All Rights Reserved.