Source Code Cross Referenced for WrongType.java in  » Scripting » Kawa » gnu » mapping » 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 » Scripting » Kawa » gnu.mapping 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 1999, 2004  Per M.A. Bothner.
002:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
003:
004:        package gnu.mapping;
005:
006:        import gnu.bytecode.Type;
007:
008:        /** Exception thrown when a procedure parameter has the wrong type. */
009:
010:        public class WrongType extends WrappedException {
011:            /** Number of the argument, 1-origin.
012:             * <br>
013:             * Can be an integer >= 1, or one of the values <code>ARG_UNKNOWN</code>,
014:             * <code>ARG_VARNAME</code>, or <code>ARG_DESCRIPTION</code>.
015:             */
016:            public int number;
017:
018:            /** <code>number==ARG_UNKNOWN</code> means unknown argument number. */
019:            public static final int ARG_UNKNOWN = -1;
020:
021:            /** <code>number==ARG_VARNAME</code> means not a call,
022:             * <code>procname</code> is a variable name.*/
023:            public static final int ARG_VARNAME = -2;
024:
025:            /** <code>number==ARG_DESCRIPTION</code> means not a call,
026:             * <code>procname</code> describes the target. (deprecated/unused) */
027:            public static final int ARG_DESCRIPTION = -3;
028:
029:            /** <code>number==ARG_CAST</code> means a general cast. */
030:            public static final int ARG_CAST = -4;
031:
032:            /** Name of <code>Procedure</code> that threw the exception (if non-null). */
033:            public String procname;
034:
035:            /** The <code>Procedure</code> that threw the exception (if non-null). */
036:            public Procedure proc;
037:
038:            /** The actual argument that was bad. */
039:            public Object argValue;
040:
041:            /** The expected parameter type (a Type or TypeValue), or a string name/description. */
042:            public Object expectedType;
043:
044:            public WrongType(String name, int n, String u) {
045:                super (null, null);
046:                procname = name;
047:                number = n;
048:                expectedType = u;
049:            }
050:
051:            public WrongType(Procedure proc, int n, ClassCastException ex) {
052:                super (ex);
053:                this .proc = proc;
054:                this .procname = proc.getName();
055:                this .number = n;
056:            }
057:
058:            public WrongType(ClassCastException ex, Procedure proc, int n,
059:                    Object argValue) {
060:                this (proc, n, ex);
061:                this .argValue = argValue;
062:            }
063:
064:            public WrongType(Procedure proc, int n, Object argValue) {
065:                this .proc = proc;
066:                this .procname = proc.getName();
067:                this .number = n;
068:                this .argValue = argValue;
069:            }
070:
071:            public WrongType(Procedure proc, int n, Object argValue,
072:                    Type expectedType) {
073:                this .proc = proc;
074:                this .procname = proc.getName();
075:                this .number = n;
076:                this .argValue = argValue;
077:                this .expectedType = expectedType;
078:            }
079:
080:            public WrongType(Procedure proc, int n, Object argValue,
081:                    String expectedType) {
082:                this (proc.getName(), n, argValue, expectedType);
083:                this .proc = proc;
084:            }
085:
086:            public WrongType(String procName, int n, Object argValue,
087:                    String expectedType) {
088:                this .procname = procName;
089:                this .number = n;
090:                this .argValue = argValue;
091:                this .expectedType = expectedType;
092:            }
093:
094:            public WrongType(String procname, int n, ClassCastException ex) {
095:                super (ex);
096:                this .procname = procname;
097:                this .number = n;
098:            }
099:
100:            public WrongType(ClassCastException ex, String procname, int n,
101:                    Object argValue) {
102:                this (procname, n, ex);
103:                this .argValue = argValue;
104:            }
105:
106:            /** @deprecated */
107:            public static WrongType make(ClassCastException ex, Procedure proc,
108:                    int n) {
109:                return new WrongType(proc, n, ex);
110:            }
111:
112:            /** @deprecated */
113:            public static WrongType make(ClassCastException ex,
114:                    String procname, int n) {
115:                return new WrongType(procname, n, ex);
116:            }
117:
118:            /** This interface is designed for a compact call sequence. */
119:            public static WrongType make(ClassCastException ex, Procedure proc,
120:                    int n, Object argValue) {
121:                WrongType wex = new WrongType(proc, n, ex);
122:                wex.argValue = argValue;
123:                return wex;
124:            }
125:
126:            /** This interface is designed for a compact call sequence. */
127:            public static WrongType make(ClassCastException ex,
128:                    String procname, int n, Object argValue) {
129:                WrongType wex = new WrongType(procname, n, ex);
130:                wex.argValue = argValue;
131:                return wex;
132:            }
133:
134:            public String getMessage() {
135:                StringBuffer sbuf = new StringBuffer(100);
136:                if (number == ARG_DESCRIPTION) {
137:                    sbuf.append(procname);
138:                } else if (number == ARG_CAST || number == ARG_VARNAME) {
139:                    sbuf.append("Value");
140:                } else {
141:                    sbuf.append("Argument ");
142:                    if (number > 0) {
143:                        sbuf.append('#');
144:                        sbuf.append(number);
145:                    }
146:                }
147:                if (argValue != null) {
148:                    sbuf.append(" (");
149:                    String argString = argValue.toString();
150:                    if (argString.length() > 50) {
151:                        sbuf.append(argString.substring(0, 47));
152:                        sbuf.append("...");
153:                    } else
154:                        sbuf.append(argString);
155:                    sbuf.append(")");
156:                }
157:                if (procname != null && number != ARG_DESCRIPTION) {
158:                    sbuf.append(number == ARG_VARNAME ? " for variable '"
159:                            : " to '");
160:                    sbuf.append(procname);
161:                    sbuf.append("'");
162:                }
163:                sbuf.append(" has wrong type");
164:                if (argValue != null) {
165:                    sbuf.append(" (");
166:                    sbuf.append(argValue.getClass().getName());
167:                    sbuf.append(")");
168:                }
169:                Object expectType = expectedType;
170:                if (expectType == null && number > 0
171:                        && proc instanceof  MethodProc)
172:                    expectType = ((MethodProc) proc)
173:                            .getParameterType(number - 1);
174:                if (expectType != null && expectType != Type.pointer_type) {
175:                    sbuf.append(" (expected: ");
176:                    if (expectType instanceof  Type)
177:                        expectType = ((Type) expectType).getName();
178:                    else if (expectType instanceof  Class)
179:                        expectType = ((Class) expectType).getName();
180:                    sbuf.append(expectType);
181:                    sbuf.append(")");
182:                }
183:                Throwable ex = getCause();
184:                if (ex != null) {
185:                    String msg = ex.getMessage();
186:                    if (msg != null) {
187:                        sbuf.append(" (");
188:                        sbuf.append(msg);
189:                        sbuf.append(')');
190:                    }
191:                }
192:                return sbuf.toString();
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.