View Javadoc

1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
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.apache.jetspeed.om.profile.psml;
18  
19  import org.apache.jetspeed.services.idgenerator.JetspeedIdGenerator;
20  
21  import org.apache.jetspeed.om.profile.*;
22  
23  /***
24   * Base simple bean-like implementation of the IdentityElement interface
25   * suitable for Castor XML serialization.
26   * 
27   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
28   * @version $Id: PsmlIdentityElement.java,v 1.6 2004/02/23 03:02:54 jford Exp $
29   */
30  public /*abstract*/ class PsmlIdentityElement extends PsmlConfigElement implements IdentityElement, java.io.Serializable                                                
31  {
32  
33      private String id = null;
34      
35      private MetaInfo metaInfo = null;
36  
37      private Skin skin = null;
38  
39      private Layout layout = null;
40  
41      private Control control = null;
42  
43      private Controller controller = null ;
44  
45      public PsmlIdentityElement()
46      {}
47  
48      /*** @see org.apache.jetspeed.om.profile.IdentityElement#getId */
49      public String getId()
50      {
51          if (this.id == null)
52          {
53              this.id = JetspeedIdGenerator.getNextPeid();
54          }
55          return this.id;
56      }
57                                  
58      /*** @see org.apache.jetspeed.om.profile.IdentityElement#setId */
59      public void setId( String id )
60      {
61          this.id = id;
62      }
63    
64      /*** @see org.apache.jetspeed.om.profile.IdentityElement#getSkin */
65      public Skin getSkin()
66      {
67          return this.skin;
68      }
69  
70      /*** @see org.apache.jetspeed.om.profile.IdentityElement#setSkin */
71      public void setSkin(Skin skin)
72      {
73          this.skin = skin;
74      }
75  
76      /*** @see org.apache.jetspeed.om.profile.IdentityElement#getLayout */
77      public Layout getLayout()
78      {
79          return this.layout;
80      }
81  
82      /*** @see org.apache.jetspeed.om.profile.IdentityElement#setLayout */
83      public void setLayout(Layout layout)
84      {
85          this.layout = layout;
86      }
87  
88      /*** @see org.apache.jetspeed.om.profile.IdentityElement#getControl */
89      public Control getControl()
90      {
91          return this.control;
92      }
93  
94      /*** @see org.apache.jetspeed.om.profile.IdentityElement#setControl */
95      public void setControl(Control control)
96      {
97          this.control = control;
98      }
99  
100     public Controller getController()
101     {
102         return this.controller;
103     }
104 
105     public void setController(Controller controller)
106     {
107         this.controller = controller;
108     }
109 
110 
111     // Castor serialization methods
112     
113     /***
114      * Required by Castor 0.8.11 XML serialization for retrieving the metainfo
115      * @see org.apache.jetspeed.om.profile.IdentityElement#getMetaInfo 
116      */
117     public MetaInfo getMetaInfo()
118     {
119         return this.metaInfo;
120     }
121                                 
122     /*** 
123      * Required by Castor 0.8.11 XML serialization for setting the entry
124      * metainfo
125      * @see org.apache.jetspeed.om.profile.IdentityElement#setMetaInfo 
126      */
127     public void setMetaInfo( MetaInfo metaInfo )
128     {
129         this.metaInfo = metaInfo;
130     }
131 
132     // helper getter setters into meta info
133 
134     /*** @see org.apache.jetspeed.om.profile.MetaInfo#getTitle */
135     public String getTitle()
136     {
137         if (this.metaInfo != null)
138         {
139             return this.metaInfo.getTitle();
140         }
141         
142         return null;
143     }
144                                 
145     /*** @see org.apache.jetspeed.om.profile.MetaInfo#setTitle */
146     public void setTitle(String title)
147     {
148         if (this.metaInfo == null)
149         {
150             this.metaInfo = new PsmlMetaInfo();
151         }
152         
153         this.metaInfo.setTitle(title);
154     }
155 
156     /*** @see org.apache.jetspeed.om.profile.MetaInfo#getDescription */
157     public String getDescription()
158     {
159         if (this.metaInfo != null)
160         {
161             return this.metaInfo.getDescription();
162         }
163         
164         return null;
165     }
166                                 
167     /*** @see org.apache.jetspeed.om.profile.MetaInfo#setDescription */
168     public void setDescription(String description)
169     {
170         if (this.metaInfo == null)
171         {
172             this.metaInfo = new PsmlMetaInfo();
173         }
174         
175         this.metaInfo.setDescription(description);
176     }
177 
178     /*** @see org.apache.jetspeed.om.profile.MetaInfo#getImage */
179     public String getImage()
180     {
181         if (this.metaInfo != null)
182         {
183             return this.metaInfo.getImage();
184         }
185         
186         return null;
187     }
188                                 
189     /*** @see org.apache.jetspeed.om.profile.MetaInfo#setImage */
190     public void setImage(String image)
191     {
192         if (this.metaInfo == null)
193         {
194             this.metaInfo = new PsmlMetaInfo();
195         }
196         
197         this.metaInfo.setImage(image);
198     }
199 
200     /***
201      * Create a clone of this object
202      */
203     public Object clone()
204         throws java.lang.CloneNotSupportedException
205     {
206         Object cloned = super.clone();
207         
208         // clone some member variables
209         ((PsmlIdentityElement)cloned).metaInfo = ((this.metaInfo == null) ? null : (MetaInfo) this.metaInfo.clone());
210         ((PsmlIdentityElement)cloned).skin = ((this.skin == null) ? null : (Skin) this.skin.clone());
211         ((PsmlIdentityElement)cloned).layout = ((this.layout == null) ? null : (Layout) this.layout.clone());
212         ((PsmlIdentityElement)cloned).control = ((this.control == null) ? null : (Control) this.control.clone());
213         ((PsmlIdentityElement)cloned).controller = ((this.controller == null) ? null : (Controller) this.controller.clone());
214         
215         return cloned;
216 
217     }   // clone
218 }