01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.romaframework.core.schema;
18:
19: import java.io.Serializable;
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: import org.romaframework.core.util.DynaBean;
24:
25: public abstract class SchemaFeatures implements Cloneable, Serializable {
26:
27: protected Map<String, DynaBean> allFeatures;
28:
29: public SchemaFeatures() {
30: allFeatures = new HashMap<String, DynaBean>();
31: }
32:
33: @Override
34: protected Object clone() throws CloneNotSupportedException {
35: SchemaFeatures cloned = (SchemaFeatures) super .clone();
36: cloned.allFeatures = new HashMap<String, DynaBean>();
37: for (Map.Entry<String, DynaBean> entry : allFeatures.entrySet()) {
38: cloned.allFeatures.put(entry.getKey(), (DynaBean) entry
39: .getValue().clone());
40: }
41: return cloned;
42: }
43:
44: public Map<String, DynaBean> getAllFeatures() {
45: return allFeatures;
46: }
47:
48: public DynaBean getFeatures(String iAspectName) {
49: return allFeatures.get(iAspectName);
50: }
51:
52: public void setFeatures(String iAspectName, DynaBean iFeatures) {
53: allFeatures.put(iAspectName, iFeatures);
54: }
55:
56: public Object getFeature(String iAspectName, String iFeatureName) {
57: DynaBean features = getFeatures(iAspectName);
58: if (features != null)
59: return features.getAttribute(iFeatureName);
60: return null;
61: }
62:
63: public void setFeature(String iAspectName, String iFeatureName,
64: Object iFeatureValue) {
65: getFeatures(iAspectName).setAttribute(iFeatureName,
66: iFeatureValue);
67: }
68: }
|