View Javadoc

1   
2   /*
3    * Copyright (c) 2005-2007 Creative Sphere Limited.
4    * All rights reserved. This program and the accompanying materials
5    * are made available under the terms of the Eclipse Public License v1.0
6    * which accompanies this distribution, and is available at
7    * http://www.eclipse.org/legal/epl-v10.html
8    *
9    * Contributors:
10   *
11   *   Creative Sphere - initial API and implementation
12   *
13   */
14  package org.abstracthorizon.danube.beanconsole;
15  
16  /**
17   * This bean represents a definition of an object or a property
18   *
19   * @author Daniel Sendula
20   */
21  public class BeanDef {
22  
23      /** Constant describing no access */
24      public static final String NO_ACCESS = "-";
25  
26      /** Constant describing read only access through bean info */
27      public static final String RO = "RO";
28  
29      /** Constant describing read/write access through bean info */
30      public static final String RW = "RW";
31  
32      /** Constant describing write only access through bean info */
33      public static final String WO = "WO";
34  
35      /** Constant describing read/write access through reflection (no property editors for the type) */
36      public static final String RW_RAW = "rw";
37  
38      /** Constant describing read only access through reflection (no property editors for the type) */
39      public static final String RO_RAW = "ro";
40  
41      /** Constant describing write only access through reflection (no property editors for the type) */
42      public static final String WO_RAW = "wo";
43  
44      /** Max value size */
45      public static final int MAX_VALUE_SIZE = 70;
46  
47      /** Max type size */
48      public static final int MAX_TYPE_SIZE = 16;
49  
50      /** Object's or property's name */
51      protected String name;
52  
53      /** Object's or property's description */
54      protected String desc;
55  
56      /** Object's or property's type */
57      protected String type;
58  
59      /** Object's or property's type shortened to the {@link #MAX_TYPE_SIZE} characters */
60      protected String shortType;
61  
62      /** Object's or property's acess type */
63      protected String access;
64  
65      /** Object's or property's value as an string */
66      protected String value;
67  
68      /** Object's or property's value as an string shortened to the max {@link #MAX_VALUE_SIZE} characters */
69      protected String shortValue;
70  
71      /** Does the object or property contain the reference that can be followed */
72      protected boolean followable;
73  
74      /**
75       * Constructor
76       * @param name name
77       * @param type type
78       * @param access access
79       * @param value value
80       * @param followable is followable
81       */
82      public BeanDef(String name, String desc, String type, String access, String value, boolean followable) {
83          this.name = name;
84          this.desc = desc;
85          this.type = type;
86          this.access = access;
87          this.value = value;
88          this.followable = followable;
89  
90          if (value.length() > MAX_VALUE_SIZE) {
91              shortValue = value.substring(0, MAX_VALUE_SIZE) + "...";
92          } else {
93              shortValue = value;
94          }
95  
96          if (type.length() > MAX_TYPE_SIZE) {
97              int i = type.indexOf('.');
98              int j = type.lastIndexOf('.');
99              if (i+4 >= j) {
100                 shortType = type;
101             } else {
102                 shortType = type.substring(0, i+4) + ".." + type.substring(j);
103             }
104 
105 
106         } else {
107             shortType = type;
108         }
109     }
110 
111     /**
112      * Returns name
113      * @return name
114      */
115     public String getName() {
116         return name;
117     }
118 
119     /**
120      * Returns desc
121      * @return desc
122      */
123     public String getDesc() {
124         return desc;
125     }
126 
127     /**
128      * Returns type
129      * @return type
130      */
131     public String getType() {
132         return type;
133     }
134 
135     /**
136      * Returns short type
137      * @return short type
138      */
139     public String getShortType() {
140         return shortType;
141     }
142 
143     /**
144      * Returns access
145      * @return access
146      */
147     public String getAccess() {
148         return access;
149     }
150 
151     /**
152      * Returns value
153      * @return value
154      */
155     public String getValue() {
156         return value;
157     }
158 
159     /**
160      * Returns short value
161      * @return short value
162      */
163     public String getShortValue() {
164         return shortValue;
165     }
166 
167     /**
168      * Returns followable flag
169      * @return followable flag
170      */
171     public boolean isFollowable() {
172         return followable;
173     }
174 
175     /**
176      * Returns followable flag
177      * @return followable flag
178      */
179     public boolean getFollowable() {
180         return followable;
181     }
182 }