01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.resultio.text;
07:
08: import java.io.IOException;
09: import java.io.OutputStream;
10: import java.io.OutputStreamWriter;
11: import java.io.Writer;
12: import java.nio.charset.Charset;
13:
14: import org.openrdf.query.resultio.BooleanQueryResultFormat;
15: import org.openrdf.query.resultio.BooleanQueryResultWriter;
16:
17: /**
18: * Writer for the plain text boolean result format.
19: *
20: * @author Arjohn Kampman
21: */
22: public class BooleanTextWriter implements BooleanQueryResultWriter {
23:
24: /*-----------*
25: * Variables *
26: *-----------*/
27:
28: /**
29: * The writer to write the boolean result to.
30: */
31: private Writer writer;
32:
33: /*--------------*
34: * Constructors *
35: *--------------*/
36:
37: public BooleanTextWriter(OutputStream out) {
38: writer = new OutputStreamWriter(out, Charset
39: .forName("US-ASCII"));
40: }
41:
42: /*---------*
43: * Methods *
44: *---------*/
45:
46: public final BooleanQueryResultFormat getBooleanQueryResultFormat() {
47: return BooleanQueryResultFormat.TEXT;
48: }
49:
50: public void write(boolean value) throws IOException {
51: writer.write(Boolean.toString(value));
52: writer.flush();
53: }
54: }
|