T
- The type managed by the Header
.C
- the generic typeSerializable
, Cloneable
, Iterable<T>
, Collection<T>
, List<T>
, RandomAccess
, org.refcodes.structure.Clearable
, org.refcodes.structure.Keys<T,C>
, org.refcodes.structure.Keys.MutableKeys<T,C>
, ColumnsTemplate<T,C>
, HeaderTemplate<T,C>
FormattedHeaderImpl
, HeaderImpl
public abstract class AbstractHeader<T,C extends Column<? extends T>> extends ArrayList<C> implements HeaderTemplate<T,C>, Cloneable
modCount
Constructor | Description |
---|---|
AbstractHeader() |
Constructs the
AbstractHeader instance. |
AbstractHeader(C... aHeader) |
Constructs the
AbstractHeader instance configured with the
provided Column instances. |
Modifier and Type | Method | Description |
---|---|---|
void |
add(int aIndex,
C aColumn) |
|
boolean |
add(C aColumn) |
|
boolean |
containsKey(Object aKey) |
|
C |
delete(String aKey) |
|
Record<T> |
fromStorageString(Record<String> aStringRecord) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Row<T> |
fromStorageString(Row<String> aStringRow) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Row<T> |
fromStorageStringRecord(Record<String> aStringRecord) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Record<T> |
fromStorageStringRow(Row<String> aStringRow) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Record<T> |
fromStorageStrings(Record<String[]> aStringsRecord) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Row<T> |
fromStorageStrings(Row<String[]> aStringsRow) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Row<T> |
fromStorageStringsRecord(Record<String[]> aStringsRecord) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Record<T> |
fromStorageStringsRow(Row<String[]> aStringsRow) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
C |
get(Object aKey) |
|
int |
indexOf(String aKey) |
Determines the index of the column with the given key or -1 if there is
none such column.
|
Set<String> |
keySet() |
|
Record<String> |
toPrintable(Record<? extends T> aRecord) |
To printable.
|
Row<String> |
toPrintable(Row<? extends T> aRow) |
To printable.
|
Record<String> |
toPrintableRecord(Row<? extends T> aRow) |
A special
Column implementation might 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). |
Row<String> |
toPrintableRow(Record<? extends T> aRecord) |
To printable row.
|
Record<T> |
toRecord(Row<? extends T> aRow) |
To record.
|
Record<?> |
toRecordIgnoreType(Row<?> aRow) |
Similar to
HeaderTemplate.toRecord(Row) with the difference that conversion is
done ignoring the type of the HeaderTemplate Column
instances and the according value(s). |
Row<T> |
toRow(Record<? extends T> aRecord) |
To row.
|
Row<?> |
toRowIgnoreType(Record<?> aRecord) |
Similar to
HeaderTemplate.toRow(Record) with the difference that conversion is
done ignoring the type of the HeaderTemplate Column
instances and the according value(s). |
Record<String> |
toStorageString(Record<? extends T> aRecord) |
To storage string.
|
Row<String> |
toStorageString(Row<? extends T> aRow) |
To storage string.
|
Record<String> |
toStorageStringRecord(Row<? extends T> aRow) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Row<String> |
toStorageStringRow(Record<? extends T> aRecord) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Record<String[]> |
toStorageStrings(Record<? extends T> aRecord) |
To storage strings.
|
Row<String[]> |
toStorageStrings(Row<? extends T> aRow) |
To storage strings.
|
Record<String[]> |
toStorageStringsRecord(Row<? extends T> aRow) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Row<String[]> |
toStorageStringsRow(Record<? extends T> aRecord) |
A special
Column implementation might provide its own text
exchange format for the given objects. |
Collection<C> |
values() |
containsAll, toString
equals, hashCode
addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
parallelStream, removeIf, stream
containsValue, withColumns
addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
public AbstractHeader()
AbstractHeader
instance.@SafeVarargs public AbstractHeader(C... aHeader)
AbstractHeader
instance configured with the
provided Column
instances.aHeader
- The Column
instances to be contained in the
AbstractHeader
in the order as passed.public boolean containsKey(Object aKey)
public int indexOf(String aKey)
public Record<String> toStorageString(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
toStorageString
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- the recordHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Row<String> toStorageString(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
toStorageString
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- the rowHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Record<T> fromStorageString(Record<String> aStringRecord) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Record
containing only
String
objects to a Record
with the given types and via
HeaderTemplate.toStorageString(Record)
back to the String
Record
(bijective).
This method may use a Column
instance's method
Column.fromStorageString(String)
.fromStorageString
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringRecord
- the String
Record
to be converted to
a type Record
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given Columns
and the Row
, i.e. the
index for the given key in the header may be out of index of the
given row or the given key does not exist in the
HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Row<T> fromStorageString(Row<String> aStringRow) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Row
containing only
String
objects to a Row
with the given types and via
HeaderTemplate.toStorageString(Row)
back to the String
Row
(bijective).
This method may use a Column
instance's method
Column.fromStorageString(String)
.fromStorageString
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringRow
- the String
Row
to be converted to a
type Row
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Record<String[]> toStorageStrings(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
toStorageStrings
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- the recordHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Row<String[]> toStorageStrings(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
toStorageStrings
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- the rowHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Row<T> fromStorageStrings(Row<String[]> aStringsRow) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Row
containing only
String
objects to a Row
with the given types and via
HeaderTemplate.toStorageStrings(Row)
back to the String
array
Row
(bijective).
This method may use a Column
instance's method
Column.fromStorageStrings(String[])
.
Supporting String
arrays enables to address data sinks which
support multiple values in one filed (for example some NoSQL databases
such as Amazon's simple DB supports multiple values in one row's entry).fromStorageStrings
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringsRow
- the String
array Row
to be converted
to a type Row
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Record<T> fromStorageStrings(Record<String[]> aStringsRecord) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Record
containing only
String
objects to a Record
with the given types and via
HeaderTemplate.toStorageStrings(Record)
back to the String
Record
(bijective).
This method may use a Column
instance's method
Column.fromStorageStrings(String[])
.
Supporting String
arrays enables to address data sinks which
support multiple values in one filed (for example some NoSQL databases
such as Amazon's simple DB supports multiple values in one row's entry).fromStorageStrings
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringsRecord
- the String
array Record
to be
converted to a type Record
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given Columns
and the Row
, i.e. the
index for the given key in the header may be out of index of the
given row or the given key does not exist in the
HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Record<String> toPrintable(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
toPrintable
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- the recordHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Row<String> toPrintable(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
toPrintable
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- the rowHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Row<T> toRow(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
toRow
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- the recordHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Row<?> toRowIgnoreType(Record<?> aRecord) throws HeaderMismatchException
HeaderTemplate.toRow(Record)
with the difference that conversion is
done ignoring the type of the HeaderTemplate
Column
instances and the according value(s).toRowIgnoreType
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- The Record
to use when creating the Row
.Row
according to the Column
instances of the
HeaderTemplate
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.public Record<T> toRecord(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
toRecord
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- the rowHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Record<?> toRecordIgnoreType(Row<?> aRow) throws HeaderMismatchException
HeaderTemplate.toRecord(Row)
with the difference that conversion is
done ignoring the type of the HeaderTemplate
Column
instances and the according value(s).toRecordIgnoreType
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- The Record
to use when creating the Record
.Row
according to the Column
instances of the
HeaderTemplate
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.public Row<T> fromStorageStringRecord(Record<String> aStringRecord) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Record
containing only
String
objects to a Row
with the given types and via
HeaderTemplate.toStorageStringRecord(Row)
back to the String
Record
(bijective).
This method may use a Column
instance's method
Column.fromStorageString(String)
.fromStorageStringRecord
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringRecord
- the String
Record
to be converted to
a type Row
.Row
representation of the String
Record
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Record<String> toStorageStringRecord(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Row
of the given type to a
Record
containing only String
values and via
HeaderTemplate.fromStorageStringRecord(Record)
back to the actual Row
(bijective).
This method may use a Column
instance's method
Column.toStorageString(Object)
.
-------------------------------------------------------------------------
TODO !!! STILL TO BE TESTED !!!
-------------------------------------------------------------------------toStorageStringRecord
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- The Row
to be converted to a String
Record
.String
representation of the value.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ColumnMismatchException
- Thrown in case a value was found in the
e.g. in a Row
of the wrong type than specified by a
Column
of the HeaderTemplate
.public Record<T> fromStorageStringRow(Row<String> aStringRow) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Row
containing only
String
objects to a Record
with the given types and via
HeaderTemplate.toStorageStringRow(Record)
back to the String
Row
(bijective).
This method may use a Column
instance's method
Column.fromStorageString(String)
.fromStorageStringRow
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringRow
- the String
Row
to be converted to a
type Record
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Row<String> toStorageStringRow(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Record
of the given type to a
Row
containing only String
values and via
HeaderTemplate.fromStorageStringRecord(Record)
back to the actual
Record
(bijective).
This method may use a Column
instance's method
Column.toStorageString(Object)
.
-------------------------------------------------------------------------
TODO !!! STILL TO BE TESTED !!!
-------------------------------------------------------------------------toStorageStringRow
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- The Row
to be converted to a String
Record
.String
representation of the value.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ColumnMismatchException
- Thrown in case a value was found in the
e.g. in a Record
of the wrong type than specified by a
Column
of the HeaderTemplate
.public Row<T> fromStorageStringsRecord(Record<String[]> aStringsRecord) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Record
containing only
String
arrays to a Row
with the given types and via
HeaderTemplate.toStorageStringsRecord(Row)
back to the String
Record
(bijective).
This method may use a Column
instance's method
Column.fromStorageStrings(String[])
.
Supporting String
arrays enables to address data sinks which
support multiple values in one filed (for example some NoSQL databases
such as Amazon's simple DB supports multiple values in one row's entry).fromStorageStringsRecord
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringsRecord
- the String
Record
to be converted
to a type Row
.Row
representation of the String
Record
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Record<String[]> toStorageStringsRecord(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Row
of the given type to a
Record
containing only String
arrays and via
HeaderTemplate.fromStorageStringsRecord(Record)
back to the actual Row
(bijective).
This method may use a Column
instance's method
Column.toStorageStrings(Object)
.
Supporting String
arrays enables to address data sinks which
support multiple values in one filed (for example some NoSQL databases
such as Amazon's simple DB supports multiple values in one row's entry).
-------------------------------------------------------------------------
TODO !!! STILL TO BE TESTED !!!
-------------------------------------------------------------------------toStorageStringsRecord
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- The Row
to be converted to a String
Record
.String
representation of the value.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ColumnMismatchException
- Thrown in case a value was found in the
e.g. in a Row
of the wrong type than specified by a
Column
of the HeaderTemplate
.public Record<T> fromStorageStringsRow(Row<String[]> aStringsRow) throws HeaderMismatchException, ParseException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Row
containing only
String
arrays to a Record
with the given types and via
HeaderTemplate.toStorageStringsRow(Record)
back to the String
Row
(bijective).
This method may use a Column
instance's method
Column.fromStorageStrings(String[])
.
Supporting String
arrays enables to address data sinks which
support multiple values in one filed (for example some NoSQL databases
such as Amazon's simple DB supports multiple values in one row's entry).fromStorageStringsRow
in interface HeaderTemplate<T,C extends Column<? extends T>>
aStringsRow
- the String
Row
to be converted to a
type Record
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ParseException
- in case parsing the input was not possiblepublic Row<String[]> toStorageStringsRow(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
Column
implementation might provide its own text
exchange format for the given objects. This method enables the
HeaderTemplate
to convert a Record
of the given type to a
Row
containing only String
arrays and via
HeaderTemplate.fromStorageStringsRecord(Record)
back to the actual
Record
(bijective).
This method may use a Column
instance's method
Column.toStorageStrings(Object)
.
Supporting String
arrays enables to address data sinks which
support multiple values in one filed (for example some NoSQL databases
such as Amazon's simple DB supports multiple values in one row's entry).
-------------------------------------------------------------------------
TODO !!! STILL TO BE TESTED !!!
-------------------------------------------------------------------------toStorageStringsRow
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- The Row
to be converted to a String
Record
.String
representation of the value.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ColumnMismatchException
- Thrown in case a value was found in the
e.g. in a Record
of the wrong type than specified by a
Column
of the HeaderTemplate
.public Row<String> toPrintableRow(Record<? extends T> aRecord) throws HeaderMismatchException, ColumnMismatchException
toPrintableRow
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRecord
- the recordHeaderMismatchException
- the header mismatch exceptionColumnMismatchException
- the column mismatch exceptionpublic Record<String> toPrintableRecord(Row<? extends T> aRow) throws HeaderMismatchException, ColumnMismatchException
Column
implementation might 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 the HeaderTemplate
to convert a Row
of the given type to a human readable text
Record
. The human readable text, in comparison to the method
HeaderTemplate.toStorageString(Row)
(or HeaderTemplate.toRecordIgnoreType(Row)
) is
not intended to be converted back to the actual value (not bijective).
This method may use a Column
instance's method
Column.toPrintable(Object)
; it also might enrich the output of
the Column.toPrintable(Object)
with device specific additional
data such as ANSI Escape-Codes and with information regarding the
Row
as a whole and not just be regarding a single value.
-------------------------------------------------------------------------
TODO !!! STILL TO BE TESTED !!!
-------------------------------------------------------------------------toPrintableRecord
in interface HeaderTemplate<T,C extends Column<? extends T>>
aRow
- the Row
to be converted to a human readable text
Record
.Record
representation of the
Row
.HeaderMismatchException
- Thrown in case there is a mismatch
between the given HeaderMismatchException
and the
Row
, i.e. the index for the given key in the header may
be out of index of the given row or the given key does not exist
in the HeaderTemplate
.ColumnMismatchException
- Thrown in case a value was found in the
e.g. in a Row
of the wrong type than specified by a
Column
of the HeaderTemplate
.public boolean add(C aColumn)
public void add(int aIndex, C aColumn)
Copyright © 2018. All rights reserved.