KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > PropertyInfo


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
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  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo;
13
14 import java.io.Serializable JavaDoc;
15
16 /**
17  * Serializable information about a property. For properties that are
18  * configurable beans themselves the type will be TYPE_SERVER_BEAN and
19  * the children array will be filled in. The value for these is a bean
20  * defined status object. It should have a useful but short toString().
21  */

22 public class PropertyInfo implements Serializable JavaDoc, Comparable JavaDoc {
23
24     public static final int TYPE_SERVER_BEAN = 1;
25     public static final int TYPE_INT = 2;
26     public static final int TYPE_STRING = 3;
27     public static final int TYPE_BOOLEAN = 4;
28
29     private String JavaDoc name;
30     private int type;
31     private String JavaDoc displayName;
32     private String JavaDoc description;
33     private Object JavaDoc value;
34     private PropertyInfo[] children;
35
36     public PropertyInfo() {
37     }
38
39     public String JavaDoc getName() {
40         return name;
41     }
42
43     public void setName(String JavaDoc name) {
44         this.name = name;
45     }
46
47     public int getType() {
48         return type;
49     }
50
51     public void setType(int type) {
52         this.type = type;
53     }
54
55     public String JavaDoc getDisplayName() {
56         return displayName;
57     }
58
59     public void setDisplayName(String JavaDoc displayName) {
60         this.displayName = displayName;
61     }
62
63     public String JavaDoc getDescription() {
64         return description;
65     }
66
67     public void setDescription(String JavaDoc description) {
68         this.description = description;
69     }
70
71     public Object JavaDoc getValue() {
72         return value;
73     }
74
75     public void setValue(Object JavaDoc value) {
76         this.value = value;
77     }
78
79     public PropertyInfo[] getChildren() {
80         return children;
81     }
82
83     public void setChildren(PropertyInfo[] children) {
84         this.children = children;
85     }
86
87     /**
88      * Order by name.
89      */

90     public int compareTo(Object JavaDoc o) {
91         return name.compareTo(((PropertyInfo)o).name);
92     }
93
94     public String JavaDoc toString() {
95         if (type == TYPE_SERVER_BEAN) {
96             return displayName;
97         }
98         return displayName + ": " + value;
99     }
100
101     /**
102      * Dump to System.out.
103      */

104     public void dump(String JavaDoc indent) {
105         System.out.println(indent + this);
106         if (type == TYPE_SERVER_BEAN) {
107             indent = indent + " ";
108             int n = children.length;
109             for (int i = 0; i < n; i++) children[i].dump(indent);
110         }
111     }
112
113     /**
114      * Find the child with name or null if none.
115      */

116     public PropertyInfo findChild(String JavaDoc name) {
117         if (children == null) return null;
118         for (int i = children.length - 1; i >= 0; i--) {
119             PropertyInfo child = children[i];
120             if (child.name.equals(name)) return child;
121         }
122         return null;
123     }
124 }
125
Popular Tags