Class BooleanFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class BooleanFormat
    extends java.text.Format
    Formatter for boolean numbers.

    The boolean formatter pattern consists of at least a pair of values separated by '|'. Several pairs can be specified separated by commas.

    When several pairs are specified, only the first one is used for output.

    An option "[strict]" can prefix the pattern MUST match either false or true. Default behavior is to return FALSE when not matching any of the pair values. When not in strict mode, the strings are all trimmed before comparing with case insensitive string compare.

    Author:
    Christopher Mindus
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.Format

        java.text.Format.Field
    • Constructor Summary

      Constructors 
      ConstructorDescription
      BooleanFormat​(java.lang.String pattern)
      Constructs the boolean formatter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      java.lang.StringBufferformat​(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
      Formats an object and appends the resulting text to a given string buffer.
      java.lang.ObjectparseObject​(java.lang.String source)
      Parses text from the beginning of the given string to produce an object.
      java.lang.ObjectparseObject​(java.lang.String source, java.text.ParsePosition pos)
      Parses text from a string to produce an object.
      • Methods inherited from class java.text.Format

        clone, format, formatToCharacterIterator
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BooleanFormat

        public BooleanFormat​(java.lang.String pattern)
                      throws java.lang.IllegalArgumentException
        Constructs the boolean formatter.
        Parameters:
        pattern - The pattern.
        Throws:
        java.lang.IllegalArgumentException - If the format is in error.
    • Method Detail

      • format

        public java.lang.StringBuffer format​(java.lang.Object obj,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition pos)
        Formats an object and appends the resulting text to a given string buffer.

        If the pos argument identifies a field used by the format, then its indices are set to the beginning and end of the first such field encountered.

        Specified by:
        format in class java.text.Format
        Parameters:
        obj - The object to format.
        toAppendTo - To where the text is to be appended
        pos - A FieldPosition identifying a field in the formatted text.
        Returns:
        The string buffer passed in as toAppendTo, with formatted text appended.
        Throws:
        java.lang.NullPointerException - if toAppendTo or pos is null.
        java.lang.IllegalArgumentException - if the Format cannot format the given object.
      • parseObject

        public java.lang.Object parseObject​(java.lang.String source,
                                            java.text.ParsePosition pos)
        Parses text from a string to produce an object.

        The method attempts to parse text starting at the index given by pos.

        If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed object is returned. The updated pos can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of pos is not changed, the error index of pos is set to the index of the character where the error occurred, and null is returned.

        Specified by:
        parseObject in class java.text.Format
        Parameters:
        source - A String, part of which should be parsed.
        pos - A ParsePosition object with index and error index information as described above.
        Returns:
        An Object parsed from the string. In case of error, returns null.
      • parseObject

        public java.lang.Object parseObject​(java.lang.String source)
                                     throws java.text.ParseException
        Parses text from the beginning of the given string to produce an object. The method may not use the entire text of the given string.
        Overrides:
        parseObject in class java.text.Format
        Parameters:
        source - A String whose beginning should be parsed.
        Returns:
        An Object parsed from the string.
        Throws:
        java.text.ParseException - if the beginning of the specified string cannot be parsed.