Package org.refcodes.textual
Class ColumnFormatMetricsImpl
- java.lang.Object
-
- org.refcodes.textual.ColumnWidthMetricsImpl
-
- org.refcodes.textual.ColumnFormatMetricsImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.ColumnWidthAccessor
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<ColumnWidthMetrics>
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
,org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
,ColumnFormatMetrics
,ColumnWidthMetrics
,HorizAlignTextModeAccessor.HorizAlignTextModeBuilder<ColumnWidthMetrics>
,HorizAlignTextModeAccessor.HorizAlignTextModeMutator
,MoreTextModeAccessor.MoreTextModeBuilder<ColumnWidthMetrics>
,MoreTextModeAccessor.MoreTextModeMutator
,SplitTextModeAccessor.SplitTextModeBuilder<ColumnWidthMetrics>
,SplitTextModeAccessor.SplitTextModeMutator
,TextFormatModeAccessor.TextFormatModeBuilder<ColumnWidthMetrics>
,TextFormatModeAccessor.TextFormatModeMutator
- Direct Known Subclasses:
ColumnSetupMetricsImpl
public class ColumnFormatMetricsImpl extends ColumnWidthMetricsImpl implements ColumnFormatMetrics
Implementation of theColumnFormatMetrics
interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.ColumnWidthAccessor
org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<B extends org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<B>>, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator, org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthProperty
-
-
Constructor Summary
Constructors Constructor Description ColumnFormatMetricsImpl()
Instantiates a new column format metrics impl.ColumnFormatMetricsImpl(int aWidth, ColumnWidthType aWidthType)
Constructs a column's width, either in percent (%) or in number of chars.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getHeaderEscapeCode()
Returns the ANSI Escape-Code for the header.EscapeCodeFactory
getHeaderEscapeCodeFactory()
Gets the ANSI Escape-Code factory for the header.HorizAlignTextMode
getHeaderHorizAlignTextMode()
Gets the alignment mode for the header.MoreTextMode
getHeaderMoreTextMode()
Gets the alignment mode for the header.SplitTextMode
getHeaderSplitTextMode()
Returns theSplitTextMode
for the header.TextFormatMode
getHeaderTextFormatMode()
Returns theTextFormatMode
for the header.java.lang.String
getRowEscapeCode()
Returns the ANSI Escape-Code for the rows and returns thisColumnFormatMetrics
instance as of the Builder-Pattern.EscapeCodeFactory
getRowEscapeCodeFactory()
Gets the ANSI Escape-Code factory for the row.HorizAlignTextMode
getRowHorizAlignTextMode()
Gets the alignment mode for the row.MoreTextMode
getRowMoreTextMode()
Gets the alignment mode for the row.SplitTextMode
getRowSplitTextMode()
Returns theSplitTextMode
for the row.TextFormatMode
getRowTextFormatMode()
Returns theTextFormatMode
for the row.void
setEscapeCode(java.lang.String aEscapeCode)
Sets an ANSI Escape-Code for the header and the rows.void
setHeaderEscapeCode(java.lang.String aEscapeCode)
Sets an ANSI Escape-Code for the header.void
setHeaderEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory)
Sets an ANSI Escape-Code factory for the header.void
setHeaderHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an alignment mode for the header.void
setHeaderMoreTextMode(MoreTextMode aMoreTextMode)
Sets a more-text mode for the header.void
setHeaderSplitTextMode(SplitTextMode aSplitTextMode)
Sets theSplitTextMode
for the header.void
setHeaderTextFormatMode(TextFormatMode aTextFormatMode)
Sets theTextFormatMode
for the header.void
setMoreTextMode(MoreTextMode aMoreTextMode)
Sets the more-text mode for the more-text mode property.void
setRowEscapeCode(java.lang.String aEscapeCode)
Sets an ANSI Escape-Code for the rows and returns thisColumnFormatMetrics
instance as of the Builder-Pattern.void
setRowEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory)
Sets an ANSI Escape-Code factory for the row.void
setRowHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an alignment mode for the row.void
setRowMoreTextMode(MoreTextMode aMoreTextMode)
Sets a more-text mode for the row.void
setRowSplitTextMode(SplitTextMode aSplitTextMode)
Sets theSplitTextMode
for the row.void
setRowTextFormatMode(TextFormatMode aTextFormatMode)
Sets theTextFormatMode
for the row.java.lang.String
toHeaderEscapeCode(java.lang.Object aIdentifier)
Determines the ANSI Escape-Code by evaluating the provided ID: If anEscapeCodeFactory
has been set viaColumnFormatMetrics.setEscapeCodeFactory(EscapeCodeFactory)
and the factory returns a value different to null, then this value is returned.java.lang.String
toRowEscapeCode(java.lang.Object aIdentifier)
Determines the ANSI Escape-Code by evaluating the provided ID: If anEscapeCodeFactory
has been set viaColumnFormatMetrics.setEscapeCodeFactory(EscapeCodeFactory)
and the factory returns a value different to null, then this value is returned.ColumnFormatMetrics
withColumnWidth(int aColumnWidth)
-
Methods inherited from interface org.refcodes.textual.ColumnFormatMetrics
fromColumnFormatMetrics, setEscapeCodeFactory, setHorizAlignTextMode, setSplitTextMode, setTextFormatMode, withColumnWidthType, withEscapeCode, withEscapeCodeFactory, withHeaderEscapeCode, withHeaderEscapeCodeFactory, withHeaderHorizAlignTextMode, withHeaderMoreTextMode, withHeaderSplitTextMode, withHeaderTextFormatMode, withHorizAlignTextMode, withMoreTextMode, withRowEscapeCode, withRowEscapeCodeFactory, withRowHorizAlignTextMode, withRowMoreTextMode, withRowSplitTextMode, withRowTextFormatMode, withSplitTextMode, withTextFormatMode
-
Methods inherited from interface org.refcodes.mixin.ColumnWidthAccessor.ColumnWidthMutator
setColumnWidth
-
Methods inherited from interface org.refcodes.textual.ColumnWidthMetrics
fromColumnWidthMetrics, getColumnWidthType, setColumnWidthType
-
Methods inherited from class org.refcodes.textual.ColumnWidthMetricsImpl
getColumnWidth, getColumnWidthType, setColumnWidth, setColumnWidthType, toString
-
-
-
-
Constructor Detail
-
ColumnFormatMetricsImpl
public ColumnFormatMetricsImpl()
Instantiates a new column format metrics impl.
-
ColumnFormatMetricsImpl
public ColumnFormatMetricsImpl(int aWidth, ColumnWidthType aWidthType)
Constructs a column's width, either in percent (%) or in number of chars.- Parameters:
aWidth
- The width for the column, either in percent (%) or in number of chars, depending on the providedColumnWidthType
.aWidthType
- The type of the width being provided, either percent (%) or number of chars.
-
-
Method Detail
-
withColumnWidth
public ColumnFormatMetrics withColumnWidth(int aColumnWidth)
- Specified by:
withColumnWidth
in interfaceColumnFormatMetrics
- Specified by:
withColumnWidth
in interfaceorg.refcodes.mixin.ColumnWidthAccessor.ColumnWidthBuilder<ColumnWidthMetrics>
- Overrides:
withColumnWidth
in classColumnWidthMetricsImpl
-
setEscapeCode
public void setEscapeCode(java.lang.String aEscapeCode)
Sets an ANSI Escape-Code for the header and the rows. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
setEscapeCode
in interfaceColumnFormatMetrics
- Parameters:
aEscapeCode
- TheString
to be used for ANSI escaping.
-
setHeaderEscapeCode
public void setHeaderEscapeCode(java.lang.String aEscapeCode)
Sets an ANSI Escape-Code for the header. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
setHeaderEscapeCode
in interfaceColumnFormatMetrics
- Parameters:
aEscapeCode
- TheString
to be used for ANSI escaping.
-
getHeaderEscapeCode
public java.lang.String getHeaderEscapeCode()
Returns the ANSI Escape-Code for the header. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
getHeaderEscapeCode
in interfaceColumnFormatMetrics
- Returns:
- The
String
to be used for ANSI escaping.
-
setRowEscapeCode
public void setRowEscapeCode(java.lang.String aEscapeCode)
Sets an ANSI Escape-Code for the rows and returns thisColumnFormatMetrics
instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.- Specified by:
setRowEscapeCode
in interfaceColumnFormatMetrics
- Parameters:
aEscapeCode
- TheString
to be used for ANSI escaping.
-
getRowEscapeCode
public java.lang.String getRowEscapeCode()
Returns the ANSI Escape-Code for the rows and returns thisColumnFormatMetrics
instance as of the Builder-Pattern. The latest ANSI Escape-Code being set wins.- Specified by:
getRowEscapeCode
in interfaceColumnFormatMetrics
- Returns:
- The
String
to be used for ANSI escaping.
-
setMoreTextMode
public void setMoreTextMode(MoreTextMode aMoreTextMode)
Sets the more-text mode for the more-text mode property.- Specified by:
setMoreTextMode
in interfaceColumnFormatMetrics
- Specified by:
setMoreTextMode
in interfaceMoreTextModeAccessor.MoreTextModeMutator
- Parameters:
aMoreTextMode
- The more-text mode to be stored by the more-text mode property.
-
setHeaderHorizAlignTextMode
public void setHeaderHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an alignment mode for the header.- Specified by:
setHeaderHorizAlignTextMode
in interfaceColumnFormatMetrics
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.
-
getHeaderHorizAlignTextMode
public HorizAlignTextMode getHeaderHorizAlignTextMode()
Gets the alignment mode for the header.- Specified by:
getHeaderHorizAlignTextMode
in interfaceColumnFormatMetrics
- Returns:
- The
HorizAlignTextMode
to be used for aligning the text.
-
setRowHorizAlignTextMode
public void setRowHorizAlignTextMode(HorizAlignTextMode aHorizAlignTextMode)
Sets an alignment mode for the row.- Specified by:
setRowHorizAlignTextMode
in interfaceColumnFormatMetrics
- Parameters:
aHorizAlignTextMode
- TheHorizAlignTextMode
to be used for aligning the text.
-
getRowHorizAlignTextMode
public HorizAlignTextMode getRowHorizAlignTextMode()
Gets the alignment mode for the row.- Specified by:
getRowHorizAlignTextMode
in interfaceColumnFormatMetrics
- Returns:
- The
HorizAlignTextMode
to be used for aligning the text.
-
setHeaderMoreTextMode
public void setHeaderMoreTextMode(MoreTextMode aMoreTextMode)
Sets a more-text mode for the header.- Specified by:
setHeaderMoreTextMode
in interfaceColumnFormatMetrics
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for truncating the text.
-
getHeaderMoreTextMode
public MoreTextMode getHeaderMoreTextMode()
Gets the alignment mode for the header.- Specified by:
getHeaderMoreTextMode
in interfaceColumnFormatMetrics
- Returns:
- The
MoreTextMode
to be used for truncating the text.
-
setRowMoreTextMode
public void setRowMoreTextMode(MoreTextMode aMoreTextMode)
Sets a more-text mode for the row.- Specified by:
setRowMoreTextMode
in interfaceColumnFormatMetrics
- Parameters:
aMoreTextMode
- TheMoreTextMode
to be used for truncating the text.
-
getRowMoreTextMode
public MoreTextMode getRowMoreTextMode()
Gets the alignment mode for the row.- Specified by:
getRowMoreTextMode
in interfaceColumnFormatMetrics
- Returns:
- The
MoreTextMode
to be used for truncating the text.
-
setHeaderTextFormatMode
public void setHeaderTextFormatMode(TextFormatMode aTextFormatMode)
Sets theTextFormatMode
for the header.- Specified by:
setHeaderTextFormatMode
in interfaceColumnFormatMetrics
- Parameters:
aTextFormatMode
- TheTextFormatMode
to be set for the header;
-
getHeaderTextFormatMode
public TextFormatMode getHeaderTextFormatMode()
Returns theTextFormatMode
for the header.- Specified by:
getHeaderTextFormatMode
in interfaceColumnFormatMetrics
- Returns:
- The
TextFormatMode
to be set for the header;
-
setRowTextFormatMode
public void setRowTextFormatMode(TextFormatMode aTextFormatMode)
Sets theTextFormatMode
for the row.- Specified by:
setRowTextFormatMode
in interfaceColumnFormatMetrics
- Parameters:
aTextFormatMode
- TheTextFormatMode
to be set for the row;
-
getRowTextFormatMode
public TextFormatMode getRowTextFormatMode()
Returns theTextFormatMode
for the row.- Specified by:
getRowTextFormatMode
in interfaceColumnFormatMetrics
- Returns:
- The
TextFormatMode
to be set for the row;
-
setHeaderSplitTextMode
public void setHeaderSplitTextMode(SplitTextMode aSplitTextMode)
Sets theSplitTextMode
for the header.- Specified by:
setHeaderSplitTextMode
in interfaceColumnFormatMetrics
- Parameters:
aSplitTextMode
- TheSplitTextMode
to be set for the header;
-
getHeaderSplitTextMode
public SplitTextMode getHeaderSplitTextMode()
Returns theSplitTextMode
for the header.- Specified by:
getHeaderSplitTextMode
in interfaceColumnFormatMetrics
- Returns:
- The
SplitTextMode
to be set for the header;
-
setRowSplitTextMode
public void setRowSplitTextMode(SplitTextMode aSplitTextMode)
Sets theSplitTextMode
for the row.- Specified by:
setRowSplitTextMode
in interfaceColumnFormatMetrics
- Parameters:
aSplitTextMode
- TheSplitTextMode
to be set for the row;
-
getRowSplitTextMode
public SplitTextMode getRowSplitTextMode()
Returns theSplitTextMode
for the row.- Specified by:
getRowSplitTextMode
in interfaceColumnFormatMetrics
- Returns:
- The
SplitTextMode
to be set for the row;
-
setHeaderEscapeCodeFactory
public void setHeaderEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory)
Sets an ANSI Escape-Code factory for the header. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
setHeaderEscapeCodeFactory
in interfaceColumnFormatMetrics
- Parameters:
aEscapeCodeFactory
- TheEscapeCodeFactory
to be used for determining ANSI escaping.
-
getHeaderEscapeCodeFactory
public EscapeCodeFactory getHeaderEscapeCodeFactory()
Gets the ANSI Escape-Code factory for the header. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
getHeaderEscapeCodeFactory
in interfaceColumnFormatMetrics
- Returns:
- The
EscapeCodeFactory
to be used for determining ANSI escaping.
-
toHeaderEscapeCode
public java.lang.String toHeaderEscapeCode(java.lang.Object aIdentifier)
Determines the ANSI Escape-Code by evaluating the provided ID: If anEscapeCodeFactory
has been set viaColumnFormatMetrics.setEscapeCodeFactory(EscapeCodeFactory)
and the factory returns a value different to null, then this value is returned. Else the value returned byColumnFormatMetrics.getHeaderEscapeCode()
is returned as fallback.- Specified by:
toHeaderEscapeCode
in interfaceColumnFormatMetrics
- Parameters:
aIdentifier
- The ID for which to lookup an Escape-Code.- Returns:
- The identified Escape-Code or null if none was identifiable.
-
setRowEscapeCodeFactory
public void setRowEscapeCodeFactory(EscapeCodeFactory aEscapeCodeFactory)
Sets an ANSI Escape-Code factory for the row. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
setRowEscapeCodeFactory
in interfaceColumnFormatMetrics
- Parameters:
aEscapeCodeFactory
- TheEscapeCodeFactory
to be used for determining ANSI escaping. configuration.
-
getRowEscapeCodeFactory
public EscapeCodeFactory getRowEscapeCodeFactory()
Gets the ANSI Escape-Code factory for the row. In case an ANSI Escape-Code is set, then the ANSI Escape-Code is prepended and an ANSI Reset-Code is appended to the according text being printed.- Specified by:
getRowEscapeCodeFactory
in interfaceColumnFormatMetrics
- Returns:
- The
EscapeCodeFactory
to be used for determining ANSI escaping.
-
toRowEscapeCode
public java.lang.String toRowEscapeCode(java.lang.Object aIdentifier)
Determines the ANSI Escape-Code by evaluating the provided ID: If anEscapeCodeFactory
has been set viaColumnFormatMetrics.setEscapeCodeFactory(EscapeCodeFactory)
and the factory returns a value different to null, then this value is returned. Else the value returned byColumnFormatMetrics.getRowEscapeCode()
is returned as fallback.- Specified by:
toRowEscapeCode
in interfaceColumnFormatMetrics
- Parameters:
aIdentifier
- The ID for which to lookup an Escape-Code.- Returns:
- The identified Escape-Code or null if none was identifiable.
-
-