1 19 24 25 package org.netbeans.modules.j2ee.sun.sunresources.beans; 26 import org.netbeans.modules.schema2beans.*; 27 import java.util.*; 28 29 31 public class Field extends org.netbeans.modules.schema2beans.BaseBean 32 { 33 34 static Vector comparators = new Vector(); 35 36 static public final String FIELDTYPE = "FieldType"; static public final String REQUIRED = "Required"; static public final String NAME = "Name"; static public final String FIELD_VALUE = "FieldValue"; static public final String TAG = "Tag"; 42 public Field() { 43 this(Common.USE_DEFAULT_VALUES); 44 } 45 46 public Field(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-value", FIELD_VALUE, 56 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 57 FieldValue.class); 58 this.createProperty("tag", TAG, 60 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 61 Tag.class); 62 this.initialize(options); 63 } 64 65 void initialize(int options) 67 { 68 69 } 70 71 public void setFieldType(java.lang.String value) { 73 setAttributeValue(FIELDTYPE, value); 74 } 75 76 public java.lang.String getFieldType() { 78 return getAttributeValue(FIELDTYPE); 79 } 80 81 public void setRequired(java.lang.String value) { 83 setAttributeValue(REQUIRED, value); 84 } 85 86 public java.lang.String getRequired() { 88 return getAttributeValue(REQUIRED); 89 } 90 91 public void setName(String value) { 93 this.setValue(NAME, value); 94 } 95 96 public String getName() { 98 return (String )this.getValue(NAME); 99 } 100 101 public void setFieldValue(FieldValue value) { 103 this.setValue(FIELD_VALUE, value); 104 } 105 106 public FieldValue getFieldValue() { 108 return (FieldValue)this.getValue(FIELD_VALUE); 109 } 110 111 public void setTag(Tag value) { 113 this.setValue(TAG, value); 114 } 115 116 public Tag getTag() { 118 return (Tag)this.getValue(TAG); 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 (getFieldType() == null) { 133 throw new org.netbeans.modules.schema2beans.ValidateException("getFieldType() == null", "fieldType", this); } 135 if (getRequired() == null) { 137 throw new org.netbeans.modules.schema2beans.ValidateException("getRequired() == null", "required", this); } 139 if (getName() == null) { 141 throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); } 143 if (getFieldValue() == null) { 145 throw new org.netbeans.modules.schema2beans.ValidateException("getFieldValue() == null", "fieldValue", this); } 147 getFieldValue().validate(); 148 if (getTag() != null) { 150 getTag().validate(); 151 } 152 } 153 154 public void dump(StringBuffer str, String indent){ 156 String s; 157 org.netbeans.modules.schema2beans.BaseBean n; 158 str.append(indent); 159 str.append("Name"); str.append(indent+"\t"); str.append("<"); s = this.getName(); 163 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(NAME, 0, str, indent); 166 167 str.append(indent); 168 str.append("FieldValue"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getFieldValue(); 170 if (n != null) 171 n.dump(str, indent + "\t"); else 173 str.append(indent+"\tnull"); this.dumpAttributes(FIELD_VALUE, 0, str, indent); 175 176 str.append(indent); 177 str.append("Tag"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getTag(); 179 if (n != null) 180 n.dump(str, indent + "\t"); else 182 str.append(indent+"\tnull"); this.dumpAttributes(TAG, 0, str, indent); 184 185 } 186 public String dumpBeanNode(){ 187 StringBuffer str = new StringBuffer (); 188 str.append("Field\n"); this.dump(str, "\n "); return str.toString(); 191 }} 192 193 195 196 216 | Popular Tags |