Package org.refcodes.textual
Class TextBorderBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.TextBorderBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.graphical.BoxBorderModeAccessor
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
,TableStyleAccessor
,TableStyleAccessor.TableStyleBuilder<TextBorderBuilder>
,TableStyleAccessor.TableStyleMutator
,TableStyleAccessor.TableStyleProperty
,Text<TextBorderBuilder>
,TextAccessor
,TextAccessor.TextBuilder<TextBorderBuilder>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
,TextBorderBuilder
public class TextBorderBuilderImpl extends java.lang.Object implements TextBorderBuilder
The Class TextBorderBuilderImpl.- Author:
- steiner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.BoxBorderModeAccessor
org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<B extends org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<B>>, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
-
Nested classes/interfaces inherited from interface org.refcodes.textual.TableStyleAccessor
TableStyleAccessor.TableStyleBuilder<B extends TableStyleAccessor.TableStyleBuilder<?>>, TableStyleAccessor.TableStyleMutator, TableStyleAccessor.TableStyleProperty
-
Nested classes/interfaces inherited from interface org.refcodes.textual.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
-
-
Constructor Summary
Constructors Constructor Description TextBorderBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description char
getBorderChar()
Retrieves the border char from the border char property.int
getBorderWidth()
Retrieves the border width from the border width property.org.refcodes.graphical.BoxBorderMode
getBoxBorderMode()
TableStyle
getTableStyle()
Gets the currently setTableStyle
being used.java.lang.String[]
getText()
Retrieves the text from the text property.void
setBorderChar(char aBorderChar)
Sets the border char for the border char property.void
setBorderWidth(int aBorderWidth)
Sets the border width for the border width property.void
setBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
void
setTableStyle(TableStyle aTableStyle)
Sets theTableStyle
to be used.void
setText(java.lang.String... aText)
Sets the text for the text property.protected static java.lang.String[]
toAsciiBorder(java.lang.String[] aText)
Adds a predefined "single-line" border to the provided text.protected static java.lang.String[]
toBorder(java.lang.String[] aText, char aTopLeftBorderChar, char aTopRightBorderChar, char aBottomLeftBorderChar, char aBottomRightBorderChar, char aTopBorderChar, char aRightBorderChar, char aBottomBorderChar, char aLeftBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
Adds a predefined border according border to the provided text.protected static java.lang.String[]
toBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
Adds the according border with the given char and the provided width to the provided text.protected static java.lang.String[]
toBottomBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.protected static java.lang.String[]
toDoubleBorder(java.lang.String[] aText)
Adds a predefined "double-line" border to the provided text.protected static java.lang.String[]
toLeftBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided witdh to the provided text.protected static java.lang.String
toLine(int aLength, char aFillChar)
Returns aString
with the given length and containing only the provided fill character.protected static java.lang.String[]
toRightBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.protected static java.lang.String[]
toSingleBorder(java.lang.String[] aText)
Adds a predefined "single-line" border to the provided text.java.lang.String
toString()
TheString
being build by the builder upon the settings of the attributes.java.lang.String
toString(java.lang.String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.java.lang.String[]
toStrings()
TheString
s being build by the builder upon the settings of the attributes.java.lang.String[]
toStrings(java.lang.String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.protected static java.lang.String[]
toTopBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.TextBorderBuilder
withBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
TextBorderBuilder
withTableStyle(TableStyle aTableStyle)
Sets the rowsTableStyle
to use returns this builder as of the Builder-Pattern.B
withText(java.lang.String... aText)
With text.B
withText(java.util.Collection<java.lang.String> aText)
With text.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.textual.TextAccessor
getText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextBuilder
withText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextMutator
setText, setText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProvider
toString
-
Methods inherited from interface org.refcodes.textual.TextBorderBuilder
withBorderChar, withBorderWidth
-
-
-
-
Method Detail
-
getBoxBorderMode
public org.refcodes.graphical.BoxBorderMode getBoxBorderMode()
- Specified by:
getBoxBorderMode
in interfaceorg.refcodes.graphical.BoxBorderModeAccessor
-
setBoxBorderMode
public void setBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
- Specified by:
setBoxBorderMode
in interfaceorg.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator
-
withBoxBorderMode
public TextBorderBuilder withBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
- Specified by:
withBoxBorderMode
in interfaceorg.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>
-
getTableStyle
public TableStyle getTableStyle()
Gets the currently setTableStyle
being used.- Specified by:
getTableStyle
in interfaceTableStyleAccessor
- Returns:
- The currently configured
TableStyle
s.
-
setTableStyle
public void setTableStyle(TableStyle aTableStyle)
Sets theTableStyle
to be used.- Specified by:
setTableStyle
in interfaceTableStyleAccessor.TableStyleMutator
- Parameters:
aTableStyle
- TheTableStyle
to be stored by theTableStyle
property.
-
withTableStyle
public TextBorderBuilder withTableStyle(TableStyle aTableStyle)
Sets the rowsTableStyle
to use returns this builder as of the Builder-Pattern.- Specified by:
withTableStyle
in interfaceTableStyleAccessor.TableStyleBuilder<TextBorderBuilder>
- Parameters:
aTableStyle
- TheTableStyle
to be used when printing a row or the header.- Returns:
- This
TableBuilder
instance to continue configuration.
-
getBorderChar
public char getBorderChar()
Retrieves the border char from the border char property.- Specified by:
getBorderChar
in interfaceTextBorderBuilder
- Returns:
- The border char stored by the border char property.
-
setBorderChar
public void setBorderChar(char aBorderChar)
Sets the border char for the border char property.- Specified by:
setBorderChar
in interfaceTextBorderBuilder
- Parameters:
aBorderChar
- The border char to be stored by the text align mode property.
-
getBorderWidth
public int getBorderWidth()
Retrieves the border width from the border width property.- Specified by:
getBorderWidth
in interfaceTextBorderBuilder
- Returns:
- The border width stored by the border width property.
-
setBorderWidth
public void setBorderWidth(int aBorderWidth)
Sets the border width for the border width property.- Specified by:
setBorderWidth
in interfaceTextBorderBuilder
- Parameters:
aBorderWidth
- The border width to be stored by the text align mode property.
-
toStrings
public java.lang.String[] toStrings()
TheString
s being build by the builder upon the settings of the attributes.- Specified by:
toStrings
in interfaceTextAccessor.TextProvider
- Specified by:
toStrings
in interfaceTextBorderBuilder
- Returns:
- The according resulting
String
array
-
toStrings
public java.lang.String[] toStrings(java.lang.String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
(do not change the text property) as this would not be thread safe!- Specified by:
toStrings
in interfaceText<TextBorderBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toLeftBorder
protected static java.lang.String[] toLeftBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided witdh to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toRightBorder
protected static java.lang.String[] toRightBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toTopBorder
protected static java.lang.String[] toTopBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toBottomBorder
protected static java.lang.String[] toBottomBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.- Returns:
- The text with the according border being applied.
-
toBorder
protected static java.lang.String[] toBorder(java.lang.String[] aText, int aBorderWidth, char aBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
Adds the according border with the given char and the provided width to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aBorderWidth
- The width of the border to be drawn.aBorderChar
- The character of the border to be drawn.aBoxBorderMode
- the box border mode- Returns:
- The text with the according border being applied.
-
toBorder
protected static java.lang.String[] toBorder(java.lang.String[] aText, char aTopLeftBorderChar, char aTopRightBorderChar, char aBottomLeftBorderChar, char aBottomRightBorderChar, char aTopBorderChar, char aRightBorderChar, char aBottomBorderChar, char aLeftBorderChar, org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
Adds a predefined border according border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.aTopLeftBorderChar
- The top left border's character.aTopRightBorderChar
- The top right border's character.aBottomLeftBorderChar
- The bottom left border's character.aBottomRightBorderChar
- The bottom right border's character.aTopBorderChar
- the top border charaRightBorderChar
- the right border charaBottomBorderChar
- the bottom border charaLeftBorderChar
- the left border charaBoxBorderMode
- the box border mode- Returns:
- The text with the according border being applied.
-
toSingleBorder
protected static java.lang.String[] toSingleBorder(java.lang.String[] aText)
Adds a predefined "single-line" border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.- Returns:
- The text with the according border being applied.
-
toDoubleBorder
protected static java.lang.String[] toDoubleBorder(java.lang.String[] aText)
Adds a predefined "double-line" border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.- Returns:
- The text with the according border being applied.
-
toAsciiBorder
protected static java.lang.String[] toAsciiBorder(java.lang.String[] aText)
Adds a predefined "single-line" border to the provided text.- Parameters:
aText
- The text to which the border is to be applied.- Returns:
- The text with the according border being applied.
-
toLine
protected static java.lang.String toLine(int aLength, char aFillChar)
Returns aString
with the given length and containing only the provided fill character.- Parameters:
aLength
- The length to be reached.aFillChar
- The char to be used for filling up- Returns:
- The
String
filled with the fill character till the provided length.
-
getText
public java.lang.String[] getText()
Retrieves the text from the text property.- Specified by:
getText
in interfaceTextAccessor
- Returns:
- The text stored by the text property.
-
setText
public void setText(java.lang.String... aText)
Sets the text for the text property.- Specified by:
setText
in interfaceTextAccessor.TextMutator
- Parameters:
aText
- The text to be stored by the text property.
-
withText
public B withText(java.lang.String... aText)
With text.
-
withText
public B withText(java.util.Collection<java.lang.String> aText)
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
public java.lang.String toString()
TheString
being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).- Specified by:
toString
in interfaceTextAccessor.TextProvider
- Overrides:
toString
in classjava.lang.Object
- Returns:
- The according resulting
String
-
toString
public java.lang.String toString(java.lang.String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
. Implementation requirements: This method must not(!) be implemented by callingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
(do not change the text property) as this would not be thread safe!
-
-