1 23 package org.objectweb.jorm.mapper.rdb.metainfo; 24 25 import org.objectweb.jorm.metainfo.api.MetaObject; 26 import org.objectweb.jorm.metainfo.lib.BasicGenClassMapping; 27 28 import java.util.List ; 29 import java.util.Collection ; 30 31 34 public class RdbGenClassMapping extends BasicGenClassMapping 35 implements RdbMappingInfos { 36 39 private RdbTable table; 40 41 44 List tableNames = null; 45 46 49 List tables = null; 50 51 60 public RdbGenClassMapping(String ruleName, MetaObject linkedMO, 61 MetaObject parent) { 62 super(ruleName,linkedMO, parent); 63 table = null; 64 73 } 74 75 79 80 84 public RdbTable createRdbTable(String tablename) { 85 if (table == null) { 86 table = new RdbTable(this, getLinkedMO(), tablename); 87 table.setLogger(getLogger()); 88 table.setLoggerFactory(getLoggerFactory()); 89 } 90 return table; 91 } 92 93 97 public RdbTable getRdbTable() { 98 return table; 99 } 100 101 public RdbExternalTable createRdbExternalTable(String tableName) { 102 int idx = tableNames.indexOf(tableName); 103 RdbExternalTable t; 104 if (idx == -1) { 105 t = new RdbExternalTable(this, getLinkedMO(), tableName); 106 t.setLogger(getLogger()); 107 t.setLoggerFactory(getLoggerFactory()); 108 tableNames.add(tableName); 109 tables.add(t); 110 } 111 else { 112 t = (RdbExternalTable) tables.get(idx); 113 } 114 return t; 115 } 116 117 public RdbExternalTable removeRdbExternalTable(String tableName) { 118 int idx = tableNames.indexOf(tableName); 119 if (idx != -1) { 120 tableNames.remove(idx); 121 return (RdbExternalTable) tables.remove(idx); 122 } 123 return null; 124 } 125 126 public Collection getRdbExternalTables() { 127 return tables; 128 } 129 130 public RdbExternalTable getRdbExternalTable(String tableName) { 131 int idx = tableNames.indexOf(tableName); 132 if (idx != -1) { 133 return (RdbExternalTable) tables.get(idx); 134 } 135 return null; 136 } 137 public RdbTable getMainTable() { 138 return table; 139 } 140 141 public List getExternalTables() { 142 return tables; 143 } 144 145 public List getExternalTableNames() { 146 return tableNames; 147 } 148 149 } 150 | Popular Tags |