Source Code Cross Referenced for PEAException.java in  » Portal » Open-Portal » com » sun » portal » wsrp » consumer » cli » 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 » Portal » Open Portal » com.sun.portal.wsrp.consumer.cli 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: PEAException.java,v 1.4 2005/10/21 16:17:23 jtb Exp $
003:         * Copyright 2003 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.wsrp.consumer.cli;
014:
015:        import java.io.PrintWriter;
016:
017:        import com.sun.portal.desktop.DesktopError;
018:
019:        /**
020:         * A <code>PEAException</code> is thrown when there are errors.
021:         */
022:
023:        public class PEAException extends Exception {
024:
025:            public static final String RESOURCE_BASE = "wsrpPEA";
026:
027:            protected static java.util.Locale locale = java.util.Locale
028:                    .getDefault();
029:
030:            protected java.lang.Throwable origEx = null;
031:            protected java.lang.String key = null;
032:            protected java.lang.Object[] tokens = null;
033:
034:            /*
035:             * CONSTRUCTORS
036:             */
037:
038:            /**
039:             * Constructs an instance of the <code>PEAException</code> class.
040:             * @param key key string to index into resource bundle to retieve
041:             *            localized message
042:             */
043:            public PEAException(java.lang.String key) {
044:                super (key);
045:                this .key = key;
046:            }
047:
048:            /**
049:             * Constructs an instance of the <code>PEAException</code> class.
050:             * @param key key string to index into resource bundle to retieve
051:             *            localized message
052:             * @param tokens array of tokens to be used by the exception message
053:             */
054:            public PEAException(java.lang.String key, java.lang.Object[] tokens) {
055:                super (key);
056:                this .key = key;
057:                this .tokens = tokens;
058:            }
059:
060:            /**
061:             * Constructs an instance of the <code>PEAException</code> class.
062:             * @param key key string to index into resource bundle to retieve
063:             *            localized message
064:             * @param t Throwable object provided by the object which is throwing
065:             */
066:            public PEAException(java.lang.String key, java.lang.Throwable t) {
067:                super (key);
068:                origEx = t;
069:                this .key = key;
070:            }
071:
072:            /**
073:             * Constructs an instance of the <code>PEAException</code> class.
074:             * @param key key string to index into resource bundle to retieve
075:             *            localized message
076:             * @param t Throwable object provided by the object which is throwing 
077:             * @param tokens array of tokens to be used by the exception message
078:             */
079:            public PEAException(java.lang.String key, java.lang.Throwable t,
080:                    java.lang.Object[] tokens) {
081:                super (key);
082:                origEx = t;
083:                this .key = key;
084:                this .tokens = tokens;
085:            }
086:
087:            /**
088:             * Constructs an instance of the <code>PEAException</code> class.
089:             * @param t Throwable object provided by the object which is throwing 
090:             *  the exception
091:             */
092:            public PEAException(java.lang.Throwable t) {
093:                super (t.getMessage());
094:                origEx = t;
095:            }
096:
097:            public static void setLocale(java.util.Locale loc) {
098:                locale = loc;
099:            }
100:
101:            public String getMessage() {
102:                // non-localized resource bundle
103:                java.util.ResourceBundle rb = java.util.PropertyResourceBundle
104:                        .getBundle(RESOURCE_BASE, java.util.Locale.getDefault());
105:                return getMessageFromRB(rb, key, tokens);
106:            }
107:
108:            public Throwable getWrapped() {
109:                return origEx;
110:            }
111:
112:            public String getWrappedMessage() {
113:                String msg = null;
114:                if (origEx != null) {
115:                    if (origEx instanceof  DesktopError) {
116:                        Throwable wrapped = ((DesktopError) origEx).getCause();
117:                        if (wrapped != null) {
118:                            //msg = origEx.getMessage() + wrapped.getMessage();
119:                            msg = wrapped.getMessage();
120:                        } else {
121:                            msg = origEx.getMessage();
122:                        }
123:                    } else {
124:                        msg = origEx.getMessage();
125:                    }
126:                }
127:                return msg;
128:            }
129:
130:            public String getLocalizedMessage() {
131:                // localized resource bundle
132:                java.util.ResourceBundle rb = java.util.PropertyResourceBundle
133:                        .getBundle(RESOURCE_BASE, locale);
134:                String msg = null;
135:                try {
136:                    msg = getMessageFromRB(rb, key, tokens);
137:                } catch (Throwable t) {
138:                    //
139:                    // if it fails to look up resource, just use the key
140:                    // name as the error message
141:                    //
142:                    msg = key;
143:                }
144:                return msg;
145:            }
146:
147:            private String getMessageFromRB(java.util.ResourceBundle rb,
148:                    java.lang.String key, java.lang.Object[] tokens)
149:                    throws java.util.MissingResourceException {
150:
151:                String msg = rb.getString(key);
152:
153:                if (tokens != null && tokens.length > 0) {
154:                    java.text.MessageFormat mf = new java.text.MessageFormat("");
155:                    mf.setLocale(rb.getLocale());
156:                    mf.applyPattern(msg);
157:                    return mf.format(tokens);
158:                } else {
159:                    return msg;
160:                }
161:            }
162:
163:            public void printStackTrace() {
164:                if (origEx != null) {
165:                    origEx.printStackTrace();
166:                } else {
167:                    super .printStackTrace();
168:                }
169:            }
170:
171:            public void printStackTrace(PrintWriter pw) {
172:                if (origEx != null) {
173:                    origEx.printStackTrace(pw);
174:                } else {
175:                    super.printStackTrace(pw);
176:                }
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.