Top Description Inners Fields Constructors Methods
com.ibm.icu.text

pack-priv final Class BreakTransliterator

extends Transliterator
Class Inheritance
Imports
java.text.CharacterIterator, com.ibm.icu.lang.UCharacter, com.ibm.icu.util.ICUCloneNotSupportedException, .ULocale

Inserts the specified characters at word breaks. To restrict it to particular characters, use a filter.

Todo

this is an internal class, and only temporary. Remove it once we have \b notation in Transliterator.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private BreakIterator
private int[]
private int
private String
pack-priv static final int
Inherited from com.ibm.icu.text.Transliterator:
DEBUGFORWARDID_DELIMID_SEPREVERSEVARIANT_SEP

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet
TODO
targetSet
)

Overrides com.ibm.icu.text.Transliterator.addSourceTargetSet.

Returns the set of all characters that may be generated as replacement text by this transliterator, filtered by BOTH the input filter, and the current getFilter().
public BreakIterator
public String
protected synchronized void
handleTransliterate(Replaceable
the buffer holding transliterated and untransliterated text
text
,
Transliterator.Position
the indices indicating the start, limit, context start, and context limit of the text.
pos
,
boolean
if true, assume more text may be inserted at pos.limit and act accordingly. Otherwise, transliterate all text between pos.start and pos.limit and move pos.start up to pos.limit.
incremental
)

Implements abstract com.ibm.icu.text.Transliterator.handleTransliterate.

Abstract method that concrete subclasses define to implement their transliteration algorithm.
pack-priv static void
register()

Registers standard variants with the system.

public void
public void
setInsertion(String insertion)

Inherited from com.ibm.icu.text.Transliterator:
baseToRulescreateFromRulesfilteredTransliteratefinishTransliterationgetAvailableIDsgetAvailableSourcesgetAvailableTargetsgetAvailableVariantsgetBasicInstancegetDisplayNamegetDisplayNamegetDisplayNamegetElementsgetFiltergetFilterAsUnicodeSetgetIDgetInstancegetInstancegetInversegetMaximumContextLengthgetSourceSetgetTargetSethandleGetSourceSetregisterAliasregisterAnyregisterClassregisterFactoryregisterInstanceregisterInstanceregisterSpecialInversesetFiltersetIDsetMaximumContextLengthtoRulestransformtransliteratetransliteratetransliteratetransliteratetransliteratetransliterateunregister

Field Detail

biback to summary
private BreakIterator bi
boundariesback to summary
private int[] boundaries
boundaryCountback to summary
private int boundaryCount
insertionback to summary
private String insertion
LETTER_OR_MARK_MASKback to summary
pack-priv static final int LETTER_OR_MARK_MASK

Constructor Detail

BreakTransliteratorback to summary
public BreakTransliterator(String ID, UnicodeFilter filter, BreakIterator bi, String insertion)
BreakTransliteratorback to summary
public BreakTransliterator(String ID, UnicodeFilter filter)

Method Detail

addSourceTargetSetback to summary
public void addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet)

Overrides com.ibm.icu.text.Transliterator.addSourceTargetSet.

Doc from com.ibm.icu.text.Transliterator.addSourceTargetSet.

Returns the set of all characters that may be generated as replacement text by this transliterator, filtered by BOTH the input filter, and the current getFilter().

SHOULD BE OVERRIDDEN BY SUBCLASSES. It is probably an error for any transliterator to NOT override this, but we can't force them to for backwards compatibility.

Other methods vector through this.

When gathering the information on source and target, the compound transliterator makes things complicated. For example, suppose we have:

Global FILTER = [ax]
a > b;
:: NULL;
b > c;
x > d;
While the filter just allows a and x, b is an intermediate result, which could produce c. So the source and target sets cannot be gathered independently. What we have to do is filter the sources for the first transliterator according to the global filter, intersect that transliterator's filter. Based on that we get the target. The next transliterator gets as a global filter (global + last target). And so on.

There is another complication:

Global FILTER = [ax]
a >|b;
b >c;
Even though b would be filtered from the input, whenever we have a backup, it could be part of the input. So ideally we will change the global filter as we go.
Parameters
targetSet:UnicodeSet

TODO

Annotations
@Override
getBreakIteratorback to summary
public BreakIterator getBreakIterator()
getInsertionback to summary
public String getInsertion()
handleTransliterateback to summary
protected synchronized void handleTransliterate(Replaceable text, Transliterator.Position pos, boolean incremental)

