Source Code Cross Referenced for StringCharacterIterator.java in  » Internationalization-Localization » icu4j » com » ibm » icu » text » 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.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 1996-2006, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:
008:        // NOTE:  This class is identical to java.text.StringCharacterIterator
009:        // in JDK 1.2.  It's copied here because the JDK 1.1 version of
010:        // StringCharacterIterator has a bug that prevents it from working
011:        // right with RuleBasedBreakIterator.  This class is unnecessary
012:        // when using RuleBasedBreakIterator with JDK 1.2.
013:        package com.ibm.icu.text;
014:
015:        import java.text.CharacterIterator;
016:
017:        /**
018:         * <code>StringCharacterIterator</code> implements the
019:         * <code>CharacterIterater</code> protocol for a <code>String</code>.
020:         * The <code>StringCharacterIterator</code> class iterates over the
021:         * entire <code>String</code>.
022:         *
023:         * @see CharacterIterator
024:         * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
025:         */
026:        ///CLOVER:OFF
027:        public final class StringCharacterIterator implements  CharacterIterator {
028:            private String text;
029:            private int begin;
030:            private int end;
031:            // invariant: begin <= pos <= end
032:            private int pos;
033:
034:            /**
035:             * Constructs an iterator with an initial index of 0.
036:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
037:             */
038:            public StringCharacterIterator(String text) {
039:                this (text, 0);
040:            }
041:
042:            /**
043:             * Constructs an iterator with the specified initial index.
044:             *
045:             * @param  text   The String to be iterated over
046:             * @param  pos    Initial iterator position     
047:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
048:             */
049:            public StringCharacterIterator(String text, int pos) {
050:                this (text, 0, text.length(), pos);
051:            }
052:
053:            /**
054:             * Constructs an iterator over the given range of the given string, with the
055:             * index set at the specified position.
056:             *
057:             * @param  text   The String to be iterated over
058:             * @param  begin  Index of the first character
059:             * @param  end    Index of the character following the last character
060:             * @param  pos    Initial iterator position 
061:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
062:             */
063:            public StringCharacterIterator(String text, int begin, int end,
064:                    int pos) {
065:                if (text == null) {
066:                    throw new NullPointerException();
067:                }
068:                this .text = text;
069:
070:                if (begin < 0 || begin > end || end > text.length()) {
071:                    throw new IllegalArgumentException(
072:                            "Invalid substring range");
073:                }
074:
075:                if (pos < begin || pos > end) {
076:                    throw new IllegalArgumentException("Invalid position");
077:                }
078:
079:                this .begin = begin;
080:                this .end = end;
081:                this .pos = pos;
082:            }
083:
084:            /**
085:             * Reset this iterator to point to a new string.  This package-visible
086:             * method is used by other java.text classes that want to avoid allocating
087:             * new StringCharacterIterator objects every time their setText method
088:             * is called.
089:             *
090:             * @param  text   The String to be iterated over 
091:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
092:             */
093:            public void setText(String text) {
094:                if (text == null) {
095:                    throw new NullPointerException();
096:                }
097:                this .text = text;
098:                this .begin = 0;
099:                this .end = text.length();
100:                this .pos = 0;
101:            }
102:
103:            /**
104:             * Implements CharacterIterator.first() for String.
105:             * @see CharacterIterator#first 
106:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
107:             */
108:            public char first() {
109:                pos = begin;
110:                return current();
111:            }
112:
113:            /**
114:             * Implements CharacterIterator.last() for String.
115:             * @see CharacterIterator#last 
116:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
117:             */
118:            public char last() {
119:                if (end != begin) {
120:                    pos = end - 1;
121:                } else {
122:                    pos = end;
123:                }
124:                return current();
125:            }
126:
127:            /**
128:             * Implements CharacterIterator.setIndex() for String.
129:             * @see CharacterIterator#setIndex 
130:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
131:             */
132:            public char setIndex(int p) {
133:                if (p < begin || p > end) {
134:                    throw new IllegalArgumentException("Invalid index");
135:                }
136:                pos = p;
137:                return current();
138:            }
139:
140:            /**
141:             * Implements CharacterIterator.current() for String.
142:             * @see CharacterIterator#current 
143:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
144:             */
145:            public char current() {
146:                if (pos >= begin && pos < end) {
147:                    return text.charAt(pos);
148:                } else {
149:                    return DONE;
150:                }
151:            }
152:
153:            /**
154:             * Implements CharacterIterator.next() for String.
155:             * @see CharacterIterator#next 
156:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
157:             */
158:            public char next() {
159:                if (pos < end - 1) {
160:                    pos++;
161:                    return text.charAt(pos);
162:                } else {
163:                    pos = end;
164:                    return DONE;
165:                }
166:            }
167:
168:            /**
169:             * Implements CharacterIterator.previous() for String.
170:             * @see CharacterIterator#previous 
171:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
172:             */
173:            public char previous() {
174:                if (pos > begin) {
175:                    pos--;
176:                    return text.charAt(pos);
177:                } else {
178:                    return DONE;
179:                }
180:            }
181:
182:            /**
183:             * Implements CharacterIterator.getBeginIndex() for String.
184:             * @see CharacterIterator#getBeginIndex 
185:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
186:             */
187:            public int getBeginIndex() {
188:                return begin;
189:            }
190:
191:            /**
192:             * Implements CharacterIterator.getEndIndex() for String.
193:             * @see CharacterIterator#getEndIndex 
194:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
195:             */
196:            public int getEndIndex() {
197:                return end;
198:            }
199:
200:            /**
201:             * Implements CharacterIterator.getIndex() for String.
202:             * @see CharacterIterator#getIndex 
203:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
204:             */
205:            public int getIndex() {
206:                return pos;
207:            }
208:
209:            /**
210:             * Compares the equality of two StringCharacterIterator objects.
211:             * @param obj the StringCharacterIterator object to be compared with.
212:             * @return true if the given obj is the same as this
213:             * StringCharacterIterator object; false otherwise. 
214:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
215:             */
216:            public boolean equals(Object obj) {
217:                if (this  == obj) {
218:                    return true;
219:                }
220:                if (!(obj instanceof  StringCharacterIterator)) {
221:                    return false;
222:                }
223:
224:                StringCharacterIterator that = (StringCharacterIterator) obj;
225:
226:                if (hashCode() != that.hashCode()) {
227:                    return false;
228:                }
229:                if (!text.equals(that.text)) {
230:                    return false;
231:                }
232:                if (pos != that.pos || begin != that.begin || end != that.end) {
233:                    return false;
234:                }
235:                return true;
236:            }
237:
238:            /**
239:             * Computes a hashcode for this iterator.
240:             * @return A hash code 
241:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
242:             */
243:            public int hashCode() {
244:                return text.hashCode() ^ pos ^ begin ^ end;
245:            }
246:
247:            /**
248:             * Creates a copy of this iterator.
249:             * @return A copy of this 
250:             * @deprecated ICU 2.4. Use java.text.StringCharacterIterator instead.
251:             */
252:            public Object clone() {
253:                try {
254:                    StringCharacterIterator other = (StringCharacterIterator) super 
255:                            .clone();
256:                    return other;
257:                } catch (CloneNotSupportedException e) {
258:                    throw new IllegalStateException();
259:                }
260:            }
261:
262:        }
263:        ///CLOVER:ON
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.