Package com.exedio.cope
Class DataField
- java.lang.Object
-
- com.exedio.cope.Feature
-
- com.exedio.cope.Field<DataField.Value>
-
- com.exedio.cope.DataField
-
- All Implemented Interfaces:
Settable<DataField.Value>
,Serializable
public final class DataField extends Field<DataField.Value>
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DataField.Value
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_LENGTH
-
Constructor Summary
Constructors Constructor Description DataField()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DataField.Value
get(Item item)
Returns the data of this persistent data field.void
get(Item item, File sink)
Reads data for this persistent data field and writes it into the given file.void
get(Item item, OutputStream sink)
Reads data for this persistent data field and writes it into the given stream.void
get(Item item, Path sink)
byte[]
getArray(Item item)
Returns the data of this persistent data field.long
getLength(Item item)
Returns the length of the data of this persistent data field.long
getMaximumLength()
DataFieldVaultInfo
getVaultInfo()
boolean
isAnnotatedVault()
boolean
isNull(Item item)
Returns, whether there is no data for this field.DataField
lengthMax(long maximumLength)
SetValue<?>
map(byte[] array)
SetValue<?>
map(File file)
SetValue<?>
map(InputStream stream)
SetValue<?>
map(Path path)
static int
min(int i, long l)
DataField
optional()
Returns a new Field, that differs from this Field by being optional.void
set(Item item, byte[] data)
Provides data for this persistent data field.void
set(Item item, DataField.Value data)
Provides data for this persistent data field.void
set(Item item, File data)
Provides data for this persistent data field.void
set(Item item, InputStream data)
Provides data for this persistent data field.void
set(Item item, Path data)
Provides data for this persistent data field.StartsWithCondition
startsWith(byte[] value)
Deprecated.UsestartsWithIfSupported(byte[])
instead.StartsWithCondition
startsWithIfSupported(byte[] value)
The result may cause anUnsupportedQueryException
when used, if the field is stored in avault
.DataField
toFinal()
Returns a new Field, that differs from this Field by being final.static DataField.Value
toValue(byte[] array)
Returns null, ifarray
is null.static DataField.Value
toValue(File file)
Returns null, iffile
is null.static DataField.Value
toValue(InputStream stream)
Returns null, ifstream
is null.static DataField.Value
toValue(Path path)
Returns null, iffile
is null.static DataField.Value
toValue(ZipFile file, ZipEntry entry)
Returns null, iffile
is null.-
Methods inherited from class com.exedio.cope.Field
castCollection, check, execute, getColumnName, getInitialExceptions, getInitialType, getPatterns, getValueClass, isFinal, isInitial, isMandatory, mapNull
-
Methods inherited from class com.exedio.cope.Feature
afterModelCreated, getAbstractType, getAnnotation, getID, getLocalizationKeys, getName, getPattern, getType, isAnnotationPresent, isSourceAlready, mount, readResolve, requireMounted, toString, toString, writeReplace
-
-
-
-
Field Detail
-
DEFAULT_LENGTH
public static final long DEFAULT_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
toFinal
public DataField toFinal()
Description copied from class:Field
Returns a new Field, that differs from this Field by being final. If this Field is already final, the the result is equal to this Field.- Specified by:
toFinal
in classField<DataField.Value>
- See Also:
Field.isFinal()
-
optional
public DataField optional()
Description copied from class:Field
Returns a new Field, that differs from this Field by being optional. If this Field is already optional, the the result is equal to this Field.- Specified by:
optional
in classField<DataField.Value>
- See Also:
Field.isMandatory()
-
lengthMax
public DataField lengthMax(long maximumLength)
-
getMaximumLength
public long getMaximumLength()
-
isAnnotatedVault
public boolean isAnnotatedVault()
-
min
public static int min(int i, long l)
- Throws:
IllegalArgumentException
- if either i or l is negative
-
getLength
public long getLength(@Nonnull Item item)
Returns the length of the data of this persistent data field. Returns -1, if there is no data for this field.
-
get
public DataField.Value get(Item item)
Returns the data of this persistent data field. Returns null, if there is no data for this field.- Specified by:
get
in classField<DataField.Value>
-
getArray
@Nullable public byte[] getArray(@Nonnull Item item)
Returns the data of this persistent data field. Returns null, if there is no data for this field.
-
get
public void get(@Nonnull Item item, @Nonnull OutputStream sink) throws IOException
Reads data for this persistent data field and writes it into the given stream. Does nothing, if there is no data for this field.- Throws:
NullPointerException
- ifsink
is null.IOException
- if writingsink
throws an IOException.
-
get
public void get(@Nonnull Item item, @Nonnull Path sink) throws IOException
- Throws:
IOException
-
get
public void get(@Nonnull Item item, @Nonnull File sink) throws IOException
Reads data for this persistent data field and writes it into the given file. Does nothing, if there is no data for this field.- Throws:
NullPointerException
- ifsink
is null.IOException
- if writingsink
throws an IOException.
-
set
public void set(@Nonnull Item item, DataField.Value data)
Provides data for this persistent data field.- Specified by:
set
in classField<DataField.Value>
- Parameters:
data
- give null to remove data.- Throws:
MandatoryViolationException
- if data is null and field ismandatory
.DataLengthViolationException
- if data is longer thangetMaximumLength()
-
set
public void set(@Nonnull Item item, byte[] data)
Provides data for this persistent data field.- Parameters:
data
- give null to remove data.- Throws:
MandatoryViolationException
- if data is null and field ismandatory
.DataLengthViolationException
- if data is longer thangetMaximumLength()
-
set
public void set(@Nonnull Item item, InputStream data) throws IOException
Provides data for this persistent data field. Closesdata
after reading the contents of the stream.- Parameters:
data
- give null to remove data.- Throws:
MandatoryViolationException
- if data is null and field ismandatory
.DataLengthViolationException
- if data is longer thangetMaximumLength()
IOException
- if reading data throws an IOException.
-
set
public void set(@Nonnull Item item, Path data) throws IOException
Provides data for this persistent data field.- Parameters:
data
- give null to remove data.- Throws:
MandatoryViolationException
- if data is null and field ismandatory
.DataLengthViolationException
- if data is longer thangetMaximumLength()
IOException
- if reading data throws an IOException.
-
set
public void set(@Nonnull Item item, File data) throws IOException
Provides data for this persistent data field.- Parameters:
data
- give null to remove data.- Throws:
MandatoryViolationException
- if data is null and field ismandatory
.DataLengthViolationException
- if data is longer thangetMaximumLength()
IOException
- if reading data throws an IOException.
-
toValue
public static DataField.Value toValue(byte[] array)
Returns null, ifarray
is null.
-
toValue
public static DataField.Value toValue(InputStream stream)
Returns null, ifstream
is null.
-
toValue
public static DataField.Value toValue(Path path)
Returns null, iffile
is null.
-
toValue
public static DataField.Value toValue(File file)
Returns null, iffile
is null.
-
toValue
public static DataField.Value toValue(ZipFile file, ZipEntry entry)
Returns null, iffile
is null.
-
map
public SetValue<?> map(byte[] array)
-
map
public SetValue<?> map(InputStream stream)
-
getVaultInfo
public DataFieldVaultInfo getVaultInfo()
-
startsWithIfSupported
public StartsWithCondition startsWithIfSupported(byte[] value)
The result may cause anUnsupportedQueryException
when used, if the field is stored in avault
.
-
startsWith
@Deprecated public StartsWithCondition startsWith(byte[] value)
Deprecated.UsestartsWithIfSupported(byte[])
instead.
-
-