Source Code Cross Referenced for Tokenizer.java in  » UML » jrefactory » org » acm » seguin » pretty » 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 » UML » jrefactory » org.acm.seguin.pretty 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *Author:  Mike Atkinson
003:         *
004:         *This software has been developed under the copyleft
005:         *rules of the GNU General Public License.  Please
006:         *consult the GNU General Public License for more
007:         *details about use and distribution of this software.
008:         */
009:        package org.acm.seguin.pretty;
010:
011:        import net.sourceforge.jrefactory.parser.Token;
012:
013:        /**
014:         *  Parses a XDoclet javadoc comment tag
015:         *
016:         * @author   Mike Atkinson
017:         * @created  June 22, 2003
018:         * @since    JRefactory 2.7.02
019:         */
020:        public class Tokenizer {
021:            /**Description of the Field */
022:            protected StringBuffer buffer;
023:            /**Description of the Field */
024:            protected int index;
025:            /**Description of the Field */
026:            protected int last;
027:            /**Description of the Field */
028:            protected String value;
029:
030:            /**  Represents spaces */
031:            public final static int SPACE = 0;
032:
033:            /**  Represents newline */
034:            public final static int NEWLINE = 1;
035:
036:            /**  Represents a word */
037:            public final static int WORD = 2;
038:
039:            /**
040:             *  Constructor for the JavadocTokenizer object
041:             *
042:             * @paraminit  Description of Parameter
043:             * @paraminit  Description of Parameter
044:             */
045:            public Tokenizer(String init) {
046:                value = init;
047:                index = 0;
048:                buffer = new StringBuffer();
049:                last = value.length();
050:            }
051:
052:            /**
053:             *  Description of the Method
054:             *
055:             * @return  Description of the Returned Value
056:             */
057:            public boolean hasNext() {
058:                return index < last;
059:            }
060:
061:            /**
062:             *  Description of the Method
063:             *
064:             * @return  Description of the Returned Value
065:             */
066:            public Token next() {
067:                Token result = new Token();
068:
069:                if (index == last) {
070:                    result.kind = SPACE;
071:                    result.image = " ";
072:                    return result;
073:                }
074:
075:                buffer.setLength(0);
076:                if (((index == 0) && (value.charAt(index) == '*'))
077:                        || ((index == 0) && (value.charAt(index) == '/'))
078:                        || (value.charAt(index) == '\r')
079:                        || (value.charAt(index) == '\n')) {
080:                    if (value.charAt(index) == '/') {
081:                        index++;
082:                    }
083:
084:                    loadNewline();
085:                    result.kind = NEWLINE;
086:                    result.image = buffer.toString();
087:
088:                    //System.out.println("Found a newline:  [" + result.image + "]");
089:                } else if (Character.isWhitespace(value.charAt(index))) {
090:                    loadSpace();
091:                    result.kind = SPACE;
092:                    result.image = buffer.toString();
093:                    //System.out.println("Found a space:  [" + result.image + "]");
094:                } else {
095:                    loadWord();
096:                    result.kind = WORD;
097:                    result.image = checkEnd(buffer.toString());
098:                    //System.out.println("Found a word:  [" + result.image + "]");
099:                }
100:
101:                return result;
102:            }
103:
104:            /**  Loads a particular word. */
105:            protected void loadWord() {
106:                int start = index;
107:
108:                while ((index < last)
109:                        && !Character.isWhitespace(value.charAt(index))
110:                        && ((value.charAt(index) != '<') || (index == start))) {
111:                    buffer.append(value.charAt(index));
112:                    index++;
113:
114:                    if (value.charAt(index - 1) == '>')
115:                        return;
116:                }
117:            }
118:
119:            /**
120:             *  Checks that the end of the word doesn't end with end of comment
121:             *
122:             * @paramvalue  Description of Parameter
123:             * @return      the revised value
124:             * @paramvalue  the value to check
125:             */
126:            private String checkEnd(String value) {
127:                if (value.endsWith("*/")) {
128:                    return value.substring(0, value.length() - 2);
129:                }
130:                return value;
131:            }
132:
133:            /**
134:             *  Moves from the end of one line past the * on the next line and possibly
135:             *  to the end of the comment.
136:             */
137:            private void loadNewline() {
138:                while ((index < last)
139:                        && Character.isWhitespace(value.charAt(index))) {
140:                    buffer.append(value.charAt(index));
141:                    index++;
142:                }
143:
144:                while ((index < last) && (value.charAt(index) == '*')) {
145:                    buffer.append(value.charAt(index));
146:                    index++;
147:                }
148:
149:                if ((index < last)
150:                        && (value.charAt(index - 1) == '*' && value
151:                                .charAt(index) == '/')) {
152:                    buffer.append(value.charAt(index));
153:                    index++;
154:                }
155:            }
156:
157:            /**  Description of the Method */
158:            private void loadSpace() {
159:                while ((index < last)
160:                        && Character.isWhitespace(value.charAt(index))
161:                        && (value.charAt(index) != '\n')
162:                        && (value.charAt(index) != '\r')) {
163:                    buffer.append(value.charAt(index));
164:                    index++;
165:                }
166:            }
167:
168:            /**
169:             *  Description of the Method
170:             *
171:             * @paramvalue  Description of Parameter
172:             * @return      Description of the Return Value
173:             * @paramvalue  Description of the Parameter
174:             */
175:            public static boolean hasContent(String value) {
176:                if (value == null) {
177:                    return false;
178:                }
179:
180:                int valueLength = value.length();
181:
182:                if (valueLength == 0) {
183:                    return false;
184:                }
185:
186:                int start = 0;
187:
188:                if (value.charAt(0) == '/') {
189:                    start++;
190:                }
191:
192:                int last = valueLength - 1;
193:
194:                for (int ndx = start; ndx < last; ndx++) {
195:                    char ch = value.charAt(ndx);
196:
197:                    if (!(Character.isWhitespace(ch) || (ch == '*'))) {
198:                        return true;
199:                    }
200:                }
201:
202:                char ch = value.charAt(last);
203:
204:                return !(Character.isWhitespace(ch) || (ch == '*') || (ch == '/'));
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.