- java.lang.Object
-
- de.carne.mcd.PlainMCDOutput
-
- All Implemented Interfaces:
MCDOutput,java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class PlainMCDOutput extends java.lang.Object implements MCDOutput, java.io.Closeable, java.io.Flushable
MCDOutput implementation which emits the decoded to data to a PrintWriter or PrintStream.
-
-
Constructor Summary
Constructors Constructor Description PlainMCDOutput(java.io.PrintStream ps, boolean autoClose)Constructs a new MCDOutput instance.PlainMCDOutput(java.io.Writer out, boolean autoClose)Constructs a new MCDOutput instance.PlainMCDOutput(java.nio.channels.WritableByteChannel channel, boolean autoClose)Constructs a new MCDOutput instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()@NonNull MCDOutputdecreaseIndent()Decreases the indent level of all following print calls:voidflush()@NonNull MCDOutputincreaseIndent()Increases the indent level of all following print calls:MCDOutputprint(java.lang.String text)Prints a standard text.MCDOutputprintComment(java.lang.String comment)Prints a comment text.MCDOutputprintError(java.lang.String error)Prints an error text.MCDOutputprintKeyword(java.lang.String keyword)Prints a keyword text.MCDOutputprintLabel(java.lang.String label)Prints a label text.MCDOutputprintln()Prints a line break.MCDOutputprintln(java.lang.String text)Prints a standard text and a line break.MCDOutputprintlnComment(java.lang.String comment)Prints a comment text and a line break.MCDOutputprintlnError(java.lang.String error)Prints an error text and a line break.MCDOutputprintlnKeyword(java.lang.String keyword)Prints a keyword text and a line break.MCDOutputprintlnLabel(java.lang.String label)Prints a label text and a line break.MCDOutputprintlnOperator(java.lang.String operator)Prints an operator text and a line break.MCDOutputprintlnValue(java.lang.String value)Prints a value text and a line break.MCDOutputprintOperator(java.lang.String operator)Prints an operator text.MCDOutputprintValue(java.lang.String value)Prints a value text.
-
-
-
Constructor Detail
-
PlainMCDOutput
public PlainMCDOutput(java.io.Writer out, boolean autoClose)Constructs a new MCDOutput instance.- Parameters:
out- the Writer to emit the decoded data to.autoClose- whether to automatically close the PrintWriter when this channel is closed.
-
PlainMCDOutput
public PlainMCDOutput(java.io.PrintStream ps, boolean autoClose)Constructs a new MCDOutput instance.- Parameters:
ps- the PrintStream to emit the decoded data to.autoClose- whether to automatically close the PrintWriter when this channel is closed.
-
PlainMCDOutput
public PlainMCDOutput(java.nio.channels.WritableByteChannel channel, boolean autoClose)Constructs a new MCDOutput instance.- Parameters:
channel- the WritableByteChannel to emit the decoded data to.autoClose- whether to automatically close the PrintWriter when this channel is closed.
-
-
Method Detail
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
increaseIndent
public @NonNull MCDOutput increaseIndent() throws java.io.IOException
Description copied from interface:MCDOutputIncreases the indent level of all following print calls:- Specified by:
increaseIndentin interfaceMCDOutput- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
decreaseIndent
public @NonNull MCDOutput decreaseIndent() throws java.io.IOException
Description copied from interface:MCDOutputDecreases the indent level of all following print calls:- Specified by:
decreaseIndentin interfaceMCDOutput- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
println
public MCDOutput println() throws java.io.IOException
Description copied from interface:MCDOutputPrints a line break.
-
print
public MCDOutput print(java.lang.String text) throws java.io.IOException
Description copied from interface:MCDOutputPrints a standard text.
-
println
public MCDOutput println(java.lang.String text) throws java.io.IOException
Description copied from interface:MCDOutputPrints a standard text and a line break.
-
printValue
public MCDOutput printValue(java.lang.String value) throws java.io.IOException
Description copied from interface:MCDOutputPrints a value text.- Specified by:
printValuein interfaceMCDOutput- Parameters:
value- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printlnValue
public MCDOutput printlnValue(java.lang.String value) throws java.io.IOException
Description copied from interface:MCDOutputPrints a value text and a line break.- Specified by:
printlnValuein interfaceMCDOutput- Parameters:
value- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printComment
public MCDOutput printComment(java.lang.String comment) throws java.io.IOException
Description copied from interface:MCDOutputPrints a comment text.- Specified by:
printCommentin interfaceMCDOutput- Parameters:
comment- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printlnComment
public MCDOutput printlnComment(java.lang.String comment) throws java.io.IOException
Description copied from interface:MCDOutputPrints a comment text and a line break.- Specified by:
printlnCommentin interfaceMCDOutput- Parameters:
comment- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printKeyword
public MCDOutput printKeyword(java.lang.String keyword) throws java.io.IOException
Description copied from interface:MCDOutputPrints a keyword text.- Specified by:
printKeywordin interfaceMCDOutput- Parameters:
keyword- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printlnKeyword
public MCDOutput printlnKeyword(java.lang.String keyword) throws java.io.IOException
Description copied from interface:MCDOutputPrints a keyword text and a line break.- Specified by:
printlnKeywordin interfaceMCDOutput- Parameters:
keyword- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printOperator
public MCDOutput printOperator(java.lang.String operator) throws java.io.IOException
Description copied from interface:MCDOutputPrints an operator text.- Specified by:
printOperatorin interfaceMCDOutput- Parameters:
operator- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printlnOperator
public MCDOutput printlnOperator(java.lang.String operator) throws java.io.IOException
Description copied from interface:MCDOutputPrints an operator text and a line break.- Specified by:
printlnOperatorin interfaceMCDOutput- Parameters:
operator- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printLabel
public MCDOutput printLabel(java.lang.String label) throws java.io.IOException
Description copied from interface:MCDOutputPrints a label text.- Specified by:
printLabelin interfaceMCDOutput- Parameters:
label- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printlnLabel
public MCDOutput printlnLabel(java.lang.String label) throws java.io.IOException
Description copied from interface:MCDOutputPrints a label text and a line break.- Specified by:
printlnLabelin interfaceMCDOutput- Parameters:
label- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printError
public MCDOutput printError(java.lang.String error) throws java.io.IOException
Description copied from interface:MCDOutputPrints an error text.- Specified by:
printErrorin interfaceMCDOutput- Parameters:
error- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
printlnError
public MCDOutput printlnError(java.lang.String error) throws java.io.IOException
Description copied from interface:MCDOutputPrints an error text and a line break.- Specified by:
printlnErrorin interfaceMCDOutput- Parameters:
error- the text to print.- Returns:
- this instance for chaining.
- Throws:
java.io.IOException- if an I/O error occurs.
-
-