1 23 24 package org.objectweb.medor.query.jorm.lib; 25 26 import org.objectweb.jorm.metainfo.api.GenClassRef; 27 import org.objectweb.jorm.metainfo.api.TypedElement; 28 import org.objectweb.jorm.metainfo.api.MetaObject; 29 import org.objectweb.medor.api.Field; 30 import org.objectweb.medor.api.MedorException; 31 32 import java.util.Iterator ; 33 import java.util.Map ; 34 35 39 public class GenClassExtent extends BasicJormExtent { 40 41 private GenClassRef gcr; 42 43 private String elementFieldName; 44 45 public GenClassExtent() { 46 } 47 48 public GenClassExtent(String _name, String pnFieldName) { 49 super(_name, pnFieldName); 50 } 51 52 59 public GenClassExtent(GenClassRef gcr, 60 String _name, 61 String pnameFieldName, 62 String elemName) throws MedorException { 63 super(_name, pnameFieldName); 64 this.gcr = gcr; 65 66 identifier = new PNameField(getFieldName(name, pnFieldName), gcr, true, this); 68 fields.add(identifier); 69 name2field.put(identifier.getName(), identifier); 70 71 Field f = null; 73 elementFieldName = getFieldName(name, elemName); 74 if (gcr.isClassRef()) { 75 f = new PNameField(elementFieldName, gcr.getClassRef(), this); 76 } else if (gcr.isGenClassRef()) { 77 f = new PNameField(elementFieldName, gcr.getGenClassRef(), false, this); 78 } else if (gcr.isPrimitive()) { 79 f = new BasicJormField(elementFieldName, this, gcr.getPrimitiveElement()); 80 } 81 fields.add(f); 82 name2field.put(f.getName(), f); 83 84 for (Iterator idxIt = gcr.getIndexFields().iterator(); 86 idxIt.hasNext();) { 87 TypedElement te1 = (TypedElement) idxIt.next(); 88 f = new BasicJormField( 89 getFieldName(name, te1.getName()), this, gcr); 90 fields.add(f); 91 name2field.put(f.getName(), f); 92 } 93 } 94 95 public Object clone(Object clone, 96 Map obj2clone) throws CloneNotSupportedException { 97 clone = super.clone(clone, obj2clone); 98 ((GenClassExtent) clone).gcr = gcr; 99 ((GenClassExtent) clone).elementFieldName = elementFieldName; 100 return clone; 101 } 102 103 104 public String getElementFieldName() { 105 return elementFieldName; 106 } 107 108 public MetaObject getMetaObject() { 109 return gcr; 110 } 111 112 public String getJormName() { 113 return gcr.getGenClassId(); 114 } 115 116 } 117 | Popular Tags |