Implements abstract com.ibm.icu.text.Transliterator.handleTransliterate.

Doc from com.ibm.icu.text.Transliterator.handleTransliterate.

Abstract method that concrete subclasses define to implement their transliteration algorithm. This method handles both incremental and non-incremental transliteration. Let originalStart refer to the value of pos.start upon entry.

  • If incremental is false, then this method should transliterate all characters between pos.start and pos.limit. Upon return pos.start must == pos.limit.
  • If incremental is true, then this method should transliterate all characters between pos.start and pos.limit that can be unambiguously transliterated, regardless of future insertions of text at pos.limit. Upon return, pos.start should be in the range [originalStart, pos.limit). pos.start should be positioned such that characters [originalStart, pos.start) will not be changed in the future by this transliterator and characters [pos.start, pos.limit) are unchanged.

Implementations of this method should also obey the following invariants:

  • pos.limit and pos.contextLimit should be updated to reflect changes in length of the text between pos.start and pos.limit. The difference pos.contextLimit - pos.limit should not change.
  • pos.contextStart should not change.
  • Upon return, neither pos.start nor pos.limit should be less than originalStart.
  • Text before originalStart and text after pos.limit should not change.
  • Text before pos.contextStart and text after pos.contextLimit should be ignored.

Subclasses may safely assume that all characters in [pos.start, pos.limit) are filtered. In other words, the filter has already been applied by the time this method is called. See filteredTransliterate().

This method is not for public consumption. Calling this method directly will transliterate [pos.start, pos.limit) without applying the filter. End user code should call transliterate() instead of this method. Subclass code should call filteredTransliterate() instead of this method.

Parameters
text:Replaceable

the buffer holding transliterated and untransliterated text

pos:Transliterator.Position

the indices indicating the start, limit, context start, and context limit of the text.

incremental:boolean

if true, assume more text may be inserted at pos.limit and act accordingly. Otherwise, transliterate all text between pos.start and pos.limit and move pos.start up to pos.limit.

Annotations
@Override
registerback to summary
pack-priv static void register()

Registers standard variants with the system. Called by Transliterator during initialization.

setBreakIteratorback to summary
public void setBreakIterator(BreakIterator bi)
setInsertionback to summary
public void setInsertion(String insertion)
com.ibm.icu.text back to summary

pack-priv final Class BreakTransliterator.ReplaceableCharacterIterator

extends Object
implements CharacterIterator
Class Inheritance
  • java.lang.Object
  • com.ibm.icu.text.BreakTransliterator.ReplaceableCharacterIterator
All Implemented Interfaces
java.text.CharacterIterator, java.lang.Cloneable

Field Summary

Modifier and TypeField and Description
private int
private int
private int
private Replaceable

Constructor Summary

AccessConstructor and Description
public
ReplaceableCharacterIterator(Replaceable
The String to be iterated over
text
,
int
Index of the first character
begin
,
int
Index of the character following the last character
end
,
int
Initial iterator position
pos
)

Constructs an iterator over the given range of the given string, with the index set at the specified position.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

A copy of this
clone
()

Overrides java.lang.Object.clone.

Implements java.text.CharacterIterator.clone.

Creates a copy of this iterator.
public char
current()

Implements java.text.CharacterIterator.current.

Implements CharacterIterator.current() for String.
public boolean

Returns:

true if the given obj is the same as this ReplaceableCharacterIterator object; false otherwise.
equals
(Object
the ReplaceableCharacterIterator object to be compared with.
obj
)

Overrides java.lang.Object.equals.

Compares the equality of two ReplaceableCharacterIterator objects.
public char
first()

Implements java.text.CharacterIterator.first.

Implements CharacterIterator.first() for String.
public int
getBeginIndex()

Implements java.text.CharacterIterator.getBeginIndex.

Implements CharacterIterator.getBeginIndex() for String.
public int
getEndIndex()

Implements java.text.CharacterIterator.getEndIndex.

Implements CharacterIterator.getEndIndex() for String.
public int
getIndex()

Implements java.text.CharacterIterator.getIndex.

Implements CharacterIterator.getIndex() for String.
public int

Returns:

A hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Computes a hashcode for this iterator.
public char
last()

Implements java.text.CharacterIterator.last.

Implements CharacterIterator.last() for String.
public char
next()

Implements java.text.CharacterIterator.next.

Implements CharacterIterator.next() for String.
public char
previous()

Implements java.text.CharacterIterator.previous.

