001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    
018    package org.apache.geronimo.gbean;
019    
020    import java.io.Serializable;
021    
022    /**
023     * Describes an attibute of a GBean.
024     *
025     * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
026     */
027    public class GAttributeInfo implements Serializable {
028        /**
029         * Name of this attribute.
030         */
031        private final String name;
032    
033        /**
034         * Type of this attribute.
035         */
036        private final String type;
037    
038        /**
039         * Is this attribute persistent?
040         */
041        private final boolean persistent;
042    
043        /**
044         * Is this attribute manageable?
045         */
046        private final boolean manageable;
047    
048        /**
049         * Is this attribute readable?
050         */
051        private final boolean readable;
052    
053        /**
054         * Is this attribute writiable?
055         */
056        private final boolean writable;
057    
058        /**
059         * Name of the getter method.
060         * The default is "get" + name.  In the case of a defualt value we do a caseless search for the name.
061         */
062        private final String getterName;
063    
064        /**
065         * Name of the setter method.
066         * The default is "set" + name.  In the case of a defualt value we do a caseless search for the name.
067         */
068        private final String setterName;
069    
070        public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, String getterName, String setterName) {
071            this(name, type, persistent, manageable, getterName != null, setterName != null, getterName, setterName);
072        }
073    
074        public GAttributeInfo(String name, String type, boolean persistent, boolean manageable, boolean readable, boolean writable, String getterName, String setterName) {
075            this.name = name;
076            this.type = type;
077            this.persistent = persistent;
078            //non persistent attributes cannot be manageable
079            this.manageable = manageable & persistent;
080            this.readable = readable;
081            this.writable = writable;
082            this.getterName = getterName;
083            this.setterName = setterName;
084        }
085    
086        public String getName() {
087            return name;
088        }
089    
090        public String getType() {
091            return type;
092        }
093    
094        public boolean isPersistent() {
095            return persistent;
096        }
097    
098        public boolean isManageable() {
099            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    }