<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.text.BreakIterator
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.text.html">This Package</a>  <a href="Package-java.text.html">Previous</a>  <a href="java.text.ChoiceFormat.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.text.BreakIterator
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.text.BreakIterator
</pre>
<hr>
<dl>
  <dt> public abstract class <b>BreakIterator</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.lang.Cloneable.html#_top_">Cloneable</a>, <a href="java.io.Serializable.html#_top_">Serializable</a>
</dl>
The <code>BreakIterator</code> class implements methods for finding
 the location of boundaries in text. Instances of <code>BreakIterator</code>
 maintain a current position and scan over text
 returning the index of characters where boundaries occur.
 Internally, <code>BreakIterator</code> scans text using a
 <code>CharacterIterator</code>, and is thus able to scan text held
 by any object implementing that protocol. A <code>StringCharacterIterator</code>
 is used to scan <code>String</code> objects passed to <code>setText</code>.
 <p>
 You use the factory methods provided by this class to create
 instances of various types of break iterators. In particular,
 use <code>getWordIterator</code>, <code>getLineIterator</code>,
 <code>getSentenceIterator</code>, and <code>getCharacterIterator</code>
 to create <code>BreakIterator</code>s that perform
 word, line, sentence, and character boundary analysis respectively.
 A single <code>BreakIterator</code> can work only on one unit
 (word, line, sentence, and so on). You must use a different iterator
 for each unit boundary analysis you wish to perform.
 <p>
 Line boundary analysis determines where a text string can be
 broken when line-wrapping. The mechanism correctly handles
 punctuation and hyphenated words.
 <p>
 Sentence boundary analysis allows selection with correct interpretation
 of periods within numbers and abbreviations, and trailing punctuation
 marks such as quotation marks and parentheses.
 <p>
 Word boundary analysis is used by search and replace functions, as
 well as within text editing applications that allow the user to
 select words with a double click. Word selection provides correct
 interpretation of punctuation marks within and following
 words. Characters that are not part of a word, such as symbols
 or punctuation marks, have word-breaks on both sides.
 <p>
 Character boundary analysis allows users to interact with characters
 as they expect to, for example, when moving the cursor through a text
 string. Character boundary analysis provides correct navigation of
 through character strings, regardless of how the character is stored.
 For example, an accented character might be stored as a base character
 and a diacritical mark. What users consider to be a character can
 differ between languages.
 <p>
 <code>BreakIterator</code> is intended for use with natural
 languages only. Do not use this class to tokenize a programming language.
 <P>
 <strong>Examples</strong>:<P>
 Creating and using text boundaries
 <blockquote>
 <pre>
 public static void main(String args[]) {
      if (args.length == 1) {
          String stringToExamine = args[0];
          //print each word in order
          BreakIterator boundary = BreakIterator.getWordInstance();
          boundary.setText(stringToExamine);
          printEachForward(boundary, stringToExamine);
          //print each sentence in reverse order
          boundary = BreakIterator.getSentenceInstance(Locale.US);
          boundary.setText(stringToExamine);
          printEachBackward(boundary, stringToExamine);
          printFirst(boundary, stringToExamine);
          printLast(boundary, stringToExamine);
      }
 }
 </pre>
 </blockquote>
 Print each element in order
 <blockquote>
 <pre>
 public static void printEachForward(BreakIterator boundary, String source) {
     int start = boundary.first();
     for (int end = boundary.next();
          end != BreakIterator.DONE;
          start = end, end = boundary.next()) {
          System.out.println(source.substring(start,end));
     }
 }
 </pre>
 </blockquote>
 Print each element in reverse order
 <blockquote>
 <pre>
 public static void printEachBackward(BreakIterator boundary, String source) {
     int end = boundary.last();
     for (int start = boundary.previous();
          start != BreakIterator.DONE;
          end = start, start = boundary.previous()) {
         System.out.println(source.substring(start,end));
     }
 }
 </pre>
 </blockquote>
 Print first element
 <blockquote>
 <pre>
 public static void printFirst(BreakIterator boundary, String source) {
     int start = boundary.first();
     int end = boundary.next();
     System.out.println(source.substring(start,end));
 }
 </pre>
 </blockquote>
 Print last element
 <blockquote>
 <pre>
 public static void printLast(BreakIterator boundary, String source) {
     int end = boundary.last();
     int start = boundary.previous();
     System.out.println(source.substring(start,end));
 }
 </pre>
 </blockquote>
 Print the element at a specified position
 <blockquote>
 <pre>
 public static void printAt(BreakIterator boundary, int pos, String source) {
     int end = boundary.following(pos);
     int start = boundary.previous();
     System.out.println(source.substring(start,end));
 }
 </pre>
 </blockquote>
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.text.CharacterIterator.html#_top_">CharacterIterator</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
</h2>
<dl>
  <dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#DONE"><b>DONE</b></a>
  <dd>  DONE is returned by previous() and next() after all valid
 boundaries have been returned.
