KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > struts > HeritableComponentDefinition


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
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 package com.blandware.atleap.webapp.struts;
17
18 import org.apache.struts.tiles.ComponentDefinition;
19 import org.apache.struts.tiles.xmlDefinition.XmlDefinition;
20
21 /**
22  * <p>This class provides possibility to get name of parent tiles definition</p>
23  * <p><a HREF="HeritableComponentDefinition.java.htm"><i>View Source</i></a></p>
24  * <p/>
25  *
26  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
27  * @version $Revision: 1.5 $ $Date: 2005/08/04 17:25:20 $
28  */

29 public class HeritableComponentDefinition extends ComponentDefinition {
30
31     /**
32      * Extends attribute value.
33      */

34     private String JavaDoc inherit;
35
36     /**
37      * Copy Constructor.
38      * Creates a new definition initialized with parent definition.
39      * Does a shallow copy : attributes are shared between copies, but not the Map
40      * containing attributes. Added link to parent definition.
41      */

42     public HeritableComponentDefinition(ComponentDefinition definition) {
43         super(definition);
44     }
45
46     /**
47      * Constructor.
48      * Creates a new definition initialized from a RawDefinition.
49      * Raw definitions are used to read definition from a data source (xml file, db, ...).
50      * A RawDefinition mainly contains properties of type String, while Definition
51      * contains more complex type (ex : Controller).
52      * Do a shallow copy : attributes are shared between objects, but not the Map
53      * containing attributes.
54      * OO Design issues : Actually RawDefinition (XmlDefinition) extends ComponentDefinition.
55      * This must not be the case. I have do it because I am lazy.
56      */

57     public HeritableComponentDefinition(XmlDefinition definition) {
58         this((ComponentDefinition) definition);
59         setExtends(definition.getExtends());
60     }
61
62     /**
63      * Sets name of definition that is extented by this one
64      *
65      * @param name Name of the extended definition.
66      */

67     public void setExtends(String JavaDoc name) {
68         inherit = name;
69     }
70
71     /**
72      * Gets name of definition that is extented by this one
73      *
74      * @return Name of the extended definition.
75      */

76     public String JavaDoc getExtends() {
77         return inherit;
78     }
79
80     /**
81      * Gets whether this definition extends some other definition or not
82      *
83      * @return Whether this definition extends some other definition
84      */

85     public boolean isExtending() {
86         return inherit != null;
87     }
88
89 }
90
Popular Tags