Class FormattedColumn<T>
java.lang.Object
org.refcodes.textual.ColumnWidthMetrics
org.refcodes.textual.ColumnFormatMetrics
org.refcodes.textual.ColumnSetupMetrics
org.refcodes.tabular.FormattedColumn<T>
- Type Parameters:
T- The type managed by theFormattedColumn.
- All Implemented Interfaces:
VisibleAccessor, VisibleAccessor.VisibleBuilder<ColumnSetupMetrics>, VisibleAccessor.VisibleMutator, VisibleAccessor.VisibleProperty, ColumnWidthAccessor, ColumnWidthAccessor.ColumnWidthBuilder<ColumnWidthMetrics>, ColumnWidthAccessor.ColumnWidthMutator, ColumnWidthAccessor.ColumnWidthProperty, KeyAccessor<String>, NameAccessor, NameAccessor.NameBuilder<ColumnSetupMetrics>, NameAccessor.NameMutator, NameAccessor.NameProperty, TypeAccessor<T>, Column<T>, HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<ColumnFormatMetrics>, HorizAlignTextModeAccessor.HorizAlignTextModeMutator, MoreTextModeAccessor.MoreTextModeBuilder<ColumnFormatMetrics>, MoreTextModeAccessor.MoreTextModeMutator, SplitTextModeAccessor.SplitTextModeBuilder<ColumnFormatMetrics>, SplitTextModeAccessor.SplitTextModeMutator, TextFormatModeAccessor.TextFormatModeBuilder<ColumnFormatMetrics>, TextFormatModeAccessor.TextFormatModeMutator
The
FormattedColumn class enriches a Column with
rendering metrics (as of the ColumnSetupMetrics) mostly for
text-based output such as for generating output for a terminal / console.-
Nested Class Summary
Nested classes/interfaces inherited from interface ColumnWidthAccessor
ColumnWidthAccessor.ColumnWidthBuilder<B>, ColumnWidthAccessor.ColumnWidthMutator, ColumnWidthAccessor.ColumnWidthPropertyNested classes/interfaces inherited from interface KeyAccessor
KeyAccessor.KeyBuilder<K,B>, KeyAccessor.KeyMutator<K>, KeyAccessor.KeyProperty<K> Nested classes/interfaces inherited from interface NameAccessor
NameAccessor.NameBuilder<B>, NameAccessor.NameMutator, NameAccessor.NamePropertyNested classes/interfaces inherited from interface TypeAccessor
TypeAccessor.TypeBuilder<T,B>, TypeAccessor.TypeMutator<T>, TypeAccessor.TypeProperty<T> Nested classes/interfaces inherited from interface VisibleAccessor
VisibleAccessor.VisibleBuilder<B>, VisibleAccessor.VisibleMutator, VisibleAccessor.VisibleProperty -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFormattedColumn(String aKey, Class<T> aType) Instantiates a new formatted column decorator.FormattedColumn(String aKey, Class<T> aType, ColumnSetupMetrics aColumnSetupMetrics) Wrapper for the providedColumnSetupMetricsdecorating it with additionalColumnfunctionality.FormattedColumn(Column<T> aColumn) Wrapper for the providedColumndecorating it with additionalColumnSetupMetricsfunctionality.FormattedColumn(Column<T> aColumn, ColumnSetupMetrics aColumnSetupMetrics) Wrapper for the providedColumnand the providedColumnSetupMetricsdecorating it with each other's additional functionality. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidfromColumnFormatMetrics(ColumnFormatMetrics aColumnFormatMetrics) voidfromColumnSetupMetrics(ColumnSetupMetrics aColumnSetupMetrics) voidfromColumnWidthMetrics(ColumnWidthMetrics aColumnWidthMetrics) fromStorageString(String aStringValue) AColumnimplementation can provide its own text exchange format for the given objects.fromStorageStrings(String[] aStringArray) AColumnimplementation can provide its own text exchange format for the given objects.intgetKey()getName()getType()voidhide()booleanvoidsetColumnWidth(int aColumnWidth) voidsetColumnWidthType(ColumnWidthType aColumnWidthType) voidsetEscapeCode(String aEscapeCode) voidsetEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory) voidsetHeaderEscapeCode(String aEscapeCode) voidsetHeaderEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory) voidsetHeaderHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode) voidsetHeaderMoreTextMode(MoreTextMode aMoreTextMode) voidsetHeaderSplitTextMode(SplitTextMode aSplitTextMode) voidsetHeaderTextFormatMode(TextFormatMode aTextFormatMode) voidsetHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode) voidsetMoreTextMode(MoreTextMode aMoreTextMode) voidvoidsetRowEscapeCode(String aEscapeCode) voidsetRowEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory) voidsetRowHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode) voidsetRowMoreTextMode(MoreTextMode aMoreTextMode) voidsetRowSplitTextMode(SplitTextMode aSplitTextMode) voidsetRowTextFormatMode(TextFormatMode aTextFormatMode) voidsetSplitTextMode(SplitTextMode aSplitTextMode) voidsetTextFormatMode(TextFormatMode aTextFormatMode) voidsetVisible(boolean isVisible) voidshow()toHeaderEscapeCode(Object aIdentifier) toPrintable(T aValue) AColumnimplementation can provide its own printable format of the given objects; for example a human readable text representation of the value (or in very https://www.metacodes.proized cases even enriched with ANSI escape codes).toRowEscapeCode(Object aIdentifier) toStorageString(T aValue) AColumnimplementation can provide its own text exchange format for the given objects.String[]toStorageStrings(T aValue) AColumnimplementation can provide its own text exchange format for the given objects.withColumnWidth(int aColumnWidth) withColumnWidthType(ColumnWidthType aColumnWidthType) withEscapeCode(String aEscapeCode) withEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory) withHeaderEscapeCode(String aEscapeCode) withHeaderEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory) withHeaderHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode) withHeaderMoreTextMode(MoreTextMode aMoreTextMode) withHeaderSplitTextMode(SplitTextMode aSplitTextMode) withHeaderTextFormatMode(TextFormatMode aTextFormatMode) withHide()withHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode) withMoreTextMode(MoreTextMode aMoreTextMode) withRowEscapeCode(String aEscapeCode) withRowEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory) withRowHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode) withRowMoreTextMode(MoreTextMode aMoreTextMode) withRowSplitTextMode(SplitTextMode aSplitTextMode) withRowTextFormatMode(TextFormatMode aTextFormatMode) withShow()withSplitTextMode(SplitTextMode aSplitTextMode) withTextFormatMode(TextFormatMode aTextFormatMode) withVisible(boolean isVisible) Methods inherited from class ColumnWidthMetrics
toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Column
getValue, toStorageString_Methods inherited from interface ColumnWidthAccessor.ColumnWidthProperty
letColumnWidthMethods inherited from interface NameAccessor.NameProperty
letNameMethods inherited from interface VisibleAccessor
isHiddenMethods inherited from interface VisibleAccessor.VisibleProperty
letVisible
-
Constructor Details
-
FormattedColumn
-
FormattedColumn
Wrapper for the providedColumndecorating it with additionalColumnSetupMetricsfunctionality.- Parameters:
aColumn- TheColumnto be decorated.
-
FormattedColumn
Wrapper for the providedColumnSetupMetricsdecorating it with additionalColumnfunctionality.- Parameters:
aKey- The key for theColumn.aType- The type to be used.aColumnSetupMetrics- TheColumnSetupMetricsto be decorated.
-
FormattedColumn
Wrapper for the providedColumnand the providedColumnSetupMetricsdecorating it with each other's additional functionality.- Parameters:
aColumn- TheColumnto be decorated.aColumnSetupMetrics- TheColumnSetupMetricsto be decorated.
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceNameAccessor- Overrides:
getNamein classColumnSetupMetrics
-
isVisible
public boolean isVisible()- Specified by:
isVisiblein interfaceVisibleAccessor- Overrides:
isVisiblein classColumnSetupMetrics
-
getColumnWidth
public int getColumnWidth()- Specified by:
getColumnWidthin interfaceColumnWidthAccessor- Overrides:
getColumnWidthin classColumnWidthMetrics
-
withVisible
- Specified by:
withVisiblein interfaceVisibleAccessor.VisibleBuilder<T>- Overrides:
withVisiblein classColumnSetupMetrics
-
setName
- Specified by:
setNamein interfaceNameAccessor.NameMutator- Overrides:
setNamein classColumnSetupMetrics
-
setVisible
public void setVisible(boolean isVisible) - Specified by:
setVisiblein interfaceVisibleAccessor.VisibleMutator- Overrides:
setVisiblein classColumnSetupMetrics
-
setColumnWidth
public void setColumnWidth(int aColumnWidth) - Specified by:
setColumnWidthin interfaceColumnWidthAccessor.ColumnWidthMutator- Overrides:
setColumnWidthin classColumnWidthMetrics
-
withName
- Specified by:
withNamein interfaceNameAccessor.NameBuilder<T>- Overrides:
withNamein classColumnSetupMetrics
-
withColumnWidth
- Specified by:
withColumnWidthin interfaceColumnWidthAccessor.ColumnWidthBuilder<T>- Overrides:
withColumnWidthin classColumnSetupMetrics
-
show
public void show()- Specified by:
showin interfaceVisibleAccessor.VisibleMutator
-
withShow
- Specified by:
withShowin interfaceVisibleAccessor.VisibleBuilder<T>- Overrides:
withShowin classColumnSetupMetrics
-
getColumnWidthType
- Overrides:
getColumnWidthTypein classColumnWidthMetrics
-
hide
public void hide()- Specified by:
hidein interfaceVisibleAccessor.VisibleMutator
-
withHide
- Specified by:
withHidein interfaceVisibleAccessor.VisibleBuilder<T>- Overrides:
withHidein classColumnSetupMetrics
-
withEscapeCode
- Overrides:
withEscapeCodein classColumnSetupMetrics
-
setColumnWidthType
- Overrides:
setColumnWidthTypein classColumnWidthMetrics
-
withHeaderEscapeCode
- Overrides:
withHeaderEscapeCodein classColumnSetupMetrics
-
fromColumnWidthMetrics
- Overrides:
fromColumnWidthMetricsin classColumnWidthMetrics
-
withRowEscapeCode
- Overrides:
withRowEscapeCodein classColumnSetupMetrics
-
withColumnWidthType
- Overrides:
withColumnWidthTypein classColumnSetupMetrics
-
withHorizAlignTextMode
- Specified by:
withHorizAlignTextModein interfaceHorizAlignTextModeAccessor.HorizAlignTextModeBuilder<T>- Overrides:
withHorizAlignTextModein classColumnSetupMetrics
-
withHeaderHorizAlignTextMode
- Overrides:
withHeaderHorizAlignTextModein classColumnSetupMetrics
-
withRowHorizAlignTextMode
- Overrides:
withRowHorizAlignTextModein classColumnSetupMetrics
-
withMoreTextMode
- Specified by:
withMoreTextModein interfaceMoreTextModeAccessor.MoreTextModeBuilder<T>- Overrides:
withMoreTextModein classColumnSetupMetrics
-
withHeaderMoreTextMode
- Overrides:
withHeaderMoreTextModein classColumnSetupMetrics
-
setEscapeCodeFactory
- Overrides:
setEscapeCodeFactoryin classColumnFormatMetrics
-
withRowMoreTextMode
- Overrides:
withRowMoreTextModein classColumnSetupMetrics
-
withTextFormatMode
- Specified by:
withTextFormatModein interfaceTextFormatModeAccessor.TextFormatModeBuilder<T>- Overrides:
withTextFormatModein classColumnSetupMetrics
-
withSplitTextMode
- Specified by:
withSplitTextModein interfaceSplitTextModeAccessor.SplitTextModeBuilder<T>- Overrides:
withSplitTextModein classColumnSetupMetrics
-
withHeaderSplitTextMode
- Overrides:
withHeaderSplitTextModein classColumnSetupMetrics
-
withRowSplitTextMode
- Overrides:
withRowSplitTextModein classColumnSetupMetrics
-
withHeaderTextFormatMode
- Overrides:
withHeaderTextFormatModein classColumnSetupMetrics
-
withRowTextFormatMode
- Overrides:
withRowTextFormatModein classColumnSetupMetrics
-
withEscapeCodeFactory
- Overrides:
withEscapeCodeFactoryin classColumnSetupMetrics
-
setHeaderEscapeCodeFactory
- Overrides:
setHeaderEscapeCodeFactoryin classColumnFormatMetrics
-
withHeaderEscapeCodeFactory
- Overrides:
withHeaderEscapeCodeFactoryin classColumnSetupMetrics
-
withRowEscapeCodeFactory
- Overrides:
withRowEscapeCodeFactoryin classColumnSetupMetrics
-
getHeaderEscapeCodeFactory
- Overrides:
getHeaderEscapeCodeFactoryin classColumnFormatMetrics
-
fromColumnSetupMetrics
- Overrides:
fromColumnSetupMetricsin classColumnSetupMetrics
-
toHeaderEscapeCode
- Overrides:
toHeaderEscapeCodein classColumnFormatMetrics
-
setRowEscapeCodeFactory
- Overrides:
setRowEscapeCodeFactoryin classColumnFormatMetrics
-
getRowEscapeCodeFactory
- Overrides:
getRowEscapeCodeFactoryin classColumnFormatMetrics
-
toRowEscapeCode
- Overrides:
toRowEscapeCodein classColumnFormatMetrics
-
setEscapeCode
- Overrides:
setEscapeCodein classColumnFormatMetrics
-
setHeaderEscapeCode
- Overrides:
setHeaderEscapeCodein classColumnFormatMetrics
-
getHeaderEscapeCode
- Overrides:
getHeaderEscapeCodein classColumnFormatMetrics
-
setRowEscapeCode
- Overrides:
setRowEscapeCodein classColumnFormatMetrics
-
getRowEscapeCode
- Overrides:
getRowEscapeCodein classColumnFormatMetrics
-
setHorizAlignTextMode
- Specified by:
setHorizAlignTextModein interfaceHorizAlignTextModeAccessor.HorizAlignTextModeMutator- Overrides:
setHorizAlignTextModein classColumnFormatMetrics
-
setHeaderHorizAlignTextMode
- Overrides:
setHeaderHorizAlignTextModein classColumnFormatMetrics
-
getHeaderHorizAlignTextMode
- Overrides:
getHeaderHorizAlignTextModein classColumnFormatMetrics
-
setRowHorizAlignTextMode
- Overrides:
setRowHorizAlignTextModein classColumnFormatMetrics
-
getRowHorizAlignTextMode
- Overrides:
getRowHorizAlignTextModein classColumnFormatMetrics
-
setMoreTextMode
- Specified by:
setMoreTextModein interfaceMoreTextModeAccessor.MoreTextModeMutator- Overrides:
setMoreTextModein classColumnFormatMetrics
-
setHeaderMoreTextMode
- Overrides:
setHeaderMoreTextModein classColumnFormatMetrics
-
getHeaderMoreTextMode
- Overrides:
getHeaderMoreTextModein classColumnFormatMetrics
-
setRowMoreTextMode
- Overrides:
setRowMoreTextModein classColumnFormatMetrics
-
getRowMoreTextMode
- Overrides:
getRowMoreTextModein classColumnFormatMetrics
-
setTextFormatMode
- Specified by:
setTextFormatModein interfaceTextFormatModeAccessor.TextFormatModeMutator- Overrides:
setTextFormatModein classColumnFormatMetrics
-
setSplitTextMode
- Specified by:
setSplitTextModein interfaceSplitTextModeAccessor.SplitTextModeMutator- Overrides:
setSplitTextModein classColumnFormatMetrics
-
setHeaderSplitTextMode
- Overrides:
setHeaderSplitTextModein classColumnFormatMetrics
-
getHeaderSplitTextMode
- Overrides:
getHeaderSplitTextModein classColumnFormatMetrics
-
setRowSplitTextMode
- Overrides:
setRowSplitTextModein classColumnFormatMetrics
-
getRowSplitTextMode
- Overrides:
getRowSplitTextModein classColumnFormatMetrics
-
setHeaderTextFormatMode
- Overrides:
setHeaderTextFormatModein classColumnFormatMetrics
-
getHeaderTextFormatMode
- Overrides:
getHeaderTextFormatModein classColumnFormatMetrics
-
setRowTextFormatMode
- Overrides:
setRowTextFormatModein classColumnFormatMetrics
-
getRowTextFormatMode
- Overrides:
getRowTextFormatModein classColumnFormatMetrics
-
fromColumnFormatMetrics
- Overrides:
fromColumnFormatMetricsin classColumnFormatMetrics
-
getType
- Specified by:
getTypein interfaceTypeAccessor<T>
-
getKey
- Specified by:
getKeyin interfaceKeyAccessor<T>
-
toStorageString
AColumnimplementation can provide its own text exchange format for the given objects. This method enables theColumnto convert a value of the given type to aStringand viaColumn.fromStorageString(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 storageStringrepresentation of the elements in that array are represented by a single returnedString. Question: Why does the detour through the methodColumn.toStorageString(Object)not function?!? Having this snippet in the code seems to be fine for the compiler ... tryingColumn.toStorageString_(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 methodColumn.toStorageStrings(Object)may be used instead.- Specified by:
toStorageStringin interfaceColumn<T>- Parameters:
aValue- the element to be converted to aString.- Returns:
- The
Stringrepresentation of the value.
-
toStorageStrings
AColumnimplementation can provide its own text exchange format for the given objects. This method enables theColumnto convert a value of the given type to aStringarray and viaColumn.fromStorageStrings(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 storageStringrepresentations of the elements in that array may be placed in dedicated entries of the returnedStringarray. In case T is not an array type then the returnedStringarray 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 methodColumn.toStorageString(Object)may be used instead.- Specified by:
toStorageStringsin interfaceColumn<T>- Parameters:
aValue- the element to be converted to aStringarray.- Returns:
- The
Stringarray representation of the value.
-
fromStorageString
AColumnimplementation can provide its own text exchange format for the given objects. This method enables theColumnto convert aStringvalue to a value of the given type and viaColumn.toStorageString(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 storageStringrepresentation 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 methodColumn.fromStorageStrings(String[])may be used instead.- Specified by:
fromStorageStringin interfaceColumn<T>- Parameters:
aStringValue- The value to be converted to a type instance.- Returns:
- The type representation of the value.
- Throws:
ParseException- in case parsing theStringwas not possible
-
fromStorageStrings
AColumnimplementation can provide its own text exchange format for the given objects. This method enables theColumnto convert aStringarray value to a value of the given type and viaColumn.toStorageStrings(Object)back to theStringarray (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 storageStringrepresentations of the elements in that array may be placed in dedicated entries of the providedStringarray. In case T is not an array type then the passedStringarray 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 methodColumn.fromStorageString(String)may be used instead.- Specified by:
fromStorageStringsin interfaceColumn<T>- Parameters:
aStringArray- The value to be converted to a type instance.- Returns:
- The type representation of the value.
- Throws:
ParseException- in case parsing theStringwas not possible
-
toPrintable
AColumnimplementation can provide its own printable format of the given objects; for example a human readable text representation of the value (or in very https://www.metacodes.proized cases even enriched with ANSI escape codes). This method enables theColumnto convert a value of the given type to a human readable text. The human readable text, in comparison to the methodObject.toString()(orColumn.toStorageString(Object)) is not intended to be converted back to the actual value (not bijective). This method may be used aHeaderinstance's methodHeaderRow.toPrintable(Record).- Specified by:
toPrintablein interfaceColumn<T>- Parameters:
aValue- the element to be converted to a human readable text.- Returns:
- The human readable representation of the value.
-
contains
Tests whether theRecordcontains a value identified by theColumninstance's key and where the value's type is assignable to theColumninstance'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 theColumninstance's type.- Specified by:
containsin interfaceColumn<T>- Parameters:
aRecord- TheRecordwhich to test if there is a value associated to theColumninstance's key and if it can be casted to theColumninstance's type.- Returns:
- True in case the
Recordcontains a value identified by theColumninstance's key and where the value's type is assignable to theColumninstance's type.
-
get
Retrieves a type correct value from theRecordidentified by theColumninstance's key. In case the type of theColumninstance does not match the value's type associated with theColumninstance's key, then aColumnMismatchExceptionis thrown.- Specified by:
getin interfaceColumn<T>- Parameters:
aRecord- TheRecordfrom which to retrieve the value associated to theColumninstances key.- Returns:
- The value from the
Recordassociated to theColumninstances key. - Throws:
ColumnMismatchException- in case the value in theRecordassociated with theColumninstance's key does not fit theColumninstance's type.
-
remove
Removes an entry (key and value pair) from the providedRecordmatching the key and the type of theColumn.- Specified by:
removein interfaceColumn<T>- Parameters:
aRecord- TheRecordfrom which to remove the related entry.- Returns:
- The value related to the given
Columninstance's key or null if there was none such value found. - Throws:
ColumnMismatchException- in case the value in theRecordassociated with theColumninstance's key does not fit theColumninstance's type.
-