Source Code Cross Referenced for Result.java in  » Mail-Clients » columba-1.4 » org » columba » mail » spellcheck » cswilly » 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 » Mail Clients » columba 1.4 » org.columba.mail.spellcheck.cswilly 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Revision: 1.1 $
003:         * $Date: 2006/06/10 13:32:32 $
004:         * $Author: fdietz $
005:         *
006:         * Copyright (C) 2001 C. Scott Willy
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:        package org.columba.mail.spellcheck.cswilly;
023:
024:        import java.util.ArrayList;
025:        import java.util.List;
026:        import java.util.StringTokenizer;
027:
028:        /**
029:         * Models the result of a spell check of a single word.
030:         *<p>
031:         *   Features of a spell check result are:</p>
032:         *   <ul>
033:         *     <li>contains the result of checking one&nbsp; word</li>
034:         *     <li>has the original word</li>
035:         *     <li>has a type of result (i.e. OK, ERROR, NONE, SUGGESTION)</li>
036:         *     <li>has a list of suggested replacement words (if type is SUGGESTION)</li>
037:         *     <li>has an offset into the line where the original word was found</li>
038:         *   </ul>
039:         *   <p>The possible result types are:
040:         *   <dl>
041:         *     <dt>OK</dt>
042:         *     <dd>the original word was found in the dictionary.</dd>
043:         *     <dt>ERROR</dt>
044:         *     <dd>Internal error (e.g. aspell process died, wrong version of aspell, phase
045:         *       of moon wrong).</dd>
046:         *     <dt>NONE</dt>
047:         *     <dd>the original word was not found in the dictionary and no suggestions were
048:         *       found.</dd>
049:         *     <dt>SUGGESTION</dt>
050:         *     <dd>the original word was not found in the dictionary and one or more
051:         *       suggested replacements were found.</dd>
052:         *   </dl>
053:         */
054:        public class Result {
055:            public static final Type ERROR = new Type("Error");
056:            public static final Type OK = new Type("OK ");
057:            public static final Type NONE = new Type("None");
058:            public static final Type SUGGESTION = new Type("Suggestion");
059:            private int _offset;
060:            private Type _type;
061:            private List _suggestions;
062:            private String _originalWord;
063:
064:            public Result(String line) {
065:                if ((line == null) || (line.length() <= 0)) {
066:                    processError(line);
067:                } else if (line.charAt(0) == '*') {
068:                    processOk(line);
069:                } else if (line.charAt(0) == '&') {
070:                    processSuggestion(line);
071:                } else if (line.charAt(0) == '#') {
072:                    processNone(line);
073:                } else {
074:                    processError(line);
075:                }
076:            }
077:
078:            public int getOffset() {
079:                return _offset;
080:            }
081:
082:            public Type getType() {
083:                return _type;
084:            }
085:
086:            public List getSuggestions() {
087:                return _suggestions;
088:            }
089:
090:            public String getOriginalWord() {
091:                return _originalWord;
092:            }
093:
094:            public String toString() {
095:                StringBuffer buff = new StringBuffer();
096:                buff.append("[type:");
097:                buff.append(_type);
098:                buff.append(",originalWord:");
099:                buff.append(_originalWord);
100:                buff.append(",offset:");
101:                buff.append(_offset);
102:                buff.append(",suggestions:");
103:                buff.append(_suggestions);
104:
105:                return buff.toString();
106:            }
107:
108:            private void processError(String line) {
109:                _offset = 0;
110:                _type = ERROR;
111:                _suggestions = new ArrayList();
112:                _originalWord = "";
113:            }
114:
115:            private void processOk(String line) {
116:                _offset = 0;
117:                _type = OK;
118:                _suggestions = new ArrayList();
119:                _originalWord = "";
120:            }
121:
122:            private void processNone(String line) {
123:                _type = NONE;
124:                _suggestions = new ArrayList();
125:
126:                StringTokenizer st = new StringTokenizer(line);
127:                st.nextToken(); // skip '#'
128:                _originalWord = st.nextToken();
129:                _offset = Integer.parseInt(st.nextToken());
130:            }
131:
132:            private void processSuggestion(String line) {
133:                _type = SUGGESTION;
134:
135:                StringTokenizer st = new StringTokenizer(line);
136:                st.nextToken(); // skip '#'
137:                _originalWord = st.nextToken();
138:
139:                int count = Integer.parseInt(st.nextToken().trim());
140:                _suggestions = new ArrayList(count);
141:                _offset = Integer.parseInt(st.nextToken(":").trim());
142:
143:                st = new StringTokenizer(st.nextToken(":"), ",");
144:
145:                while (st.hasMoreTokens()) {
146:                    String suggestion = st.nextToken().trim();
147:                    _suggestions.add(suggestion);
148:                }
149:            }
150:
151:            private static class Type {
152:                private final String _typeName;
153:
154:                Type(String typeName) {
155:                    _typeName = typeName;
156:                }
157:
158:                public String toString() {
159:                    return _typeName;
160:                }
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.