Package ball.activation
Class ReaderWriterDataSource
- java.lang.Object
-
- ball.activation.AbstractDataSource
-
- ball.activation.FilterDataSource
-
- ball.activation.ReaderWriterDataSource
-
- All Implemented Interfaces:
DataSourceDefaultMethods,DataSource
- Direct Known Subclasses:
JAXBDataSource,TextTable,ThrowableDataSource
public class ReaderWriterDataSource extends FilterDataSource
DataSourceimplementation that provides aBufferedReaderwrapping theDataSourceInputStreamand aPrintWriterwrapping theDataSourceOutputStream.- Author:
- Allen D. Ball
-
-
Field Summary
Fields Modifier and Type Field Description protected static CharsetCHARSET-
Fields inherited from interface ball.activation.DataSourceDefaultMethods
APPLICATION_OCTET_STREAM, APPLICATION_XML, CONTENT_TYPE, TEXT_HTML, TEXT_PLAIN
-
-
Constructor Summary
Constructors Constructor Description ReaderWriterDataSource(String name, String type)ReaderWriterDataSource(String name, String type, Charset charset)ReaderWriterDataSource(String name, String type, Charset charset, String content)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BufferedReadergetBufferedReader()Method to return a newBufferedReaderto read the underlyingInputStream.CharsetgetCharset()PrintStreamgetPrintStream()Method to return a newPrintStreamto write to the underlyingOutputStream.PrintWritergetPrintWriter()Method to return a newPrintWriterto write to the underlyingOutputStream.ReadergetReader()Method to return a newReaderto read the underlyingInputStream.WritergetWriter()Method to return a newWriterto write to the underlyingOutputStream.protected static StringnameOf(Charset charset)Convenience method to get the name of aCharset.StringtoString()voidwriteTo(PrintWriter writer)Method to write the contents of thisDataSourceto aPrintWriter.-
Methods inherited from class ball.activation.FilterDataSource
getContentType, getDataSource, getInputStream, getName, getOutputStream, setContentType, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ball.activation.DataSourceDefaultMethods
clear, getInputStream, getOutputStream, length, wrap, wrap
-
-
-
-
Constructor Detail
-
ReaderWriterDataSource
@ConstructorProperties({"name","contentType"}) public ReaderWriterDataSource(String name, String type)
- Parameters:
name- Initial"Name"attribute value.type- Initial"ContentType"attribute value.
-
ReaderWriterDataSource
@ConstructorProperties({"name","contentType","charset"}) public ReaderWriterDataSource(String name, String type, Charset charset)
- Parameters:
name- Initial"Name"attribute value.type- Initial"ContentType"attribute value.charset- TheCharsetused to encode theOutputStream.
-
ReaderWriterDataSource
@ConstructorProperties({"name","contentType","charset",""}) public ReaderWriterDataSource(String name, String type, Charset charset, String content)
- Parameters:
name- Initial"Name"attribute value.type- Initial"ContentType"attribute value.charset- TheCharsetused to encode theOutputStream.content- The initial contentString.
-
-
Method Detail
-
getCharset
public Charset getCharset()
- Returns:
- The Charset.
-
getReader
public Reader getReader() throws IOException
Method to return a newReaderto read the underlyingInputStream.- Returns:
- A
Readerwrapping theDataSourceInputStream. - Throws:
IOException- If an I/O exception occurs.- See Also:
FilterDataSource.getInputStream()
-
getWriter
public Writer getWriter() throws IOException
Method to return a newWriterto write to the underlyingOutputStream.- Returns:
- A
Writerwrapping theDataSourceOutputStream. - Throws:
IOException- If an I/O exception occurs.- See Also:
FilterDataSource.getOutputStream()
-
getBufferedReader
public BufferedReader getBufferedReader() throws IOException
Method to return a newBufferedReaderto read the underlyingInputStream.- Returns:
- A
BufferedReaderwrapping theDataSourceInputStream. - Throws:
IOException- If an I/O exception occurs.- See Also:
FilterDataSource.getInputStream()
-
getPrintWriter
public PrintWriter getPrintWriter() throws IOException
Method to return a newPrintWriterto write to the underlyingOutputStream.- Returns:
- A
PrintWriterwrapping theDataSourceOutputStream. - Throws:
IOException- If an I/O exception occurs.- See Also:
FilterDataSource.getOutputStream()
-
getPrintStream
public PrintStream getPrintStream() throws IOException
Method to return a newPrintStreamto write to the underlyingOutputStream.- Returns:
- A
PrintStreamwrapping theDataSourceOutputStream. - Throws:
IOException- If an I/O exception occurs.- See Also:
FilterDataSource.getOutputStream()
-
writeTo
public void writeTo(PrintWriter writer) throws IOException
Method to write the contents of thisDataSourceto aPrintWriter.- Parameters:
writer- The targetPrintWriter.- Throws:
IOException- If a problem is encountered opening or reading theBufferedReaderor writing to thePrintWriter.- See Also:
getBufferedReader()
-
-