1 28 29 package com.idaremedia.antx.apis; 30 31 import org.apache.tools.ant.Project; 32 33 44 45 final class Tk 46 { 47 54 static String leafNameFrom(Class cls) 55 { 56 if (cls==null) { 57 throw new IllegalArgumentException ("leafFrom- NULL class"); 58 } 59 String cn = cls.getName(); 60 int i= cn.lastIndexOf('.'); 61 if (i != -1) { 62 return cn.substring(i+1).replace('$','-'); 63 } 64 return cn; 65 } 66 67 68 69 74 static String identityStringFrom(Object thing) 75 { 76 if (thing==null) { 77 return "null"; 78 } 79 return thing.getClass().getName() 80 +"@" 81 +System.identityHashCode(thing); 82 } 83 84 85 86 95 static String stringFrom(Object thing, Project P) 96 { 97 try { 98 return String.valueOf(thing); 99 } catch(RuntimeException rtX) { 100 if (P!=null) { 101 P.log(rtX.getMessage(),Project.MSG_INFO); 102 } 103 return identityStringFrom(thing); 104 } 105 } 106 107 private Tk() 108 { 109 } 110 } 111 112 | Popular Tags |