1 23 24 package org.objectweb.jorm.metainfo.lib; 25 26 import org.objectweb.jorm.metainfo.api.Class; 27 import org.objectweb.jorm.metainfo.api.*; 28 import org.objectweb.jorm.type.api.PType; 29 import org.objectweb.util.monolog.api.BasicLevel; 30 31 import java.util.ArrayList ; 32 import java.util.Iterator ; 33 import java.util.Collection ; 34 35 40 public class BasicClassRef extends BasicMetaObject 41 implements ClassRef, Comparable { 42 45 private String fieldName; 46 47 50 private Class currentClass; 51 56 private ArrayList nameDefs; 57 58 59 68 public BasicClassRef(String fieldName, Class currentClass, MetaObject parent) { 69 super(parent); 70 this.fieldName = fieldName; 71 this.currentClass = currentClass; 72 nameDefs = new ArrayList (); 73 } 74 75 public int compareTo(Object o) { 76 return fieldName.compareTo(((TypedElement) o).getName()); 77 } 78 79 83 89 public Class getMOClass() { 90 return currentClass; 91 } 92 93 98 public String getClassName() { 99 return currentClass.getName(); 100 } 101 102 106 111 public String getName() { 112 return fieldName; 113 } 114 115 120 public PType getType() { 121 return currentClass.getPType(); 122 } 123 124 128 137 138 public NameDef createRefNameDef() { 139 if (debug) 140 logger.log(BasicLevel.DEBUG, 141 "create a new NameDef () for the current ClassRef (" + fieldName + ")"); 142 BasicNameDef newNameDef = new BasicNameDef(this); 144 setLoggingOnChild(newNameDef); 145 nameDefs.add(newNameDef); 146 return newNameDef; 147 } 148 149 156 public NameDef getRefNameDef(String name) { 157 for (Iterator iter = nameDefs.iterator(); iter.hasNext();) { 158 NameDef nameDef = (NameDef) iter.next(); 159 if (nameDef.getName().equals(name)) { 160 return nameDef; 161 } 162 } 163 return null; 164 } 165 166 173 174 public Collection getRefNameDef() { 175 return nameDefs; 176 } 177 178 protected Collection getChildren() { 179 return nameDefs; 180 } 181 } 182 | Popular Tags |