01: // Copyright (c) 2000, 2001, 2006 Per M.A. Bothner and Brainfood Inc.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.lists;
05:
06: /** A Consumer is something that will accept data (output),
07: * and do something with it.
08: * A consumer is like a SAX DocumentHandler or a PrintWriter,
09: * but more abstract. If a Sequence class impleemnts Consumer,
10: * then data "written" to the sequence will be inserted in the sequence.
11: * <p>
12: * <em>Note:</em> This interface is not quite final. For example it is
13: * probable we will add methods for comments, processing instructions, etc.
14: */
15:
16: public interface Consumer
17: /* #ifdef JAVA5 */
18: // extends Appendable
19: /* #endif */
20: {
21: public void writeBoolean(boolean v);
22:
23: public void writeFloat(float v);
24:
25: public void writeDouble(double v);
26:
27: public void writeInt(int v);
28:
29: public void writeLong(long v);
30:
31: public void startDocument();
32:
33: public void endDocument();
34:
35: public void startElement(Object type);
36:
37: public void endElement();
38:
39: /** Write a attribute for the current element.
40: * This is only allowed immediately after a startElement. */
41: public void startAttribute(Object attrType);
42:
43: /** End of an attribute or end of an actual parameter.
44: * The former use matches a startAttribute; the latter may not,
45: * and can be used to separate parameters in a parameter list.
46: * This double duty suggsts the method should at least be re-named. */
47: public void endAttribute();
48:
49: public void writeObject(Object v);
50:
51: /** True if consumer is ignoring rest of element.
52: * The producer can use this information to skip ahead. */
53: public boolean ignoring();
54:
55: public void write(int ch);
56:
57: public void write(String string);
58:
59: /* #ifdef use:java.lang.CharSequence */
60: public void write(CharSequence string, int start, int length);
61:
62: /* #else */
63: // public void write(String string, int start, int length);
64: /* #endif */
65:
66: public void write(char[] buf, int start, int length);
67:
68: /* #ifdef JAVA5 */
69: // public Consumer append (char c);
70: // public Consumer append (CharSequence csq);
71: // public Consumer append (CharSequence csq, int start, int end);
72: /* #endif */
73: }
|