Java SDK Documentation  24.2.0
com.vertica.sdk.NoopTypeCoercion Class Reference
Inheritance diagram for com.vertica.sdk.NoopTypeCoercion:
Inheritance graph
Collaboration diagram for com.vertica.sdk.NoopTypeCoercion:
Collaboration graph

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< TypeCoercionPolicygetPolicy ()
 
void setPolicy (Collection< TypeCoercionPolicy > policy)
 

Protected Member Functions

Collection< TypeCoercionPolicygetDefaultPolicy ()
 
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

◆ asBinaryBytes()

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.

◆ asBoolean()

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.

◆ asCharBytes()

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.

◆ asDate()

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.

◆ asDouble()

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.

◆ asLong()

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.

◆ asTimestamp()

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.

◆ getDefaultPolicy()

Collection<TypeCoercionPolicy> 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

◆ getListIterator()

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

Provides an Iterator over Objects for a given Iterable input.

Parameters
valueSomething implementing Iterable<Object>

Implements com.vertica.sdk.TypeCoercion.

◆ getMapIterator()

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.

Parameters
valueSomething implementing Map<String,Object>

Implements com.vertica.sdk.TypeCoercion.

◆ getMetaType()

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.

◆ getPolicy()

◆ invalidInputType()

◆ setPolicy()

void com.vertica.sdk.NullTypeCoercion.setPolicy ( Collection< TypeCoercionPolicy 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
policyThe policy collection
See also
TypeCoercionPolicy
getPolicy()

Implements com.vertica.sdk.TypeCoercion.

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

◆ unsupportedType()

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

◆ valueTooLarge()

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
valueThe value being coerced.
typeThe target type.
See also
getPolicy()
#setPolicy(Collection)

Referenced by com.vertica.sdk.NoopTypeCoercion.asBinaryBytes(), com.vertica.sdk.NoopTypeCoercion.asCharBytes(), and com.vertica.sdk.StandardTypeCoercion.asCharBytes().