1 23 package org.objectweb.jorm.metainfo.lib; 24 25 import org.objectweb.jorm.metainfo.api.CompositeName; 26 import org.objectweb.jorm.metainfo.api.MetaObject; 27 import org.objectweb.jorm.metainfo.api.NameRef; 28 import org.objectweb.jorm.metainfo.api.Package; 29 import org.objectweb.jorm.util.api.Loggable; 30 import org.objectweb.util.monolog.api.Logger; 31 import org.objectweb.util.monolog.api.LoggerFactory; 32 import org.objectweb.jorm.metainfo.api.Manager; 33 34 import java.util.Map ; 35 import java.util.HashMap ; 36 37 42 public class BasicNameRef extends BasicMetaObject implements NameRef { 43 44 47 private String name; 48 49 52 private String cnSchemaName = null; 53 54 57 private CompositeName compositeNameClass; 58 59 65 private HashMap projections; 66 67 72 public BasicNameRef(CompositeName cn_Class, MetaObject parent) { 73 super(parent); 74 this.name = cn_Class.getName(); 75 this.compositeNameClass = cn_Class; 76 projections = new HashMap (); 77 } 78 79 84 public void addProjection(String namefield, String classfield) { 85 projections.put(namefield, classfield); 86 } 87 88 92 public Map getProjection() { 93 return projections; 94 } 95 96 101 public String getClassFieldName(String fieldName) { 102 return (String ) projections.get(fieldName); 103 } 104 105 109 public String getName() { 110 return name; 111 } 112 113 117 public CompositeName getCompositeName() { 118 return compositeNameClass; 119 } 120 121 public boolean equals(Object nr) { 122 if (nr instanceof NameRef) 123 return ((NameRef) nr).getName().equals(this.name); 124 else 125 return false; 126 } 127 128 129 public String getCNPackageName() { 130 if (cnSchemaName == null) { 131 MetaObject mo = compositeNameClass; 132 while (!(mo instanceof Package )) { 133 mo = mo.getParent(); 134 if (mo instanceof Manager) return null; 135 } 136 cnSchemaName = ((Package ) mo).getName(); 137 } 138 return cnSchemaName; 139 } 140 141 147 public boolean equalCNType(Object obj) { 148 if (!(obj instanceof NameRef)) return false; 149 return ((name.equals(((NameRef) obj).getName())) && 150 (getCNPackageName().equals(((NameRef) obj).getCNPackageName()))); 151 } 152 } 153 | Popular Tags |