|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.macros.OutputNull
public final class OutputNull
A "null" output device for interpreter output.
At times it is useful to disable output while interpretting
data. If you pass one of these objects to a Interpreter, then any normal output generated will be discarded.
This can be particularily useful when "loading" an interpreter with some default rules.
For example, suppose you wanted to load definitions from a file
into a AtMacros object without producing any output. You
could do this with a method like this:
public static void loadDefinitions(AtMacrosamacs, File src) throws IOException, InterpretException {Inputin = newInputReader(src); amacs.interpret(in,new {@link OutputNull OutputNull}());
AtMacros| Constructor Summary | |
|---|---|
OutputNull()
|
|
| Method Summary | |
|---|---|
static Output |
getInstance()
Reference to the single global null output device. |
void |
write(char[] buf,
int ofs,
int len)
Writes a set of characters from a buffer to the output. |
void |
write(Object o)
Outputs the string representation of a Object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OutputNull()
| Method Detail |
|---|
public void write(char[] buf,
int ofs,
int len)
throws IOException
This method is used by macro processors (such as the AtMacros class) to send a set of characters to the
output device (string, file, etc). However, since this is a
"null" writer - no output is never done.
write in interface Outputbuf - A character array to take the data from (must not be null)ofs - Offset into the buffer to the first character to start the
copy from. Should be in the range of [0,buf.length-1].len - How many characters to copy. When added to the offset, the
resulting value should not exceed the length of the array.
IOException - If a I/O error is encountered (never thrown since we don't do
anything).
public void write(Object o)
throws IOException
string representation of a Object.
This method is used by macro processors (such as the AtMacros class) to cause the string representation of a Object to be
sent to the output device. However, since this is a "null" writer
- no output is never done.
write in interface Outputobject - The object to write out (the toString() method is used to write out the string
representation of the object). You may pass null (in which
case nothing will be done).
IOException - If a I/O error is encountered (never thrown since we don't do
anything).
y *public static Output getInstance()
null output device.
Since this object doesn't do anything, a single instance can be used throughout the JVM. Use this method to get access to it (this avoid constructing new intances).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||