com.ibm.icu.text
Class DateTimePatternGenerator.FormatParser

java.lang.Object
  extended by com.ibm.icu.text.DateTimePatternGenerator.FormatParser
Enclosing class:
DateTimePatternGenerator

Deprecated. This API is ICU internal only.

public static class DateTimePatternGenerator.FormatParser
extends Object

This class provides mechanisms for parsing a SimpleDateFormat pattern or generating a new pattern, while handling the quoting. It represents the result of the parse as a list of items, where each item is either a literal string or a variable field. When parsing It can be used to find out which variable fields are in a date format, and in what order, such as for presentation in a UI as separate text entry fields. It can also be used to construct new SimpleDateFormats.

Example:

    public boolean containsZone(String pattern) {
        for (Iterator it = formatParser.set(pattern).getItems().iterator(); it.hasNext();) {
            Object item = it.next();
            if (item instanceof VariableField) {
                VariableField variableField = (VariableField) item;
                if (variableField.getType() == DateTimePatternGenerator.ZONE) {
                    return true;
                }
            }
        }
        return false;
    }
  

Status:
Internal. This API is ICU internal only.

Constructor Summary
DateTimePatternGenerator.FormatParser()
          Deprecated. This API is ICU internal only.
 
Method Summary
 List<Object> getItems()
          Deprecated. This API is ICU internal only.
 boolean hasDateAndTimeFields()
          Deprecated. This API is ICU internal only.
 Object quoteLiteral(String string)
          Deprecated. This API is ICU internal only.
 DateTimePatternGenerator.FormatParser set(String string)
          Deprecated. This API is ICU internal only.
 DateTimePatternGenerator.FormatParser set(String string, boolean strict)
          Deprecated. This API is ICU internal only.
 String toString()
          Deprecated. This API is ICU internal only.
 String toString(int start, int limit)
          Deprecated. This API is ICU internal only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateTimePatternGenerator.FormatParser

public DateTimePatternGenerator.FormatParser()
Deprecated. This API is ICU internal only.

Construct an empty date format parser, to which strings and variables can be added with set(...).

Status:
Internal. This API is ICU internal only.
Method Detail

set

public final DateTimePatternGenerator.FormatParser set(String string)
Deprecated. This API is ICU internal only.

Parses the string into a list of items.

Parameters:
string - The string to parse.
Returns:
this, for chaining
Status:
Internal. This API is ICU internal only.

set

public DateTimePatternGenerator.FormatParser set(String string,
                                                 boolean strict)
Deprecated. This API is ICU internal only.

Parses the string into a list of items, taking into account all of the quoting that may be going on.

Parameters:
string - The string to parse.
strict - If true, then only allows exactly those lengths specified by CLDR for variables. For example, "hh:mm aa" would throw an exception.
Returns:
this, for chaining
Status:
Internal. This API is ICU internal only.

getItems

public List<Object> getItems()
Deprecated. This API is ICU internal only.

Returns modifiable list which is a mixture of Strings and VariableFields, in the order found during parsing. The strings represent literals, and have all quoting removed. Thus the string "dd 'de' MM" will parse into three items:
 VariableField: dd
 String: " de "
 VariableField: MM
 
The list is modifiable, so you can add any strings or variables to it, or remove any items.

Returns:
modifiable list of items.
Status:
Internal. This API is ICU internal only.

toString

public String toString()
Deprecated. This API is ICU internal only.

Provide display form of formatted input. Each literal string is quoted if necessary.. That is, if the input was "hh':'mm", the result would be "hh:mm", since the ":" doesn't need quoting. See quoteLiteral().

Overrides:
toString in class Object
Returns:
printable output string
Status:
Internal. This API is ICU internal only.

toString

public String toString(int start,
                       int limit)
Deprecated. This API is ICU internal only.

Provide display form of a segment of the parsed input. Each literal string is minimally quoted. That is, if the input was "hh':'mm", the result would be "hh:mm", since the ":" doesn't need quoting. See quoteLiteral().

Parameters:
start - item to start from
limit - last item +1
Returns:
printable output string
Status:
Internal. This API is ICU internal only.

hasDateAndTimeFields

public boolean hasDateAndTimeFields()
Deprecated. This API is ICU internal only.

Returns true if it has a mixture of date and time variable fields: that is, at least one date variable and at least one time variable.

Returns:
true or false
Status:
Internal. This API is ICU internal only.

quoteLiteral

public Object quoteLiteral(String string)
Deprecated. This API is ICU internal only.

Each literal string is quoted as needed. That is, the ' quote marks will only be added if needed. The exact pattern of quoting is not guaranteed, thus " de la " could be quoted as " 'de la' " or as " 'de' 'la' ".

Parameters:
string - The string to check.
Returns:
string with quoted literals
Status:
Internal. This API is ICU internal only.


Copyright (c) 2011 IBM Corporation and others.