</dl>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#BreakIterator()"><b>BreakIterator</b></a>()
  <dd>  Constructor.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#clone()"><b>clone</b></a>()
  <dd>  Create a copy of this iterator
 
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#current()"><b>current</b></a>()
  <dd>  Return character index of the text boundary that was most recently
 returned by next(), previous(), first(), or last()
 
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#first()"><b>first</b></a>()
  <dd>  Return the first boundary.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#following(int)"><b>following</b></a>(int)
  <dd>  Return the first boundary following the specified offset.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getAvailableLocales()"><b>getAvailableLocales</b></a>()
  <dd>  Get the set of Locales for which BreakIterators are installed
 
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getCharacterInstance()"><b>getCharacterInstance</b></a>()
  <dd>  Create BreakIterator for character-breaks using default locale
 Returns an instance of a BreakIterator implementing character breaks.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getCharacterInstance(java.util.Locale)"><b>getCharacterInstance</b></a>(Locale)
  <dd>  Create BreakIterator for character-breaks using specified locale
 Returns an instance of a BreakIterator implementing character breaks.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLineInstance()"><b>getLineInstance</b></a>()
  <dd>  Create BreakIterator for line-breaks using default locale.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getLineInstance(java.util.Locale)"><b>getLineInstance</b></a>(Locale)
  <dd>  Create BreakIterator for line-breaks using specfied locale.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSentenceInstance()"><b>getSentenceInstance</b></a>()
  <dd>  Create BreakIterator for sentence-breaks using default locale
 Returns an instance of a BreakIterator implementing sentence breaks.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getSentenceInstance(java.util.Locale)"><b>getSentenceInstance</b></a>(Locale)
  <dd>  Create BreakIterator for sentence-breaks using specified locale
 Returns an instance of a BreakIterator implementing sentence breaks.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getText()"><b>getText</b></a>()
  <dd>  Get the text being scanned
 
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getWordInstance()"><b>getWordInstance</b></a>()
  <dd>  Create BreakIterator for word-breaks using default locale.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getWordInstance(java.util.Locale)"><b>getWordInstance</b></a>(Locale)
  <dd>  Create BreakIterator for word-breaks using specified locale.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#last()"><b>last</b></a>()
  <dd>  Return the last boundary.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#next()"><b>next</b></a>()
  <dd>  Return the boundary following the current boundary.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#next(int)"><b>next</b></a>(int)
  <dd>  Return the nth boundary from the current boundary
 
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#previous()"><b>previous</b></a>()
  <dd>  Return the boundary preceding the current boundary.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setText(java.text.CharacterIterator)"><b>setText</b></a>(CharacterIterator)
  <dd>  Set a new text for scanning.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setText(java.lang.String)"><b>setText</b></a>(String)
  <dd>  Set a new text string to be scanned.
</dl>
<a name="variables"></a>
<h2>
  <img src="images/variables.gif" width=153 height=38 alt="Variables">
</h2>
<a name="DONE"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
<b>DONE</b>
<pre>
 public static final int DONE
</pre>
<dl>
  <dd> DONE is returned by previous() and next() after all valid
 boundaries have been returned.<p>
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="BreakIterator"></a>
<a name="BreakIterator()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>BreakIterator</b>
<pre>
 protected BreakIterator()
