/*
* Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
*
* Licensed under the Aduna BSD-style license.
*/
package org.openrdf.query.resultio.text;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import org.openrdf.query.resultio.BooleanQueryResultFormat;
import org.openrdf.query.resultio.BooleanQueryResultWriter;
/**
* Writer for the plain text boolean result format.
*
* @author Arjohn Kampman
*/
public class BooleanTextWriter implements BooleanQueryResultWriter {
/*-----------*
* Variables *
*-----------*/
/**
* The writer to write the boolean result to.
*/
private Writer writer;
/*--------------*
* Constructors *
*--------------*/
public BooleanTextWriter(OutputStream out) {
writer = new OutputStreamWriter(out, Charset.forName("US-ASCII"));
}
/*---------*
* Methods *
*---------*/
public final BooleanQueryResultFormat getBooleanQueryResultFormat() {
return BooleanQueryResultFormat.TEXT;
}
public void write(boolean value)
throws IOException
{
writer.write(Boolean.toString(value));
writer.flush();
}
}