< prev index next >
src/java.base/share/classes/sun/text/normalizer/TrieIterator.java
Print this page
*** 35,55 ****
*/
package sun.text.normalizer;
/**
! * <p>Class enabling iteration of the values in a Trie.</p>
* <p>Result of each iteration contains the interval of codepoints that have
! * the same value type and the value type itself.</p>
* <p>The comparison of each codepoint value is done via extract(), which the
! * default implementation is to return the value as it is.</p>
* <p>Method extract() can be overwritten to perform manipulations on
! * codepoint values in order to perform specialized comparison.</p>
* <p>TrieIterator is designed to be a generic iterator for the CharTrie
* and the IntTrie, hence to accommodate both types of data, the return
! * result will be in terms of int (32 bit) values.</p>
! * <p>See com.ibm.icu.text.UCharacterTypeIterator for examples of use.</p>
* <p>Notes for porting utrie_enum from icu4c to icu4j:<br>
* Internally, icu4c's utrie_enum performs all iterations in its body. In Java
* sense, the caller will have to pass a object with a callback function
* UTrieEnumRange(const void *context, UChar32 start, UChar32 limit,
* uint32_t value) into utrie_enum. utrie_enum will then find ranges of
--- 35,55 ----
*/
package sun.text.normalizer;
/**
! * Class enabling iteration of the values in a Trie.
* <p>Result of each iteration contains the interval of codepoints that have
! * the same value type and the value type itself.
* <p>The comparison of each codepoint value is done via extract(), which the
! * default implementation is to return the value as it is.
* <p>Method extract() can be overwritten to perform manipulations on
! * codepoint values in order to perform specialized comparison.
* <p>TrieIterator is designed to be a generic iterator for the CharTrie
* and the IntTrie, hence to accommodate both types of data, the return
! * result will be in terms of int (32 bit) values.
! * <p>See com.ibm.icu.text.UCharacterTypeIterator for examples of use.
* <p>Notes for porting utrie_enum from icu4c to icu4j:<br>
* Internally, icu4c's utrie_enum performs all iterations in its body. In Java
* sense, the caller will have to pass a object with a callback function
* UTrieEnumRange(const void *context, UChar32 start, UChar32 limit,
* uint32_t value) into utrie_enum. utrie_enum will then find ranges of
*** 61,82 ****
* Instead of requesting the caller to implement an object for a callback.
* The caller will have to implement a subclass of TrieIterator, fleshing out
* the method extract(int) (equivalent to UTrieEnumValue). Independent of icu4j,
* the caller will have to code his own iteration and flesh out the task
* (equivalent to UTrieEnumRange) to be performed in the iteration loop.
! * </p>
! * <p>There are basically 3 usage scenarios for porting:</p>
* <p>1) UTrieEnumValue is the only implemented callback then just implement a
* subclass of TrieIterator and override the extract(int) method. The
* extract(int) method is analogus to UTrieEnumValue callback.
! * </p>
* <p>2) UTrieEnumValue and UTrieEnumRange both are implemented then implement
! * a subclass of TrieIterator, override the extract method and iterate, e.g
! * </p>
! * <p>utrie_enum(&normTrie, _enumPropertyStartsValue, _enumPropertyStartsRange,
! * set);<br>
! * In Java :<br>
* <pre>
* class TrieIteratorImpl extends TrieIterator{
* public TrieIteratorImpl(Trie data){
* super(data);
* }
--- 61,81 ----
* Instead of requesting the caller to implement an object for a callback.
* The caller will have to implement a subclass of TrieIterator, fleshing out
* the method extract(int) (equivalent to UTrieEnumValue). Independent of icu4j,
* the caller will have to code his own iteration and flesh out the task
* (equivalent to UTrieEnumRange) to be performed in the iteration loop.
! *
! * <p>There are basically 3 usage scenarios for porting:
* <p>1) UTrieEnumValue is the only implemented callback then just implement a
* subclass of TrieIterator and override the extract(int) method. The
* extract(int) method is analogus to UTrieEnumValue callback.
! *
* <p>2) UTrieEnumValue and UTrieEnumRange both are implemented then implement
! * a subclass of TrieIterator, override the extract method and iterate, e.g.<br>
! * {@code utrie_enum(&normTrie, _enumPropertyStartsValue, _enumPropertyStartsRange,
! * set);}<br>
! * In Java:<br>
* <pre>
* class TrieIteratorImpl extends TrieIterator{
* public TrieIteratorImpl(Trie data){
* super(data);
* }
*** 88,108 ****
* TrieIterator fcdIter = new TrieIteratorImpl(fcdTrieImpl.fcdTrie);
* while(fcdIter.next(result)) {
* // port the implementation of _enumPropertyStartsRange
* }
* </pre>
! * </p>
* <p>3) UTrieEnumRange is the only implemented callback then just implement
* the while loop, when utrie_enum is called
! * <pre>
* // utrie_enum(&fcdTrie, NULL, _enumPropertyStartsRange, set);
* TrieIterator fcdIter = new TrieIterator(fcdTrieImpl.fcdTrie);
* while(fcdIter.next(result)){
* set.add(result.start);
* }
! * </pre>
! * </p>
* @author synwee
* @see com.ibm.icu.impl.Trie
* @see com.ibm.icu.lang.UCharacterTypeIterator
* @since release 2.1, Jan 17 2002
*/
--- 87,107 ----
* TrieIterator fcdIter = new TrieIteratorImpl(fcdTrieImpl.fcdTrie);
* while(fcdIter.next(result)) {
* // port the implementation of _enumPropertyStartsRange
* }
* </pre>
! *
* <p>3) UTrieEnumRange is the only implemented callback then just implement
* the while loop, when utrie_enum is called
! * <pre>{@code
* // utrie_enum(&fcdTrie, NULL, _enumPropertyStartsRange, set);
* TrieIterator fcdIter = new TrieIterator(fcdTrieImpl.fcdTrie);
* while(fcdIter.next(result)){
* set.add(result.start);
* }
! * }</pre>
! *
* @author synwee
* @see com.ibm.icu.impl.Trie
* @see com.ibm.icu.lang.UCharacterTypeIterator
* @since release 2.1, Jan 17 2002
*/
< prev index next >