001: /**
002: * Copyright 2004-2005 jManage.org
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */package org.jmanage.core.management;
016:
017: /**
018: *
019: * date: Aug 13, 2004
020: * @author Rakesh Kalra
021: */
022: public class ObjectFeatureInfo implements java.io.Serializable {
023:
024: protected String name;
025: protected String description;
026:
027: public ObjectFeatureInfo(String name, String description) {
028: this .name = name;
029: this .description = description;
030: }
031:
032: public String getDescription() {
033: if (description == null)
034: return "";
035: return description;
036: }
037:
038: public String getName() {
039: return name;
040: }
041:
042: protected String getDisplayType(String type) {
043: if (type != null && type.startsWith("[")) {
044: /* convert to readable name. e.g. [Ljava.lang.String to
045: java.lang.String[]*/
046: String arrayBraces = "";
047: while (type.startsWith("[")) {
048: type = type.substring(1);
049: arrayBraces += "[]";
050: }
051: type = getArrayDisplayType(type) + arrayBraces;
052: }
053: return type;
054: }
055:
056: /**
057: * Decodes the element type
058: *
059: * <blockquote><table summary="Element types and encodings">
060: * <tr><th> Element Type <th> Encoding
061: * <tr><td> boolean <td align=center> Z
062: * <tr><td> byte <td align=center> B
063: * <tr><td> char <td align=center> C
064: * <tr><td> class or interface <td align=center> L<i>classname;</i>
065: * <tr><td> double <td align=center> D
066: * <tr><td> float <td align=center> F
067: * <tr><td> int <td align=center> I
068: * <tr><td> long <td align=center> J
069: * <tr><td> short <td align=center> S
070: * </table></blockquote>
071: *
072: * @param arrayType encoded element type without the beginning "["
073: * @return
074: */
075: private String getArrayDisplayType(String arrayType) {
076: String dataType;
077: if (arrayType.equals("Z")) {
078: dataType = "boolean";
079: } else if (arrayType.equals("B")) {
080: dataType = "byte";
081: } else if (arrayType.equals("C")) {
082: dataType = "char";
083: } else if (arrayType.equals("D")) {
084: dataType = "double";
085: } else if (arrayType.equals("F")) {
086: dataType = "float";
087: } else if (arrayType.equals("I")) {
088: dataType = "int";
089: } else if (arrayType.equals("J")) {
090: dataType = "long";
091: } else if (arrayType.equals("S")) {
092: dataType = "short";
093: } else if (arrayType.startsWith("L")) {
094: dataType = arrayType.substring(1, arrayType.length() - 1);
095: } else {
096: throw new RuntimeException("Invalid arrayType:" + arrayType);
097: }
098: return dataType;
099: }
100: }
|