cascading.tuple
Class Tuples

java.lang.Object
  extended by cascading.tuple.Tuples

public class Tuples
extends Object

Class Tuples is a helper class providing common methods to manipulate Tuple and TupleEntry instances.

See Also:
Tuple, TupleEntry

Constructor Summary
Tuples()
           
 
Method Summary
static Object[] asArray(Tuple tuple, Class[] types)
          Method asArray convert the given Tuple instance into an Object[].
static Object[] asArray(Tuple tuple, Class[] types, Object[] destination)
          Method asArray convert the given Tuple instance into an Object[].
static
<T> T[]
asArray(Tuple tuple, T[] destination)
          Method asArray copies the elements of the given Tuple instance to the given Object array.
static Tuple asModifiable(Tuple tuple)
          Method asModifiable marks the given Tuple instance as modifiable.
static Tuple asUnmodifiable(Tuple tuple)
          Method asUnmodifiable marks the given Tuple instance as unmodifiable.
static Object coerce(Object value, Class type)
           
static Tuple coerce(Tuple tuple, Class[] types)
          Method coerce forces each element value in the given Tuple to the corresponding primitive type.
static Tuple coerce(Tuple tuple, Class[] types, Tuple destination)
          Method coerce forces each element value in the given Tuple to the corresponding primitive type.
static Object coerce(Tuple tuple, int pos, Class type)
          Method coerce returns the value in the tuple at the given position to the requested type.
static Tuple create(List<Object> arrayList)
           
static Tuple extract(TupleEntry tupleEntry, Fields selector)
          Method extract creates a new Tuple from the given selector, but sets the values in the current tuple to null.
static Tuple extractTuple(TupleEntry tupleEntry, Fields selector)
          Method extractTuple returns a new Tuple based on the given selector.
static Tuple nulledCopy(Fields declarator, Tuple tuple, Fields selector)
           
static Tuple nulledCopy(TupleEntry tupleEntry, Fields selector)
           
static Tuple setOnEmpty(TupleEntry baseEntry, TupleEntry valuesEntry)
           
static boolean toBoolean(Object value)
           
static Boolean toBooleanObject(Object value)
           
static double toDouble(Object value)
           
static Double toDoubleObject(Object value)
           
static float toFloat(Object value)
           
static Float toFloatObject(Object value)
           
static int toInteger(Object value)
           
static Integer toIntegerObject(Object value)
           
static long toLong(Object value)
           
static Long toLongObject(Object value)
           
static short toShort(Object value)
           
static Short toShortObject(Object value)
           
static String toString(Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tuples

public Tuples()
Method Detail

asArray

public static <T> T[] asArray(Tuple tuple,
                              T[] destination)
Method asArray copies the elements of the given Tuple instance to the given Object array.

Parameters:
tuple - of type Tuple
destination - of type Object[]
Returns:
Object[]

asArray

public static Object[] asArray(Tuple tuple,
                               Class[] types)
Method asArray convert the given Tuple instance into an Object[]. The given Class[] array denotes the types each tuple element value should be coerced into.

Coercion types are Object, String, Integer, Long, Float, Double, Short, and Boolean.

If all Tuple element values are null, they will remain null for String and Object, but become zero for the numeric types.

The string value 'true' can be converted to the boolean true.

Parameters:
tuple - of type Tuple
types - of type Class[]
Returns:
Object[]

asArray

public static Object[] asArray(Tuple tuple,
                               Class[] types,
                               Object[] destination)
Method asArray convert the given Tuple instance into an Object[]. The given Class[] array denotes the types each tuple element value should be coerced into.

Parameters:
tuple - of type Tuple
types - of type Class[]
destination - of type Object[]
Returns:
Object[]

coerce

public static Object coerce(Tuple tuple,
                            int pos,
                            Class type)
Method coerce returns the value in the tuple at the given position to the requested type.

If the given type is a primitive (long), and the tuple value is null, 0 is returned.

If the type is an Object (Long), and the tuple value is null, null is returned.

Parameters:
tuple - of type Tuple
pos - of type int
type - of type Class
Returns:
returns the value coerced

coerce

public static Object coerce(Object value,
                            Class type)

toString

public static final String toString(Object value)

toInteger

public static final int toInteger(Object value)

toLong

public static final long toLong(Object value)

toDouble

public static final double toDouble(Object value)

toFloat

public static final float toFloat(Object value)

toShort

public static final short toShort(Object value)

toBoolean

public static final boolean toBoolean(Object value)

toIntegerObject

public static final Integer toIntegerObject(Object value)

toLongObject

public static final Long toLongObject(Object value)

toDoubleObject

public static final Double toDoubleObject(Object value)

toFloatObject

public static final Float toFloatObject(Object value)

toShortObject

public static final Short toShortObject(Object value)

toBooleanObject

public static final Boolean toBooleanObject(Object value)

coerce

public static Tuple coerce(Tuple tuple,
                           Class[] types)
Method coerce forces each element value in the given Tuple to the corresponding primitive type.

Parameters:
tuple - of type Tuple
types - of type Class[]
Returns:
Tuple

coerce

public static Tuple coerce(Tuple tuple,
                           Class[] types,
                           Tuple destination)
Method coerce forces each element value in the given Tuple to the corresponding primitive type.

This method expects the destination Tuple was created with the same size at the types array.

Parameters:
tuple - of type Tuple
types - of type Class[]
destination - of type Tuple
Returns:
Tuple

extractTuple

public static Tuple extractTuple(TupleEntry tupleEntry,
                                 Fields selector)
Method extractTuple returns a new Tuple based on the given selector. But sets the values of the given TupleEntry to null.

Parameters:
tupleEntry - of type TupleEntry
selector - of type Fields
Returns:
Tuple

extract

public static Tuple extract(TupleEntry tupleEntry,
                            Fields selector)
Method extract creates a new Tuple from the given selector, but sets the values in the current tuple to null.

Parameters:
tupleEntry - of type TupleEntry
selector - of type Fields
Returns:
Tuple

nulledCopy

public static Tuple nulledCopy(TupleEntry tupleEntry,
                               Fields selector)

nulledCopy

public static Tuple nulledCopy(Fields declarator,
                               Tuple tuple,
                               Fields selector)

setOnEmpty

public static Tuple setOnEmpty(TupleEntry baseEntry,
                               TupleEntry valuesEntry)

asUnmodifiable

public static Tuple asUnmodifiable(Tuple tuple)
Method asUnmodifiable marks the given Tuple instance as unmodifiable.

Parameters:
tuple - of type Tuple
Returns:
Tuple

asModifiable

public static Tuple asModifiable(Tuple tuple)
Method asModifiable marks the given Tuple instance as modifiable.

Parameters:
tuple - of type Tuple
Returns:
Tuple

create

public static Tuple create(List<Object> arrayList)


Copyright © 2007-2012 Concurrent, Inc. All Rights Reserved.