01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.util.transformers;
11:
12: import java.io.Reader;
13: import java.io.Writer;
14:
15: import org.mmbase.util.logging.*;
16:
17: /**
18: * Swallows all spaces.
19: *
20: * @author Michiel Meeuwissen
21: * @since MMBase-1.8
22: */
23:
24: public class SpaceSwallower extends ReaderTransformer implements
25: CharTransformer {
26:
27: private static final Logger log = Logging
28: .getLoggerInstance(SpaceSwallower.class);
29:
30: public Writer transform(Reader r, Writer w) {
31:
32: try {
33: log.debug("Starting to remove all space.");
34:
35: int c = r.read();
36: while (c != -1) {
37: if (!Character.isWhitespace((char) c)) {
38: w.write(c);
39: }
40: c = r.read();
41: }
42: log.debug("Finished");
43: } catch (java.io.IOException e) {
44: log.error(e.toString());
45: }
46: return w;
47: }
48:
49: public String toString() {
50: return "SPACESWALLOWER";
51: }
52: }
|