Class ScalarTypeFile
- java.lang.Object
-
- io.ebeaninternal.server.type.ScalarTypeBase<File>
-
- io.ebeaninternal.server.type.ScalarTypeFile
-
- All Implemented Interfaces:
StringFormatter
,StringParser
,ScalarDataReader<File>
,ScalarType<File>
public class ScalarTypeFile extends ScalarTypeBase<File>
ScalarType for streaming between a File and the database.
-
-
Constructor Summary
Constructors Constructor Description ScalarTypeFile()
Construct with reasonable defaults of Blob and 8096 buffer size.ScalarTypeFile(int jdbcType, String prefix, String suffix, File directory, int bufferSize)
Create the ScalarTypeFile.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(DataBind b, File value)
Convert (if necessary) and bind the value to the preparedStatement.File
convertFromMillis(long systemTimeMillis)
Convert the systemTimeMillis into the appropriate java object.String
formatValue(File file)
Convert the type into a string representation.DocPropertyType
getDocType()
Return the type this maps to for JSON document stores.boolean
isBinaryType()
Return true if this is a binary type and can not support parse() and format() from/to string.boolean
isDateTimeCapable()
Return true if the type can accept long systemTimeMillis input.File
jsonRead(com.fasterxml.jackson.core.JsonParser parser)
Read the value from JsonParser.void
jsonWrite(com.fasterxml.jackson.core.JsonGenerator writer, File value)
Write the value to the JsonGenerator.File
parse(String value)
Convert the string value to the appropriate java object.long
pump(InputStream is, OutputStream out)
Helper method to pump bytes from input to output.File
read(DataReader dataReader)
Read the value from the resultSet and convert if necessary to the logical bean property value.File
readData(DataInput dataInput)
Read the value from binary input.File
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, File file)
Write the value to binary output.-
Methods inherited from class io.ebeaninternal.server.type.ScalarTypeBase
asVersion, format, getJdbcType, getLength, getType, isDirty, isJdbcNative, isMutable, loadIgnore
-
-
-
-
Constructor Detail
-
ScalarTypeFile
public ScalarTypeFile()
Construct with reasonable defaults of Blob and 8096 buffer size.
-
ScalarTypeFile
public ScalarTypeFile(int jdbcType, String prefix, String suffix, File directory, int bufferSize)
Create the ScalarTypeFile.
-
-
Method Detail
-
isBinaryType
public boolean isBinaryType()
Description copied from interface:ScalarType
Return true if this is a binary type and can not support parse() and format() from/to string. This allows Ebean to optimise marshalling types to string.- Specified by:
isBinaryType
in interfaceScalarType<File>
- Overrides:
isBinaryType
in classScalarTypeBase<File>
-
read
public File 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
-
bind
public void bind(DataBind b, File 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
-
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.
-
toBeanType
public File 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).
-
jsonWrite
public void jsonWrite(com.fasterxml.jackson.core.JsonGenerator writer, File value) throws IOException
Description copied from interface:ScalarType
Write the value to the JsonGenerator.- Throws:
IOException
-
jsonRead
public File jsonRead(com.fasterxml.jackson.core.JsonParser parser) throws IOException
Description copied from interface:ScalarType
Read the value from JsonParser.- Throws:
IOException
-
getDocType
public DocPropertyType getDocType()
Description copied from interface:ScalarType
Return the type this maps to for JSON document stores.
-
formatValue
public String formatValue(File file)
Description copied from interface:ScalarType
Convert the type into a string representation.Reciprocal of parse().
-
parse
public File parse(String value)
Description copied from interface:ScalarType
Convert the string value to the appropriate java object.Mostly used to support CSV, JSON and XML parsing.
Reciprocal of formatValue().
-
convertFromMillis
public File 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).
-
readData
public File readData(DataInput dataInput) throws IOException
Description copied from interface:ScalarType
Read the value from binary input.- Throws:
IOException
-
writeData
public void writeData(DataOutput dataOutput, File file) throws IOException
Description copied from interface:ScalarType
Write the value to binary output.- Throws:
IOException
-
pump
public long pump(InputStream is, OutputStream out) throws IOException
Helper method to pump bytes from input to output.- Throws:
IOException
-
-