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 FieldGroup extends org.netbeans.modules.schema2beans.BaseBean 35 { 36 37 static Vector comparators = new Vector(); 38 39 static public final String NAME = "Name"; static public final String FIELD = "Field"; 42 public FieldGroup() { 43 this(Common.USE_DEFAULT_VALUES); 44 } 45 46 public FieldGroup(int options) 47 { 48 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 49 this.createProperty("name", NAME, 52 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 53 String .class); 54 this.createProperty("field", FIELD, 56 Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY, 57 Field.class); 58 this.createAttribute(FIELD, "field-type", "FieldType", 59 AttrProp.CDATA, 60 null, "string"); 61 this.createAttribute(FIELD, "required", "Required", 62 AttrProp.CDATA, 63 null, "true"); 64 this.initialize(options); 65 } 66 67 void initialize(int options) 69 { 70 71 } 72 73 public void setName(String value) { 75 this.setValue(NAME, value); 76 } 77 78 public String getName() { 80 return (String )this.getValue(NAME); 81 } 82 83 public void setField(int index, Field value) { 85 this.setValue(FIELD, index, value); 86 } 87 88 public Field getField(int index) { 90 return (Field)this.getValue(FIELD, index); 91 } 92 93 public void setField(Field[] value) { 95 this.setValue(FIELD, value); 96 } 97 98 public Field[] getField() { 100 return (Field[])this.getValues(FIELD); 101 } 102 103 public int sizeField() { 105 return this.size(FIELD); 106 } 107 108 public int addField(org.netbeans.modules.j2ee.sun.sunresources.beans.Field value) { 110 return this.addValue(FIELD, value); 111 } 112 113 public int removeField(org.netbeans.modules.j2ee.sun.sunresources.beans.Field value) { 118 return this.removeValue(FIELD, value); 119 } 120 121 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 123 comparators.add(c); 124 } 125 126 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 128 comparators.remove(c); 129 } 130 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 131 if (getName() == null) { 133 throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); } 135 if (sizeField() == 0) { 137 throw new org.netbeans.modules.schema2beans.ValidateException("sizeField() == 0", "field", this); } 139 for (int _index = 0; _index < sizeField(); ++_index) { 140 org.netbeans.modules.j2ee.sun.sunresources.beans.Field element = getField(_index); 141 if (element != null) { 142 element.validate(); 143 } 144 } 145 } 146 147 public void dump(StringBuffer str, String indent){ 149 String s; 150 org.netbeans.modules.schema2beans.BaseBean n; 151 str.append(indent); 152 str.append("Name"); str.append(indent+"\t"); str.append("<"); s = this.getName(); 156 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(NAME, 0, str, indent); 159 160 str.append(indent); 161 str.append("Field["+this.sizeField()+"]"); for(int i=0; i<this.sizeField(); i++) 163 { 164 str.append(indent+"\t"); 165 str.append("#"+i+":"); 166 n = (org.netbeans.modules.schema2beans.BaseBean) this.getField(i); 167 if (n != null) 168 n.dump(str, indent + "\t"); else 170 str.append(indent+"\tnull"); this.dumpAttributes(FIELD, i, str, indent); 172 } 173 174 } 175 public String dumpBeanNode(){ 176 StringBuffer str = new StringBuffer (); 177 str.append("FieldGroup\n"); this.dump(str, "\n "); return str.toString(); 180 }} 181 182 184 185 205 | Popular Tags |