1 23 24 package org.objectweb.jorm.metainfo.lib; 25 26 import org.objectweb.jorm.metainfo.api.GenClass; 27 import org.objectweb.jorm.metainfo.api.MetaObject; 28 import org.objectweb.jorm.metainfo.api.PrimitiveElement; 29 import org.objectweb.jorm.type.api.PType; 30 import org.objectweb.jorm.util.api.Loggable; 31 import org.objectweb.util.monolog.api.BasicLevel; 32 import org.objectweb.util.monolog.api.Logger; 33 import org.objectweb.util.monolog.api.LoggerFactory; 34 35 import java.util.Iterator ; 36 import java.util.HashMap ; 37 import java.util.Map ; 38 import java.util.Collection ; 39 40 47 public class BasicGenClass extends BasicMetaObject implements GenClass { 48 51 private String name; 52 53 57 private boolean isAbstract; 58 59 60 65 private Map indexFields; 66 67 76 public BasicGenClass(String name, boolean isAbstract, MetaObject parent) { 77 super(parent); 78 this.name = name; 79 this.isAbstract = isAbstract; 80 indexFields = new HashMap (); 81 } 82 83 87 92 public String getName() { 93 return name; 94 } 95 96 107 public PrimitiveElement createIndexField(String indexFieldName, 108 PType type) { 109 if (debug) 110 logger.log(BasicLevel.DEBUG, 111 "create a new PrimitiveElement (index field (" + 112 indexFieldName + ")) for the current " + "GenClass (" + 113 this.name + ")"); 114 115 PrimitiveElement result = (PrimitiveElement) 117 indexFields.get(indexFieldName); 118 if (result != null) { 119 if (debug) { 120 logger.log(BasicLevel.WARN, 121 "attention, try to create an existing PrimitiveElement (" + 122 name + "), return existing one"); 123 } 124 } else { 125 result = new BasicPrimitiveElement( 127 indexFieldName, type, PType.NOSIZE, PType.NOSIZE, this); 128 setLoggingOnChild(result); 129 indexFields.put(indexFieldName, result); 130 } 131 return result; 132 } 133 134 142 public PrimitiveElement getIndexField(String indexFieldName) { 143 return (PrimitiveElement) indexFields.get(indexFieldName); 144 } 145 146 155 public Iterator iterateIndexField() { 156 return indexFields.values().iterator(); 157 } 158 159 164 public int getIndexFieldNumber() { 165 return indexFields.size(); 166 } 167 168 protected Collection getChildren() { 169 return indexFields.values(); 170 } 171 } 172 173 | Popular Tags |