Java Doc for TrieIterator.java in  » Internationalization-Localization » icu4j » com » ibm » icu » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.impl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ibm.icu.impl.TrieIterator

All known Subclasses:   com.ibm.icu.lang.UCharacterTypeIterator,
TrieIterator
public class TrieIterator implements RangeValueIterator(Code)

Class enabling iteration of the values in a Trie.

Result of each iteration contains the interval of codepoints that have the same value type and the value type itself.

The comparison of each codepoint value is done via extract(), which the default implementation is to return the value as it is.

Method extract() can be overwritten to perform manipulations on codepoint values in order to perform specialized comparison.

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.

See com.ibm.icu.text.UCharacterTypeIterator for examples of use.

Notes for porting utrie_enum from icu4c to icu4j:
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 codepoints with the same value as determined by UTrieEnumValue(const void *context, uint32_t value). for each range, utrie_enum calls the callback function to perform a task. In this way, icu4c performs the iteration within utrie_enum. To follow the JDK model, icu4j is slightly different from icu4c. 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.

There are basically 3 usage scenarios for porting:

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.

2) UTrieEnumValue and UTrieEnumRange both are implemented then implement a subclass of TrieIterator, override the extract method and iterate, e.g

utrie_enum(&normTrie, _enumPropertyStartsValue, _enumPropertyStartsRange, set);
In Java :

 class TrieIteratorImpl extends TrieIterator{
 public TrieIteratorImpl(Trie data){
 super(data);
 }
 public int extract(int value){
 // port the implementation of _enumPropertyStartsValue here
 }
 }
 .... 
 TrieIterator fcdIter  = new TrieIteratorImpl(fcdTrieImpl.fcdTrie);
 while(fcdIter.next(result)) {
 // port the implementation of _enumPropertyStartsRange
 }
 

3) UTrieEnumRange is the only implemented callback then just implement the while loop, when utrie_enum is called

 // utrie_enum(&fcdTrie, NULL, _enumPropertyStartsRange, set);
 TrieIterator fcdIter  = new TrieIterator(fcdTrieImpl.fcdTrie);
 while(fcdIter.next(result)){
 set.add(result.start);
 }
 


author:
   synwee
See Also:   com.ibm.icu.impl.Trie
See Also:   com.ibm.icu.lang.UCharacterTypeIterator
since:
   release 2.1, Jan 17 2002



Constructor Summary
public  TrieIterator(Trie trie)
    

Method Summary
protected  intextract(int value)
     Called by next() to extracts a 32 bit value from a trie value used for comparison.
final public  booleannext(Element element)
    
final public  voidreset()
    


Constructor Detail
TrieIterator
public TrieIterator(Trie trie)(Code)
TrieEnumeration constructor
Parameters:
  trie - to be used
exception:
  IllegalArgumentException - throw when argument is null.




Method Detail
extract
protected int extract(int value)(Code)
Called by next() to extracts a 32 bit value from a trie value used for comparison. This method is to be overwritten if special manipulation is to be done to retrieve a relevant comparison. The default function is to return the value as it is.
Parameters:
  value - a value from the trie extracted value



next
final public boolean next(Element element)(Code)

Returns true if we are not at the end of the iteration, false otherwise.

The next set of codepoints with the same value type will be calculated during this call and returned in the arguement element.


Parameters:
  element - return result true if we are not at the end of the iteration, false otherwise.
exception:
  NoSuchElementException - - if no more elements exist.
See Also:   com.ibm.icu.util.RangeValueIterator.Element



reset
final public void reset()(Code)
Resets the iterator to the beginning of the iteration



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.