java.lang.Object
org.apache.jena.atlas.io.AWriterBase
org.apache.jena.atlas.io.IndentedWriter
- All Implemented Interfaces:
AutoCloseable,AWriter,Closeable
- Direct Known Subclasses:
IndentedLineBuffer
A writer that records what the current indentation level is, and
uses that to insert a prefix at each line.
It can also insert line numbers at the beginning of lines.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IndentedWriterStderr wrapped in an IndentedWriter - no line numbersstatic final IndentedWriterStdout wrapped in an IndentedWriter - no line numbers -
Constructor Summary
ConstructorsConstructorDescriptionIndentedWriter(OutputStream outStream) Construct a UTF8 IndentedWriter around an OutputStreamIndentedWriter(OutputStream outStream, boolean withLineNumbers) Construct a UTF8 IndentedWriter around an OutputStream -
Method Summary
Modifier and TypeMethodDescriptionbooleanclone()static IndentedWriterclone(IndentedWriter other) Create an independent copy of theIndentedWriter.voidclose()voidvoiddecIndent(int x) voidvoidflush()intGet indent from the left hand edgeintgetCol()Get the absolute column.intPosition past current indentbooleanFlush on newlineInitial string printed at the start of each line : defaults to no string.intWidth of the number fieldcharintgetRow()Get row/line (counts from 1)intbooleanvoidvoidincIndent(int x) booleanFlat mode - print without NL, for a more compact representationvoidnewline()voidpad()Pad to the indent (if we are before it)voidpad(int col) Pad to a given number of columns EXCLUDING the indent.voidpad(int col, boolean absoluteColumn) Pad to a given number of columns maybe including the indent.voidprint(char ch) voidprint(char[] cbuf) voidprint(char ch, int n) Print a char N timesvoidvoidvoidPrint a string N timesvoidvoidprintln()voidprintln(char ch) voidvoidsetAbsoluteIndent(int x) Set indent from the left hand edge.setEndOfLineMarker(String marker) Set the marker included at end of line - set to null for "none".setFlatMode(boolean flatMode) Flat mode - print without NL, for a more compact representationsetFlushOnNewline(boolean flushOnNewline) Flush on newline in this code.setLineNumbers(boolean lineNumbers) setLinePrefix(String str) Set the initial string printed at the start of each line.setNumberWidth(int widthOfNumbers) Set the width of the number field.setPadChar(char ch) setPadString(String str) setUnitIndent(int x) toString()Methods inherited from class org.apache.jena.atlas.io.AWriterBase
write, write, write
-
Field Details
-
stdout
Stdout wrapped in an IndentedWriter - no line numbers -
stderr
Stderr wrapped in an IndentedWriter - no line numbers
-
-
Constructor Details
-
IndentedWriter
Construct a UTF8 IndentedWriter around an OutputStream -
IndentedWriter
Construct a UTF8 IndentedWriter around an OutputStream
-
-
Method Details
-
clone
Create an independent copy of theIndentedWriter. Changes to the configuration of the copy will not affect the originalIndentedWriter. This include indentation level.
Row and column counters are reset.
Indent is initially. zero.
They do share the underlying outputWriter.- Parameters:
other-- Returns:
- IndentedWriter
-
clone
-
print
-
printf
-
print
public void print(char ch) -
print
-
println
-
println
public void println(char ch) -
println
-
println
public void println() -
print
public void print(char[] cbuf) -
print
Print a string N times -
print
public void print(char ch, int n) Print a char N times -
newline
public void newline() -
ensureStartOfLine
public void ensureStartOfLine() -
atLineStart
public boolean atLineStart() -
close
public void close() -
flush
public void flush() -
pad
public void pad()Pad to the indent (if we are before it) -
pad
public void pad(int col) Pad to a given number of columns EXCLUDING the indent.- Parameters:
col- Column number (first column is 1).
-
pad
public void pad(int col, boolean absoluteColumn) Pad to a given number of columns maybe including the indent.- Parameters:
col- Column number (first column is 1).absoluteColumn- Whether to include the indent
-
getRow
public int getRow()Get row/line (counts from 1) -
getCol
public int getCol()Get the absolute column. This is the location where the next character on the line will be printed. The IndentedWriter may not yet have padded to this place. -
incIndent
public void incIndent() -
incIndent
public void incIndent(int x) -
decIndent
public void decIndent() -
decIndent
public void decIndent(int x) -
getCurrentOffset
public int getCurrentOffset()Position past current indent -
getAbsoluteIndent
public int getAbsoluteIndent()Get indent from the left hand edge -
setAbsoluteIndent
Set indent from the left hand edge. Returnsthis. -
hasLineNumbers
public boolean hasLineNumbers() -
setLineNumbers
-
getEndOfLineMarker
-
setEndOfLineMarker
Set the marker included at end of line - set to null for "none". Usually used for debugging. -
inFlatMode
public boolean inFlatMode()Flat mode - print without NL, for a more compact representation -
setFlatMode
Flat mode - print without NL, for a more compact representation -
getFlushOnNewline
public boolean getFlushOnNewline()Flush on newline -
setFlushOnNewline
Flush on newline in this code. This is set forstdoutandstderrbut not by default otherwise. The underlying output, if it is aPrintStreammay also have a flush on newline as well (e.gSystem.out). -
getPadChar
public char getPadChar() -
setPadChar
-
getPadString
-
setPadString
-
getLinePrefix
Initial string printed at the start of each line : defaults to no string. -
setLinePrefix
Set the initial string printed at the start of each line. -
getUnitIndent
public int getUnitIndent() -
setUnitIndent
-
getNumberWidth
public int getNumberWidth()Width of the number field -
setNumberWidth
Set the width of the number field. There is also a single space after the number not included in this setting. -
toString
-