1 17 18 19 package org.apache.tomcat.util.modeler; 20 21 22 import java.io.Serializable ; 23 24 import javax.management.MBeanAttributeInfo ; 25 26 27 33 public class AttributeInfo extends FeatureInfo implements Serializable { 34 static final long serialVersionUID = -2511626862303972143L; 35 36 protected String displayName = null; 38 39 protected String getMethod = null; 41 protected String setMethod = null; 42 protected boolean readable = true; 43 protected boolean writeable = true; 44 protected boolean is = false; 45 46 48 51 public String getDisplayName() { 52 return (this.displayName); 53 } 54 55 public void setDisplayName(String displayName) { 56 this.displayName = displayName; 57 } 58 59 62 public String getGetMethod() { 63 if(getMethod == null) 64 getMethod = getMethodName(getName(), true, isIs()); 65 return (this.getMethod); 66 } 67 68 public void setGetMethod(String getMethod) { 69 this.getMethod = getMethod; 70 } 71 72 75 public boolean isIs() { 76 return (this.is); 77 } 78 79 public void setIs(boolean is) { 80 this.is = is; 81 } 82 83 84 87 public boolean isReadable() { 88 return (this.readable); 89 } 90 91 public void setReadable(boolean readable) { 92 this.readable = readable; 93 } 94 95 96 99 public String getSetMethod() { 100 if( setMethod == null ) 101 setMethod = getMethodName(getName(), false, false); 102 return (this.setMethod); 103 } 104 105 public void setSetMethod(String setMethod) { 106 this.setMethod = setMethod; 107 } 108 109 112 public boolean isWriteable() { 113 return (this.writeable); 114 } 115 116 public void setWriteable(boolean writeable) { 117 this.writeable = writeable; 118 } 119 120 122 123 127 MBeanAttributeInfo createAttributeInfo() { 128 if (info == null) { 130 info = new MBeanAttributeInfo (getName(), getType(), getDescription(), 131 isReadable(), isWriteable(), false); 132 } 133 return (MBeanAttributeInfo )info; 134 } 135 136 138 139 147 private String getMethodName(String name, boolean getter, boolean is) { 148 149 StringBuffer sb = new StringBuffer (); 150 if (getter) { 151 if (is) 152 sb.append("is"); 153 else 154 sb.append("get"); 155 } else 156 sb.append("set"); 157 sb.append(Character.toUpperCase(name.charAt(0))); 158 sb.append(name.substring(1)); 159 return (sb.toString()); 160 161 } 162 163 164 } 165 | Popular Tags |