</pre>
<dl>
  <dd> Constructor. BreakIterator is stateless and has no default behavior.
<p>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="clone()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="clone"><b>clone</b></a>
<pre>
 public <a href="java.lang.Object.html#_top_">Object</a> clone()
</pre>
<dl>
  <dd> Create a copy of this iterator
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> A copy of this
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#clone()">clone</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<a name="first()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="first"><b>first</b></a>
<pre>
 public abstract int first()
</pre>
<dl>
  <dd> Return the first boundary. The iterator's current position is set
 to the first boundary.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> The character index of the first text boundary.
  </dl></dd>
</dl>
<a name="last()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="last"><b>last</b></a>
<pre>
 public abstract int last()
</pre>
<dl>
  <dd> Return the last boundary. The iterator's current position is set
 to the last boundary.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> The character index of the last text boundary.
  </dl></dd>
</dl>
<a name="next(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="next"><b>next</b></a>
<pre>
 public abstract int next(int n)
</pre>
<dl>
  <dd> Return the nth boundary from the current boundary
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> n - which boundary to return.  A value of 0
 does nothing.  Negative values move to previous boundaries
 and positive values move to later boundaries.
    <dt> <b>Returns:</b>
    <dd> The index of the nth boundary from the current position.
  </dl></dd>
</dl>
<a name="next()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="next"><b>next</b></a>
<pre>
 public abstract int next()
</pre>
<dl>
  <dd> Return the boundary following the current boundary.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> The character index of the next text boundary or DONE if all
 boundaries have been returned.  Equivalent to next(1).
  </dl></dd>
</dl>
<a name="previous()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="previous"><b>previous</b></a>
<pre>
 public abstract int previous()
</pre>
<dl>
  <dd> Return the boundary preceding the current boundary.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> The character index of the previous text boundary or DONE if all
 boundaries have been returned.
  </dl></dd>
</dl>
<a name="following(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="following"><b>following</b></a>
<pre>
 public abstract int following(int offset)
</pre>
<dl>
  <dd> Return the first boundary following the specified offset.
 The value returned is always greater than the offset or
 the value BreakIterator.DONE
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> offset - the offset to begin scanning. Valid values
 are determined by the CharacterIterator passed to
 setText().  Invalid values cause
 an IllegalArgumentException to be thrown.
    <dt> <b>Returns:</b>
    <dd> The first boundary after the specified offset.
  </dl></dd>
</dl>
<a name="current()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="current"><b>current</b></a>
<pre>
 public abstract int current()
</pre>
<dl>
  <dd> Return character index of the text boundary that was most recently
 returned by next(), previous(), first(), or last()
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> The boundary most recently returned.
  </dl></dd>
</dl>
<a name="getText()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getText"><b>getText</b></a>
<pre>
 public abstract <a href="java.text.CharacterIterator.html#_top_">CharacterIterator</a> getText()
</pre>
<dl>
  <dd> Get the text being scanned
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the text being scanned
  </dl></dd>
</dl>
<a name="setText(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setText"><b>setText</b></a>
<pre>
 public void setText(<a href="java.lang.String.html#_top_">String</a> newText)
</pre>
<dl>
  <dd> Set a new text string to be scanned.  The current scan
 position is reset to first().
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> newText - new text to scan.
  </dl></dd>
</dl>
<a name="setText(java.text.CharacterIterator)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setText"><b>setText</b></a>
<pre>
 public abstract void setText(<a href="java.text.CharacterIterator.html#_top_">CharacterIterator</a> newText)
</pre>
<dl>
  <dd> Set a new text for scanning.  The current scan
 position is reset to first().
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> newText - new text to scan.
  </dl></dd>
</dl>
<a name="getWordInstance()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getWordInstance"><b>getWordInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getWordInstance()
</pre>
<dl>
  <dd> Create BreakIterator for word-breaks using default locale.
 Returns an instance of a BreakIterator implementing word breaks.
 WordBreak  is usefull for word selection (ex. double click)
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for word-breaks
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Locale.html#getDefault">getDefault</a>
  </dl></dd>
