Interface Tuple
-
- All Known Subinterfaces:
- OutputTuple
public interface TupleA representation of a stream's tuple. The order of the attributes match the corresponding StreamSchema for the Stream that generated the tuple.
The type of the object for an attribute is defined by its type and the mapping between SPL and Java is shown byType.MetaType.Instances of
Tupleimplementjava.io.Serializable. Serializing a tuple will also serialize itsStreamSchemareference.- See Also:
StreamingData,StreamSchema,Type.MetaType
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description TupleasReadOnlyTuple()Get an immutable version of this tuple.java.math.BigDecimalgetBigDecimal(int attributeIndex)Get an attribute as a BigDecimal.java.math.BigDecimalgetBigDecimal(java.lang.String attributeName)Get the attribute as an BigDecimal using the attribute's name.BlobgetBlob(int attributeIndex)Get an attribute as a Blob.BlobgetBlob(java.lang.String attributeName)Get the attribute as a Blob using the attribute's name.booleangetBoolean(int attributeIndex)Get an attribute as a primitive boolean.booleangetBoolean(java.lang.String attributeName)Get the attribute as a boolean using the attribute's name.java.nio.BuffergetBuffer(int attributeIndex)Get an attribute as a read-only java.nio.Buffer.<T extends java.nio.Buffer>
TgetBuffer(int attributeIndex, java.lang.Class<T> type)Get the attribute as a buffer of typeTusing the attribute's index.java.nio.BuffergetBuffer(java.lang.String attributeName)Get the attribute as a java.nio.Buffer using the attribute's name.<T extends java.nio.Buffer>
TgetBuffer(java.lang.String attributeName, java.lang.Class<T> type)Get the attribute as a buffer of typeTusing the attribute's name.bytegetByte(int attributeIndex)Get an attribute as a primitive byte.bytegetByte(java.lang.String attributeName)Get the attribute as a byte using the attribute's name.doublegetDouble(int attributeIndex)Get an attribute as a primitive double.doublegetDouble(java.lang.String attributeName)Get the attribute as a double using the attribute's name.<E extends java.lang.Enum<E>>
EgetEnum(java.lang.Class<E> enumType, int attributeIndex)Get an attribute as an enumeration.<E extends java.lang.Enum<E>>
EgetEnum(java.lang.Class<E> enumType, java.lang.String attributeName)Get the attribute as an enumeration using the attribute's name.floatgetFloat(int attributeIndex)Get an attribute as a primitive float.floatgetFloat(java.lang.String attributeName)Get the attribute as a float using the attribute's name.intgetInt(int attributeIndex)Get an attribute as a primitive int.intgetInt(java.lang.String attributeName)Get the attribute as an int using the attribute's name.java.util.List<?>getList(int attributeIndex)Get an attribute as a List.java.util.List<?>getList(java.lang.String attributeName)Get the attribute as a java.util.List using the attribute's name.longgetLong(int attributeIndex)Get an attribute as a primitive long.longgetLong(java.lang.String attributeName)Get the attribute as a long using the attribute's name.java.util.Map<?,?>getMap(int attributeIndex)Get an attribute as a Map.java.util.Map<?,?>getMap(java.lang.String attributeName)Get the attribute as a java.util.Map using the attribute's name.java.lang.ObjectgetObject(int attributeIndex)Get the object representing the attribute's value at given index.<T> TgetObject(int attributeIndex, java.lang.Class<T> type)Get an object of typeTrepresenting the attribute's value at given index.java.lang.ObjectgetObject(java.lang.String attributeName)Get the attribute as an Object using the attribute's name.<T> TgetObject(java.lang.String attributeName, java.lang.Class<T> type)Get the attribute as an object of typeTusing the attribute's name.java.util.Set<?>getSet(int attributeIndex)Get an attribute as a Set.java.util.Set<?>getSet(java.lang.String attributeName)Get the attribute as a java.util.Set using the attribute's name.shortgetShort(int attributeIndex)Get an attribute as a primitive short.shortgetShort(java.lang.String attributeName)Get the attribute as a short using the attribute's name.StreamSchemagetStreamSchema()Get the StreamSchema for this Tuple.java.lang.StringgetString(int attributeIndex)Get an attribute as a String.java.lang.StringgetString(java.lang.String attributeName)Get the attribute as a String using the attribute's name.TimestampgetTimestamp(int attributeIndex)Get an attribute as a Timestamp.TimestampgetTimestamp(java.lang.String attributeName)Get the attribute as a Timestamp using the attribute's name.TuplegetTuple(int attributeIndex)Get an attribute as a Tuple.TuplegetTuple(java.lang.String attributeName)Get the attribute as a Tuple using the attribute's name.XMLgetXML(int attributeIndex)Get an attribute as anXML.XMLgetXML(java.lang.String attributeName)Get the attribute as anXMLusing the attribute's name.
-
-
-
Method Detail
-
getStreamSchema
StreamSchema getStreamSchema()
Get the StreamSchema for this Tuple.- Returns:
- The schema for the tuple.
-
getObject
java.lang.Object getObject(int attributeIndex)
Get the object representing the attribute's value at given index. The class of the returned object is equal to the return ofType.getObjectType()for the attribute's type.If the returned object is mutable (such as Java arrays) then modifying the returned object will not modify the state of this tuple as getObject() will return a copy of its internal state.
To avoid such a copy, getBuffer() may be used for most List types.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The attribute's value for this tuple as an object.
- See Also:
getBuffer(int)
-
getObject
<T> T getObject(int attributeIndex, java.lang.Class<T> type)Get an object of typeTrepresenting the attribute's value at given index. The typeTmust match the class type of the attribute'sobject type. This method does not perform any type conversion.If the returned object is mutable (such as Java arrays) then modifying the returned object will not modify the state of this tuple as getObject() will return a copy of its internal state.
To avoid such a copy, getBuffer() may be used for most List types.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.type- Class for the type to be returned- Returns:
- The attribute's value for this tuple as an object.
- Throws:
java.lang.ClassCastException- Attribute's object type does not matchtype.- Since:
- InfoSphere® Streams Version 3.1
- See Also:
getObject(int),getBuffer(int)
-
getBoolean
boolean getBoolean(int attributeIndex)
Get an attribute as a primitive boolean. Only supported for attributes of typeBOOLEAN.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a boolean.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive boolean
-
getByte
byte getByte(int attributeIndex)
Get an attribute as a primitive byte. Only supported for attributes of typeINT8andUINT8.
UINT8attributes are returned as a 8-bit signed two's complement integer,getIntmay be used to to obtain a true representation of the unsigned value.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a byte.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive byte
-
getShort
short getShort(int attributeIndex)
Get an attribute as a primitive short. Only supported for attributes of typeINT16,INT8,UINT16andUINT8.
UINT16attributes are returned as a 16-bit signed two's complement integer,getIntmay be used to to obtain a true representation of the unsigned value.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a short.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive short
-
getInt
int getInt(int attributeIndex)
Get an attribute as a primitive int. Only supported for attributes of typeINT32,INT16,INT8,UINT32,UINT16andUINT8.
UINT32attributes are returned as a 32-bit signed two's complement integer,getLongmay be used to to obtain a true representation of the unsigned value at the cost of using an 8-byte value.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a int.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive int
-
getLong
long getLong(int attributeIndex)
Get an attribute as a primitive long. Only supported for attributes of typeINT64,INT32,INT16,INT8,UINT64UINT32,UINT16andUINT8.
UINT64attributes are returned as a 64-bit signed two's complement integer,getBigDecimalmay be used to to obtain a true representation of the unsigned value at the cost of using a BigDecimal object.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a long.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive long
-
getFloat
float getFloat(int attributeIndex)
Get an attribute as a primitive float. Only supported for attributes of typeFLOAT32.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a float.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive float
-
getDouble
double getDouble(int attributeIndex)
- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a double.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java primitive double
-
getBigDecimal
java.math.BigDecimal getBigDecimal(int attributeIndex)
Get an attribute as a BigDecimal. Only supported for attributes of typeINT64,INT32,INT16,INT8,UINT64,UINT32,UINT16,UINT8,FLOAT32,FLOAT64,DECIMAL32,DECIMAL64andDECIMAL128.- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a BigDecimal.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java BigDecimal
-
getString
java.lang.String getString(int attributeIndex)
Get an attribute as a String. Returns a string that "textually represents" the attribute's value, typically usingObject.toString()of theJava object class corresponding to the attribute's SPL type. The returned value is not always the same as SPL character encoding for the type, specifically:USTRINGandRSTRINGattributes return the corresponding JavaStringvalue, not an SPL string literal with escaped values.XMLattributes return the corresponding JavaStringvalue, not an SPL XML literal with escaped values and suffixx.LIST,MAP,SETattributes return the value oftoString()against the Java collection object.TUPLEattributes return the value ofTuple.toString().
All attributes are supported in InfoSphere® Streams Version 4.0:USTRING,RSTRING(using UTF-8 encoding),BOOLEAN(since InfoSphere® Streams Version 3.0),BLOB(usingBlob.toString(), since 4.0),COMPLEX32(seenewComplex32(), since 4.0),COMPLEX64(seenewComplex64(), since 4.0),ENUM(since 3.0),INT64,INT32,INT16,INT8,LIST(usingList.toString()since 4.0),MAP(usingMap.toString()since 4.0),SET(usingSet.toString()since 4.0),TUPLE(usingTuple.toString()since 4.0),UINT64,UINT32,UINT16,UINT8,FLOAT32,FLOAT64,TIMESTAMP(usingTimestamp.toString(), since 4.0),XML(since 3.0)- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a String.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java String
-
getTimestamp
Timestamp getTimestamp(int attributeIndex)
Get an attribute as a Timestamp. Only supported for attributes of typeTIMESTAMP- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a Timestamp.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Timestamp
-
getBuffer
java.nio.Buffer getBuffer(int attributeIndex)
Get an attribute as a read-only java.nio.Buffer. Only supported for the following types and each type returns a specificBuffersub-class.Type.MetaTypejava.nio.Buffer sub-class BLOBjava.nio.ByteBufferLIST (list<float32>)java.nio.FloatBufferLIST (list<float64>)java.nio.DoubleBufferLIST (list<int8>)java.nio.ByteBufferLIST (list<int16>)java.nio.ShortBufferLIST (list<int32>)java.nio.IntegerBufferLIST (list<int64>)java.nio.LongBufferRSTRINGjava.nio.ByteBufferLIST (list<uint8>)java.nio.ByteBuffer(since InfoSphere Streams 3.1)LIST (list<uint16>)java.nio.ShortBuffer(since InfoSphere Streams 3.1)LIST (list<uint32>)java.nio.IntegerBuffer(since InfoSphere Streams 3.1)LIST (list<uint64>)java.nio.LongBuffer(since InfoSphere Streams 3.1)This call provides a read-only view of the attribute's value without having to make a copy of the underlying data, as getObject() will do.
- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a read-only Buffer.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java Buffer
-
getBuffer
<T extends java.nio.Buffer> T getBuffer(int attributeIndex, java.lang.Class<T> type)Get the attribute as a buffer of typeTusing the attribute's index. The typeTmust match the buffer type of the attribute as described ingetBuffer(int). This method does not perform any type conversion.- Type Parameters:
T- Sub-class ofjava.nio.Buffer- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.type- Class for the buffer type to be returned.- Returns:
- The value as a read-only Buffer.
- Since:
- InfoSphere® Streams Version 3.1
- See Also:
getBuffer(int)
-
getBlob
Blob getBlob(int attributeIndex)
Get an attribute as a Blob. Only supported for attributes of typeBLOB- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a Blob.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Blob
-
getList
java.util.List<?> getList(int attributeIndex)
Get an attribute as a List. Only supported for attributes of typeLIST- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a read-only List.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java List
-
getSet
java.util.Set<?> getSet(int attributeIndex)
Get an attribute as a Set. Only supported for attributes of typeSET,- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a read-only Set.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java Set
-
getMap
java.util.Map<?,?> getMap(int attributeIndex)
Get an attribute as a Map. Only supported for attributes of typeMAP,- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a read-only Map.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to a Java Map
-
getTuple
Tuple getTuple(int attributeIndex)
Get an attribute as a Tuple. Only supported for attributes of typeTUPLE,- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as a Tuple.
- Throws:
java.lang.UnsupportedOperationException- Attribute is not a tuple type.
-
getBoolean
boolean getBoolean(java.lang.String attributeName)
Get the attribute as a boolean using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a boolean.
- See Also:
getBoolean(int)
-
getByte
byte getByte(java.lang.String attributeName)
Get the attribute as a byte using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a byte.
- See Also:
getByte(int)
-
getShort
short getShort(java.lang.String attributeName)
Get the attribute as a short using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a short.
- See Also:
getShort(int)
-
getInt
int getInt(java.lang.String attributeName)
Get the attribute as an int using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a int.
- See Also:
getInt(int)
-
getLong
long getLong(java.lang.String attributeName)
Get the attribute as a long using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a long.
- See Also:
getLong(int)
-
getFloat
float getFloat(java.lang.String attributeName)
Get the attribute as a float using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a float.
- See Also:
getFloat(int)
-
getDouble
double getDouble(java.lang.String attributeName)
Get the attribute as a double using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a double.
- See Also:
getDouble(int)
-
getBigDecimal
java.math.BigDecimal getBigDecimal(java.lang.String attributeName)
Get the attribute as an BigDecimal using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a BigDecimal.
- See Also:
getBigDecimal(int)
-
getString
java.lang.String getString(java.lang.String attributeName)
Get the attribute as a String using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a String.
- See Also:
getString(int)
-
getTimestamp
Timestamp getTimestamp(java.lang.String attributeName)
Get the attribute as a Timestamp using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a Timestamp.
- See Also:
getTimestamp(int)
-
getBuffer
java.nio.Buffer getBuffer(java.lang.String attributeName)
Get the attribute as a java.nio.Buffer using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a java.nio.Buffer.
- See Also:
getBuffer(int)
-
getBuffer
<T extends java.nio.Buffer> T getBuffer(java.lang.String attributeName, java.lang.Class<T> type)Get the attribute as a buffer of typeTusing the attribute's name.- Type Parameters:
T- Sub-class ofjava.nio.Buffer- Parameters:
attributeName- Name of attribute to be returned.type- Class for the buffer type to be returned.- Returns:
- The value as a typed buffer.
- Since:
- InfoSphere® Streams Version 3.1
- See Also:
getObject(int, Class)
-
getBlob
Blob getBlob(java.lang.String attributeName)
Get the attribute as a Blob using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a Blob.
- See Also:
getBlob(int)
-
getList
java.util.List<?> getList(java.lang.String attributeName)
Get the attribute as a java.util.List using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a java.util.List.
- See Also:
getList(int)
-
getSet
java.util.Set<?> getSet(java.lang.String attributeName)
Get the attribute as a java.util.Set using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a java.util.Set.
- See Also:
getSet(int)
-
getMap
java.util.Map<?,?> getMap(java.lang.String attributeName)
Get the attribute as a java.util.Map using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a java.util.Map.
- See Also:
getMap(int)
-
getTuple
Tuple getTuple(java.lang.String attributeName)
Get the attribute as a Tuple using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as a Tuple.
- See Also:
getTuple(int)
-
getObject
java.lang.Object getObject(java.lang.String attributeName)
Get the attribute as an Object using the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as an Object.
- See Also:
getObject(int)
-
getObject
<T> T getObject(java.lang.String attributeName, java.lang.Class<T> type)Get the attribute as an object of typeTusing the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.type- Class for the type to be returned.- Returns:
- The value as an Object.
- Since:
- InfoSphere® Streams Version 3.1
- See Also:
getObject(int, Class)
-
getXML
XML getXML(int attributeIndex)
- Parameters:
attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as an
XML. - Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to an XML- Since:
- InfoSphere® Streams Version 3.0
-
getXML
XML getXML(java.lang.String attributeName)
Get the attribute as anXMLusing the attribute's name.- Parameters:
attributeName- Name of attribute to be returned.- Returns:
- The value as an
XML. - Since:
- InfoSphere® Streams Version 3.0
- See Also:
getXML(int)
-
getEnum
<E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> enumType, int attributeIndex)Get an attribute as an enumeration. Only supported for attributes of typeENUM- Type Parameters:
E- Enumeration type- Parameters:
enumType- Class of the enumeration typeE.attributeIndex- Index of attribute to be returned, zero is the tuple's first attribute.- Returns:
- The value as an enumeration.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to an enumerationjava.lang.IllegalArgumentException- Identifier for theenumattribute is not a constant forE- Since:
- InfoSphere® Streams Version 3.0
- See Also:
EnumType
-
getEnum
<E extends java.lang.Enum<E>> E getEnum(java.lang.Class<E> enumType, java.lang.String attributeName)Get the attribute as an enumeration using the attribute's name.- Type Parameters:
E- Enumeration type- Parameters:
enumType- Class of the enumeration typeE.attributeName- Name of attribute to be returned.- Returns:
- The value as an enumeration.
- Throws:
java.lang.UnsupportedOperationException- Attribute cannot be converted to an enumerationjava.lang.IllegalArgumentException- Identifier for theenumattribute is not a constant forE- Since:
- InfoSphere® Streams Version 3.0
- See Also:
getEnum(Class, int),EnumType
-
asReadOnlyTuple
Tuple asReadOnlyTuple()
Get an immutable version of this tuple. If thisTupleis immutable thenthiswill be returned.- Returns:
- An immutable version of this tuple
- Since:
- InfoSphere® Streams Version 3.0
-
-