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