Java SDK Documentation
24.2.0
|
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< Object > | getListIterator (Object value) |
Iterator< Map.Entry< String, Object > > | getMapIterator (Object value) |
MetaType | getMetaType (Object value) |
Set< TypeCoercionPolicy > | getPolicy () |
void | setPolicy (Collection< TypeCoercionPolicy > policy) |
Protected Member Functions | |
Collection< TypeCoercionPolicy > | getDefaultPolicy () |
void | invalidInputType (Object value, VerticaType type) |
void | unsupportedType (Object value, VerticaType type) |
void | valueTooLarge (Object value, VerticaType type) |
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().
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).
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).
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.
|
protected |
Provides the default policy installed by the constructor.
For NoopTypeCoercion, the default policy favors errors and avoids modifying data:
Iterator<Object> com.vertica.sdk.NoopTypeCoercion.getListIterator | ( | Object | value | ) |
Provides an Iterator over Objects for a given Iterable input.
value | Something implementing Iterable<Object> |
Implements com.vertica.sdk.TypeCoercion.
Iterator<Map.Entry<String,Object> > 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.
value | Something implementing Map<String,Object> |
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.
|
inherited |
Returns an unmodifiable version of the policy.
Implements com.vertica.sdk.TypeCoercion.
Referenced by com.vertica.sdk.NoopTypeCoercion.asBinaryBytes(), com.vertica.sdk.NoopTypeCoercion.asCharBytes(), com.vertica.sdk.StandardTypeCoercion.asCharBytes(), com.vertica.sdk.NoopTypeCoercion.invalidInputType(), com.vertica.sdk.StandardTypeCoercion.invalidInputValue(), com.vertica.sdk.NullTypeCoercion.unsupportedType(), and com.vertica.sdk.NoopTypeCoercion.valueTooLarge().
|
protected |
Throws a TypeCoercionException if the policy includes FAIL_INVALID_INPUT_TYPE. Otherwise does nothing.
value | The value being coerced. |
type | The target type. |
Referenced by com.vertica.sdk.NoopTypeCoercion.asBinaryBytes(), com.vertica.sdk.NoopTypeCoercion.asBoolean(), com.vertica.sdk.StandardTypeCoercion.asBooleanByJava(), com.vertica.sdk.StandardTypeCoercion.asBooleanByNumeric(), com.vertica.sdk.StandardTypeCoercion.asBooleanByVertica(), com.vertica.sdk.NoopTypeCoercion.asCharBytes(), com.vertica.sdk.NoopTypeCoercion.asDate(), com.vertica.sdk.StandardTypeCoercion.asDate(), com.vertica.sdk.NoopTypeCoercion.asDouble(), com.vertica.sdk.StandardTypeCoercion.asDouble(), com.vertica.sdk.NoopTypeCoercion.asLong(), com.vertica.sdk.StandardTypeCoercion.asLong(), com.vertica.sdk.NoopTypeCoercion.asTimestamp(), and com.vertica.sdk.StandardTypeCoercion.asTimestamp().
|
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.
policy | The policy collection |
Implements com.vertica.sdk.TypeCoercion.
Referenced by com.vertica.sdk.NullTypeCoercion.NullTypeCoercion().
|
protectedinherited |
Throws a TypeCoercionException if the policy includes TypeCoercionPolicy#FAIL_UNSUPPORTED_TYPE. Otherwise does nothing.
value | The value provided which could not be coerced. |
type | The target Vertica type. |
Referenced by com.vertica.sdk.NullTypeCoercion.asBinaryBytes(), com.vertica.sdk.NullTypeCoercion.asBoolean(), com.vertica.sdk.NullTypeCoercion.asCharBytes(), com.vertica.sdk.NullTypeCoercion.asDate(), com.vertica.sdk.NullTypeCoercion.asDouble(), com.vertica.sdk.NullTypeCoercion.asLong(), and com.vertica.sdk.NullTypeCoercion.asTimestamp().
|
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.
value | The value being coerced. |
type | The target type. |
Referenced by com.vertica.sdk.NoopTypeCoercion.asBinaryBytes(), com.vertica.sdk.NoopTypeCoercion.asCharBytes(), and com.vertica.sdk.StandardTypeCoercion.asCharBytes().