Contents:
CharacterIterator
ChoiceFormat
CollationElementIterator
CollationKey
Collator
DateFormat
DateFormatSymbols
DecimalFormat
DecimalFormatSymbols
FieldPosition
Format
MessageFormat
NumberFormat
ParseException
ParsePosition
RuleBasedCollator
SimpleDateFormat
StringCharacterIterator
The package java.text is new as of Java 1.1. It contains classes that support the internationalization of Java programs. The internationalization classes can be grouped as follows:
Many of the classes in java.text rely upon a java.util.Locale object to provide information about the locale that is in use.
The Format class is the superclass of all of the classes that generate and parse string representations of various types of data. The DateFormat class formats and parses dates and times according to the customs and language of a particular locale. Similarly, the NumberFormat class formats and parses numbers, including currency values, in a locale-dependent manner.
The MessageFormat class can create a textual message from a pattern string, while ChoiceFormat maps numerical ranges to strings. By themselves, these classes do not provide different results for different locales. However, they can be used in conjunction with java.util.ResourceBundle objects that generate locale-specific pattern strings.
The Collator class handles collating strings according to the rules of a particular locale. Different languages have different characters and different rules for sorting those characters; Collator and its subclass, RuleBasedCollator, are designed to take those differences into account when collating strings. In addition, the CollationKey class can be used to optimize the sorting of a large collection of strings.
The BreakIterator class finds various boundaries, such as word boundaries and line boundaries, in textual data. Again, BreakIterator locates these boundaries according to the rules of a particular locale.
Figure 16.1 shows the class hierarchy for the java.text package.
java.text.BreakIterator
java.lang.Object
None
java.lang.Cloneable, java.io.Serializable
New as of JDK 1.1
The BreakIterator class is an abstract class that defines methods that find the locations of boundaries in text, such as word boundaries and sentence boundaries. A BreakIterator operates on the object passed to its setText() method; that object must implement the CharacterIterator interface or be a String object. When a String is passed to setText(), the BreakIterator creates an internal StringCharacterIterator to iterate over the String.
When you use a BreakIterator, you call first() to get the location of the first boundary and then repeatedly call next() to iterate through the subsequent boundaries.
The BreakIterator class defines four static factory methods that return instances of BreakIterator that locate various kinds of boundaries. Each of these factory methods selects a concrete subclass of BreakIterator based either on the default locale or a specified locale. You must create a separate instance of BreakIterator to handle each kind of boundary you are trying to locate:
public abstract class java.util.BreakIterator extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable { // Constants public final static int DONE; // Constructors protected BreakIterator(); // Class Methods public static synchronized Locale[] getAvailableLocales(); public static BreakIterator getCharacterInstance(); public static BreakIterator getCharacterInstance(Locale where); public static BreakIterator getLineInstance(); public static BreakIterator getLineInstance(Locale where); public static BreakIterator getSentenceInstance(); public static BreakIterator getSentenceInstance(Locale where); public static BreakIterator getWordInstance(); public static BreakIterator getWordInstance(Locale where); // Instance Methods public Object clone(); public abstract int current(); public abstract int first(); public abstract int following(int offset); public abstract CharacterIterator getText(); public abstract int last(); public abstract int next(); public abstract int next(int n) public abstract int previous(); public abstract void setText(CharacterIterator newText); public void setText(String newText); }
A constant that is returned by next() or previous() if there are no more breaks to be returned.
This constructor should be called only from constructors of subclasses.
An array of Locale objects.
This method returns an array of the Locale objects that can be passed to getCharacterInstance(), getLineInstance(), getSentenceInstance(), or getWordInstance().
A BreakIterator appropriate for the default Locale.
This method creates a BreakIterator that can locate character boundaries in the default Locale.
The Locale to use.
A BreakIterator appropriate for the given Locale.
This method creates a BreakIterator that can locate character boundaries in the given Locale.
A BreakIterator appropriate for the default Locale.
This method creates a BreakIterator that can locate line boundaries in the default Locale.
The Locale to use.
A BreakIterator appropriate for the given Locale.
This method creates a BreakIterator that can locate line boundaries in the given Locale.
A BreakIterator appropriate for the default Locale.
This method creates a BreakIterator that can locate sentence boundaries in the default Locale.
The Locale to use.
A BreakIterator appropriate for the given Locale.
This method creates a BreakIterator that can locate sentence boundaries in the given Locale.
A BreakIterator appropriate for the default Locale.
This method creates a BreakIterator that can locate word boundaries in the default Locale.
The Locale to use.
A BreakIterator appropriate for the given Locale.
This method creates a BreakIterator that can locate word boundaries in the given Locale.
A copy of this BreakIterator.
Object.clone()
This method creates a copy of this BreakIterator and then returns it.
The current position of this BreakIterator.
This method returns the current position of this BreakIterator. The current position is the character index of the most recently returned boundary.
The position of the first boundary of this BreakIterator.
This method finds the first boundary in this BreakIterator and returns its character index. The current position of the iterator is set to this boundary.
An offset into this BreakIterator.
The position of the first boundary after the given offset of this BreakIterator or DONE if there are no more boundaries.
If offset is not a valid value for the CharacterIterator of this BreakIterator.
This method finds the first boundary after the given offset in this BreakIterator and returns its character index.
The CharacterIterator that this BreakIterator uses.
This method returns a CharacterIterator that represents the text this BreakIterator examines.
The position of the last boundary of this BreakIterator.
This method finds the last boundary in this BreakIterator and returns its character index. The current position of the iterator is set to this boundary.
The position of the next boundary of this BreakIterator or DONE if there are no more boundaries.
This method finds the next boundary in this BreakIterator after the current position and returns its character index. The current position of the iterator is set to this boundary.
The boundary to return. A positive value moves to a later boundary a negative value moves to a previous boundary; the value 0 does nothing.
The position of the requested boundary of this BreakIterator.
This method finds the nth boundary in this BreakIterator, starting from the current position, and returns its character index. The current position of the iterator is set to this boundary.
For example, next(-2) finds the third previous boundary. Thus next(1) is equivalent to next(), next(-1) is equivalent to previous(), and next(0) does nothing.
The position of the previous boundary of this BreakIterator.
This method finds the previous boundary in this BreakIterator, starting from the current position, and returns its character index. The current position of the iterator is set to this boundary.
The CharacterIterator that contains the text to be examined.
This method tells this BreakIterator to examine the piece of text specified by the CharacterIterator. This current position of this BreakIterator is set to first().
The String that contains the text to be examined.
This method tells this BreakIterator to examine the piece of text specified by the String, using a StringCharacterIterator created from the given string. This current position of this BreakIterator is set to first().
Method | Inherited From | Method | Inherited From |
---|---|---|---|
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
CharacterIterator, Locale, String, StringCharacterIterator
This HTML Help has been published using the chm2web software. |