Java Doc for Exceptions.java in  » Ajax » zk » org » zkoss » lang » 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 » Ajax » zk » org.zkoss.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.zkoss.lang.Exceptions

Exceptions
public class Exceptions (Code)
Utilities for Exceptions.
author:
   tomyeh




Method Summary
final public static  ThrowablefindCause(Throwable ex, Class cause)
     Finds the causes of an exception, ex, to see whether any of them is the givinge type.
final public static  StringformatStackTrace(Throwable t, String prefix)
     Formats the stack trace and returns the result.
final public static  StringBufferformatStackTrace(StringBuffer sb, Throwable t, String prefix)
     Formats the stack trace and appends it to the specified string buffer.
Parameters:
  sb - the string buffer to append the stack trace.
final public static  StringBufferformatStackTrace(StringBuffer sb, Throwable t, String prefix, int maxcnt)
     Formats the stack trace and appends it to the specified string buffer, but only display at most maxcnt lines.

The maximal allowed number of lines is controlled by maxcnt.

final public static  StringgetBriefStackTrace(Throwable t)
     Returns the first few lines of the stack trace.
final public static  ThrowablegetCause(Throwable ex)
     Returns the cause of the given throwable.
final public static  StringgetExtraMessage(Throwable ex)
     Returns the extra message, or null if no extra.
final public static  StringgetMessage(Throwable ex)
     Returns a message of the exception.
final public static  StringgetMessage(int code, Object[] fmtArgs)
     Gets the message for an exception's getMessage method.
final public static  StringgetMessage(int code, Object fmtArg)
     Gets the message for an exception with one format-argument.
final public static  StringgetMessage(int code)
     Gets the message for an exception without format-argument.
final public static  ThrowablegetRealCause(Throwable ex)
     Unveils the real cause.
final public static  Throwableunwrap(Throwable ex)
     Unwraps an exception if the enclosing one is InvocationTargetException or UndeclaredThrowableException.
final public static  Throwablewrap(Throwable ex, Class targetExceptCls)
     Converts an exception to the sepecified class.
final public static  Throwablewrap(Throwable ex, Class targetExceptCls, String msg)
     Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message.
final public static  Throwablewrap(Throwable ex, Class targetExceptCls, int code, Object[] fmtArgs)
     Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message code.
final public static  Throwablewrap(Throwable ex, Class targetExceptCls, int code, Object fmtArg)
     Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message code.
final public static  Throwablewrap(Throwable ex, Class targetExceptCls, int code)
     Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message code.



Method Detail
findCause
final public static Throwable findCause(Throwable ex, Class cause)(Code)
Finds the causes of an exception, ex, to see whether any of them is the givinge type. the cause if found; null if not found



formatStackTrace
final public static String formatStackTrace(Throwable t, String prefix)(Code)
Formats the stack trace and returns the result. Currently, it only adds the prefix to each line.
Parameters:
  prefix - the prefix shown in front of each line of the stack trace;null to denote empty
See Also:   org.zkoss.util.logging.Log.realCause



formatStackTrace
final public static StringBuffer formatStackTrace(StringBuffer sb, Throwable t, String prefix)(Code)
Formats the stack trace and appends it to the specified string buffer.
Parameters:
  sb - the string buffer to append the stack trace. A string bufferwill be created if null.
Parameters:
  prefix - the prefix shown in front of each line of the stack trace;null to denote empty



formatStackTrace
final public static StringBuffer formatStackTrace(StringBuffer sb, Throwable t, String prefix, int maxcnt)(Code)
Formats the stack trace and appends it to the specified string buffer, but only display at most maxcnt lines.

The maximal allowed number of lines is controlled by maxcnt. Note: a stack frame is not counted, if it belongs to java.*, javax.* or sun.*.
Parameters:
  sb - the string buffer to append the stack trace. A string bufferwill be created if null.
Parameters:
  prefix - the prefix shown in front of each line of the stack trace;null to denote empty
Parameters:
  maxcnt - the maximal allowed number of lines to dump (<=0: no limit)




