Package org.refcodes.tabular
Interface Column<T>
-
- Type Parameters:
T
- The type managed by theColumn
.
- All Superinterfaces:
org.refcodes.mixin.KeyAccessor<java.lang.String>
,org.refcodes.mixin.TypeAccessor<T>
- All Known Subinterfaces:
FormattedColumn<T>
- All Known Implementing Classes:
AbstractColumn
,DateColumnImpl
,ExceptionColumnImpl
,FormattedColumnDecorator
,FormattedColumnImpl
,IntegerColumn
,ObjectColumn
,StringColumn
,StringsColumn
public interface Column<T> extends org.refcodes.mixin.KeyAccessor<java.lang.String>, org.refcodes.mixin.TypeAccessor<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.KeyAccessor
org.refcodes.mixin.KeyAccessor.KeyBuilder<K extends java.lang.Object,B extends org.refcodes.mixin.KeyAccessor.KeyBuilder<K,B>>, org.refcodes.mixin.KeyAccessor.KeyMutator<K extends java.lang.Object>, org.refcodes.mixin.KeyAccessor.KeyProperty<K extends java.lang.Object>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
contains(Record<?> aRecord)
T
fromStorageString(java.lang.String aStringValue)
AColumn
implementation can provide its own text exchange format for the given objects.T
fromStorageStrings(java.lang.String[] aStringArray)
AColumn
implementation can provide its own text exchange format for the given objects.T
get(Record<?> aRecord)
default T
getValue(Record<?> aRecord)
Retrieves the corresponding value from the provided record.T
remove(Record<?> aRecord)
java.lang.String
toPrintable(T aValue)
AColumn
implementation can provide its own printable format of the given objects; for example a human readable text representation of the value (or in very specialized cases even enriched with ANSI escape codes).java.lang.String
toStorageString(T aValue)
AColumn
implementation can provide its own text exchange format for the given objects.default java.lang.String
toStorageString_(java.lang.Object aValue)
AColumn
implementation can provide its own text exchange format for the given objects.java.lang.String[]
toStorageStrings(T aValue)
AColumn
implementation can provide its own text exchange format for the given objects.
-
-
-
Method Detail
-
toStorageString
java.lang.String toStorageString(T aValue)
AColumn
implementation can provide its own text exchange format for the given objects. This method enables theColumn
to convert a value of the given type to aString
and viafromStorageString(String)
back to the value (bijective). This method supports data sinks (such as relational databases) which allow only a single value in a row's entry: In case T is an array type, then the storageString
representation of the elements in that array are represented by a single returnedString
. TODO: Why does the detour through the methodtoStorageString(Object)
not function?!? Having this snippet in the code seems to be fine for the compiler ... tryingtoStorageString_(Object)
instead :-( In case a data sink (such as Amazon's SimpleDb) is to be addressed which provides dedicated support for multiple values in one row's entry, then the methodtoStorageStrings(Object)
may be used instead.- Parameters:
aValue
- the element to be converted to aString
.- Returns:
- The
String
representation of the value.
-
toStorageString_
default java.lang.String toStorageString_(java.lang.Object aValue) throws java.lang.ClassCastException
AColumn
implementation can provide its own text exchange format for the given objects. This method enables theColumn
to convert a value of the given type to aString
and viafromStorageString(String)
back to the value (bijective). This method supports data sinks (such as relational databases) which allow only a single value in a row's entry: In case T is an array type, then the storageString
representation of the elements in that array are represented by a single returnedString
. In case a data sink (such as Amazon's SimpleDb) is to be addressed which provides dedicated support for multiple values in one row's entry, then the methodtoStorageStrings(Object)
may be used instead. TODO: Why does the detour through the methodtoStorageString(Object)
not function?!? Having this snippet in the code seems to be fine for the compiler ... tryingtoStorageString_(Object)
instead :-(- Parameters:
aValue
- the element to be converted to aString
.- Returns:
- The
String
representation of the value. - Throws:
java.lang.ClassCastException
- - if the object is not null and is not assignable to the type T.
-
toStorageStrings
java.lang.String[] toStorageStrings(T aValue)
AColumn
implementation can provide its own text exchange format for the given objects. This method enables theColumn
to convert a value of the given type to aString
array and viafromStorageStrings(String[])
back to the value (bijective). This method supports data sinks (such as Amazon's SimpleDb) which provide dedicated support for multiple values in a row's entry: In case T is an array type, then the storageString
representations of the elements in that array may be placed in dedicated entries of the returnedString
array. In case T is not an array type then the returnedString
array may contain just one value. In case data sinks (such as relational databases) are to be addressed which allow only a single value in a row's entry, then the methodtoStorageString(Object)
may be used instead.- Parameters:
aValue
- the element to be converted to aString
array.- Returns:
- The
String
array representation of the value.
-
fromStorageString
T fromStorageString(java.lang.String aStringValue) throws java.text.ParseException
AColumn
implementation can provide its own text exchange format for the given objects. This method enables theColumn
to convert aString
value to a value of the given type and viatoStorageString(Object)
back to theString
(bijective). This method supports data sinks (such as relational databases) which allow only a single value in a row's entry: In case T is an array type, then the storageString
representation of the elements in that array are represented by the single passedString
. In case a data sink (such as Amazon's SimpleDb) is to be addressed which provides dedicated support for multiple values in one row's entry, then the methodfromStorageStrings(String[])
may be used instead.- Parameters:
aStringValue
- The value to be converted to a type instance.- Returns:
- The type representation of the value.
- Throws:
java.text.ParseException
- in case parsing theString
was not possible
-
fromStorageStrings
T fromStorageStrings(java.lang.String[] aStringArray) throws java.text.ParseException
AColumn
implementation can provide its own text exchange format for the given objects. This method enables theColumn
to convert aString
array value to a value of the given type and viatoStorageStrings(Object)
back to theString
array (bijective). This method supports data sinks (such as Amazon's SimpleDb) which provide dedicated support for multiple values in a row's entry: In case T is an array type, then the storageString
representations of the elements in that array may be placed in dedicated entries of the providedString
array. In case T is not an array type then the passedString
array may contain just one value. In case data sinks (such as relational databases) are to be addressed which allow only a single value in a row's entry, then the methodfromStorageString(String)
may be used instead.- Parameters:
aStringArray
- The value to be converted to a type instance.- Returns:
- The type representation of the value.
- Throws:
java.text.ParseException
- in case parsing theString
was not possible
-
toPrintable
java.lang.String toPrintable(T aValue)
AColumn
implementation can provide its own printable format of the given objects; for example a human readable text representation of the value (or in very specialized cases even enriched with ANSI escape codes). This method enables theColumn
to convert a value of the given type to a human readable text. The human readable text, in comparison to the methodObject.toString()
(ortoStorageString(Object)
) is not intended to be converted back to the actual value (not bijective). This method may be used aHeader
instance's methodHeaderRow.toPrintable(Record)
.- Parameters:
aValue
- the element to be converted to a human readable text.- Returns:
- The human readable representation of the value.
-
contains
boolean contains(Record<?> aRecord)
Tests whether theRecord
contains a value identified by theColumn
instance's key and where the value's type is assignable to theColumn
instance's type. Only if them both criteria match, then true is returned. False is returned if there is no such value or the value is not assignable to theColumn
instance's type.- Parameters:
aRecord
- TheRecord
which to test if there is a value associated to theColumn
instance's key and if it can be casted to theColumn
instance's type.- Returns:
- True in case the
Record
contains a value identified by theColumn
instance's key and where the value's type is assignable to theColumn
instance's type.
-
get
T get(Record<?> aRecord) throws ColumnMismatchException
Retrieves a type correct value from theRecord
identified by theColumn
instance's key. In case the type of theColumn
instance does not match the value's type associated with theColumn
instance's key, then aColumnMismatchException
is thrown.- Parameters:
aRecord
- TheRecord
from which to retrieve the value associated to theColumn
instances key.- Returns:
- The value from the
Record
associated to theColumn
instances key. - Throws:
ColumnMismatchException
- in case the value in theRecord
associated with theColumn
instance's key does not fit theColumn
instance's type.
-
remove
T remove(Record<?> aRecord) throws ColumnMismatchException
Removes an entry (key and value pair) from the providedRecord
matching the key and the type of theColumn
.- Parameters:
aRecord
- TheRecord
from which to remove the related entry.- Returns:
- The value related to the given
Column
instance's key or null if there was none such value found. - Throws:
ColumnMismatchException
- in case the value in theRecord
associated with theColumn
instance's key does not fit theColumn
instance's type.
-
-