Source Code Cross Referenced for StringPrepParseException.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) 2003-2005, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:        package com.ibm.icu.text;
008:
009:        import java.text.ParseException;
010:
011:        /**
012:         * Exception that signals an error has occurred while parsing the 
013:         * input to StringPrep or IDNA. 
014:         *
015:         * @author Ram Viswanadha
016:         * @stable ICU 2.8
017:         */
018:        public class StringPrepParseException extends ParseException {
019:            // Generated by serialver from JDK 1.4.1_01
020:            static final long serialVersionUID = 7160264827701651255L;
021:
022:            /**
023:             * @stable ICU 2.8
024:             */
025:            public static final int INVALID_CHAR_FOUND = 0;
026:            /**
027:             * @stable ICU 2.8
028:             */
029:            public static final int ILLEGAL_CHAR_FOUND = 1;
030:            /**
031:             * @stable ICU 2.8
032:             */
033:            public static final int PROHIBITED_ERROR = 2;
034:            /**
035:             * @stable ICU 2.8
036:             */
037:            public static final int UNASSIGNED_ERROR = 3;
038:            /**
039:             * @stable ICU 2.8
040:             */
041:            public static final int CHECK_BIDI_ERROR = 4;
042:            /**
043:             * @stable ICU 2.8
044:             */
045:            public static final int STD3_ASCII_RULES_ERROR = 5;
046:            /**
047:             * @stable ICU 2.8
048:             */
049:            public static final int ACE_PREFIX_ERROR = 6;
050:            /**
051:             * @stable ICU 2.8
052:             */
053:            public static final int VERIFICATION_ERROR = 7;
054:            /**
055:             * @stable ICU 2.8
056:             */
057:            public static final int LABEL_TOO_LONG_ERROR = 8;
058:            /**
059:             * @stable ICU 2.8
060:             */
061:            public static final int BUFFER_OVERFLOW_ERROR = 9;
062:
063:            /**
064:             * @stable ICU 2.2
065:             */
066:            public static final int ZERO_LENGTH_LABEL = 10;
067:
068:            /**
069:             * Construct a ParseException object with the given message
070:             * and error code
071:             * 
072:             * @param message A string describing the type of error that occurred
073:             * @param error   The error that has occurred
074:             * @stable ICU 2.8
075:             */
076:            public StringPrepParseException(String message, int error) {
077:                super (message, -1);
078:                this .error = error;
079:                this .line = 0;
080:            }
081:
082:            /**
083:             * Construct a ParseException object with the given message and
084:             * error code
085:             * 
086:             * @param message A string describing the type of error that occurred
087:             * @param error   The error that has occurred
088:             * @param rules   The input rules string 
089:             * @param pos     The position of error in the rules string
090:             * @stable ICU 2.8
091:             */
092:            public StringPrepParseException(String message, int error,
093:                    String rules, int pos) {
094:                super (message, -1);
095:                this .error = error;
096:                setContext(rules, pos);
097:                this .line = 0;
098:            }
099:
100:            /**
101:             * Construct  a ParseException object with the given message and error code
102:             * 
103:             * @param message    A string describing the type of error that occurred
104:             * @param error      The error that has occurred
105:             * @param rules      The input rules string 
106:             * @param pos        The position of error in the rules string
107:             * @param lineNumber The line number at which the error has occurred. 
108:             *                   If the parse engine is not using this field, it should set it to zero.  Otherwise
109:             *                   it should be a positive integer. The default value of this field
110:             *                   is -1. It will be set to 0 if the code populating this struct is not
111:             *                   using line numbers.
112:             * @stable ICU 2.8
113:             */
114:            public StringPrepParseException(String message, int error,
115:                    String rules, int pos, int lineNumber) {
116:                super (message, -1);
117:                this .error = error;
118:                setContext(rules, pos);
119:                this .line = lineNumber;
120:            }
121:
122:            /**
123:             * Compare this ParseException to another and evaluate if they are equal.
124:             * The comparison works only on the type of error and does not compare
125:             * the rules strings, if any, for equality.
126:             * 
127:             * @param other The exception that this object should be compared to
128:             * @return true if the objects are equal, false if unequal
129:             * @stable ICU 2.8
130:             */
131:            public boolean equals(Object other) {
132:                if (!(other instanceof  StringPrepParseException)) {
133:                    return false;
134:                }
135:                return ((StringPrepParseException) other).error == this .error;
136:
137:            }
138:
139:            /**
140:             * Returns the position of error in the rules string
141:             * 
142:             * @return String
143:             * @stable ICU 2.8
144:             */
145:            public String toString() {
146:                StringBuffer buf = new StringBuffer();
147:                buf.append(super .getMessage());
148:                buf.append(". preContext:  ");
149:                buf.append(preContext);
150:                buf.append(". postContext: ");
151:                buf.append(postContext);
152:                buf.append("\n");
153:                return buf.toString();
154:            }
155:
156:            private int error;
157:
158:            /**
159:             * The line on which the error occured.  If the parse engine
160:             * is not using this field, it should set it to zero.  Otherwise
161:             * it should be a positive integer. The default value of this field
162:             * is -1. It will be set to 0 if the code populating this struct is not
163:             * using line numbers.
164:             * @stable ICU 2.8  
165:             */
166:            private int line;
167:
168:            /**
169:             * Textual context before the error.  Null-terminated.
170:             * May be the empty string if not implemented by parser.
171:             * @stable ICU 2.8
172:             */
173:            private StringBuffer preContext = new StringBuffer();
174:
175:            /**
176:             * Textual context after the error.  Null-terminated.
177:             * May be the empty string if not implemented by parser.
178:             * @stable ICU 2.8   
179:             */
180:            private StringBuffer postContext = new StringBuffer();
181:
182:            private static final int PARSE_CONTEXT_LEN = 16;
183:
184:            private void setPreContext(String str, int pos) {
185:                setPreContext(str.toCharArray(), pos);
186:            }
187:
188:            private void setPreContext(char[] str, int pos) {
189:                int start = (pos <= PARSE_CONTEXT_LEN) ? 0
190:                        : (pos - (PARSE_CONTEXT_LEN - 1));
191:                int len = (start <= PARSE_CONTEXT_LEN) ? start
192:                        : PARSE_CONTEXT_LEN;
193:                preContext.append(str, start, len);
194:
195:            }
196:
197:            private void setPostContext(String str, int pos) {
198:                setPostContext(str.toCharArray(), pos);
199:            }
200:
201:            private void setPostContext(char[] str, int pos) {
202:                int start = pos;
203:                int len = str.length - start;
204:                postContext.append(str, start, len);
205:
206:            }
207:
208:            private void setContext(String str, int pos) {
209:                setPreContext(str, pos);
210:                setPostContext(str, pos);
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.