Source Code Cross Referenced for AttributeInfo.java in  » Library » Apache-commons-modeler-2.0.1-src » org » apache » commons » modeler » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons modeler 2.0.1 src » org.apache.commons.modeler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.commons.modeler;
019:
020:        import java.io.Serializable;
021:        import java.lang.reflect.Method;
022:
023:        import javax.management.Descriptor;
024:        import javax.management.modelmbean.ModelMBeanAttributeInfo;
025:
026:        /**
027:         * <p>Internal configuration information for an <code>Attribute</code>
028:         * descriptor.</p>
029:         *
030:         * @author Craig R. McClanahan
031:         * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $
032:         */
033:
034:        public class AttributeInfo extends FeatureInfo implements  Serializable {
035:            static final long serialVersionUID = -2511626862303972143L;
036:
037:            // ----------------------------------------------------- Instance Variables
038:
039:            /**
040:             * The <code>ModelMBeanAttributeInfo</code> object that corresponds
041:             * to this <code>AttributeInfo</code> instance.
042:             */
043:            protected transient ModelMBeanAttributeInfo info = null;
044:            protected String displayName = null;
045:            protected String getMethod = null;
046:            protected String setMethod = null;
047:
048:            protected transient Method getMethodObj = null;
049:            protected transient Method setMethodObj = null;
050:
051:            protected boolean readable = true;
052:            protected boolean writeable = true;
053:
054:            protected boolean is = false;
055:            protected String type = null;
056:
057:            protected String persist;
058:            protected String defaultStringValue;
059:
060:            // ------------------------------------------------------------- Properties
061:
062:            /**
063:             * Override the <code>description</code> property setter.
064:             *
065:             * @param description The new description
066:             */
067:            public void setDescription(String description) {
068:                super .setDescription(description);
069:                this .info = null;
070:            }
071:
072:            /**
073:             * Override the <code>name</code> property setter.
074:             *
075:             * @param name The new name
076:             */
077:            public void setName(String name) {
078:                super .setName(name);
079:                this .info = null;
080:            }
081:
082:            /**
083:             * The display name of this attribute.
084:             */
085:            public String getDisplayName() {
086:                return (this .displayName);
087:            }
088:
089:            public void setDisplayName(String displayName) {
090:                this .displayName = displayName;
091:            }
092:
093:            /**
094:             * The name of the property getter method, if non-standard.
095:             */
096:            public String getGetMethod() {
097:                return (this .getMethod);
098:            }
099:
100:            public void setGetMethod(String getMethod) {
101:                this .getMethod = getMethod;
102:                this .info = null;
103:            }
104:
105:            public Method getGetMethodObj() {
106:                return getMethodObj;
107:            }
108:
109:            public void setGetMethodObj(Method getMethodObj) {
110:                this .getMethodObj = getMethodObj;
111:            }
112:
113:            public Method getSetMethodObj() {
114:                return setMethodObj;
115:            }
116:
117:            public void setSetMethodObj(Method setMethodObj) {
118:                this .setMethodObj = setMethodObj;
119:            }
120:
121:            /**
122:             * Is this a boolean attribute with an "is" getter?
123:             */
124:            public boolean isIs() {
125:                return (this .is);
126:            }
127:
128:            public void setIs(boolean is) {
129:                this .is = is;
130:                this .info = null;
131:            }
132:
133:            /**
134:             * Is this attribute readable by management applications?
135:             */
136:            public boolean isReadable() {
137:                return (this .readable);
138:            }
139:
140:            public void setReadable(boolean readable) {
141:                this .readable = readable;
142:                this .info = null;
143:            }
144:
145:            /**
146:             * The name of the property setter method, if non-standard.
147:             */
148:            public String getSetMethod() {
149:                return (this .setMethod);
150:            }
151:
152:            public void setSetMethod(String setMethod) {
153:                this .setMethod = setMethod;
154:                this .info = null;
155:            }
156:
157:            /**
158:             * The fully qualified Java class name of this attribute.
159:             */
160:            public String getType() {
161:                return (this .type);
162:            }
163:
164:            public void setType(String type) {
165:                this .type = type;
166:                this .info = null;
167:            }
168:
169:            /**
170:             * Is this attribute writeable by management applications?
171:             */
172:            public boolean isWriteable() {
173:                return (this .writeable);
174:            }
175:
176:            public void setWriteable(boolean writeable) {
177:                this .writeable = writeable;
178:                this .info = null;
179:            }
180:
181:            /** Persistence policy.
182:             * All persistent attributes should have this attribute set.
183:             * Valid values:
184:             *   ???
185:             */
186:            public String getPersist() {
187:                return persist;
188:            }
189:
190:            public void setPersist(String persist) {
191:                this .persist = persist;
192:            }
193:
194:            /** Default value. If set, it can provide info to the user and
195:             * it can be used by persistence mechanism to generate a more compact
196:             * representation ( a value may not be saved if it's default )
197:             */
198:            public String getDefault() {
199:                return defaultStringValue;
200:            }
201:
202:            public void setDefault(String defaultStringValue) {
203:                this .defaultStringValue = defaultStringValue;
204:            }
205:
206:            // --------------------------------------------------------- Public Methods
207:
208:            /**
209:             * Create and return a <code>ModelMBeanAttributeInfo</code> object that
210:             * corresponds to the attribute described by this instance.
211:             */
212:            public ModelMBeanAttributeInfo createAttributeInfo() {
213:                // Return our cached information (if any)
214:                if (info != null)
215:                    return (info);
216:                if ((getMethodObj != null) || (setMethodObj != null)) {
217:                    try {
218:                        info = new ModelMBeanAttributeInfo(getName(),
219:                                getDescription(), getMethodObj, setMethodObj);
220:                        return info;
221:                    } catch (Exception ex) {
222:                        ex.printStackTrace();
223:                    }
224:                }
225:
226:                // Create and return a new information object
227:                info = new ModelMBeanAttributeInfo(getName(), getType(),
228:                        getDescription(), isReadable(), isWriteable(), false);
229:                Descriptor descriptor = info.getDescriptor();
230:                if (getDisplayName() != null)
231:                    descriptor.setField("displayName", getDisplayName());
232:                if (isReadable()) {
233:                    if (getGetMethod() != null)
234:                        descriptor.setField("getMethod", getGetMethod());
235:                    else
236:                        descriptor.setField("getMethod", getMethodName(
237:                                getName(), true, isIs()));
238:                }
239:                if (isWriteable()) {
240:                    if (getSetMethod() != null)
241:                        descriptor.setField("setMethod", getSetMethod());
242:                    else
243:                        descriptor.setField("setMethod", getMethodName(
244:                                getName(), false, false));
245:                }
246:                addFields(descriptor);
247:                info.setDescriptor(descriptor);
248:                return (info);
249:
250:            }
251:
252:            /**
253:             * Return a string representation of this attribute descriptor.
254:             */
255:            public String toString() {
256:
257:                StringBuffer sb = new StringBuffer("AttributeInfo[");
258:                sb.append("name=");
259:                sb.append(name);
260:                sb.append(", description=");
261:                sb.append(description);
262:                if (!readable) {
263:                    sb.append(", readable=");
264:                    sb.append(readable);
265:                }
266:                sb.append(", type=");
267:                sb.append(type);
268:                if (!writeable) {
269:                    sb.append(", writeable=");
270:                    sb.append(writeable);
271:                }
272:                sb.append("]");
273:                return (sb.toString());
274:
275:            }
276:
277:            // -------------------------------------------------------- Private Methods
278:
279:            /**
280:             * Create and return the name of a default property getter or setter
281:             * method, according to the specified values.
282:             *
283:             * @param name Name of the property itself
284:             * @param getter Do we want a get method (versus a set method)?
285:             * @param is If returning a getter, do we want the "is" form?
286:             */
287:            private String getMethodName(String name, boolean getter, boolean is) {
288:
289:                StringBuffer sb = new StringBuffer();
290:                if (getter) {
291:                    if (is)
292:                        sb.append("is");
293:                    else
294:                        sb.append("get");
295:                } else
296:                    sb.append("set");
297:                sb.append(Character.toUpperCase(name.charAt(0)));
298:                sb.append(name.substring(1));
299:                return (sb.toString());
300:
301:            }
302:
303:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.