1 16 package org.ajaxtags.xml; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 29 abstract class BaseXmlBuilder<V> { 30 31 private List <V> liste = new ArrayList <V>(); 32 33 protected void setListe(List <V> liste) { 34 this.liste = liste; 35 } 36 37 40 private String encoding = "UTF-8"; 41 42 45 public String getEncoding() { 46 return this.encoding; 47 } 48 49 54 public void setEncoding(String encoding) { 55 this.encoding = encoding; 56 } 57 58 protected List <V> getListe() { 59 return this.liste; 60 } 61 62 66 protected List <V> getItems() { 67 return getListe(); 68 } 69 70 74 protected abstract String getXMLString(); 75 76 79 @Override 80 public String toString() { 81 StringBuffer xml = new StringBuffer ().append("<?xml version=\"1.0\""); 82 if (getEncoding() != null) { 83 xml.append(" encoding=\""); 84 xml.append(getEncoding()); 85 xml.append("\""); 86 } 87 xml.append(" ?>"); 88 xml.append(getXMLString()); 89 90 return xml.toString(); 91 } 92 93 101 public BaseXmlBuilder<V> add(V o) { 102 this.liste.add(o); 103 return this; 104 } 105 106 109 public void clear() { 110 this.liste.clear(); 111 } 112 113 120 public V get(int index) { 121 return this.liste.get(index); 122 } 123 124 129 public boolean isEmpty() { 130 return this.liste.isEmpty(); 131 } 132 133 137 public int size() { 138 return this.liste.size(); 139 } 140 141 } 142 | Popular Tags |