com.vertica.sdk.NoopTypeCoercion Class Reference

Inheritance diagram for com.vertica.sdk.NoopTypeCoercion:

Collaboration diagram for com.vertica.sdk.NoopTypeCoercion:

Public Member Functions
ByteBuffer asBinaryBytes (Object value, int length, VerticaType type)
Boolean asBoolean (Object value, VerticaType type)
ByteBuffer asCharBytes (Object value, int length, VerticaType type)
java.sql.Date asDate (Object value, VerticaType type)
Double asDouble (Object value, VerticaType type)
Long asLong (Object value, VerticaType type)
java.sql.Timestamp asTimestamp (Object value, VerticaType type)
Iterator getListIterator (Object value)
Iterator > getMapIterator (Object value)
MetaType getMetaType (Object value)
Set getPolicy ()
void setPolicy (Collection policy)
Protected Member Functions
Collection getDefaultPolicy ()
void invalidInputType (Object value, VerticaType type)
void unsupportedType (Object value, VerticaType type)
void valueTooLarge (Object value, VerticaType type)

Detailed Description

NoopTypeCoercion implements no type conversions, but passes already-valid types to the destination. Values may be truncated if the policy includes TRUNCATE_VALUES.

The default policy favors errors and avoids modifying data. See getDefaultPolicy().

Member Function Documentation

ByteBuffer com.vertica.sdk.NoopTypeCoercion.asBinaryBytes(Object value, int length, VerticaType type)

Generates a ByteBuffer (or null) value out of a sequence of bytes. Acceptable input types are byte array and ByteBuffer. All other types are invalid and will result in null or a TypeCoercionException according to the policy.

In agreement with how 'binary' values are stored in Vertica, values smaller than the target length are right-extended to length with the zero byte.

The value will be truncated to length when necessary if TRUNCATE_VALUES is specified in the policy. Otherwise values that are too long are treated as invalid input values (see FAIL_INVALID_INPUT_VALUE).

See Also

VerticaType::isBinary()

Implements com.vertica.sdk.TypeCoercion.

Boolean com.vertica.sdk.NoopTypeCoercion.asBoolean(Object value, VerticaType type)

Generates a Boolean (or null) value out of null objects or Boolean type objects. All other types are invalid and will result in null or a TypeCoercionException according to the policy.

Implements com.vertica.sdk.TypeCoercion.

ByteBuffer com.vertica.sdk.NoopTypeCoercion.asCharBytes(Object value, int length, VerticaType type)

Generates a ByteBuffer (or null) value out of null objects or String type objects. All other types are invalid and will result in null or a TypeCoercionException according to the policy.

The bytes will not include trailing spaces if the type is 'char'.

The value will be truncated to length when necessary if TRUNCATE_VALUES is specified in the policy. Otherwise values that are too long are treated as invalid input values (see FAIL_INVALID_INPUT_VALUE).

See Also

VerticaType::isChar()

Implements com.vertica.sdk.TypeCoercion.

java.sql.Date com.vertica.sdk.NoopTypeCoercion.asDate(Object value, VerticaType type)

Generate a java.sql.Date (or null) value out of values that are either null, java.sql.Date, or java.util.Date (which includes java.sql.Timestamp and java.sql.Time types).

Note that this is an exception to the general principle of NoopTypeCoercion: some coercion may actually take place here. This is because java.util.Date is so closely related to the java.sql.Date type and much more prevalent.

Implements com.vertica.sdk.TypeCoercion.

Double com.vertica.sdk.NoopTypeCoercion.asDouble(Object value, VerticaType type)

Generates a Double (or null) value out of null objects or Double type objects. All other types are invalid and will result in null or a TypeCoercionException according to the policy.

Implements com.vertica.sdk.TypeCoercion.

Long com.vertica.sdk.NoopTypeCoercion.asLong(Object value, VerticaType type)

Generates a Long (or null) value out of null objects or Long type objects. All other types are invalid and will result in null or a TypeCoercionException according to the policy.

