org.eclipse.xtext.ui.editor.model
Class CommonBreakIterator

java.lang.Object
  extended by com.ibm.icu.text.BreakIterator
      extended by org.eclipse.xtext.ui.editor.model.CommonBreakIterator
All Implemented Interfaces:
java.lang.Cloneable

public class CommonBreakIterator
extends com.ibm.icu.text.BreakIterator

This class was copied from org.eclipse.jdt.internal.ui.text.JavaBreakIterator.

See Also:
JavaBreakIterator

Nested Class Summary
protected static class CommonBreakIterator.CamelCaseIdentifier
           
protected static class CommonBreakIterator.Identifier
           
protected static class CommonBreakIterator.LineDelimiter
           
protected static class CommonBreakIterator.Other
           
protected static class CommonBreakIterator.Run
          A run of common characters.
protected  class CommonBreakIterator.SequenceCharacterIterator
          A CharSequence based implementation of CharacterIterator.
protected static class CommonBreakIterator.Whitespace
           
 
Field Summary
protected  CommonBreakIterator.Run delimiter
           
protected  com.ibm.icu.text.BreakIterator fIterator
          The platform break iterator (word instance) used as a base.
protected  java.lang.CharSequence fText
          The text we operate on.
protected  CommonBreakIterator.Run identifier
           
protected  CommonBreakIterator.Run other
           
protected  CommonBreakIterator.Run whitespace
           
 
Fields inherited from class com.ibm.icu.text.BreakIterator
DONE, KIND_CHARACTER, KIND_LINE, KIND_SENTENCE, KIND_TITLE, KIND_WORD
 
Constructor Summary
CommonBreakIterator(boolean camelCase)
          Creates a new break iterator.
 
Method Summary
protected  CommonBreakIterator.Run consumeRun(int offset)
          Consumes a run of characters at the limits of which we introduce a break.
 int current()
          Return the iterator's current position.
 int first()
          Return the first boundary position.
 int following(int offset)
          Sets the iterator's current iteration position to be the first boundary position following the specified position.
protected  CommonBreakIterator.Run getRun(char ch)
          Returns a run based on a character.
 java.text.CharacterIterator getText()
          Returns a CharacterIterator over the text being analyzed.
 boolean isBoundary(int offset)
          Return true if the specfied position is a boundary position.
 int last()
          Return the last boundary position.
 int next()
          Advances the iterator forward one boundary.
 int next(int n)
          Advances the specified number of steps forward in the text (a negative number, therefore, advances backwards).
 int preceding(int offset)
          Sets the iterator's current iteration position to be the last boundary position preceding the specified position.
 int previous()
          Advances the iterator backward one boundary.
 void setText(java.text.CharacterIterator newText)
          Sets the iterator to analyze a new piece of text.
 void setText(java.lang.CharSequence newText)
          Creates a break iterator given a char sequence.
 void setText(java.lang.String newText)
          Sets the iterator to analyze a new piece of text.
 
Methods inherited from class com.ibm.icu.text.BreakIterator
clone, getAvailableLocales, getAvailableULocales, getBreakInstance, getCharacterInstance, getCharacterInstance, getCharacterInstance, getLineInstance, getLineInstance, getLineInstance, getLocale, getSentenceInstance, getSentenceInstance, getSentenceInstance, getTitleInstance, getTitleInstance, getTitleInstance, getWordInstance, getWordInstance, getWordInstance, registerInstance, registerInstance, unregister
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

whitespace

protected CommonBreakIterator.Run whitespace

delimiter

protected CommonBreakIterator.Run delimiter

identifier

protected CommonBreakIterator.Run identifier

other

protected CommonBreakIterator.Run other

fIterator

protected final com.ibm.icu.text.BreakIterator fIterator
The platform break iterator (word instance) used as a base.


fText

protected java.lang.CharSequence fText
The text we operate on.

Constructor Detail

CommonBreakIterator

public CommonBreakIterator(boolean camelCase)
Creates a new break iterator.

Method Detail

current

public int current()
Description copied from class: com.ibm.icu.text.BreakIterator
Return the iterator's current position.

Specified by:
current in class com.ibm.icu.text.BreakIterator
Returns:
The iterator's current position.

first

public int first()
Description copied from class: com.ibm.icu.text.BreakIterator
Return the first boundary position. This is always the beginning index of the text this iterator iterates over. For example, if the iterator iterates over a whole string, this function will always return 0. This function also updates the iteration position to point to the beginning of the text.

Specified by:
first in class com.ibm.icu.text.BreakIterator
Returns:
The character offset of the beginning of the stretch of text being broken.

following

public int following(int offset)
Description copied from class: com.ibm.icu.text.BreakIterator
Sets the iterator's current iteration position to be the first boundary position following the specified position. (Whether the specified position is itself a boundary position or not doesn't matter-- this function always moves the iteration position to the first boundary after the specified position.) If the specified position is the past-the-end position, returns DONE.

