1 19 26 27 package org.netbeans.modules.xml.multiview.test.bookmodel; 28 29 import org.w3c.dom.*; 30 import org.netbeans.modules.schema2beans.*; 31 import java.beans.*; 32 import java.util.*; 33 34 36 public class Chapter extends org.netbeans.modules.schema2beans.BaseBean 37 { 38 39 static Vector comparators = new Vector(); 40 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 0, 0); 41 42 static public final String TITLE = "Title"; static public final String SUMMARY = "Summary"; static public final String PARAGRAPH = "Paragraph"; 46 public Chapter() { 47 this(Common.USE_DEFAULT_VALUES); 48 } 49 50 public Chapter(int options) 51 { 52 super(comparators, runtimeVersion); 53 initPropertyTables(3); 55 this.createProperty("title", TITLE, 57 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 58 String .class); 59 this.createAttribute(TITLE, "lang", "Lang", 60 AttrProp.CDATA | AttrProp.FIXED, 61 null, "en"); 62 this.createProperty("summary", SUMMARY, 64 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 65 String .class); 66 this.createProperty("paragraph", PARAGRAPH, 68 Common.TYPE_0_N | Common.TYPE_STRING | Common.TYPE_KEY, 69 String .class); 70 this.initialize(options); 71 } 72 73 void initialize(int options) { 75 76 } 77 78 public void setTitle(String value) { 80 this.setValue(TITLE, value); 81 } 82 83 public String getTitle() { 85 return (String )this.getValue(TITLE); 86 } 87 88 public void setSummary(String value) { 90 this.setValue(SUMMARY, value); 91 } 92 93 public String getSummary() { 95 return (String )this.getValue(SUMMARY); 96 } 97 98 public void setParagraph(int index, String value) { 100 this.setValue(PARAGRAPH, index, value); 101 } 102 103 public String getParagraph(int index) { 105 return (String )this.getValue(PARAGRAPH, index); 106 } 107 108 public int sizeParagraph() { 110 return this.size(PARAGRAPH); 111 } 112 113 public void setParagraph(String [] value) { 115 this.setValue(PARAGRAPH, value); 116 } 117 118 public String [] getParagraph() { 120 return (String [])this.getValues(PARAGRAPH); 121 } 122 123 public int addParagraph(String value) { 125 int positionOfNewItem = this.addValue(PARAGRAPH, value); 126 return positionOfNewItem; 127 } 128 129 public int removeParagraph(String value) { 134 return this.removeValue(PARAGRAPH, value); 135 } 136 137 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 139 comparators.add(c); 140 } 141 142 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 144 comparators.remove(c); 145 } 146 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 147 boolean restrictionFailure = false; 148 boolean restrictionPassed = false; 149 if (getTitle() == null) { 151 throw new org.netbeans.modules.schema2beans.ValidateException("getTitle() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, "title", this); } 153 } 156 157 public void dump(StringBuffer str, String indent){ 159 String s; 160 Object o; 161 org.netbeans.modules.schema2beans.BaseBean n; 162 str.append(indent); 163 str.append("Title"); str.append(indent+"\t"); str.append("<"); o = this.getTitle(); 167 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(TITLE, 0, str, indent); 170 171 str.append(indent); 172 str.append("Summary"); str.append(indent+"\t"); str.append("<"); o = this.getSummary(); 176 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(SUMMARY, 0, str, indent); 179 180 str.append(indent); 181 str.append("Paragraph["+this.sizeParagraph()+"]"); for(int i=0; i<this.sizeParagraph(); i++) 183 { 184 str.append(indent+"\t"); 185 str.append("#"+i+":"); 186 str.append(indent+"\t"); str.append("<"); o = this.getParagraph(i); 189 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(PARAGRAPH, i, str, indent); 192 } 193 194 } 195 public String dumpBeanNode(){ 196 StringBuffer str = new StringBuffer (); 197 str.append("Chapter\n"); this.dump(str, "\n "); return str.toString(); 200 }} 201 202 204 205 220 | Popular Tags |