</dl>
<a name="getWordInstance(java.util.Locale)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getWordInstance"><b>getWordInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getWordInstance(<a href="java.util.Locale.html#_top_">Locale</a> where)
</pre>
<dl>
  <dd> Create BreakIterator for word-breaks using specified locale.
 Returns an instance of a BreakIterator implementing word breaks.
 WordBreak is usefull for word selection (ex. double click)
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> where - the local.  If a specific WordBreak is not
 avaliable for the specified locale, a default WordBreak is returned.
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for word-breaks
  </dl></dd>
</dl>
<a name="getLineInstance()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLineInstance"><b>getLineInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getLineInstance()
</pre>
<dl>
  <dd> Create BreakIterator for line-breaks using default locale.
 Returns an instance of a BreakIterator implementing line breaks. Line
 breaks are logically possible line breaks, actual line breaks are
 usually determined based on display width.
 LineBreak is useful for word wrapping text.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for line-breaks
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Locale.html#getDefault">getDefault</a>
  </dl></dd>
</dl>
<a name="getLineInstance(java.util.Locale)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getLineInstance"><b>getLineInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getLineInstance(<a href="java.util.Locale.html#_top_">Locale</a> where)
</pre>
<dl>
  <dd> Create BreakIterator for line-breaks using specfied locale.
 Returns an instance of a BreakIterator implementing line breaks. Line
 breaks are logically possible line breaks, actual line breaks are
 usually determined based on display width.
 LineBreak is useful for word wrapping text.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> where - the local.  If a specific LineBreak is not
 avaliable for the specified locale, a default LineBreak is returned.
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for line-breaks
  </dl></dd>
</dl>
<a name="getCharacterInstance()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getCharacterInstance"><b>getCharacterInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getCharacterInstance()
</pre>
<dl>
  <dd> Create BreakIterator for character-breaks using default locale
 Returns an instance of a BreakIterator implementing character breaks.
 Character breaks are boundaries of combining character sequences.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for character-breaks
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Locale.html#getDefault">getDefault</a>
  </dl></dd>
</dl>
<a name="getCharacterInstance(java.util.Locale)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getCharacterInstance"><b>getCharacterInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getCharacterInstance(<a href="java.util.Locale.html#_top_">Locale</a> where)
</pre>
<dl>
  <dd> Create BreakIterator for character-breaks using specified locale
 Returns an instance of a BreakIterator implementing character breaks.
 Character breaks are boundaries of combining character sequences.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> where - the local.  If a specific character break is not
 avaliable for the specified local, a default character break is returned.
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for character-breaks
  </dl></dd>
</dl>
<a name="getSentenceInstance()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSentenceInstance"><b>getSentenceInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getSentenceInstance()
</pre>
<dl>
  <dd> Create BreakIterator for sentence-breaks using default locale
 Returns an instance of a BreakIterator implementing sentence breaks.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for sentence-breaks
    <dt> <b>See Also:</b>
    <dd> <a href="java.util.Locale.html#getDefault">getDefault</a>
  </dl></dd>
</dl>
<a name="getSentenceInstance(java.util.Locale)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getSentenceInstance"><b>getSentenceInstance</b></a>
<pre>
 public static <a href="#_top_">BreakIterator</a> getSentenceInstance(<a href="java.util.Locale.html#_top_">Locale</a> where)
</pre>
<dl>
  <dd> Create BreakIterator for sentence-breaks using specified locale
 Returns an instance of a BreakIterator implementing sentence breaks.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> where - the local.  If a specific SentenceBreak is not
 avaliable for the specified local, a default SentenceBreak is returned.
    <dt> <b>Returns:</b>
    <dd> A BreakIterator for sentence-breaks
  </dl></dd>
</dl>
<a name="getAvailableLocales()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getAvailableLocales"><b>getAvailableLocales</b></a>
<pre>
 public static synchronized <a href="java.util.Locale.html#_top_">Locale</a>[] getAvailableLocales()
</pre>
<dl>
  <dd> Get the set of Locales for which BreakIterators are installed
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> available locales
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.text.html">This Package</a>  <a href="Package-java.text.html">Previous</a>  <a href="java.text.ChoiceFormat.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
