Source Code Cross Referenced for Util.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » util » 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 » Aspect oriented » aspectwerkz 2.0 » org.codehaus.aspectwerkz.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************************
002:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
003:         * http://aspectwerkz.codehaus.org                                                    *
004:         * ---------------------------------------------------------------------------------- *
005:         * The software in this package is published under the terms of the LGPL license      *
006:         * a copy of which has been included with this distribution in the license.txt file.  *
007:         **************************************************************************************/package org.codehaus.aspectwerkz.util;
008:
009:        import org.codehaus.aspectwerkz.reflect.ReflectionInfo;
010:
011:        /**
012:         * Utility methods and constants used in the AspectWerkz system.
013:         *
014:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
015:         */
016:        public final class Util {
017:            public static final Integer INTEGER_DEFAULT_VALUE = new Integer(0);
018:
019:            public static final Float FLOAT_DEFAULT_VALUE = new Float(0.0f);
020:
021:            public static final Double DOUBLE_DEFAULT_VALUE = new Double(0.0d);
022:
023:            public static final Long LONG_DEFAULT_VALUE = new Long(0L);
024:
025:            public static final Boolean BOOLEAN_DEFAULT_VALUE = new Boolean(
026:                    false);
027:
028:            public static final Character CHARACTER_DEFAULT_VALUE = new Character(
029:                    '\u0000');
030:
031:            public static final Short SHORT_DEFAULT_VALUE;
032:
033:            public static final Byte BYTE_DEFAULT_VALUE;
034:
035:            static {
036:                byte b = 0;
037:                BYTE_DEFAULT_VALUE = new Byte(b);
038:                short s = 0;
039:                SHORT_DEFAULT_VALUE = new Short(s);
040:            }
041:
042:            /**
043:             * Calculates the hash for the class name and the meta-data.
044:             *
045:             * @param className the class name
046:             * @param info      the meta-data
047:             * @return the hash
048:             */
049:            public static Integer calculateHash(final String className,
050:                    final ReflectionInfo info) {
051:                if (className == null) {
052:                    throw new IllegalArgumentException(
053:                            "class name can not be null");
054:                }
055:                if (info == null) {
056:                    throw new IllegalArgumentException("info can not be null");
057:                }
058:                int hash = 17;
059:                hash = (37 * hash) + className.hashCode();
060:                hash = (37 * hash) + info.hashCode();
061:                Integer hashKey = new Integer(hash);
062:                return hashKey;
063:            }
064:
065:            /**
066:             * Removes the AspectWerkz specific elements from the stack trace. <p/>TODO: how to mess w/ the stacktrace in JDK
067:             * 1.3.x?
068:             *
069:             * @param exception the Throwable to modify the stack trace on
070:             * @param className the name of the fake origin class of the exception
071:             */
072:            public static void fakeStackTrace(final Throwable exception,
073:                    final String className) {
074:                if (exception == null) {
075:                    throw new IllegalArgumentException(
076:                            "exception can not be null");
077:                }
078:                if (className == null) {
079:                    throw new IllegalArgumentException(
080:                            "class name can not be null");
081:                }
082:
083:                //        final List newStackTraceList = new ArrayList();
084:                //        final StackTraceElement[] stackTrace = exception.getStackTrace();
085:                //        int i;
086:                //        for (i = 1; i < stackTrace.length; i++) {
087:                //            if (stackTrace[i].getClassName().equals(className)) break;
088:                //        }
089:                //        for (int j = i; j < stackTrace.length; j++) {
090:                //            newStackTraceList.add(stackTrace[j]);
091:                //        }
092:                //
093:                //        final StackTraceElement[] newStackTrace =
094:                //                new StackTraceElement[newStackTraceList.size()];
095:                //        int k = 0;
096:                //        for (Iterator it = newStackTraceList.iterator(); it.hasNext(); k++) {
097:                //            final StackTraceElement element = (StackTraceElement)it.next();
098:                //            newStackTrace[k] = element;
099:                //        }
100:                //        exception.setStackTrace(newStackTrace);
101:            }
102:
103:            /**
104:             * Returns a String representation of a classloader Avoid to do a toString() if the resulting string is too long
105:             * (occurs on Tomcat)
106:             *
107:             * @param loader
108:             * @return String representation (toString or FQN@hashcode)
109:             */
110:            public static String classLoaderToString(ClassLoader loader) {
111:                if ((loader != null) && (loader.toString().length() < 120)) {
112:                    return loader.toString() + "@" + loader.hashCode();
113:                } else if (loader != null) {
114:                    return loader.getClass().getName() + "@"
115:                            + loader.hashCode();
116:                } else {
117:                    return "null";
118:                }
119:            }
120:
121:            /**
122:             * Helper method to support Java 1.4 like Boolean.valueOf(boolean) in Java 1.3
123:
124:             * @param b
125:             * @return
126:             */
127:            public static Boolean booleanValueOf(boolean b) {
128:                return b ? Boolean.TRUE : Boolean.FALSE;
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.