Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.tomcat.util.modeler;
 
 
 

Internal configuration information for an Attribute descriptor.

Author(s):
Craig R. McClanahan
 
 public class AttributeInfo extends FeatureInfo implements Serializable {
     static final long serialVersionUID = -2511626862303972143L;
 
     // ----------------------------------------------------- Instance Variables
     protected String displayName = null;
 
     // Information about the method to use
     protected String getMethod = null;
     protected String setMethod = null;
     protected boolean readable = true;
     protected boolean writeable = true;
     protected boolean is = false;
     
     // ------------------------------------------------------------- Properties
 
    
The display name of this attribute.
 
     public String getDisplayName() {
         return (this.);
     }
 
     public void setDisplayName(String displayName) {
         this. = displayName;
     }

    
The name of the property getter method, if non-standard.
 
     public String getGetMethod() {
         if( == null
              = getMethodName(getName(), trueisIs());
         return (this.);
     }
 
     public void setGetMethod(String getMethod) {
         this. = getMethod;
     }

    
Is this a boolean attribute with an "is" getter?
 
     public boolean isIs() {
         return (this.);
     }
 
     public void setIs(boolean is) {
         this. = is;
     }


    
Is this attribute readable by management applications?
 
     public boolean isReadable() {
         return (this.);
     }
 
     public void setReadable(boolean readable) {
         this. = readable;
     }


    
The name of the property setter method, if non-standard.
 
     public String getSetMethod() {
        if == null )
             = getMethodName(getName(), falsefalse);
        return (this.);
    }
    public void setSetMethod(String setMethod) {
        this. = setMethod;
    }

    
Is this attribute writeable by management applications?
    public boolean isWriteable() {
        return (this.);
    }
    public void setWriteable(boolean writeable) {
        this. = writeable;
    }
    // --------------------------------------------------------- Public Methods


    
Create and return a ModelMBeanAttributeInfo object that corresponds to the attribute described by this instance.
        // Return our cached information (if any)
        if ( == null) {
             = new MBeanAttributeInfo(getName(), getType(), getDescription(),
                            isReadable(), isWriteable(), false);
        }
        return (MBeanAttributeInfo);
    }
    // -------------------------------------------------------- Private Methods


    
Create and return the name of a default property getter or setter method, according to the specified values.

Parameters:
name Name of the property itself
getter Do we want a get method (versus a set method)?
is If returning a getter, do we want the "is" form?
    private String getMethodName(String nameboolean getterboolean is) {
        StringBuilder sb = new StringBuilder();
        if (getter) {
            if (is)
                sb.append("is");
            else
                sb.append("get");
        } else
            sb.append("set");
        sb.append(Character.toUpperCase(name.charAt(0)));
        sb.append(name.substring(1));
        return (sb.toString());
    }
New to GrepCode? Check out our FAQ X