1 58 package org.apache.ecs.rtf; 59 60 import java.io.OutputStream ; 61 import java.io.Writer ; 62 import java.io.PrintWriter ; 63 64 import java.util.Hashtable ; 65 import java.util.Enumeration ; 66 67 import org.apache.ecs.Element; 68 import org.apache.ecs.ConcreteElement; 69 70 public class Alignment extends RTFElement 71 { 72 private RTFElement type = new Justified(); 73 private static Hashtable _lookup = new Hashtable (); 74 private static final int CENTERED = 1; 75 private static final int JUSTIFIED = 2; 76 private static final int RIGHT = 3; 77 private static final int LEFT = 4; 78 79 public Alignment() 80 { 81 } 82 83 87 public Element addElementToRegistry(Element element) 88 { 89 type.addElementToRegistry(element); 90 return type; 91 } 92 93 98 public Element addElementToRegistry(String hashcode,Element element) 99 { 100 type.addElementToRegistry(hashcode,element); 101 return type; 102 } 103 104 110 public Element addElementToRegistry(Element element,boolean filter) 111 { 112 type.addElementToRegistry(element,filter); 113 return type; 114 } 115 116 121 public Element addElementToRegistry(String hashcode, Element element,boolean filter) 122 { 123 type.addElementToRegistry(hashcode,element,filter); 124 return type; 125 } 126 127 132 public Element addElementToRegistry(String value,boolean filter) 133 { 134 type.addElementToRegistry(value,filter); 135 return type; 136 } 137 138 144 public Element addElementToRegistry(String hashcode, String value,boolean filter) 145 { 146 type.addElementToRegistry(hashcode,value,filter); 147 return type; 148 } 149 150 154 public Element addElementToRegistry(String value) 155 { 156 type.addElementToRegistry(value); 157 return type; 158 } 159 160 164 public Element addElementToRegistry(String hashcode,String value) 165 { 166 type.addElementToRegistry(hashcode,value); 167 return type; 168 } 169 170 174 public Element removeElementFromRegistry(Element element) 175 { 176 type.removeElementFromRegistry(Integer.toString(element.hashCode())); 177 return(type); 178 } 179 180 184 public Element removeElementFromRegistry(String hashcode) 185 { 186 type.removeElementFromRegistry(hashcode); 187 return(type); 188 } 189 190 194 public boolean registryHasElement(Element element) 195 { 196 return(type.registryHasElement(element)); 197 } 198 199 202 public Enumeration elements() 203 { 204 return(type.elements()); 205 } 206 207 211 public boolean registryHasElement(String hashcode) 212 { 213 return(type.registryHasElement(hashcode)); 214 } 215 216 public Alignment setType(String type) 217 { 218 if(type.equals("centered")) 219 { 220 this.type = new Centered(); 221 } 222 else if(type.equals("justified")) 223 { 224 this.type = new Justified(); 225 } 226 else if(type.equals("right")) 227 { 228 this.type = new Right(); 229 } 230 else if(type.equals("left")) 231 { 232 this.type = new Left(); 233 } 234 return this; 235 } 236 237 public void output(OutputStream out) 238 { 239 type.output(out); 240 } 241 242 public void output(Writer out) 243 { 244 type.output(out); 245 } 246 247 public void output(PrintWriter out) 248 { 249 type.output(out); 250 } 251 252 { 254 _lookup.put("centered",Integer.toString(CENTERED)); 255 _lookup.put("justified",Integer.toString(JUSTIFIED)); 256 _lookup.put("right",Integer.toString(RIGHT)); 257 _lookup.put("left",Integer.toString(LEFT)); 258 } 259 } 260 | Popular Tags |