java.lang.Object
org.refcodes.textual.EscapeTextBuilder
- All Implemented Interfaces:
Text<EscapeTextBuilder>
,TextAccessor
,TextAccessor.TextBuilder<Text<EscapeTextBuilder>>
,TextAccessor.TextMutator
,TextAccessor.TextProperty
,TextAccessor.TextProvider
The
EscapeTextBuilder
provides means to "escape" and "unescape" text,
e.g. simple marshaling and unmarshaling.-
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
-
Method Summary
Modifier and TypeMethodDescriptionaddEscapeProperty
(String aKey, String aValue) Adds the escape property.addEscapeProperty
(org.refcodes.struct.Property aProperty) Adds the escape property.static String
Default text escape implementation used by theEscapeTextBuilder
in case no escapeProperty
matrix has been supplied.static String
asUnEscaped
(String aEscapedText) Default text un-escape implementation used by theEscapeTextBuilder
in case no escapeProperty
matrix has been supplied.org.refcodes.struct.Property[]
Gets the escape properties.Retrieves the escape text mode from the escape text mode property.String[]
getText()
Retrieves the text from the text property.void
setEscapeProperties
(org.refcodes.struct.Property... aProperties) Sets the escape properties.void
setEscapeTextMode
(EscapeTextMode aEscapeTextMode) Sets the escape text mode for the escape text mode property.void
Sets the text for the text property.protected String[]
toEscaped
(String[] aText, List<org.refcodes.struct.Property> aProperties, EscapeTextMode aEscapeTextMode) To escaped.static String
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.struct.Property> aProperties, EscapeTextMode aEscapeTextMode) To escaped.protected static String
toEscapedRegexp
(char aDelimiter) To escaped regexp.protected static String
toRegExEscaped
(String aText) To reg ex escaped.toString()
TheString
being build by the builder upon the settings of the attributes.Race condition safe shortcut for usingText.withText(String...)
followed byTextAccessor.TextProvider.toString()
.String[]
TheString
s being build by the builder upon the settings of the attributes.String[]
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.withEscapeProperties
(org.refcodes.struct.Property... aProperties) With escape properties.withEscapeTextMode
(EscapeTextMode aEscapeTextMode) Sets the escape text mode for the escape text mode property.With text.withText
(Collection<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.TextMutator
setText
Methods inherited from interface org.refcodes.textual.TextAccessor.TextProperty
letText, letText
-
Constructor Details
-
EscapeTextBuilder
public EscapeTextBuilder()
-
-
Method Details
-
getEscapeTextMode
Retrieves the escape text mode from the escape text mode property.- Returns:
- The escape text mode stored by the escape text mode property.
-
setEscapeTextMode
Sets the escape text mode for the escape text mode property.- Parameters:
aEscapeTextMode
- The escape text mode to be stored by the align text mode property.
-
getEscapeProperties
public org.refcodes.struct.Property[] getEscapeProperties()Gets the escape properties.- Returns:
- the escape properties
-
setEscapeProperties
public void setEscapeProperties(org.refcodes.struct.Property... aProperties) Sets the escape properties.- Parameters:
aProperties
- the new escape properties
-
addEscapeProperty
Adds the escape property.- Parameters:
aProperty
- the property- Returns:
- the escape text builder
-
addEscapeProperty
Adds the escape property.- Parameters:
aKey
- the keyaValue
- the value- Returns:
- the escape text builder
-
toStrings
TheString
s being build by the builder upon the settings of the attributes.- Returns:
- The according resulting
String
array
-
toStrings
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!- Parameters:
aText
- The text to be processed.- Returns:
- The according resulting
String
array
-
withEscapeTextMode
Sets the escape text mode for the escape text mode property.- Parameters:
aEscapeTextMode
- The escape text mode to be stored by the align text mode property.- Returns:
- The builder for applying multiple build operations.
-
withEscapeProperties
With escape properties.- Parameters:
aProperties
- the properties- Returns:
- the escape text builder
-
toEscaped
protected String[] toEscaped(String[] aText, List<org.refcodes.struct.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.struct.Property> aProperties, EscapeTextMode aEscapeTextMode) To escaped.- Parameters:
aText
- the textaProperties
- the propertiesaEscapeTextMode
- the escape text mode- Returns:
- the string
-
toEscaped
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
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.
-
asEscaped
Default text escape implementation used by theEscapeTextBuilder
in case no escapeProperty
matrix has been supplied.- Parameters:
aUnEscapedText
- The text to be escaped.- Returns:
- The escaped text.
-
asUnEscaped
Default text un-escape implementation used by theEscapeTextBuilder
in case no escapeProperty
matrix has been supplied.- Parameters:
aEscapedText
- The text to be un-escaped.- Returns:
- The un-escaped text.
-
toEscapedRegexp
To escaped regexp.- Parameters:
aDelimiter
- the delimiter- Returns:
- the string
-
toRegExEscaped
To reg ex escaped.- Parameters:
aText
- the text- Returns:
- the string
-
getText
Retrieves the text from the text property.- Specified by:
getText
in interfaceTextAccessor
- Returns:
- The text stored by the text property.
-
setText
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
With text. -
withText
With text.- Specified by:
withText
in interfaceTextAccessor.TextBuilder<B extends Text<B>>
- Parameters:
aText
- the text- Returns:
- the b
-
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
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!
-