Class BreakTransliterator
- java.lang.Object
-
- com.ibm.icu.text.Transliterator
-
- com.ibm.icu.text.BreakTransliterator
-
- All Implemented Interfaces:
StringTransform
,Transform<java.lang.String,java.lang.String>
final class BreakTransliterator extends Transliterator
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 Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
BreakTransliterator.ReplaceableCharacterIterator
-
Nested classes/interfaces inherited from class com.ibm.icu.text.Transliterator
Transliterator.Factory, Transliterator.Position
-
-
Field Summary
Fields Modifier and Type Field Description private BreakIterator
bi
private int[]
boundaries
private int
boundaryCount
private java.lang.String
insertion
(package private) static int
LETTER_OR_MARK_MASK
-
Fields inherited from class com.ibm.icu.text.Transliterator
DEBUG, FORWARD, ID_DELIM, ID_SEP, REVERSE, VARIANT_SEP
-
-
Constructor Summary
Constructors Constructor Description BreakTransliterator(java.lang.String ID, UnicodeFilter filter)
BreakTransliterator(java.lang.String ID, UnicodeFilter filter, BreakIterator bi, java.lang.String insertion)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet)
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().BreakIterator
getBreakIterator()
java.lang.String
getInsertion()
protected void
handleTransliterate(Replaceable text, Transliterator.Position pos, boolean incremental)
Abstract method that concrete subclasses define to implement their transliteration algorithm.(package private) static void
register()
Registers standard variants with the system.void
setBreakIterator(BreakIterator bi)
void
setInsertion(java.lang.String insertion)
-
Methods inherited from class com.ibm.icu.text.Transliterator
baseToRules, createFromRules, filteredTransliterate, finishTransliteration, getAvailableIDs, getAvailableSources, getAvailableTargets, getAvailableVariants, getBasicInstance, getDisplayName, getDisplayName, getDisplayName, getElements, getFilter, getFilterAsUnicodeSet, getID, getInstance, getInstance, getInverse, getMaximumContextLength, getSourceSet, getTargetSet, handleGetSourceSet, registerAlias, registerAny, registerClass, registerFactory, registerInstance, registerInstance, registerSpecialInverse, setFilter, setID, setMaximumContextLength, toRules, transform, transliterate, transliterate, transliterate, transliterate, transliterate, transliterate, unregister
-
-
-
-
Field Detail
-
bi
private BreakIterator bi
-
insertion
private java.lang.String insertion
-
boundaries
private int[] boundaries
-
boundaryCount
private int boundaryCount
-
LETTER_OR_MARK_MASK
static final int LETTER_OR_MARK_MASK
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BreakTransliterator
public BreakTransliterator(java.lang.String ID, UnicodeFilter filter, BreakIterator bi, java.lang.String insertion)
-
BreakTransliterator
public BreakTransliterator(java.lang.String ID, UnicodeFilter filter)
-
-
Method Detail
-
getInsertion
public java.lang.String getInsertion()
-
setInsertion
public void setInsertion(java.lang.String insertion)
-
getBreakIterator
public BreakIterator getBreakIterator()
-
setBreakIterator
public void setBreakIterator(BreakIterator bi)
-
handleTransliterate
protected void handleTransliterate(Replaceable text, Transliterator.Position pos, boolean incremental)
Description copied from class:Transliterator
Abstract method that concrete subclasses define to implement their transliteration algorithm. This method handles both incremental and non-incremental transliteration. LetoriginalStart
refer to the value ofpos.start
upon entry.- If
incremental
is false, then this method should transliterate all characters betweenpos.start
andpos.limit
. Upon returnpos.start
must ==pos.limit
. - If
incremental
is true, then this method should transliterate all characters betweenpos.start
andpos.limit
that can be unambiguously transliterated, regardless of future insertions of text atpos.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
andpos.contextLimit
should be updated to reflect changes in length of the text betweenpos.start
andpos.limit
. The differencepos.contextLimit - pos.limit
should not change. pos.contextStart
should not change.- Upon return, neither
pos.start
norpos.limit
should be less thanoriginalStart
. - Text before
originalStart
and text afterpos.limit
should not change. - Text before
pos.contextStart
and text afterpos.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. SeefilteredTransliterate()
.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 calltransliterate()
instead of this method. Subclass code should callfilteredTransliterate()
instead of this method.- Specified by:
handleTransliterate
in classTransliterator
- Parameters:
text
- the buffer holding transliterated and untransliterated textpos
- the indices indicating the start, limit, context start, and context limit of the text.incremental
- if true, assume more text may be inserted atpos.limit
and act accordingly. Otherwise, transliterate all text betweenpos.start
andpos.limit
and movepos.start
up topos.limit
.- See Also:
Transliterator.transliterate(com.ibm.icu.text.Replaceable, int, int)
- If
-
register
static void register()
Registers standard variants with the system. Called by Transliterator during initialization.
-
addSourceTargetSet
public void addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet)
Description copied from class:Transliterator
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.- Overrides:
addSourceTargetSet
in classTransliterator
targetSet
- TODO- See Also:
Transliterator.getTargetSet()
-
-