KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > management > ObjectFeatureInfo


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.core.management;
17
18 /**
19  *
20  * date: Aug 13, 2004
21  * @author Rakesh Kalra
22  */

23 public class ObjectFeatureInfo implements java.io.Serializable JavaDoc {
24
25     protected String JavaDoc name;
26     protected String JavaDoc description;
27
28     public ObjectFeatureInfo(String JavaDoc name, String JavaDoc description) {
29         this.name = name;
30         this.description = description;
31     }
32
33     public String JavaDoc getDescription() {
34         if(description == null)
35             return "";
36         return description;
37     }
38
39     public String JavaDoc getName() {
40         return name;
41     }
42
43     protected String JavaDoc getDisplayType(String JavaDoc type){
44         if(type != null && type.startsWith("[")){
45             /* convert to readable name. e.g. [Ljava.lang.String to
46                 java.lang.String[]*/

47             String JavaDoc arrayBraces = "";
48             while(type.startsWith("[")){
49                 type = type.substring(1);
50                 arrayBraces += "[]";
51             }
52             type = getArrayDisplayType(type) + arrayBraces;
53         }
54         return type;
55     }
56
57     /**
58      * Decodes the element type
59      *
60      * <blockquote><table summary="Element types and encodings">
61      * <tr><th> Element Type <th> Encoding
62      * <tr><td> boolean <td align=center> Z
63      * <tr><td> byte <td align=center> B
64      * <tr><td> char <td align=center> C
65      * <tr><td> class or interface <td align=center> L<i>classname;</i>
66      * <tr><td> double <td align=center> D
67      * <tr><td> float <td align=center> F
68      * <tr><td> int <td align=center> I
69      * <tr><td> long <td align=center> J
70      * <tr><td> short <td align=center> S
71      * </table></blockquote>
72      *
73      * @param arrayType encoded element type without the beginning "["
74      * @return
75      */

76     private String JavaDoc getArrayDisplayType(String JavaDoc arrayType){
77         String JavaDoc dataType;
78         if(arrayType.equals("Z")){
79             dataType = "boolean";
80         }else if(arrayType.equals("B")){
81             dataType = "byte";
82         }else if(arrayType.equals("C")){
83             dataType = "char";
84         }else if(arrayType.equals("D")){
85             dataType = "double";
86         }else if(arrayType.equals("F")){
87             dataType = "float";
88         }else if(arrayType.equals("I")){
89             dataType = "int";
90         }else if(arrayType.equals("J")){
91             dataType = "long";
92         }else if(arrayType.equals("S")){
93             dataType = "short";
94         }else if(arrayType.startsWith("L")){
95             dataType = arrayType.substring(1, arrayType.length() - 1);
96         }else{
97             throw new RuntimeException JavaDoc("Invalid arrayType:" + arrayType);
98         }
99         return dataType;
100     }
101 }
102
Popular Tags