Class ScalarTypeBaseVarchar<T>
- java.lang.Object
-
- io.ebeaninternal.server.type.ScalarTypeBase<T>
-
- io.ebeaninternal.server.type.ScalarTypeBaseVarchar<T>
-
- All Implemented Interfaces:
StringFormatter
,StringParser
,ScalarDataReader<T>
,ScalarType<T>
- Direct Known Subclasses:
ScalarTypeChar
,ScalarTypeCharArray
,ScalarTypeCidr
,ScalarTypeClass
,ScalarTypeCurrency
,ScalarTypeInet
,ScalarTypeInetAddress
,ScalarTypeInetAddressPostgres
,ScalarTypeJodaPeriod
,ScalarTypeLocale
,ScalarTypeOffsetTime
,ScalarTypePath
,ScalarTypePeriod
,ScalarTypeTimeZone
,ScalarTypeURI
,ScalarTypeURL
,ScalarTypeZoneId
,ScalarTypeZoneOffset
public abstract class ScalarTypeBaseVarchar<T> extends ScalarTypeBase<T>
Base ScalarType for types which converts to and from a VARCHAR database column.
-
-
Constructor Summary
Constructors Constructor Description ScalarTypeBaseVarchar(Class<T> type)
ScalarTypeBaseVarchar(Class<T> type, boolean jdbcNative, int jdbcType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
bind(DataBind b, T value)
Convert (if necessary) and bind the value to the preparedStatement.abstract T
convertFromDbString(String dbValue)
Convert from DB string value to the target type.T
convertFromMillis(long systemTimeMillis)
Convert the systemTimeMillis into the appropriate java object.abstract String
convertToDbString(T beanValue)
Convert to DB string from the target type.String
format(Object value)
Convert the type into a string representation.abstract String
formatValue(T v)
Format the target type to a string.DocPropertyType
getDocType()
Return the type this maps to for JSON document stores.boolean
isDateTimeCapable()
Return true if the type can accept long systemTimeMillis input.T
jsonRead(com.fasterxml.jackson.core.JsonParser parser)
Read the value from JsonParser.void
jsonWrite(com.fasterxml.jackson.core.JsonGenerator writer, T value)
Write the value to the JsonGenerator.abstract T
parse(String value)
Parse from a formatted string value.T
read(DataReader dataReader)
Read the value from the resultSet and convert if necessary to the logical bean property value.T
readData(DataInput dataInput)
Read the value from binary input.T
toBeanType(Object value)
Convert the value as necessary to the logical Bean type.Object
toJdbcType(Object value)
Convert the value as necessary to the JDBC type.void
writeData(DataOutput dataOutput, T value)
Write the value to binary output.-
Methods inherited from class io.ebeaninternal.server.type.ScalarTypeBase
asVersion, getJdbcType, getLength, getType, isBinaryType, isDirty, isJdbcNative, isMutable, loadIgnore
-
-
-
-
Constructor Detail
-
ScalarTypeBaseVarchar
public ScalarTypeBaseVarchar(Class<T> type)
-
ScalarTypeBaseVarchar
public ScalarTypeBaseVarchar(Class<T> type, boolean jdbcNative, int jdbcType)
-
-
Method Detail
-
formatValue
public abstract String formatValue(T v)
Format the target type to a string.
-
convertFromDbString
public abstract T convertFromDbString(String dbValue)
Convert from DB string value to the target type.
-
convertToDbString
public abstract String convertToDbString(T beanValue)
Convert to DB string from the target type.
-
bind
public void bind(DataBind b, T value) throws SQLException
Description copied from interface:ScalarType
Convert (if necessary) and bind the value to the preparedStatement.value may need to be converted from the logical bean property type to the JDBC type.
- Throws:
SQLException
-
read
public T read(DataReader dataReader) throws SQLException
Description copied from interface:ScalarType
Read the value from the resultSet and convert if necessary to the logical bean property value.- Throws:
SQLException
-
toBeanType
public T toBeanType(Object value)
Description copied from interface:ScalarType
Convert the value as necessary to the logical Bean type.The type as per the bean property.
This is used to automatically convert id values (typically from a string to a int, long or UUID).
-
toJdbcType
public Object toJdbcType(Object value)
Description copied from interface:ScalarType
Convert the value as necessary to the JDBC type.Note that this should also match the type as per the getJdbcType() method.
This is typically used when the matching type is used in a where clause and we use this to ensure it is an appropriate jdbc type.
-
convertFromMillis
public T convertFromMillis(long systemTimeMillis)
Description copied from interface:ScalarType
Convert the systemTimeMillis into the appropriate java object.For non dateTime types this will throw an exception.
-
isDateTimeCapable
public boolean isDateTimeCapable()
Description copied from interface:ScalarType
Return true if the type can accept long systemTimeMillis input.This is used to determine if is is sensible to use the
ScalarType.convertFromMillis(long)
method.This includes the Date, Calendar, sql Date, Time, Timestamp, JODA types as well as Long, BigDecimal and String (although it generally is not expected to parse systemTimeMillis to a String or BigDecimal).
-
format
public String format(Object value)
Description copied from interface:ScalarType
Convert the type into a string representation.This assumes the value is of the correct type.
This is so that ScalarType also implements the StringFormatter interface.
- Specified by:
format
in interfaceScalarType<T>
- Specified by:
format
in interfaceStringFormatter
- Overrides:
format
in classScalarTypeBase<T>
-
readData
public T readData(DataInput dataInput) throws IOException
Description copied from interface:ScalarType
Read the value from binary input.- Throws:
IOException
-
writeData
public void writeData(DataOutput dataOutput, T value) throws IOException
Description copied from interface:ScalarType
Write the value to binary output.- Throws:
IOException
-
jsonRead
public T jsonRead(com.fasterxml.jackson.core.JsonParser parser) throws IOException
Description copied from interface:ScalarType
Read the value from JsonParser.- Throws:
IOException
-
jsonWrite
public void jsonWrite(com.fasterxml.jackson.core.JsonGenerator writer, T value) throws IOException
Description copied from interface:ScalarType
Write the value to the JsonGenerator.- Throws:
IOException
-
getDocType
public DocPropertyType getDocType()
Description copied from interface:ScalarType
Return the type this maps to for JSON document stores.
-
-