java.text
Class SimpleTextBoundary

java.lang.Object
  extended byjava.text.BreakIterator
      extended byjava.text.SimpleTextBoundary
All Implemented Interfaces:
Cloneable

final class SimpleTextBoundary
extends BreakIterator

SimpleTextBoundary is an implementation of the BreakIterator protocol. SimpleTextBoundary uses a state machine to compute breaks. There are currently several subclasses of SimpleTextBoundary that compute breaks for sentences, words, lines, and characters. They are accessable through static functions of SimpleTextBoundary.

See Also:
BreakIterator

Nested Class Summary
 
Nested classes inherited from class java.text.BreakIterator
 
Field Summary
private  TextBoundaryData data
           
private static char END_OF_STRING
           
private  int pos
           
private  CharacterIterator text
           
 
Fields inherited from class java.text.BreakIterator
DONE
 
Constructor Summary
protected SimpleTextBoundary(TextBoundaryData data)
          Create a SimpleTextBoundary using the specified tables.
 
Method Summary
 Object clone()
          Overrides Cloneable
 int current()
          Return the boundary last returned by previous or next
 boolean equals(Object obj)
          Compares the equality of two SimpleTextBoundary objects.
 int first()
          Return the first boundary.
 int following(int offset)
          Return the first boundary after the specified offset
 CharacterIterator getText()
          Get the text being scanned by the enumeration
 int hashCode()
          Compute a hashcode for this enumeration
 boolean isBoundary(int offset)
          Return true if the specified position is a boundary position.
 int last()
          Return the last boundary.
protected  int mappedChar(char c)
           
 int next()
          Return the next text boundary
 int next(int increment)
          Return the nth boundary from the current boundary
private  int nextPosition(int offset)
           
 int preceding(int offset)
          Return the last boundary preceding the specified offset
 int previous()
          Return the boundary preceding the last boundary
private  int previousSafePosition(int offset)
           
 void setText(CharacterIterator newText)
          Set a new text to scan.
 void setText(String newText)
          Set a new text string for enumeration.
 
Methods inherited from class java.text.BreakIterator
getAvailableLocales, getCharacterInstance, getCharacterInstance, getLineInstance, getLineInstance, getSentenceInstance, getSentenceInstance, getWordInstance, getWordInstance
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pos

private transient int pos

text

private transient CharacterIterator text

data

private TextBoundaryData data

END_OF_STRING

private static final char END_OF_STRING
See Also:
Constant Field Values
Constructor Detail

SimpleTextBoundary

protected SimpleTextBoundary(TextBoundaryData data)
Create a SimpleTextBoundary using the specified tables. Currently, the table format is private.

Parameters:
data - data used for boundary determination
Method Detail

equals

public boolean equals(Object obj)
Compares the equality of two SimpleTextBoundary objects.

Overrides:
equals in class Object
Parameters:
obj - the SimpleTextBoundary object to be compared with.
Returns:
true if the given obj is the same as this SimpleTextBoundary object; false otherwise.
See Also:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
Compute a hashcode for this enumeration

Overrides:
hashCode in class Object
Returns:
A hash code
See Also:
Object.equals(java.lang.Object), Hashtable

clone

public Object clone()
Overrides Cloneable

Overrides:
clone in class BreakIterator
Returns:
A copy of this

getText

public CharacterIterator getText()
Get the text being scanned by the enumeration

Specified by:
getText in class BreakIterator
Returns:
the text being scanned by the enumeration

setText

public void setText(String newText)
Set a new text string for enumeration. The position of the enumerator is reset to first().

Overrides:
setText in class BreakIterator
Parameters:
newText - new text to scan.

setText

public void setText(CharacterIterator newText)
Set a new text to scan. The position is reset to first().

Specified by:
setText in class BreakIterator
Parameters:
newText - new text to scan.

first

public int first()
Return the first boundary. The iterator's current position is set to the first boundary.

Specified by:
first in class BreakIterator
Returns:
The character index of the first text boundary.

last

public int last()
Return the last boundary. The iterator's current position is set to the last boundary.

Specified by:
last in class BreakIterator
Returns:
The character index of the last text boundary.

next

public int next(int increment)
Return the nth boundary from the current boundary

Specified by:
next in class BreakIterator
Parameters:
increment - which boundary to return. A value of 0 does nothing. Negative values move to previous boundaries and positive values move to later boundaries.
Returns:
the nth boundary from the current position.

previous

public int previous()
Return the boundary preceding the last boundary

Specified by:
previous in class BreakIterator
Returns:
The character index of the previous text boundary or DONE if all boundaries have been returned.

next

public int next()
Return the next text boundary

Specified by:
next in class BreakIterator
Returns:
the character offset of the text boundary or DONE if all boundaries have been returned.

isBoundary

public boolean isBoundary(int offset)
Return true if the specified position is a boundary position.

Overrides:
isBoundary in class BreakIterator
Parameters:
offset - the offset to check.
Returns:
True if "offset" is a boundary position.

following

public int following(int offset)
Return the first boundary after the specified offset

Specified by:
following in class BreakIterator
Parameters:
offset - the offset to start
Returns:
int the first boundary after offset

preceding

public int preceding(int offset)
Return the last boundary preceding the specified offset

Overrides:
preceding in class BreakIterator
Parameters:
offset - the offset to start
Returns:
the last boundary before offset

current

public int current()
Return the boundary last returned by previous or next

Specified by:
current in class BreakIterator
Returns:
int the boundary last returned by previous or next

previousSafePosition

private int previousSafePosition(int offset)

nextPosition

private int nextPosition(int offset)

mappedChar

protected int mappedChar(char c)