Package org.refcodes.textual
Class EscapeTextBuilderImpl
- java.lang.Object
-
- org.refcodes.textual.EscapeTextBuilderImpl
-
- All Implemented Interfaces:
EscapeTextBuilder
,Text<EscapeTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<EscapeTextBuilder>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
public class EscapeTextBuilderImpl extends Object implements EscapeTextBuilder
The Class EscapeTextBuilderImpl.- Author:
- steiner
-
-
Nested Class Summary
-
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 EscapeTextBuilderImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EscapeTextBuilder
addEscapeProperty(String aKey, String aValue)
Adds the escape property.EscapeTextBuilder
addEscapeProperty(org.refcodes.structure.Property aProperty)
Adds the escape property.org.refcodes.structure.Property[]
getEscapeProperties()
Gets the escape properties.EscapeTextMode
getEscapeTextMode()
Retrieves the escape text mode from the escape text mode property.String[]
getText()
Retrieves the text from the text property.void
setEscapeProperties(org.refcodes.structure.Property... aProperties)
Sets the escape properties.void
setEscapeTextMode(EscapeTextMode aEscapeTextMode)
Sets the escape text mode for the escape text mode property.void
setText(String... aText)
Sets the text for the text property.protected String[]
toEscaped(String[] aText, List<org.refcodes.structure.Property> aProperties, EscapeTextMode aEscapeTextMode)
To escaped.static String
toEscaped(String aUnEscaped, String[][] aEscapeMatrix)
Escapes a text using the provided escape matrix which must be a two dimensional array with two elements per line and where the element at position 0 (of a line) represents the character and the element at position 1 (of a line) the escaped character.protected String
toEscaped(String aText, List<org.refcodes.structure.Property> aProperties, EscapeTextMode aEscapeTextMode)
To escaped.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 escaped 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()
.static String
toUnEscaped(String aEscaped, String[][] aEscapeMatrix)
Unescapes a text using the provided escape matrix which must be a two dimensional array with two elements per line and where the element at position 0 (of a line) represents the character and the element at position 1 (of a line) the escaped character.B
withText(String... aText)
With text.B
withText(Collection<String> aText)
With text.-
Methods inherited from interface org.refcodes.textual.EscapeTextBuilder
build, toString, withEscapeProperties, withEscapeTextMode
-
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
-
-
-
-
Method Detail
-
getEscapeTextMode
public EscapeTextMode getEscapeTextMode()
Retrieves the escape text mode from the escape text mode property.- Specified by:
getEscapeTextMode
in interfaceEscapeTextBuilder
- Returns:
- The escape text mode stored by the escape text mode property.
-
setEscapeTextMode
public void setEscapeTextMode(EscapeTextMode aEscapeTextMode)
Sets the escape text mode for the escape text mode property.- Specified by:
setEscapeTextMode
in interfaceEscapeTextBuilder
- Parameters:
aEscapeTextMode
- The escape text mode to be stored by the align text mode property.
-
getEscapeProperties
public org.refcodes.structure.Property[] getEscapeProperties()
Gets the escape properties.- Specified by:
getEscapeProperties
in interfaceEscapeTextBuilder
- Returns:
- the escape properties
-
setEscapeProperties
public void setEscapeProperties(org.refcodes.structure.Property... aProperties)
Sets the escape properties.- Specified by:
setEscapeProperties
in interfaceEscapeTextBuilder
- Parameters:
aProperties
- the new escape properties
-
addEscapeProperty
public EscapeTextBuilder addEscapeProperty(org.refcodes.structure.Property aProperty)
Adds the escape property.- Specified by:
addEscapeProperty
in interfaceEscapeTextBuilder
- Parameters:
aProperty
- the property- Returns:
- the escape text builder
-
addEscapeProperty
public EscapeTextBuilder addEscapeProperty(String aKey, String aValue)
Adds the escape property.- Specified by:
addEscapeProperty
in interfaceEscapeTextBuilder
- Parameters:
aKey
- the keyaValue
- the value- Returns:
- the escape text builder
-
toStrings
public String[] toStrings() throws IllegalStateException
TheString
s being escaped by the builder upon the settings of the attributes.- Specified by:
toStrings
in interfaceEscapeTextBuilder
- Specified by:
toStrings
in interfaceTextAccessor.TextProvider
- Returns:
- The according resulting
String
array - Throws:
IllegalStateException
-
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<EscapeTextBuilder>
- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
toEscaped
protected String[] toEscaped(String[] aText, List<org.refcodes.structure.Property> aProperties, EscapeTextMode aEscapeTextMode)
To escaped.- Parameters:
aText
- the textaProperties
- the propertiesaEscapeTextMode
- the escape text mode- Returns:
- the string[]
-
toEscaped
protected String toEscaped(String aText, List<org.refcodes.structure.Property> aProperties, EscapeTextMode aEscapeTextMode)
To escaped.- Parameters:
aText
- the textaProperties
- the propertiesaEscapeTextMode
- the escape text mode- Returns:
- the string
-
toEscaped
public static String toEscaped(String aUnEscaped, String[][] aEscapeMatrix)
Escapes a text using the provided escape matrix which must be a two dimensional array with two elements per line and where the element at position 0 (of a line) represents the character and the element at position 1 (of a line) the escaped character.- Parameters:
aUnEscaped
- The text to be escaped.aEscapeMatrix
- The matrix to be used for escaping.- Returns:
- The escape text as of the escape matrix.
-
toUnEscaped
public static String toUnEscaped(String aEscaped, String[][] aEscapeMatrix)
Unescapes a text using the provided escape matrix which must be a two dimensional array with two elements per line and where the element at position 0 (of a line) represents the character and the element at position 1 (of a line) the escaped character.- Parameters:
aEscaped
- The text to be unescaped.aEscapeMatrix
- The matrix to be used for unescaping.- Returns:
- The unescape text as of the escape matrix.
-
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!
-
-