1 4 package com.tc.aspectwerkz.util; 5 6 import com.tc.aspectwerkz.reflect.ReflectionInfo; 7 8 13 public final class Util { 14 public static final Integer INTEGER_DEFAULT_VALUE = new Integer (0); 15 16 public static final Float FLOAT_DEFAULT_VALUE = new Float (0.0f); 17 18 public static final Double DOUBLE_DEFAULT_VALUE = new Double (0.0d); 19 20 public static final Long LONG_DEFAULT_VALUE = new Long (0L); 21 22 public static final Boolean BOOLEAN_DEFAULT_VALUE = new Boolean (false); 23 24 public static final Character CHARACTER_DEFAULT_VALUE = new Character ('\u0000'); 25 26 public static final Short SHORT_DEFAULT_VALUE; 27 28 public static final Byte BYTE_DEFAULT_VALUE; 29 30 static { 31 byte b = 0; 32 BYTE_DEFAULT_VALUE = new Byte (b); 33 short s = 0; 34 SHORT_DEFAULT_VALUE = new Short (s); 35 } 36 37 44 public static Integer calculateHash(final String className, final ReflectionInfo info) { 45 if (className == null) { 46 throw new IllegalArgumentException ("class name can not be null"); 47 } 48 if (info == null) { 49 throw new IllegalArgumentException ("info can not be null"); 50 } 51 int hash = 17; 52 hash = (37 * hash) + className.hashCode(); 53 hash = (37 * hash) + info.hashCode(); 54 Integer hashKey = new Integer (hash); 55 return hashKey; 56 } 57 58 65 public static void fakeStackTrace(final Throwable exception, final String className) { 66 if (exception == null) { 67 throw new IllegalArgumentException ("exception can not be null"); 68 } 69 if (className == null) { 70 throw new IllegalArgumentException ("class name can not be null"); 71 } 72 73 } 92 93 100 public static String classLoaderToString(ClassLoader loader) { 101 if ((loader != null) && (loader.toString().length() < 120)) { 102 return loader.toString() + "@" + loader.hashCode(); 103 } else if (loader != null) { 104 return loader.getClass().getName() + "@" + loader.hashCode(); 105 } else { 106 return "null"; 107 } 108 } 109 110 116 public static Boolean booleanValueOf(boolean b) { 117 return b ? Boolean.TRUE : Boolean.FALSE; 118 } 119 } | Popular Tags |