1 23 package org.objectweb.jorm.metainfo.lib; 24 25 import org.objectweb.jorm.metainfo.api.Class; 26 import org.objectweb.jorm.metainfo.api.Mapping; 27 import org.objectweb.jorm.metainfo.api.ClassProject; 28 import org.objectweb.jorm.metainfo.api.MetaObject; 29 import org.objectweb.util.monolog.api.BasicLevel; 30 31 import java.util.Collection ; 32 import java.util.HashMap ; 33 import java.util.Set ; 34 35 36 42 public class BasicClassProject extends BasicMetaObject implements ClassProject { 43 46 String projectName; 47 48 51 HashMap mappings; 52 53 61 public BasicClassProject(String projectName, MetaObject parent) { 62 super(parent); 63 this.projectName = projectName; 64 mappings = new HashMap (); 65 } 66 67 71 75 public String getProjectName() { 76 return projectName; 77 } 78 79 83 public void setProjectName(String name) { 84 this.projectName = name; 85 } 86 87 91 public Collection getMappings() { 92 return mappings.values(); 93 } 94 95 101 public Mapping getMapping(String mapperName) { 102 Mapping mapping = (Mapping) mappings.get(mapperName); 103 return mapping; 104 } 105 106 110 public Set getMappers() { 111 return mappings.keySet(); 112 } 113 114 120 public Mapping createMapping(String mapperName) { 121 if (debug) { 122 logger.log(BasicLevel.DEBUG, 123 "Create a new Mapping (" + mapperName + 124 ") for the current ClassProject (" + projectName + ")"); 125 } 126 Mapping mp = (Mapping) mappings.get(mapperName); 128 if (mp == null) { 129 mp = getManager().getMappingFactory(mapperName) 130 .createMapping(mapperName, this); 131 setLoggingOnChild(mp); 132 mappings.put(mapperName, mp); 133 } else { 134 String className = ((Class ) getParent()).getName(); 135 if (debug) { 136 logger.log(BasicLevel.DEBUG, 137 "try to map twice the class (" + className + 138 ") using the mapper (" + mapperName + 139 "), the existing mapping is returned."); 140 } 141 } 142 return mp; 143 } 144 145 protected Collection getChildren() { 146 return mappings.values(); 147 } 148 } 149 | Popular Tags |