| 1 14 15 package com.idaremedia.antx.tests; 16 17 import java.util.Iterator ; 18 import java.util.Map ; 19 20 import org.apache.tools.ant.Project; 21 22 import com.idaremedia.antx.AntX; 23 import com.idaremedia.antx.helpers.Strings; 24 import com.idaremedia.antx.ownhelpers.ProjectDependentSkeleton; 25 26 36 37 public final class UncloneableNothingType extends ProjectDependentSkeleton 38 { 39 42 public UncloneableNothingType() 43 { 44 } 45 46 47 50 public String getId() 51 { 52 return getClass().getName()+"@"+ 53 String.valueOf(System.identityHashCode(this)); 54 } 55 56 57 58 66 public synchronized String getTypeName() 67 { 68 if (m_typeName==null) { 69 verifyInProject_("typeName"); 70 Class myClass = getClass(); 71 Iterator itr= getProject().getDataTypeDefinitions(). 72 entrySet().iterator(); while (itr.hasNext()) { 74 Map.Entry mE= (Map.Entry )itr.next(); 75 if (myClass==mE.getValue()) { 76 m_typeName = (String )mE.getKey(); 77 break; 78 } 79 } 80 } 81 return m_typeName==null ? Strings.NONE : m_typeName; 82 } 83 84 85 86 88 public void setLabel(String label) 89 { 90 m_label = label; 91 StringBuffer sb = new StringBuffer (100); 92 sb.append(label); 93 sb.append(Strings.NL); 94 sb.append("Id: "); 95 sb.append(getId()); 96 sb.append(Strings.NL); 97 sb.append("TypeName: "); 98 sb.append(getTypeName()); 99 System.out.println(sb.toString()); 100 } 101 102 103 104 107 public String toString() 108 { 109 return m_label; 110 } 111 112 113 114 118 protected final void verifyInProject_(String calr) 119 { 120 if (getProject()==null) { 121 String ermsg = AntX.uistrs().get("cv.verifyInP","UncloneableNothingType:",calr); 122 log(ermsg, Project.MSG_ERR); 123 throw new IllegalStateException (ermsg); 124 } 125 } 126 127 128 private String m_label=""; 129 private String m_typeName;} 131 132 133 134 | Popular Tags |