getBriefStackTrace
final public static String getBriefStackTrace(Throwable t)(Code)
Returns the first few lines of the stack trace. It is useful to make the cause exception's stacktrace to be part of the message of the exception thrown to the user.



getCause
final public static Throwable getCause(Throwable ex)(Code)
Returns the cause of the given throwable. It is the same as t.getCause, but it solves the compatibility of J2EE that might not support JDK 1.4.



getExtraMessage
final public static String getExtraMessage(Throwable ex)(Code)
Returns the extra message, or null if no extra.

Currently, it handles only SQLException




getMessage
final public static String getMessage(Throwable ex)(Code)
Returns a message of the exception.



getMessage
final public static String getMessage(int code, Object[] fmtArgs)(Code)
Gets the message for an exception's getMessage method.

It actually delegates to Messages, and then appends an error code.




getMessage
final public static String getMessage(int code, Object fmtArg)(Code)
Gets the message for an exception with one format-argument.



getMessage
final public static String getMessage(int code)(Code)
Gets the message for an exception without format-argument.



getRealCause
final public static Throwable getRealCause(Throwable ex)(Code)
Unveils the real cause. A throwable object is called a real cause, if it doesn't have any cause (or called chained throwable).
Parameters:
  ex - the throwable the real cause; ex itself if it is already the real cause
See Also:   Exceptions.wrap



unwrap
final public static Throwable unwrap(Throwable ex)(Code)
Unwraps an exception if the enclosing one is InvocationTargetException or UndeclaredThrowableException.

Use it if you are catching exceptions thrown by Method.invoke().




wrap
final public static Throwable wrap(Throwable ex, Class targetExceptCls)(Code)
Converts an exception to the sepecified class. If any of causes is the specified class, the cause is returned. If the giving exception is RuntimeException or error, it is re-thrown directly. In other words, Unlike Exceptions.findCause , it is designed to be used in the throw statement as follows.

Usage 1: one kind of exception is examined.


 try {
 ...
 } catch (Exception ex) {
 throw (MyException)Exceptions.wrap(ex, MyException.class);
 }

Usage 2: two kinds of exceptions are examined.


 try {
 ...
 } catch (Exception ex) {
 Throwable t = Exceptions.findCause(ex, AnotherException.class);
 if (t != null)
 throw (AnotherException)t;
 throw (MyException)Exceptions.wrap(ex, MyException.class);
 }

Usage 3: two kinds of exceptions are examined.


 try {
 ...
 } catch (AnotherException ex) {
 throw ex;
 } catch (Exception ex) {
 throw (MyException)Exceptions.wrap(ex, MyException.class);
 }

If you already know the exception, you don't need this method -- AnotherException won't never be RuntimeException or MyException.


 try {
 ...
 } catch (AnotherException ex) {
 throw new MyException(ex);
 }

Note: It assumes the exception has the constructor: MyException(Throwable cause);
Parameters:
  targetExceptCls - the class of exception to be converted to
Parameters:
  ex - the exception being caught (and to be converted)
See Also:   Exceptions.getRealCause
See Also:   SystemException.Aide.wrap




wrap
final public static Throwable wrap(Throwable ex, Class targetExceptCls, String msg)(Code)
Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message. Thus, the target exception class must has the constructor: MyException(String msg, Throwable cause);



wrap
final public static Throwable wrap(Throwable ex, Class targetExceptCls, int code, Object[] fmtArgs)(Code)
Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message code. Thus, the target exception class must has the constructor: MyException(int code, Object[] fmtArgs, Throwable cause);



wrap
final public static Throwable wrap(Throwable ex, Class targetExceptCls, int code, Object fmtArg)(Code)
Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message code. Thus, the target exception class must has the constructor: MyException(int code, Object fmtArgs, Throwable cause);



wrap
final public static Throwable wrap(Throwable ex, Class targetExceptCls, int code)(Code)
Converts an exception to the sepecified class plus a message. It is similar to Exceptions.wrap(Throwable,Class) but with an additional message code. Thus, the target exception class must has the constructor: MyException(int code, Throwable cause);



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.