Implements CharacterIterator.previous() for String.
public char
setIndex(int
the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied.
p
)

Implements java.text.CharacterIterator.setIndex.

Implements CharacterIterator.setIndex() for String.
public void
setText(Replaceable
The String to be iterated over
text
)

Reset this iterator to point to a new string.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

beginback to summary
private int begin
endback to summary
private int end
posback to summary
private int pos
textback to summary
private Replaceable text

Constructor Detail

ReplaceableCharacterIteratorback to summary
public ReplaceableCharacterIterator(Replaceable text, int begin, int end, int pos)

Constructs an iterator over the given range of the given string, with the index set at the specified position.

Parameters
text:Replaceable

The String to be iterated over

begin:int

Index of the first character

end:int

Index of the character following the last character

pos:int

Initial iterator position

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements java.text.CharacterIterator.clone.

Creates a copy of this iterator.

Returns:Object

A copy of this

Annotations
@Override
currentback to summary
public char current()

Implements java.text.CharacterIterator.current.

Implements CharacterIterator.current() for String.

Returns:char

Doc from java.text.CharacterIterator.current.

the character at the current position or DONE if the current position is off the end of the text.

Annotations
@Override
See Also
CharacterIterator#current
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares the equality of two ReplaceableCharacterIterator objects.

Parameters
obj:Object

the ReplaceableCharacterIterator object to be compared with.

Returns:boolean

true if the given obj is the same as this ReplaceableCharacterIterator object; false otherwise.

Annotations
@Override
firstback to summary
public char first()

Implements java.text.CharacterIterator.first.

Implements CharacterIterator.first() for String.

Returns:char

Doc from java.text.CharacterIterator.first.

the first character in the text, or DONE if the text is empty

Annotations
@Override
See Also
CharacterIterator#first
getBeginIndexback to summary
public int getBeginIndex()

Implements java.text.CharacterIterator.getBeginIndex.

Implements CharacterIterator.getBeginIndex() for String.

Returns:int

Doc from java.text.CharacterIterator.getBeginIndex.

the index at which the text begins.

Annotations
@Override
See Also
CharacterIterator#getBeginIndex
getEndIndexback to summary
public int getEndIndex()

Implements java.text.CharacterIterator.getEndIndex.

Implements CharacterIterator.getEndIndex() for String.

Returns:int

Doc from java.text.CharacterIterator.getEndIndex.

the index after the last character in the text

Annotations
@Override
See Also
CharacterIterator#getEndIndex
getIndexback to summary
public int getIndex()

Implements java.text.CharacterIterator.getIndex.

Implements CharacterIterator.getIndex() for String.

Returns:int

Doc from java.text.CharacterIterator.getIndex.

the current index.

Annotations
@Override
See Also
CharacterIterator#getIndex
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Computes a hashcode for this iterator.

Returns:int

A hash code

Annotations
@Override
lastback to summary
public char last()

Implements java.text.CharacterIterator.last.

Implements CharacterIterator.last() for String.

Returns:char

Doc from java.text.CharacterIterator.last.

the last character in the text, or DONE if the text is empty

Annotations
@Override
See Also
CharacterIterator#last
nextback to summary
public char next()

Implements java.text.CharacterIterator.next.

Implements CharacterIterator.next() for String.

Returns:char

Doc from java.text.CharacterIterator.next.

the character at the new position or DONE if the new position is off the end of the text range.

Annotations
@Override
See Also
CharacterIterator#next
previousback to summary
public char previous()

Implements java.text.CharacterIterator.previous.

Implements CharacterIterator.previous() for String.

Returns:char

Doc from java.text.CharacterIterator.previous.

the character at the new position or DONE if the current position is equal to getBeginIndex().

Annotations
@Override
See Also
CharacterIterator#previous
setIndexback to summary
public char setIndex(int p)

Implements java.text.CharacterIterator.setIndex.

Implements CharacterIterator.setIndex() for String.

Parameters
p:int

Doc from java.text.CharacterIterator.setIndex.

the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied.

Returns:char

Doc from java.text.CharacterIterator.setIndex.

the character at the specified position or DONE if the specified position is equal to getEndIndex()

Annotations
@Override
See Also
CharacterIterator#setIndex
setTextback to summary
public void setText(Replaceable text)

Reset this iterator to point to a new string. This package-visible method is used by other java.text classes that want to avoid allocating new ReplaceableCharacterIterator objects every time their setText method is called.

Parameters
text:Replaceable

The String to be iterated over