Source Code Cross Referenced for CharacterIteratorWrapper.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 Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 1996-2004, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:        package com.ibm.icu.impl;
008:
009:        import java.text.CharacterIterator;
010:
011:        import com.ibm.icu.text.*;
012:
013:        /**
014:         * This class is a wrapper around CharacterIterator and implements the 
015:         * UCharacterIterator protocol
016:         * @author ram
017:         */
018:
019:        public class CharacterIteratorWrapper extends UCharacterIterator {
020:
021:            private CharacterIterator iterator;
022:
023:            public CharacterIteratorWrapper(CharacterIterator iter) {
024:                if (iter == null) {
025:                    throw new IllegalArgumentException();
026:                }
027:                iterator = iter;
028:            }
029:
030:            /**
031:             * @see UCharacterIterator#current()
032:             */
033:            public int current() {
034:                int c = iterator.current();
035:                if (c == CharacterIterator.DONE) {
036:                    return DONE;
037:                }
038:                return c;
039:            }
040:
041:            /**
042:             * @see UCharacterIterator#getLength()
043:             */
044:            public int getLength() {
045:                return (iterator.getEndIndex() - iterator.getBeginIndex());
046:            }
047:
048:            /**
049:             * @see UCharacterIterator#getIndex()
050:             */
051:            public int getIndex() {
052:                return iterator.getIndex();
053:            }
054:
055:            /**
056:             * @see UCharacterIterator#next()
057:             */
058:            public int next() {
059:                int i = iterator.current();
060:                iterator.next();
061:                if (i == CharacterIterator.DONE) {
062:                    return DONE;
063:                }
064:                return i;
065:            }
066:
067:            /**
068:             * @see UCharacterIterator#previous()
069:             */
070:            public int previous() {
071:                int i = iterator.previous();
072:                if (i == CharacterIterator.DONE) {
073:                    return DONE;
074:                }
075:                return i;
076:            }
077:
078:            /**
079:             * @see UCharacterIterator#setIndex(int)
080:             */
081:            public void setIndex(int index) {
082:                try {
083:                    iterator.setIndex(index);
084:                } catch (IllegalArgumentException e) {
085:                    throw new IndexOutOfBoundsException();
086:                }
087:            }
088:
089:            /**
090:             * @see UCharacterIterator#setToLimit()
091:             */
092:            public void setToLimit() {
093:                iterator.setIndex(iterator.getEndIndex());
094:            }
095:
096:            /**
097:             * @see UCharacterIterator#getText(char[])
098:             */
099:            public int getText(char[] fillIn, int offset) {
100:                int length = iterator.getEndIndex() - iterator.getBeginIndex();
101:                int currentIndex = iterator.getIndex();
102:                if (offset < 0 || offset + length > fillIn.length) {
103:                    throw new IndexOutOfBoundsException(Integer
104:                            .toString(length));
105:                }
106:
107:                for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator
108:                        .next()) {
109:                    fillIn[offset++] = ch;
110:                }
111:                iterator.setIndex(currentIndex);
112:
113:                return length;
114:            }
115:
116:            /**
117:             * Creates a clone of this iterator.  Clones the underlying character iterator.
118:             * @see UCharacterIterator#clone()
119:             */
120:            public Object clone() {
121:                try {
122:                    CharacterIteratorWrapper result = (CharacterIteratorWrapper) super 
123:                            .clone();
124:                    result.iterator = (CharacterIterator) this .iterator.clone();
125:                    return result;
126:                } catch (CloneNotSupportedException e) {
127:                    return null; // only invoked if bad underlying character iterator
128:                }
129:            }
130:
131:            public int moveIndex(int delta) {
132:                int length = iterator.getEndIndex() - iterator.getBeginIndex();
133:                int idx = iterator.getIndex() + delta;
134:
135:                if (idx < 0) {
136:                    idx = 0;
137:                } else if (idx > length) {
138:                    idx = length;
139:                }
140:                return iterator.setIndex(idx);
141:            }
142:
143:            /**
144:             * @see UCharacterIterator#getCharacterIterator()
145:             */
146:            public CharacterIterator getCharacterIterator() {
147:                return (CharacterIterator) iterator.clone();
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.