Source Code Cross Referenced for ReportingException.java in  » Web-Server » Rimfaxe-Web-Server » com » rimfaxe » thread » 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 » Web Server » Rimfaxe Web Server » com.rimfaxe.thread 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.rimfaxe.thread;
002:
003:        import java.io.StringWriter;
004:        import java.io.PrintWriter;
005:        import java.util.HashMap;
006:        import java.io.OutputStream;
007:        import java.io.PrintStream;
008:
009:        /** Default base class for all exceptions.
010:         */
011:
012:        public class ReportingException extends Exception {
013:            /** The nested exception */
014:            private ReportingException mNestedException;
015:
016:            /** The name value pair Hashmap */
017:            private HashMap mHashMap = null; // name value pair hashmap
018:
019:            /** Constructs a ReportingException with message of the value passed through
020:             * the constructor.
021:             * @aMsg The msg string passed parameter is the message
022:             * assigned to this ReportingException.
023:             */
024:
025:            public ReportingException(String aMessage) {
026:                super (aMessage);
027:            }
028:
029:            /** the put method inserts name value pairs into the given exception. These values
030:             * should be passed parameters within the method and also other values of interest.
031:             * This method nests ReportingExceptions and stores other Exception values as their stack trace.
032:             * @param aName is a name String
033:             * @param aValue is a value String
034:             */
035:
036:            public synchronized void put(String aName, Object aValue) {
037:                if (aValue instanceof  ReportingException)
038:                    mNestedException = (ReportingException) aValue;
039:                else if (aValue instanceof  Exception) {
040:                    mHashMap.put(aName, getStackTraceOf((Exception) aValue));
041:                } else
042:                    mHashMap.put(aName, aValue);
043:            }
044:
045:            /** the printStackTrace method outputs the stack trace to System.out
046:             *  this overrides the method printStackTrace from Exception.
047:             */
048:
049:            public void printStackTrace() {
050:                //printStackTrace((OutputStream)System.out);
051:            }
052:
053:            /** the printStackTrace method outputs the stack trace to aOutputStream
054:             *  this overrides the method printStackTrace from Exception.
055:             *  @param aKey string.
056:             */
057:
058:            public void printStackTrace(OutputStream aOutputStream) {
059:                PrintStream lPrintStream = new PrintStream(aOutputStream);
060:                lPrintStream.print(getStackTrace());
061:            }
062:
063:            /** the getTrace method returns a String value containing
064:             *  the stack trace for this exception. This does not use getStackTrace
065:             *  which is now implemented in Java 1.4
066:             *  @return String containing stack trace.
067:             */
068:
069:            public String getTrace() {
070:                StringBuffer lBuffer = new StringBuffer();
071:
072:                lBuffer.append("\n\n------------------------\n");
073:                lBuffer.append(this .getMessage());
074:                lBuffer.append("\n------------------------\n\n");
075:                if (mNestedException == null) { // this is the end of the tree -- print the stack trace information
076:                    lBuffer.append(getStackTraceOf(this ));
077:                } else {
078:
079:                    if (!mHashMap.isEmpty()) {
080:                        lBuffer.append("\n-- Name Value Pairs --\n");
081:                        lBuffer.append(mHashMap.toString());
082:                    } else
083:                        lBuffer.append("\n-------------------\n");
084:                    lBuffer.append(mNestedException.getStackTrace()); // recursive call to nested exception
085:                }
086:
087:                return lBuffer.toString();
088:            }
089:
090:            /** Gets the stored nested exception.
091:             *  This method is very useful to the ExceptionHandler which needs to know the entire stack of exceptions.
092:             *   @return nested exception */
093:            public Throwable getNestedException() {
094:                return mNestedException;
095:            }
096:
097:            /** Utility method to get the stack trace string of the specified throwable. */
098:            private String getStackTraceOf(Throwable aThrowable) {
099:                if (aThrowable == null)
100:                    return null;
101:
102:                StringWriter s = new StringWriter();
103:                aThrowable.printStackTrace(new PrintWriter(s));
104:                return s.toString();
105:            }
106:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.