KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > components > ComponentVersion


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH.
17  * Portions created by the Initial Developer are Copyright (C) 2006
18  * the Initial Developer. All Rights Reserved.
19  *
20  * Contributor(s):
21  * Felix Gnass [fgnass at neteye dot de]
22  *
23  * ***** END LICENSE BLOCK ***** */

24 package org.riotfamily.components;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.Map JavaDoc;
28
29 /**
30  * Versioned model for a component. The component properties are stored as
31  * map of Strings, additionally a type information is included which is used
32  * to look up a {@link Component} instance from the {@link ComponentRepository}.
33  */

34 public class ComponentVersion {
35
36     private Long JavaDoc id;
37
38     private String JavaDoc type;
39
40     private Map JavaDoc properties;
41
42     private boolean dirty;
43
44     private VersionContainer container;
45
46     public ComponentVersion() {
47     }
48
49     public ComponentVersion(String JavaDoc type) {
50         this.type = type;
51     }
52
53     public ComponentVersion(ComponentVersion prototype) {
54         if (prototype != null) {
55             this.type = prototype.getType();
56             this.container = prototype.getContainer();
57             this.properties = new HashMap JavaDoc(prototype.getProperties());
58         }
59     }
60
61     /**
62      * Returns the entity's id set via {@link #setId(Long)}.
63      */

64     public Long JavaDoc getId() {
65         return this.id;
66     }
67
68     /**
69      * Sets the entity's id.
70      */

71     public void setId(Long JavaDoc id) {
72         this.id = id;
73     }
74
75     /**
76      * Returns the component-type. The String returned by this method is used
77      * to lookup a component implementation from the ComponentRepository.
78      */

79     public String JavaDoc getType() {
80         return this.type;
81     }
82
83     /**
84      * Sets the component-type.
85      */

86     public void setType(String JavaDoc type) {
87         this.type = type;
88         setDirty(true);
89     }
90
91     public Map JavaDoc getProperties() {
92         if (properties == null) {
93             properties = new HashMap JavaDoc();
94         }
95         return properties;
96     }
97
98     public void setProperties(Map JavaDoc properties) {
99         this.properties = properties;
100     }
101
102     public String JavaDoc getProperty(String JavaDoc key) {
103         if (properties == null) {
104             return null;
105         }
106         return (String JavaDoc) properties.get(key);
107     }
108
109     public void setProperty(String JavaDoc key, String JavaDoc text) {
110         getProperties().put(key, text);
111         setDirty(true);
112     }
113
114     /**
115      * Returns the VersionContainer this version belongs to.
116      */

117     public VersionContainer getContainer() {
118         return container;
119     }
120
121     public void setContainer(VersionContainer container) {
122         this.container = container;
123     }
124
125     public boolean isDirty() {
126         return this.dirty;
127     }
128
129     public void setDirty(boolean dirty) {
130         this.dirty = dirty;
131     }
132
133 }
134
Popular Tags