Source Code Cross Referenced for WordBreakIterator.java in  » Report » pentaho-report » org » jfree » report » util » 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 » Report » pentaho report » org.jfree.report.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * ===========================================
003:         * JFreeReport : a free Java reporting library
004:         * ===========================================
005:         *
006:         * Project Info:  http://reporting.pentaho.org/
007:         *
008:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009:         *
010:         * This library is free software; you can redistribute it and/or modify it under the terms
011:         * of the GNU Lesser General Public License as published by the Free Software Foundation;
012:         * either version 2.1 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015:         * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         * See the GNU Lesser General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU Lesser General Public License along with this
019:         * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020:         * Boston, MA 02111-1307, USA.
021:         *
022:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023:         * in the United States and other countries.]
024:         *
025:         * ------------
026:         * WordBreakIterator.java
027:         * ------------
028:         * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029:         */package org.jfree.report.util;
030:
031:        /**
032:         * Behaves similiar to BreakIterator.getWordInstance() but handles line break delimeters
033:         * as simple whitespaces.
034:         * <p/>
035:         * This class is not synchronized.
036:         *
037:         * @author Thomas Morgner.
038:         * @deprecated This functionality is now provided by LibFonts.
039:         */
040:        public class WordBreakIterator {
041:            /**
042:             * A useful constant.
043:             */
044:            public static final int DONE = -1;
045:
046:            /**
047:             * The current position.
048:             */
049:            private int position;
050:
051:            /**
052:             * Storage for characters.
053:             */
054:            private char[] text;
055:
056:            /**
057:             * Creates a new iterator.
058:             *
059:             * @param text the text to break.
060:             */
061:            public WordBreakIterator(final String text) {
062:                setText(text);
063:            }
064:
065:            /**
066:             * Returns the next word boundary.
067:             *
068:             * @return The index of the next word boundary.
069:             */
070:            public int next() {
071:                if (position == DONE) {
072:                    return DONE;
073:                }
074:                if (text == null) {
075:                    return DONE;
076:                }
077:                if (position == text.length) {
078:                    return DONE;
079:                }
080:
081:                //lastFound = position;
082:
083:                if (Character.isWhitespace(text[position])) {
084:                    // search the first non whitespace character ..., this is the beginning of the word
085:                    while ((position < text.length)
086:                            && (Character.isWhitespace(text[position]))) {
087:                        position++;
088:                    }
089:                    return position;
090:                } else {
091:                    // now search the first whitespace character ..., this is the end of the word
092:                    while ((position < text.length)
093:                            && (Character.isWhitespace(text[position]) == false)) {
094:                        position++;
095:                    }
096:                    return position;
097:                }
098:            }
099:
100:            /**
101:             * Same like next(), but returns the End-Of-Text as if there was a linebreak added
102:             * (Reader.readLine() compatible)
103:             *
104:             * @return The next position.
105:             */
106:            public int nextWithEnd() {
107:                final int pos = position;
108:                if (pos == DONE || pos == text.length) {
109:                    return DONE;
110:                }
111:                final int retval = next();
112:                if (retval == DONE) {
113:                    return text.length;
114:                }
115:                return retval;
116:            }
117:
118:            /**
119:             * Returns the position of the previous break.
120:             *
121:             * @return The index.
122:             */
123:            public int previous() {
124:                //return lastFound;
125:
126:                if (position == 0) {
127:                    return 0;
128:                }
129:                if (text == null) {
130:                    return DONE;
131:                }
132:                if (position == DONE) {
133:                    position = text.length;
134:                    return position;
135:                }
136:                //lastFound = position;
137:
138:                if (Character.isWhitespace(text[position - 1])) {
139:                    // search the first non whitespace character ..., this is the beginning of the word
140:                    while ((position > 0)
141:                            && (Character.isWhitespace(text[position - 1]))) {
142:                        position--;
143:                    }
144:                    return position;
145:                } else {
146:                    // now search the first whitespace character ..., this is the end of the word
147:                    while ((position > 0)
148:                            && (Character.isWhitespace(text[position - 1]) == false)) {
149:                        position--;
150:                    }
151:                    return position;
152:                }
153:
154:            }
155:
156:            /**
157:             * Returns the text to be broken up.
158:             *
159:             * @return the text.
160:             */
161:            public String getText() {
162:                return new String(text);
163:            }
164:
165:            /**
166:             * Sets the text to be broken up.
167:             *
168:             * @param text the text.
169:             */
170:            public void setText(final String text) {
171:                position = 0;
172:                //lastFound = 0;
173:                this .text = text.toCharArray();
174:            }
175:
176:            /**
177:             * Returns the current parsing position of this iterator.
178:             *
179:             * @return returns the current parsing position of this iterator.
180:             */
181:            public int getPosition() {
182:                return position;
183:            }
184:
185:            /**
186:             * Defines the current parse position for the word break iterator. The position must be
187:             * positive and within the range of the current text.
188:             *
189:             * @param position the position.
190:             */
191:            public void setPosition(final int position) {
192:                if (position < 0) {
193:                    throw new IndexOutOfBoundsException("Position < 0");
194:                }
195:                if (position > text.length) {
196:                    throw new IndexOutOfBoundsException(
197:                            "Position > text.length");
198:                }
199:                this.position = position;
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.