The Segment implements the java.text.CharacterIterator interface to support use with the i18n support without copying text into a string.
| Modifier and Type | Field and Description |
|---|---|
| public char[] | array
This is the array containing the text of interest. |
| pack-priv boolean | copy
Whether the array is a copy of data or not. |
| public int | count
This is the number of array elements that make up the text of interest. |
| public int | offset
This is the offset into the array that the desired text begins. |
| private boolean | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Segment(char[]
the array to refer to array, int the offset into the array offset, int the number of characters count)Creates a new segment referring to an existing array. |
| Modifier and Type | Method and Description |
|---|---|
| public char | charAt(int index)
Implements java. Returns the |
| public Object | Returns: the copyOverrides java. Implements java. Creates a shallow copy. |
| public char | Returns: the character at the current position or DONE if the current position is off the end of the text.Implements java. Gets the character at the current position (as returned by getIndex()). |
| public char | Returns: the first character in the text, or DONE if the text is emptyImplements java. Sets the position to getBeginIndex() and returns the character at that position. |
| public int | Returns: the index at which the text begins.Implements java. Returns the start index of the text. |
| public int | Returns: the index after the last character in the textImplements java. Returns the end index of the text. |
| public int | Returns: the current index.Implements java. Returns the current index. |
| public boolean | Returns: whether or not partial returns are valid.Flag to indicate that partial returns are valid. |
| public char | Returns: the last character in the text, or DONE if the text is emptyImplements java. Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position. |
| public int | |
| public char | Returns: the character at the new position or DONE if the new position is off the end of the text range.Implements java. Increments the iterator's index by one and returns the character at the new index. |
| public char | Returns: the character at the new position or DONE if the current position is equal to getBeginIndex().Implements java. Decrements the iterator's index by one and returns the character at the new index. |
| public char | Returns: the character at the specified position or DONE if the specified position is equal to getEndIndex()the position within the text. Valid values range from
getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown
if an invalid value is supplied. position)Implements java. Sets the position to the specified position in the text and returns that character. |
| public void | setPartialReturn(boolean
whether or not partial returns are valid. p)Flag to indicate that partial returns are valid. |
| public CharSequence | subSequence(int start, int end)
Implements java. Returns a |
| public String | Returns: the stringOverrides java. Implements java. Converts a segment into a String. |
| array | back to summary |
|---|---|
| public char[] array This is the array containing the text of interest. This array should never be modified; it is available only for efficiency. | |
| copy | back to summary |
|---|---|
| pack-priv boolean copy Whether the array is a copy of data or not. | |
| count | back to summary |
|---|---|
| public int count This is the number of array elements that make up the text of interest. | |
| offset | back to summary |
|---|---|
| public int offset This is the offset into the array that the desired text begins. | |
| partialReturn | back to summary |
|---|---|
| private boolean partialReturn | |
| pos | back to summary |
|---|---|
| private int pos | |
| Segment | back to summary |
|---|---|
| public Segment() Creates a new segment. | |
| Segment | back to summary |
|---|---|
| public Segment(char[] array, int offset, int count) Creates a new segment referring to an existing array.
| |
| charAt | back to summary |
|---|---|
| public char charAt(int index) Implements java. Doc from java. Returns the If the
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Implements java. Creates a shallow copy.
| |
| current | back to summary |
|---|---|
| public char current() Implements java. Gets the character at the current position (as returned by getIndex()).
| |
| first | back to summary |
|---|---|
| public char first() Implements java. Sets the position to getBeginIndex() and returns the character at that position.
| |
| getBeginIndex | back to summary |
|---|---|
| public int getBeginIndex() Implements java. Returns the start index of the text.
| |
| getEndIndex | back to summary |
|---|---|
| public int getEndIndex() Implements java. Returns the end index of the text. This index is the index of the first character following the end of the text.
| |
| getIndex | back to summary |
|---|---|
| public int getIndex() Implements java. Returns the current index.
| |
| isPartialReturn | back to summary |
|---|---|
| public boolean isPartialReturn() Flag to indicate that partial returns are valid.
| |
| last | back to summary |
|---|---|
| public char last() Implements java. Sets the position to getEndIndex()-1 (getEndIndex() if the text is empty) and returns the character at that position.
| |
| length | back to summary |
|---|---|
| public int length() Implements java. Doc from java. Returns the length of this character sequence. The length is the number
of 16-bit
| |
| next | back to summary |
|---|---|
| public char next() Implements java. Increments the iterator's index by one and returns the character at the new index. If the resulting index is greater or equal to getEndIndex(), the current index is reset to getEndIndex() and a value of DONE is returned.
| |
| previous | back to summary |
|---|---|
| public char previous() Implements java. Decrements the iterator's index by one and returns the character at the new index. If the current index is getBeginIndex(), the index remains at getBeginIndex() and a value of DONE is returned.
| |
| setIndex | back to summary |
|---|---|
| public char setIndex(int position) Implements java. Sets the position to the specified position in the text and returns that character.
| |
| setPartialReturn | back to summary |
|---|---|
| public void setPartialReturn(boolean p) Flag to indicate that partial returns are valid. If the flag is true, an implementation of the interface method Document.getText(position,length,Segment) should return as much text as possible without making a copy. The default state of the flag is false which will cause Document.getText(position,length,Segment) to provide the same return behavior it always had, which may or may not make a copy of the text depending upon the request.
| |
| subSequence | back to summary |
|---|---|
| public CharSequence subSequence(int start, int end) Implements java. Doc from java. Returns a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements java. Converts a segment into a String.
| |