01: package org.andromda.core.configuration;
02:
03: import java.io.Serializable;
04:
05: import java.util.Collection;
06: import java.util.LinkedHashMap;
07: import java.util.Map;
08:
09: /**
10: * A configurable namespace object. These are passed to Plugin instances (Cartridges, etc.).
11: *
12: * @author Chad Brandon
13: */
14: public class Namespace implements Serializable {
15: /**
16: * The namespace name.
17: */
18: private String name;
19:
20: /**
21: * Returns name of this Namespace. Will correspond to a Plugin name (or it can be be 'default' if we want it's
22: * settings to be used everywhere).
23: *
24: * @return String
25: */
26: public String getName() {
27: return this .name;
28: }
29:
30: /**
31: * Sets the name of this Namespace.
32: *
33: * @param name The name to set
34: */
35: public void setName(final String name) {
36: this .name = name;
37: }
38:
39: /**
40: * Stores the collected properties
41: */
42: private final Map properties = new LinkedHashMap();
43:
44: /**
45: * Adds a property to this Namespace object. A property must correspond to a java bean property name on a Plugin in
46: * order for it to be set during processing. Otherwise the property will just be ignored.
47: *
48: * @param property the property to add to this namespace.
49: */
50: public void addProperty(final Property property) {
51: if (property != null) {
52: this .properties.put(property.getName(), property);
53: }
54: }
55:
56: /**
57: * Retrieves the property with the specified name.
58: *
59: * @param name the name of the property.
60: *
61: * @return the property
62: */
63: public Property getProperty(final String name) {
64: return (Property) this .properties.get(name);
65: }
66:
67: /**
68: * Gets all namespaces belonging to this namespaces instance.
69: *
70: * @return all namespaces.
71: */
72: public Collection getProperties() {
73: return this .properties.values();
74: }
75:
76: /**
77: * @see java.lang.Object#toString()
78: */
79: public String toString() {
80: return super .toString() + "[" + this .name + "]";
81: }
82: }
|