Package gnu.lists
Class PrintConsumer
- java.lang.Object
-
- java.io.Writer
-
- java.io.PrintWriter
-
- gnu.lists.PrintConsumer
-
- All Implemented Interfaces:
Consumer,XConsumer,Closeable,Flushable,Appendable,AutoCloseable,Consumer<Object>,DoubleConsumer,IntConsumer,LongConsumer
- Direct Known Subclasses:
HttpPrinter,XMLPrinter
public class PrintConsumer extends PrintWriter implements Appendable, XConsumer
A Consumer that extends a PrintWriter. Useful for formatting.
-
-
Constructor Summary
Constructors Constructor Description PrintConsumer(Consumer out, boolean autoFlush)PrintConsumer(OutputStream out, boolean autoFlush)PrintConsumer(Writer out)PrintConsumer(Writer out, boolean autoFlush)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrintConsumerappend(char c)PrintConsumerappend(CharSequence csq)PrintConsumerappend(CharSequence csq, int start, int end)protected voidbeforeContent()protected voidbeforeNode()voidbeginEntity(Object baseUri)protected voidclearWordEnd()voidendAttribute()End of an attribute or end of an actual parameter.voidendDocument()voidendElement()voidendEntity()voidendHiderSection()End section controled by a show/hide buttonvoidendLogicalBlock(String suffix)static voidendLogicalBlock(String suffix, Consumer out)protected voidendNumber()voidfreshLine()gnu.kawa.io.PrettyWritergetPrettyWriter()booleanignoring()True if consumer is ignoring rest of element.booleanisDomTerm()voidsetIndentation(int amount, boolean current)voidstartAttribute(Object attrType)Write a attribute for the current element.voidstartDocument()voidstartElement(Object type)voidstartHiderSection(boolean show)Start section controled by a show/hide button.voidstartLogicalBlock(String prefix, boolean perLine, String suffix)static voidstartLogicalBlock(String prefix, boolean perLine, String suffix, Consumer out)voidstartLogicalBlock(String prefix, String suffix, int indent)protected voidstartNumber()voidwrite(CharSequence csq, int start, int length)voidwriteBoolean(boolean v)voidwriteBreak(int kind)voidwriteBreakFill()static voidwriteBreakFill(Consumer out)voidwriteBreakLinear()Write a new-line iff the containing section cannot be printed on one line.voidwriteCDATA(char[] chars, int offset, int length)voidwriteComment(char[] chars, int offset, int length)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteObject(Object v)voidwriteProcessingInstruction(String target, char[] content, int offset, int length)protected voidwriteRaw(char[] chars, int start, int length)protected voidwriteRaw(int v)protected voidwriteRaw(String str)protected voidwriteRaw(String str, int start, int length)voidwriteShowHideButton(boolean show)If supported (i.e.voidwriteSpace(int kind)voidwriteSpaceFill()static voidwriteSpaceFill(Consumer out)voidwriteSpaceLinear()voidwriteWordEnd()voidwriteWordStart()-
Methods inherited from class java.io.PrintWriter
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, write
-
Methods inherited from class java.io.Writer
nullWriter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gnu.lists.Consumer
accept, accept, accept, accept, write, write, write
-
Methods inherited from interface java.util.function.DoubleConsumer
andThen
-
Methods inherited from interface java.util.function.IntConsumer
andThen
-
Methods inherited from interface java.util.function.LongConsumer
andThen
-
-
-
-
Field Detail
-
skipping
protected boolean skipping
-
base
protected Consumer base
-
-
Constructor Detail
-
PrintConsumer
public PrintConsumer(Writer out)
-
PrintConsumer
public PrintConsumer(Writer out, boolean autoFlush)
-
PrintConsumer
public PrintConsumer(Consumer out, boolean autoFlush)
-
PrintConsumer
public PrintConsumer(OutputStream out, boolean autoFlush)
-
-
Method Detail
-
getPrettyWriter
public gnu.kawa.io.PrettyWriter getPrettyWriter()
-
startNumber
protected void startNumber()
-
endNumber
protected void endNumber()
-
append
public PrintConsumer append(char c)
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceConsumer- Overrides:
appendin classPrintWriter
-
append
public PrintConsumer append(CharSequence csq)
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceConsumer- Overrides:
appendin classPrintWriter
-
append
public PrintConsumer append(CharSequence csq, int start, int end)
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceConsumer- Overrides:
appendin classPrintWriter
-
write
public void write(CharSequence csq, int start, int length)
-
freshLine
public void freshLine()
-
writeSpace
public void writeSpace(int kind)
-
writeBreak
public void writeBreak(int kind)
-
writeBreakFill
public static void writeBreakFill(Consumer out)
-
writeBreakFill
public void writeBreakFill()
-
writeSpaceFill
public static void writeSpaceFill(Consumer out)
-
writeSpaceFill
public void writeSpaceFill()
-
writeSpaceLinear
public void writeSpaceLinear()
-
writeBreakLinear
public void writeBreakLinear()
Write a new-line iff the containing section cannot be printed on one line. Either all linear-style newlines in a logical block becomes spaces (if it all fits in a line), or none of them do.
-
setIndentation
public void setIndentation(int amount, boolean current)
-
isDomTerm
public boolean isDomTerm()
-
writeShowHideButton
public void writeShowHideButton(boolean show)
If supported (i.e. on DomTerm), "print" a show/hide button.
-
startHiderSection
public void startHiderSection(boolean show)
Start section controled by a show/hide button. Must be properly nested within/around logical blocks. Current only supported on DomTerm.
-
endHiderSection
public void endHiderSection()
End section controled by a show/hide button
-
startLogicalBlock
public static void startLogicalBlock(String prefix, boolean perLine, String suffix, Consumer out)
-
endLogicalBlock
public void endLogicalBlock(String suffix)
-
beforeContent
protected void beforeContent()
-
beforeNode
protected void beforeNode()
-
writeWordStart
public void writeWordStart()
-
writeWordEnd
public void writeWordEnd()
-
clearWordEnd
protected void clearWordEnd()
-
writeBoolean
public void writeBoolean(boolean v)
- Specified by:
writeBooleanin interfaceConsumer
-
writeFloat
public void writeFloat(float v)
- Specified by:
writeFloatin interfaceConsumer
-
writeDouble
public void writeDouble(double v)
- Specified by:
writeDoublein interfaceConsumer
-
startDocument
public void startDocument()
- Specified by:
startDocumentin interfaceConsumer
-
endDocument
public void endDocument()
- Specified by:
endDocumentin interfaceConsumer
-
startElement
public void startElement(Object type)
- Specified by:
startElementin interfaceConsumer
-
endElement
public void endElement()
- Specified by:
endElementin interfaceConsumer
-
startAttribute
public void startAttribute(Object attrType)
Description copied from interface:ConsumerWrite a attribute for the current element. This is only allowed immediately after a startElement.- Specified by:
startAttributein interfaceConsumer
-
endAttribute
public void endAttribute()
Description copied from interface:ConsumerEnd of an attribute or end of an actual parameter. The former use matches a startAttribute; the latter may not, and can be used to separate parameters in a parameter list. This double duty suggsts the method should at least be re-named.- Specified by:
endAttributein interfaceConsumer
-
writeComment
public void writeComment(char[] chars, int offset, int length)- Specified by:
writeCommentin interfaceXConsumer
-
writeProcessingInstruction
public void writeProcessingInstruction(String target, char[] content, int offset, int length)
- Specified by:
writeProcessingInstructionin interfaceXConsumer
-
writeCDATA
public void writeCDATA(char[] chars, int offset, int length)- Specified by:
writeCDATAin interfaceXConsumer
-
beginEntity
public void beginEntity(Object baseUri)
- Specified by:
beginEntityin interfaceXConsumer
-
writeRaw
protected void writeRaw(int v)
-
writeRaw
protected void writeRaw(String str)
-
writeRaw
protected void writeRaw(String str, int start, int length)
-
writeRaw
protected void writeRaw(char[] chars, int start, int length)
-
writeObject
public void writeObject(Object v)
- Specified by:
writeObjectin interfaceConsumer
-
-