1 8 package org.codehaus.aspectwerkz.util; 9 10 import org.codehaus.aspectwerkz.reflect.ReflectionInfo; 11 12 17 public final class Util { 18 public static final Integer INTEGER_DEFAULT_VALUE = new Integer (0); 19 20 public static final Float FLOAT_DEFAULT_VALUE = new Float (0.0f); 21 22 public static final Double DOUBLE_DEFAULT_VALUE = new Double (0.0d); 23 24 public static final Long LONG_DEFAULT_VALUE = new Long (0L); 25 26 public static final Boolean BOOLEAN_DEFAULT_VALUE = new Boolean (false); 27 28 public static final Character CHARACTER_DEFAULT_VALUE = new Character ('\u0000'); 29 30 public static final Short SHORT_DEFAULT_VALUE; 31 32 public static final Byte BYTE_DEFAULT_VALUE; 33 34 static { 35 byte b = 0; 36 BYTE_DEFAULT_VALUE = new Byte (b); 37 short s = 0; 38 SHORT_DEFAULT_VALUE = new Short (s); 39 } 40 41 48 public static Integer calculateHash(final String className, final ReflectionInfo info) { 49 if (className == null) { 50 throw new IllegalArgumentException ("class name can not be null"); 51 } 52 if (info == null) { 53 throw new IllegalArgumentException ("info can not be null"); 54 } 55 int hash = 17; 56 hash = (37 * hash) + className.hashCode(); 57 hash = (37 * hash) + info.hashCode(); 58 Integer hashKey = new Integer (hash); 59 return hashKey; 60 } 61 62 69 public static void fakeStackTrace(final Throwable exception, final String className) { 70 if (exception == null) { 71 throw new IllegalArgumentException ("exception can not be null"); 72 } 73 if (className == null) { 74 throw new IllegalArgumentException ("class name can not be null"); 75 } 76 77 } 96 97 104 public static String classLoaderToString(ClassLoader loader) { 105 if ((loader != null) && (loader.toString().length() < 120)) { 106 return loader.toString() + "@" + loader.hashCode(); 107 } else if (loader != null) { 108 return loader.getClass().getName() + "@" + loader.hashCode(); 109 } else { 110 return "null"; 111 } 112 } 113 114 120 public static Boolean booleanValueOf(boolean b) { 121 return b?Boolean.TRUE:Boolean.FALSE; 122 } 123 } | Popular Tags |