KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > lists > Consumer


1 // Copyright (c) 2000, 2001, 2006 Per M.A. Bothner and Brainfood Inc.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.lists;
5
6 /** A Consumer is something that will accept data (output),
7  * and do something with it.
8  * A consumer is like a SAX DocumentHandler or a PrintWriter,
9  * 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   public void writeDouble(double v);
25   public void writeInt(int v);
26   public void writeLong(long v);
27
28   public void beginDocument();
29   public void endDocument();
30
31   public void beginGroup(Object JavaDoc type);
32   public void endGroup();
33
34   /** Write a attribute for the current group.
35    * This is only allowed immediately after a beginGroup. */

36   public void beginAttribute(Object JavaDoc attrType);
37
38   /** End of an attribute or end of an actual parameter.
39    * The former use matches a beginAttribute; the latter may not,
40    * and can be used to separate parameters in a parameter list.
41    * This double duty suggsts the method should at least be re-named. */

42   public void endAttribute();
43
44   public void writeObject(Object JavaDoc v);
45
46   /** True if consumer is ignoring rest of group.
47    * The producer can use this information to skip ahead. */

48   public boolean ignoring();
49
50   public void write(int ch);
51   public void write(String JavaDoc string);
52   /* #ifdef use:java.lang.CharSequence */
53   public void write(CharSequence JavaDoc string, int start, int length);
54   /* #else */
55   // public void write(String string, int start, int length);
56
/* #endif */
57   
58   public void write(char[] buf, int start, int length);
59
60   /* #ifdef JAVA5 */
61   // public Consumer append (char c);
62
// public Consumer append (CharSequence csq);
63
// public Consumer append (CharSequence csq, int start, int end);
64
/* #endif */
65 }
66
Popular Tags