1 10 package org.mmbase.util.transformers; 11 12 import java.io.*; 13 14 21 22 public abstract class ReaderTransformer implements CharTransformer { 23 24 public abstract Writer transform(Reader r, Writer w); 26 27 public Writer transformBack(Reader r, Writer w) { 29 throw new UnsupportedOperationException ("transformBack is not supported for this transformer"); 30 } 31 32 public final Writer transformBack(Reader r) { 34 return transformBack(r, new StringWriter()); 35 } 36 37 public final Writer transform(Reader r) { 39 return transform(r, new StringWriter()); 40 } 41 42 public String transform(String r) { 44 if (r == null) return null; 45 Writer sw = transform(new StringReader(r)); 46 return sw.toString(); 47 } 48 49 public String transformBack(String r) { 51 if (r == null) return null; 52 Writer sw = transformBack(new StringReader(r)); 53 return sw.toString(); 54 } 55 } 56 | Popular Tags |