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 PrintConsumer
append(char c)
PrintConsumer
append(CharSequence csq)
PrintConsumer
append(CharSequence csq, int start, int end)
protected void
beforeContent()
protected void
beforeNode()
void
beginEntity(Object baseUri)
protected void
clearWordEnd()
void
endAttribute()
End of an attribute or end of an actual parameter.void
endDocument()
void
endElement()
void
endEntity()
void
endHiderSection()
End section controled by a show/hide buttonvoid
endLogicalBlock(String suffix)
static void
endLogicalBlock(String suffix, Consumer out)
protected void
endNumber()
void
freshLine()
gnu.kawa.io.PrettyWriter
getPrettyWriter()
boolean
ignoring()
True if consumer is ignoring rest of element.boolean
isDomTerm()
void
setIndentation(int amount, boolean current)
void
startAttribute(Object attrType)
Write a attribute for the current element.void
startDocument()
void
startElement(Object type)
void
startHiderSection(boolean show)
Start section controled by a show/hide button.void
startLogicalBlock(String prefix, boolean perLine, String suffix)
static void
startLogicalBlock(String prefix, boolean perLine, String suffix, Consumer out)
void
startLogicalBlock(String prefix, String suffix, int indent)
protected void
startNumber()
void
write(CharSequence csq, int start, int length)
void
writeBoolean(boolean v)
void
writeBreak(int kind)
void
writeBreakFill()
static void
writeBreakFill(Consumer out)
void
writeBreakLinear()
Write a new-line iff the containing section cannot be printed on one line.void
writeCDATA(char[] chars, int offset, int length)
void
writeComment(char[] chars, int offset, int length)
void
writeDouble(double v)
void
writeFloat(float v)
void
writeInt(int v)
void
writeLong(long v)
void
writeObject(Object v)
void
writeProcessingInstruction(String target, char[] content, int offset, int length)
protected void
writeRaw(char[] chars, int start, int length)
protected void
writeRaw(int v)
protected void
writeRaw(String str)
protected void
writeRaw(String str, int start, int length)
void
writeShowHideButton(boolean show)
If supported (i.e.void
writeSpace(int kind)
void
writeSpaceFill()
static void
writeSpaceFill(Consumer out)
void
writeSpaceLinear()
void
writeWordEnd()
void
writeWordStart()
-
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:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
- Overrides:
append
in classPrintWriter
-
append
public PrintConsumer append(CharSequence csq)
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
- Overrides:
append
in classPrintWriter
-
append
public PrintConsumer append(CharSequence csq, int start, int end)
- Specified by:
append
in interfaceAppendable
- Specified by:
append
in interfaceConsumer
- Overrides:
append
in 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:
writeBoolean
in interfaceConsumer
-
writeFloat
public void writeFloat(float v)
- Specified by:
writeFloat
in interfaceConsumer
-
writeDouble
public void writeDouble(double v)
- Specified by:
writeDouble
in interfaceConsumer
-
startDocument
public void startDocument()
- Specified by:
startDocument
in interfaceConsumer
-
endDocument
public void endDocument()
- Specified by:
endDocument
in interfaceConsumer
-
startElement
public void startElement(Object type)
- Specified by:
startElement
in interfaceConsumer
-
endElement
public void endElement()
- Specified by:
endElement
in interfaceConsumer
-
startAttribute
public void startAttribute(Object attrType)
Description copied from interface:Consumer
Write a attribute for the current element. This is only allowed immediately after a startElement.- Specified by:
startAttribute
in interfaceConsumer
-
endAttribute
public void endAttribute()
Description copied from interface:Consumer
End 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:
endAttribute
in interfaceConsumer
-
writeComment
public void writeComment(char[] chars, int offset, int length)
- Specified by:
writeComment
in interfaceXConsumer
-
writeProcessingInstruction
public void writeProcessingInstruction(String target, char[] content, int offset, int length)
- Specified by:
writeProcessingInstruction
in interfaceXConsumer
-
writeCDATA
public void writeCDATA(char[] chars, int offset, int length)
- Specified by:
writeCDATA
in interfaceXConsumer
-
beginEntity
public void beginEntity(Object baseUri)
- Specified by:
beginEntity
in 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:
writeObject
in interfaceConsumer
-
-