- java.lang.Object
-
- org.refcodes.textual.TextBorderBuilder
-
- All Implemented Interfaces:
org.refcodes.graphical.BoxBorderModeAccessor
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeMutator
,org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
,Text<TextBorderBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<TextBorderBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
,TextBoxGridAccessor
,TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
,TextBoxGridAccessor.TextBoxGridMutator
,TextBoxGridAccessor.TextBoxGridProperty
public class TextBorderBuilder extends Object implements Text<TextBorderBuilder>, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty, org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeBuilder<TextBorderBuilder>, TextBoxGridAccessor.TextBoxGridProperty, TextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
"Draws" a border around a text. The text border can be provided by adjusting properties such as theTableStyle
or theBoxBorderMode
. When providing aTableStyle
, then theTableStyle.getBody()
characters are used to draw the border.
-
-
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.TextAccessor
TextAccessor.TextBuilder<B extends TextAccessor.TextBuilder<B>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider
-
Nested classes/interfaces inherited from interface org.refcodes.textual.TextBoxGridAccessor
TextBoxGridAccessor.TextBoxGridBuilder<B extends TextBoxGridAccessor.TextBoxGridBuilder<?>>, TextBoxGridAccessor.TextBoxGridMutator, TextBoxGridAccessor.TextBoxGridProperty
-
-
Constructor Summary
Constructors Constructor Description TextBorderBuilder()
-
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()
String[]
getText()
Retrieves the text from the text property.TextBoxGrid
getTextBoxGrid()
Gets the currently setTextBoxGrid
being used.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
setText(String... aText)
Sets the text for the text property.void
setTextBoxGrid(TextBoxGrid aTextBoxGrid)
Sets theTextBoxGrid
to be used.void
setTextBoxStyle(TextBoxStyle aTextBoxStyle)
protected static String[]
toAsciiBorder(String[] aText)
Adds a predefined "single-line" border to the provided text.protected static String[]
toBorder(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.static String[]
toBorder(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 String[]
toBottomBorder(String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.protected static String[]
toDoubleBorder(String[] aText)
Adds a predefined "double-line" border to the provided text.protected static String[]
toLeftBorder(String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided witdh to the provided text.protected static String
toLine(int aLength, char aFillChar)
Returns aString
with the given length and containing only the provided fill character.protected static String[]
toRightBorder(String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.protected static String[]
toSingleBorder(String[] aText)
Adds a predefined "single-line" border to the provided text.String
toString()
TheString
being build by the builder upon the settings of the attributes.String
toString(String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
toStrings()
TheString
s being build by the builder upon the settings of the attributes.String[]
toStrings(String... aText)
Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toStrings()
.protected static String[]
toTopBorder(String[] aText, int aBorderWidth, char aBorderChar)
Adds the according border with the given char and the provided width to the provided text.TextBorderBuilder
withBorderChar(char aBorderChar)
Sets the border char for the border char property.TextBorderBuilder
withBorderWidth(int aBorderWidth)
Sets the border width for the border width property.TextBorderBuilder
withBoxBorderMode(org.refcodes.graphical.BoxBorderMode aBoxBorderMode)
B
withText(String... aText)
With text.B
withText(Collection<String> aText)
With text.TextBorderBuilder
withTextBoxGrid(TextBoxGrid aTextBoxGrid)
Sets the rowsTextBoxGrid
to use returns this builder as of the Builder-Pattern.TextBorderBuilder
withTextBoxStyle(TextBoxStyle aTextBoxStyle)
Convenience method forwithTextBoxGrid(TextBoxGrid)
to set theTextBoxGrid
from aTextBoxStyle
value-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.graphical.BoxBorderModeAccessor.BoxBorderModeProperty
letBoxBorderMode
-
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.TextProperty
letText, letText
-
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProvider
toString
-
Methods inherited from interface org.refcodes.textual.TextBoxGridAccessor.TextBoxGridProperty
letTextBoxGrid
-
-
-
-
Method Detail
-
setTextBoxStyle
public void setTextBoxStyle(TextBoxStyle aTextBoxStyle)
- Parameters:
aTextBoxStyle
- TheTextBoxStyle
which'sTextBoxGrid
is to be set.
-
withTextBoxStyle
public TextBorderBuilder withTextBoxStyle(TextBoxStyle aTextBoxStyle)
Convenience method forwithTextBoxGrid(TextBoxGrid)
to set theTextBoxGrid
from aTextBoxStyle
value- Parameters:
aTextBoxStyle
- TheTextBoxStyle
which'sTextBoxGrid
is to be set.- Returns:
- This instance as of the builder pattern,
-
withBorderChar
public TextBorderBuilder withBorderChar(char aBorderChar)
Sets the border char for the border char property.- Parameters:
aBorderChar
- The border char to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
withBorderWidth
public TextBorderBuilder withBorderWidth(int aBorderWidth)
Sets the border width for the border width property.- Parameters:
aBorderWidth
- The border width to be stored by the text align mode property.- Returns:
- The builder for applying multiple build operations.
-
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>
-
getTextBoxGrid
public TextBoxGrid getTextBoxGrid()
Gets the currently setTextBoxGrid
being used.- Specified by:
getTextBoxGrid
in interfaceTextBoxGridAccessor
- Returns:
- The currently configured
TextBoxGrid
s.
-
setTextBoxGrid
public void setTextBoxGrid(TextBoxGrid aTextBoxGrid)
Sets theTextBoxGrid
to be used.- Specified by:
setTextBoxGrid
in interfaceTextBoxGridAccessor.TextBoxGridMutator
- Parameters:
aTextBoxGrid
- TheTextBoxGrid
to be stored by theTextBoxGrid
property.
-
withTextBoxGrid
public TextBorderBuilder withTextBoxGrid(TextBoxGrid aTextBoxGrid)
Sets the rowsTextBoxGrid
to use returns this builder as of the Builder-Pattern.- Specified by:
withTextBoxGrid
in interfaceTextBoxGridAccessor.TextBoxGridBuilder<TextBorderBuilder>
- Parameters:
aTextBoxGrid
- TheTextBoxGrid
to be used when printing a row or the header.- Returns:
- This
TextBoxGridAccessor.TextBoxGridBuilder
instance to continue configuration.
-
getBorderChar
public char getBorderChar()
Retrieves the border char from the border char property.- 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.- 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.- 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.- Parameters:
aBorderWidth
- The border width to be stored by the text align mode property.
-
toStrings
public String[] toStrings()
TheString
s being build by the builder upon the settings of the attributes.- Specified by:
toStrings
in interfaceTextAccessor.TextProvider
- Returns:
- The according resulting
String
array
-
toStrings
public String[] toStrings(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 String[] toLeftBorder(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 String[] toRightBorder(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 String[] toTopBorder(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 String[] toBottomBorder(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
public static String[] toBorder(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 String[] toBorder(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 String[] toSingleBorder(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 String[] toDoubleBorder(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 String[] toAsciiBorder(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 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 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(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(String... aText)
With text.
-
withText
public B withText(Collection<String> aText)
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
toString
public 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 classObject
- Returns:
- The according resulting
String
-
toString
public String toString(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!
-
-