KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > profileservice > simple1 > PropertyInfoImpl


1 package org.jboss.test.profileservice.simple1;
2
3 import org.jboss.profileservice.spi.PropertyInfo;
4 import org.jboss.profileservice.spi.OpenType;
5
6 import java.util.Set JavaDoc;
7 import java.util.Map JavaDoc;
8 import java.util.HashMap JavaDoc;
9
10 /**
11  * @author ccrouch@jboss.org
12  * @version $Revision$
13  */

14 public class PropertyInfoImpl implements PropertyInfo {
15
16     private String JavaDoc name;
17     private Object JavaDoc value;
18     private Map JavaDoc fields;
19
20
21     public PropertyInfoImpl(String JavaDoc name, OpenType type) {
22         fields = new HashMap JavaDoc();
23         this.name = name;
24         fields.put("openType", type);
25     }
26
27     public String JavaDoc getName() {
28         return name;
29     }
30
31     public String JavaDoc getDescription() {
32         return (String JavaDoc) fields.get("org.jboss.profileservice.description");
33     }
34
35     public Set JavaDoc<?> getLegalValues() {
36          return (Set JavaDoc<?>) fields.get("legalValues");
37     }
38
39     public Comparable JavaDoc<?> getMinValue() {
40         return null;
41     }
42
43     public Comparable JavaDoc<?> getMaxValue() {
44         return null;
45     }
46
47     public boolean isValue(Object JavaDoc obj) {
48         return false;
49     }
50
51     public OpenType<?> getOpenType() {
52         return (OpenType<?>) fields.get("openType");
53     }
54
55    public Object JavaDoc getFieldValue(String JavaDoc fieldName)
56    {
57       return fields.get(fieldName);
58    }
59
60    public void setFields(String JavaDoc[] fieldNames, Object JavaDoc[] fieldValues)
61    {
62       if (fieldNames == null || fieldValues == null)
63       {
64          throw new IllegalArgumentException JavaDoc("Neither fieldNames array nor fieldValues array can be null");
65       }
66
67       if (fieldNames.length != fieldValues.length)
68       {
69          throw new IllegalArgumentException JavaDoc("size of fieldNames array must match size of fieldValues array");
70       }
71
72       for (int i=0; i<fieldNames.length; i++)
73       {
74          fields.put(fieldNames[i], fieldValues[i]);
75       }
76    }
77
78
79    public Object JavaDoc getValue() {
80        return value;
81    }
82
83     public void setValue(Object JavaDoc value) {
84         this.value = value;
85     }
86 }
87
Popular Tags