001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Rodrigo Westrupp
028: */
029:
030: package com.caucho.amber.cfg;
031:
032: import java.util.HashMap;
033:
034: /**
035: * <attributes> tag in the orm.xml
036: */
037: public class AttributesConfig {
038:
039: // no attributes
040:
041: // elements
042: private HashMap<String, IdConfig> _idMap = new HashMap<String, IdConfig>();
043:
044: private HashMap<String, BasicConfig> _basicMap = new HashMap<String, BasicConfig>();
045:
046: private EmbeddedIdConfig _embeddedId;
047:
048: private HashMap<String, VersionConfig> _versionMap = new HashMap<String, VersionConfig>();
049:
050: private HashMap<String, ManyToOneConfig> _manyToOneMap = new HashMap<String, ManyToOneConfig>();
051:
052: private HashMap<String, OneToManyConfig> _oneToManyMap = new HashMap<String, OneToManyConfig>();
053:
054: private HashMap<String, OneToOneConfig> _oneToOneMap = new HashMap<String, OneToOneConfig>();
055:
056: private HashMap<String, ManyToManyConfig> _manyToManyMap = new HashMap<String, ManyToManyConfig>();
057:
058: private HashMap<String, EmbeddedConfig> _embeddedMap = new HashMap<String, EmbeddedConfig>();
059:
060: private HashMap<String, TransientConfig> _transientMap = new HashMap<String, TransientConfig>();
061:
062: /**
063: * Adds a new <basic>.
064: */
065: public void addBasic(BasicConfig basic) {
066: _basicMap.put(basic.getName(), basic);
067: }
068:
069: /**
070: * Returns the <basic> map.
071: */
072: public HashMap<String, BasicConfig> getBasicMap() {
073: return _basicMap;
074: }
075:
076: /**
077: * Returns a <basic> config.
078: */
079: public BasicConfig getBasic(String name) {
080: return _basicMap.get(name);
081: }
082:
083: /**
084: * Adds a new <id>.
085: */
086: public void addId(IdConfig id) {
087: _idMap.put(id.getName(), id);
088: }
089:
090: /**
091: * Returns the <id> map.
092: */
093: public HashMap<String, IdConfig> getIdMap() {
094: return _idMap;
095: }
096:
097: /**
098: * Returns an <id> config.
099: */
100: public IdConfig getId(String name) {
101: return _idMap.get(name);
102: }
103:
104: /**
105: * Returns the <embedded-id> config.
106: */
107: public EmbeddedIdConfig getEmbeddedId() {
108: return _embeddedId;
109: }
110:
111: /**
112: * Sets the <embedded-id> config.
113: */
114: public void setEmbeddedId(EmbeddedIdConfig embeddedId) {
115: _embeddedId = embeddedId;
116: }
117:
118: public HashMap<String, VersionConfig> getVersionMap() {
119: return _versionMap;
120: }
121:
122: public void addVersion(VersionConfig version) {
123: _versionMap.put(version.getName(), version);
124: }
125:
126: public VersionConfig getVersion(String name) {
127: return _versionMap.get(name);
128: }
129:
130: public HashMap<String, ManyToOneConfig> getManyToOneMap() {
131: return _manyToOneMap;
132: }
133:
134: public void addManyToOne(ManyToOneConfig manyToOne) {
135: _manyToOneMap.put(manyToOne.getName(), manyToOne);
136: }
137:
138: public ManyToOneConfig getManyToOne(String name) {
139: return _manyToOneMap.get(name);
140: }
141:
142: public HashMap<String, OneToManyConfig> getOneToManyMap() {
143: return _oneToManyMap;
144: }
145:
146: public void addOneToMany(OneToManyConfig oneToMany) {
147: _oneToManyMap.put(oneToMany.getName(), oneToMany);
148: }
149:
150: public OneToManyConfig getOneToMany(String name) {
151: return _oneToManyMap.get(name);
152: }
153:
154: public HashMap<String, OneToOneConfig> getOneToOneMap() {
155: return _oneToOneMap;
156: }
157:
158: public void addOneToOne(OneToOneConfig oneToOne) {
159: _oneToOneMap.put(oneToOne.getName(), oneToOne);
160: }
161:
162: public OneToOneConfig getOneToOne(String name) {
163: return _oneToOneMap.get(name);
164: }
165:
166: public HashMap<String, ManyToManyConfig> getManyToManyMap() {
167: return _manyToManyMap;
168: }
169:
170: public void addManyToMany(ManyToManyConfig manyToMany) {
171: _manyToManyMap.put(manyToMany.getName(), manyToMany);
172: }
173:
174: public ManyToManyConfig getManyToMany(String name) {
175: return _manyToManyMap.get(name);
176: }
177:
178: public HashMap<String, EmbeddedConfig> getEmbeddedMap() {
179: return _embeddedMap;
180: }
181:
182: public void addEmbedded(EmbeddedConfig embedded) {
183: _embeddedMap.put(embedded.getName(), embedded);
184: }
185:
186: public EmbeddedConfig getEmbedded(String name) {
187: return _embeddedMap.get(name);
188: }
189:
190: public HashMap<String, TransientConfig> getTransientMap() {
191: return _transientMap;
192: }
193:
194: public void addTransient(TransientConfig transientConfig) {
195: _transientMap.put(transientConfig.getName(), transientConfig);
196: }
197:
198: public TransientConfig getTransient(String name) {
199: return _transientMap.get(name);
200: }
201: }
|