View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  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  package org.apache.geronimo.gbean;
19  
20  import java.io.Serializable;
21  
22  /**
23   * Describes an attibute of a GBean.
24   *
25   * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
26   */
27  public class GAttributeInfo implements Serializable {
28      /**
29       * Name of this attribute.
30       */
31      private final String name;
32  
33      /**
34       * Type of this attribute.
35       */
36      private final String type;
37  
38      /**
39       * Is this attribute persistent?
40       */
41      private final boolean persistent;
42  
43      /**
44       * Is this attribute manageable?
45       */
46      private final boolean manageable;
47  
48      /**
49       * Is this attribute readable?
50       */
51      private final boolean readable;
52  
53      /**
54       * Is this attribute writiable?
55       */
56      private final boolean writable;
57  
58      /**
59       * Name of the getter method.
60       * The default is "get" + name.  In the case of a defualt value we do a caseless search for the name.
61       */
62      private final String getterName;
63  
64      /**
65       * Name of the setter method.
66       * The default is "set" + name.  In the case of a defualt value we do a caseless search for the name.
67       */
68      private final String setterName;
69  
70      public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, String getterName, String setterName) {
71          this(name, type, persistent, manageable, getterName != null, setterName != null, getterName, setterName);
72      }
73  
74      public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, boolean readable, boolean writable, String getterName, String setterName) {
75          this.name = name;
76          this.type = type;
77          this.persistent = persistent;
78          //non persistent attributes cannot be manageable
79          this.manageable = manageable & persistent;
80          this.readable = readable;
81          this.writable = writable;
82          this.getterName = getterName;
83          this.setterName = setterName;
84      }
85  
86      public String getName() {
87          return name;
88      }
89  
90      public String getType() {
91          return type;
92      }
93  
94      public boolean isPersistent() {
95          return persistent;
96      }
97  
98      public boolean isManageable() {
99          return manageable;
100     }
101 
102     public boolean isReadable() {
103         return readable;
104     }
105 
106     public boolean isWritable() {
107         return writable;
108     }
109 
110     public String getGetterName() {
111         return getterName;
112     }
113 
114     public String getSetterName() {
115         return setterName;
116     }
117 
118     public String toString() {
119         return "[GAttributeInfo: name=" + name +
120                 " type=" + type +
121                 " persistent=" + persistent +
122                 " manageable=" + manageable +
123                 " readable=" + readable +
124                 " writable=" + writable +
125                 " getterName=" + getterName +
126                 " setterName=" + setterName +
127                 "]";
128     }
129 }