Source Code Cross Referenced for Util.java in  » Net » Terracotta » com » tc » 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 » Net » Terracotta » com.tc.aspectwerkz.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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