2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  /*
19   * $Id: AttributeBean.java 464373 2006-10-16 04:21:54Z rahul $
20   */
21  package org.apache.shale.clay.config.beans;
22  
23  import java.io.Serializable;
24  
25  
26  /***
27   * <p>Represents a value for a component property or a tag attribute.
28   * Instances of this class will be placed in the {@link ComponentBean}
29   * <code>attributes</code> collection.</p>
30   */
31  public class AttributeBean extends SymbolBean implements Serializable {
32  
33      /***
34       * <p>Unique id used by the <code>Serializable</code> interface.</p>
35       */
36      private static final long serialVersionUID = 3102689599088266442L;
37  
38      /***
39       * <p>Mnemonic the signifies the a method binding expression.</p>
40       */
41      public static final String BINDING_TYPE_METHOD = "MB";
42  
43      /***
44       * <p>Mnemonic that signifies a value binding expression.</p>
45       */
46      public static final String BINDING_TYPE_VALUE = "VB";
47  
48      /***
49       * <p>This code means that if the attribute value contains an expression,
50       * it will be evalutated before populating the component.</p>
51       */
52      public static final String BINDING_TYPE_EARLY = "Early";
53  
54      /***
55       * <p>This constant indicates that the attribute value will be passed as its
56       * literal value and no attempt to evaluate a contained expression will
57       * be preformed.</p>
58       */
59      public static final String BINDING_TYPE_NONE = "None";
60  
61      /***
62       * <p>The parent meta component that contains this attribute in its
63       * attributes collection.
64       * </p>
65       */
66      private ComponentBean hasAParent = null;
67  
68      /***
69       * <p>A meta component reference that this object is inherited from.</p>
70       */
71      private AttributeBean isAParent = null;
72  
73      /***
74       * <p>This property represents the type of binding allowed
75       * for this attribute by the component.</p>
76       */
77      private String bindingType = null;
78  
79      /***
80       * <p>A boolean flag that the meta component inheritance has been
81       * resolved for this object instance.
82       * </p>
83       */
84      private boolean isInheritanceFinal = false;
85  
86      /***
87       * @return named value list that represents the object's state
88       */
89      public String toString() {
90          StringBuffer buff = new StringBuffer();
91          buff.append("name=\"").append(getName()).append("\" value=\"").append(getValue())
92              .append("\" bindingType=\"").append(bindingType).append("\"");
93          return buff.toString();
94      }
95  
96      /***
97       * <p>Returns the parent component containing this object instance.</p>
98       *
99       * @return composition parent
100      */
101     public ComponentBean getHasAParent() {
102         return hasAParent;
103     }
104 
105     /***
106      * <p>Sets the parent component that contains this object instance.</p>
107      *
108      * @param bean the composition parent
109      */
110     public void setHasAParent(ComponentBean bean) {
111         hasAParent = bean;
112     }
113 
114     /***
115      * <p>Returns a parent component that this component extends in terms of
116      * a meta relationship.</p>
117      *
118      * @return returns the inheritance parent
119      */
120     public AttributeBean getIsAParent() {
121         return isAParent;
122     }
123 
124     /***
125      * <p>Sets a parent component that this component extends in terms of
126      * a meta relationship.</p>
127      *
128      * @param bean the inheritance parent
129      */
130     public void setIsAParent(AttributeBean bean) {
131         isAParent = bean;
132     }
133 
134     /***
135      * <p>Returns a String that indicates the binding type for the attribute.  The
136      * valid values include ("VB", "MB", "None", "Early").</p>
137      *
138      * @return binding type enumeration
139      */
140     public String getBindingType() {
141        return bindingType;
142     }
143 
144     /***
145      * <p>Sets a String that indicates the binding type for the attribute.  The
146      * valid values include ("VB", "MB", "None", "Early").</p>
147      *
148      * @param bindingType enumeration
149      */
150     public void setBindingType(String bindingType) {
151         if (bindingType != null
152            && (bindingType.equals(BINDING_TYPE_METHOD)
153            || bindingType.equals(BINDING_TYPE_VALUE)
154            || bindingType.equals(BINDING_TYPE_EARLY)
155            || bindingType.equals(BINDING_TYPE_NONE))) {
156 
157             this.bindingType = bindingType;
158         } else {
159             this.bindingType = null;
160         }
161     }
162 
163     /***
164      * <p>Returns boolean that indicates the meta inheritance relationships have
165      * been resolved.</p>
166      *
167      * @return <code>true</code> if inheritance has been resolved
168      */
169     public boolean isInheritanceFinal() {
170         return isInheritanceFinal;
171     }
172 
173     /***
174      * <p>Sets a boolean that indicates the meta inheritance relationships have
175      * been resolved.</p>
176      *
177      * @param b <code>true</code> if inheritance has been resolved
178      */
179     public void setInheritanceFinal(boolean b) {
180         isInheritanceFinal = b;
181     }
182 
183 }
184 
185