Specified by:
following in class com.ibm.icu.text.BreakIterator
Parameters:
offset - The character position to start searching from.
Returns:
The position of the first boundary position following "offset" (whether or not "offset" itself is a boundary position), or DONE if "offset" is the past-the-end offset.

consumeRun

protected CommonBreakIterator.Run consumeRun(int offset)
Consumes a run of characters at the limits of which we introduce a break.

Parameters:
offset - the offset to start at
Returns:
the run that was consumed

getRun

protected CommonBreakIterator.Run getRun(char ch)
Returns a run based on a character.

Parameters:
ch - the character to test
Returns:
the correct character given ch

getText

public java.text.CharacterIterator getText()
Description copied from class: com.ibm.icu.text.BreakIterator
Returns a CharacterIterator over the text being analyzed. For at least some subclasses of BreakIterator, this is a reference to the actual iterator being used by the BreakIterator, and therefore, this function's return value should be treated as const. No guarantees are made about the current position of this iterator when it is returned. If you need to move that position to examine the text, clone this function's return value first.

Specified by:
getText in class com.ibm.icu.text.BreakIterator
Returns:
A CharacterIterator over the text being analyzed.

isBoundary

public boolean isBoundary(int offset)
Description copied from class: com.ibm.icu.text.BreakIterator
Return true if the specfied position is a boundary position. If the function returns true, the current iteration position is set to the specified position; if the function returns false, the current iteration position is set as though following() had been called.

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

last

public int last()
Description copied from class: com.ibm.icu.text.BreakIterator
Return the last boundary position. This is always the "past-the-end" index of the text this iterator iterates over. For example, if the iterator iterates over a whole string (call it "text"), this function will always return text.length(). This function also updated the iteration position to point to the end of the text.

Specified by:
last in class com.ibm.icu.text.BreakIterator
Returns:
The character offset of the end of the stretch of text being broken.

next

public int next()
Description copied from class: com.ibm.icu.text.BreakIterator
Advances the iterator forward one boundary. The current iteration position is updated to point to the next boundary position after the current position, and this is also the value that is returned. If the current position is equal to the value returned by last(), or to DONE, this function returns DONE and sets the current position to DONE.

Specified by:
next in class com.ibm.icu.text.BreakIterator
Returns:
The position of the first boundary position following the iteration position.

next

public int next(int n)
Description copied from class: com.ibm.icu.text.BreakIterator
Advances the specified number of steps forward in the text (a negative number, therefore, advances backwards). If this causes the iterator to advance off either end of the text, this function returns DONE; otherwise, this function returns the position of the appropriate boundary. Calling this function is equivalent to calling next() or previous() n times.

Specified by:
next in class com.ibm.icu.text.BreakIterator
Parameters:
n - The number of boundaries to advance over (if positive, moves forward; if negative, moves backwards).
Returns:
The position of the boundary n boundaries from the current iteration position, or DONE if moving n boundaries causes the iterator to advance off either end of the text.

preceding

public int preceding(int offset)
Description copied from class: com.ibm.icu.text.BreakIterator
Sets the iterator's current iteration position to be the last boundary position preceding the specified position. (Whether the specified position is itself a boundary position or not doesn't matter-- this function always moves the iteration position to the last boundary before the specified position.) If the specified position is the starting position, returns DONE.

Overrides:
preceding in class com.ibm.icu.text.BreakIterator
Parameters:
offset - The character position to start searching from.
Returns:
The position of the last boundary position preceding "offset" (whether of not "offset" itself is a boundary position), or DONE if "offset" is the starting offset of the iterator.

previous

public int previous()
Description copied from class: com.ibm.icu.text.BreakIterator
Advances the iterator backward one boundary. The current iteration position is updated to point to the last boundary position before the current position, and this is also the value that is returned. If the current position is equal to the value returned by first(), or to DONE, this function returns DONE and sets the current position to DONE.

Specified by:
previous in class com.ibm.icu.text.BreakIterator
Returns:
The position of the last boundary position preceding the iteration position.

setText

public void setText(java.lang.String newText)
Description copied from class: com.ibm.icu.text.BreakIterator
Sets the iterator to analyze a new piece of text. The new piece of text is passed in as a String, and the current iteration position is reset to the beginning of the string. (The old text is dropped.)

Overrides:
setText in class com.ibm.icu.text.BreakIterator
Parameters:
newText - A String containing the text to analyze with this BreakIterator.

setText

public void setText(java.lang.CharSequence newText)
Creates a break iterator given a char sequence.

Parameters:
newText - the new text

setText

public void setText(java.text.CharacterIterator newText)
Description copied from class: com.ibm.icu.text.BreakIterator
Sets the iterator to analyze a new piece of text. The BreakIterator is passed a CharacterIterator through which it will access the text itself. The current iteration position is reset to the CharacterIterator's start index. (The old iterator is dropped.)

Specified by:
setText in class com.ibm.icu.text.BreakIterator
Parameters:
newText - A CharacterIterator referring to the text to analyze with this BreakIterator (the iterator's current position is ignored, but its other state is significant).