1 19 24 25 package org.netbeans.modules.j2ee.sun.sunresources.beans; 26 27 import org.w3c.dom.*; 28 import org.netbeans.modules.schema2beans.*; 29 import java.beans.*; 30 import java.util.*; 31 32 34 public class FieldValue extends org.netbeans.modules.schema2beans.BaseBean 35 { 36 37 static Vector comparators = new Vector(); 38 39 static public final String DEFAULT_FIELD_VALUE = "DefaultFieldValue"; static public final String OPTION_VALUE_PAIR = "OptionValuePair"; 42 public FieldValue() { 43 this(Common.USE_DEFAULT_VALUES); 44 } 45 46 public FieldValue(int options) 47 { 48 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 49 this.createProperty("default-field-value", DEFAULT_FIELD_VALUE, 52 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 53 String .class); 54 this.createProperty("option-value-pair", OPTION_VALUE_PAIR, 56 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 57 OptionValuePair.class); 58 this.initialize(options); 59 } 60 61 void initialize(int options) 63 { 64 65 } 66 67 public void setDefaultFieldValue(String value) { 69 this.setValue(DEFAULT_FIELD_VALUE, value); 70 } 71 72 public String getDefaultFieldValue() { 74 return (String )this.getValue(DEFAULT_FIELD_VALUE); 75 } 76 77 public void setOptionValuePair(int index, OptionValuePair value) { 79 this.setValue(OPTION_VALUE_PAIR, index, value); 80 } 81 82 public OptionValuePair getOptionValuePair(int index) { 84 return (OptionValuePair)this.getValue(OPTION_VALUE_PAIR, index); 85 } 86 87 public void setOptionValuePair(OptionValuePair[] value) { 89 this.setValue(OPTION_VALUE_PAIR, value); 90 } 91 92 public OptionValuePair[] getOptionValuePair() { 94 return (OptionValuePair[])this.getValues(OPTION_VALUE_PAIR); 95 } 96 97 public int sizeOptionValuePair() { 99 return this.size(OPTION_VALUE_PAIR); 100 } 101 102 public int addOptionValuePair(org.netbeans.modules.j2ee.sun.sunresources.beans.OptionValuePair value) { 104 return this.addValue(OPTION_VALUE_PAIR, value); 105 } 106 107 public int removeOptionValuePair(org.netbeans.modules.j2ee.sun.sunresources.beans.OptionValuePair value) { 112 return this.removeValue(OPTION_VALUE_PAIR, value); 113 } 114 115 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 117 comparators.add(c); 118 } 119 120 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 122 comparators.remove(c); 123 } 124 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 125 if (getDefaultFieldValue() == null) { 127 throw new org.netbeans.modules.schema2beans.ValidateException("getDefaultFieldValue() == null", "defaultFieldValue", this); } 129 for (int _index = 0; _index < sizeOptionValuePair(); ++_index) { 131 org.netbeans.modules.j2ee.sun.sunresources.beans.OptionValuePair element = getOptionValuePair(_index); 132 if (element != null) { 133 element.validate(); 134 } 135 } 136 } 137 138 public void dump(StringBuffer str, String indent){ 140 String s; 141 org.netbeans.modules.schema2beans.BaseBean n; 142 str.append(indent); 143 str.append("DefaultFieldValue"); str.append(indent+"\t"); str.append("<"); s = this.getDefaultFieldValue(); 147 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(DEFAULT_FIELD_VALUE, 0, str, indent); 150 151 str.append(indent); 152 str.append("OptionValuePair["+this.sizeOptionValuePair()+"]"); for(int i=0; i<this.sizeOptionValuePair(); i++) 154 { 155 str.append(indent+"\t"); 156 str.append("#"+i+":"); 157 n = (org.netbeans.modules.schema2beans.BaseBean) this.getOptionValuePair(i); 158 if (n != null) 159 n.dump(str, indent + "\t"); else 161 str.append(indent+"\tnull"); this.dumpAttributes(OPTION_VALUE_PAIR, i, str, indent); 163 } 164 165 } 166 public String dumpBeanNode(){ 167 StringBuffer str = new StringBuffer (); 168 str.append("FieldValue\n"); this.dump(str, "\n "); return str.toString(); 171 }} 172 173 175 176 196 | Popular Tags |