Class BooleanFormat
java.lang.Object
com.aquima.interactions.foundation.text.BooleanFormat
- All Implemented Interfaces:
Serializable
BooleanFormat is a class which formats boolean's to string and can parse strings representations back into booleans.
A LeanNumberFormat uses a similar syntax like the java DecimalFormat class but with some exceptions. The syntax is
geared at number display only. Currency etc is not part of this specification.
A LeanNumberFormat pattern can be divided into 4 parts.
Syntax: true-spec;false-spec
true-spec A true-spec is a comma separated list of values representing true. For example: true,yes,1,ok is a true-spec that will create a boolean=true for all 4 values. While it will use true as a rendering out put. false-spec A false-spec is also comma separated list of values representing false with the first one defaulted as output.Examples
- true;false The default
- true,yes,ok,oui,si,1;false,no,cancel,non,no,0 An extended example.
- Since:
- 6.0
- Author:
- F. van der Meer
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBooleanFormat
(String pattern) Constructs a number format based on a pattern. -
Method Summary
-
Constructor Details
-
BooleanFormat
Constructs a number format based on a pattern. The pattern is parsed according to the specifications ofBooleanFormat
- Parameters:
pattern
- The pattern specifying the boolean pattern as described in the class header.- Throws:
PatternException
- When the pattern was invalid.
-
-
Method Details
-
parse
This method parses an input text and returns the boolean value. The complete text should be a boolean during parse. If the parse fails a ParseException is thrown.- Parameters:
text
- The text to parse, which should never be a null pointer or zero-length- Returns:
- The boolean value parsed for the text
- Throws:
ParseException
- When the text could not be parsed to a boolean
-
format
Formats an boolean to it's string representation. The returned value can be parsed into the a boolean by this class.- Parameters:
booleanValue
- the value which should be converted to a text representation.- Returns:
- The string representation of this boolean which should never be null
-