Class BasicHeaderPrintWriter
java.lang.Object
java.io.Writer
java.io.PrintWriter
org.apache.derby.impl.services.stream.BasicHeaderPrintWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable, HeaderPrintWriter
Basic class to print lines with headers.
STUB: Should include code to emit a new line before a header which is not the first thing on the line.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final PrintWriterGetHeaderprivate final StringFields inherited from class PrintWriter
out -
Constructor Summary
ConstructorsConstructorDescriptionBasicHeaderPrintWriter(OutputStream writeTo, PrintWriterGetHeader headerGetter, boolean canClose, String streamName) the constructor sets up the HeaderPrintWriter.BasicHeaderPrintWriter(Writer writeTo, PrintWriterGetHeader headerGetter, boolean canClose, String writerName) the constructor sets up the HeaderPrintWriter. -
Method Summary
Modifier and TypeMethodDescription(package private) voidcomplete()Flushes stream, and optionally also closes it if constructed with canClose equal to true.Return the header for the stream.getName()Gets the name of the wrapped writer or streamGets a PrintWriter object for writing to this HeaderPrintWriter.voidprintlnWithHeader(String message) Puts out some setup info for the current write and the write(s) that will be put out next.Methods inherited from class PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, writeMethods inherited from class Writer
nullWriterMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HeaderPrintWriter
flush, print, println, println
-
Field Details
-
headerGetter
-
canClose
private final boolean canClose -
name
-
-
Constructor Details
-
BasicHeaderPrintWriter
BasicHeaderPrintWriter(OutputStream writeTo, PrintWriterGetHeader headerGetter, boolean canClose, String streamName) the constructor sets up the HeaderPrintWriter.- Parameters:
writeTo- Where to write to.headerGetter- Object to get headers for output lines.canClose- If true,complete()will also close writeTostreamName- Name of writeTo, e.g. a file name- See Also:
-
BasicHeaderPrintWriter
BasicHeaderPrintWriter(Writer writeTo, PrintWriterGetHeader headerGetter, boolean canClose, String writerName) the constructor sets up the HeaderPrintWriter.- Parameters:
writeTo- Where to write to.headerGetter- Object to get headers for output lines.canClose- If true,complete()will also close writeTowriterName- Name of writeTo, e.g. a file name- See Also:
-
-
Method Details
-
printlnWithHeader
Description copied from interface:HeaderPrintWriterPuts out some setup info for the current write and the write(s) that will be put out next. It ends with a \n\r.All other writes to the stream use the PrintStream interface.
- Specified by:
printlnWithHeaderin interfaceHeaderPrintWriter
-
getHeader
Description copied from interface:HeaderPrintWriterReturn the header for the stream.- Specified by:
getHeaderin interfaceHeaderPrintWriter
-
getPrintWriter
Description copied from interface:HeaderPrintWriterGets a PrintWriter object for writing to this HeaderPrintWriter. Users may use the HeaderPrintWriter to access methods not included in this interface or to invoke methods or constructors which require a PrintWriter. Interleaving calls to a printWriter and its associated HeaderPrintWriter is not supported.- Specified by:
getPrintWriterin interfaceHeaderPrintWriter
-
getName
Description copied from interface:HeaderPrintWriterGets the name of the wrapped writer or stream- Specified by:
getNamein interfaceHeaderPrintWriter
-
complete
void complete()Flushes stream, and optionally also closes it if constructed with canClose equal to true.
-