Implements com.vertica.sdk.TypeCoercion.

java.sql.Timestamp com.vertica.sdk.NoopTypeCoercion.asTimestamp(Object value, VerticaType type)

Generate a java.sql.Timestamp (or null) value out of values that are either null, java.sql.Timestamp, or java.util.Date (which includes java.sql.Date and java.sql.Time types).

Note that this is an exception to the general principle of NoopTypeCoercion; some coercion may actually take place here. This is because java.util.Date is so closely related to the java.sql.Timestamp type and much more prevalent.

Implements com.vertica.sdk.TypeCoercion.

Collection com.vertica.sdk.NoopTypeCoercion.getDefaultPolicy()

protected

Provides the default policy installed by the constructor.

For NoopTypeCoercion, the default policy favors errors and avoids modifying data:

  • FAIL_SDK_UNSUPPORTED_TYPE

  • FAIL_UNSUPPORTED_TYPE

  • FAIL_INVALID_INPUT_TYPE

  • FAIL_INVALID_INPUT_VALUE

Iterator com.vertica.sdk.NoopTypeCoercion.getListIterator(Object value)

Provides an Iterator over Objects for a given Iterable input.

Parameters

  • value: Something implementing Iterable

Implements com.vertica.sdk.TypeCoercion.

Iterator > com.vertica.sdk.NoopTypeCoercion.getMapIterator(Object value)

Provides an Iterator over map entries for a given Map.

Internal maps are assumed to have String keys. A ClassCastException will eventually result if there are internal maps with keys that are not Strings.

Parameters

  • value: Something implementing Map

Implements com.vertica.sdk.TypeCoercion.

MetaType com.vertica.sdk.NoopTypeCoercion.getMetaType(Object value)

Detects Java standard Map and Iterable types.

Internal maps are assumed to have String keys. A ClassCastException will result if there are internal maps with keys that are not Strings.

Implements com.vertica.sdk.TypeCoercion.

Set com.vertica.sdk.NullTypeCoercion.getPolicy()

inherited Returns an unmodifiable version of the policy.

Returns The policy collection.

See Also

setPolicy

Implements com.vertica.sdk.TypeCoercion.

Referenced by

void com.vertica.sdk.NoopTypeCoercion.invalidInputType(Object value, VerticaType type)

protected

Throws a TypeCoercionException if the policy includes FAIL_INVALID_INPUT_TYPE. Otherwise does nothing.

Parameters

  • value: The value being coerced.
  • type: The target type.

See Also

getPolicy() #setPolicy(Collection)

Referenced by

void com.vertica.sdk.NullTypeCoercion.setPolicy(Collection policy)

inherited Sets the policies for this TypeCoercion instance. Policies generally dictate which scenarios generate exceptions and allow for different error handling choices without implementing a new TypeCoercion class.

Parameters

  • policy: The policy collection

See Also

TypeCoercionPolicy

getPolicy()

Implements com.vertica.sdk.TypeCoercion.

Referenced by com.vertica.sdk.NullTypeCoercion.NullTypeCoercion().

void com.vertica.sdk.NullTypeCoercion.unsupportedType(Object value, VerticaType type)

protected inherited Throws a TypeCoercionException if the policy includes TypeCoercionPolicy#FAIL_UNSUPPORTED_TYPE. Otherwise does nothing.

Parameters

  • value: The value provided which could not be coerced.
  • type: The target Vertica type.

See Also

getPolicy() #setPolicy(Collection)

Referenced by

void com.vertica.sdk.NoopTypeCoercion.valueTooLarge(Object value, VerticaType type)

protected

Throws a TypeCoercionException with a TRUNCATE_VALUES cause if the policy includes FAIL_INVALID_INPUT_VALUE. Otherwise does nothing.

This should only be called if the policy does not request truncation via TRUNCATE_VALUES.

Parameters

  • value: The value being coerced.
  • type: The target type.

See Also

getPolicy() #setPolicy(Collection)

Referenced by