|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ashridgetech.jamda.code.CodeWriter
Provides services for writing program code to a Writer
.
Field Summary | |
protected java.io.Writer |
underlyingWriter
The Writer with which this instance was constructed |
Constructor Summary | |
CodeWriter(java.io.Writer writer)
Construct a CodeWriter attached to a Writer . |
Method Summary | |
CodeWriter |
begin()
Write the start of a new block. |
CodeWriter |
commaDoubleList(java.util.Collection tokens1,
java.util.Collection tokens2)
Write a list pairs of tokens, separated by commas. |
CodeWriter |
commaList(java.util.Collection tokens)
Write a list of tokens, separated by commas. |
void |
copyNoIndent(java.io.Reader r)
Insert a piece of text from a Reader
into the code, without any extra indenting,
but keeping any indenting in the lines read from the Reader . |
void |
copyWithIndent(java.io.Reader r)
Insert a piece of text from a Reader
into the code, placing the current indent before each line,
in addition to any indenting in the lines read from the Reader . |
CodeWriter |
end()
Write the end of a block, followed by a blank line. |
CodeWriter |
end(java.lang.String comment)
Decrease the indent level. |
CodeWriter |
endLine(java.lang.String code)
Write a piece of code to the output Writer
with a new line after it. |
void |
flush()
Flush the Writer used by this CodeWriter . |
java.io.PrintWriter |
getWriter()
Get the PrintWriter to which this CodeWriter
outputs code. |
CodeWriter |
in()
Increase the indent level by one. |
CodeWriter |
line(java.lang.String line)
Write a line of code, indented to the current indent level. |
CodeWriter |
newline()
End the current line on the output Writer . |
CodeWriter |
newline(int nLines)
Write zero or more newlines, the first of which will end the current line on the output Writer . |
CodeWriter |
out()
Decrease the indent level by one. |
static java.lang.String |
quote(java.lang.String s)
Surround a string with double quotes, escaping any double quotes within it. |
CodeWriter |
space()
Insert a space into the current line. |
CodeWriter |
spaceWrite(java.lang.String code)
Write a space to the output CodeWriter ,
followed by a piece of code. |
CodeWriter |
spaceWrite(java.lang.String code1,
java.lang.String code2)
Write two pieces of code to the output Writer ,
with a space before each one. |
CodeWriter |
spaceWrite(java.lang.String code1,
java.lang.String code2,
java.lang.String code3)
Write three pieces of code to the output Writer ,
with a space before each one. |
CodeWriter |
startLine()
Start a line of code, indented to the current indent level, leaving the current position on the same line. |
CodeWriter |
startLine(java.lang.String code)
Start a line of code, indented to the current indent level, write a piece of code, leaving the current position on the same line. |
CodeWriter |
write(java.lang.String code)
Write a piece of code to the output Writer . |
CodeWriter |
write(java.lang.String code1,
java.lang.String code2)
Write two pieces of code to the output Writer . |
CodeWriter |
write(java.lang.String code1,
java.lang.String code2,
java.lang.String code3)
Write three pieces of code to the output Writer . |
CodeWriter |
writeSpace(java.lang.String code)
Write a piece of code to the output CodeWriter ,
followed by a space |
CodeWriter |
writeSpace(java.lang.String code1,
java.lang.String code2)
Write two pieces of code to the output Writer ,
with a space after each one. |
CodeWriter |
writeSpace(java.lang.String code1,
java.lang.String code2,
java.lang.String code3)
Write three pieces of code to the output Writer ,
with a space after each one. |
CodeWriter |
writeSpaced(java.lang.String code)
Write a piece of code to the output CodeWriter ,
preceded and followed by a space |
CodeWriter |
writeSpaced(java.lang.String code1,
java.lang.String code2)
Write two pieces of code to the output Writer ,
with a space before the first, between each and after the last. |
CodeWriter |
writeSpaced(java.lang.String code1,
java.lang.String code2,
java.lang.String code3)
Write three pieces of code to the output Writer ,
with a space before the first, between each and after the last. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final java.io.Writer underlyingWriter
Writer
with which this instance was constructed
Constructor Detail |
public CodeWriter(java.io.Writer writer)
CodeWriter
attached to a Writer
.
writer
- the Writer
to which the code is written
- stored in underlyingWriter
.Method Detail |
public java.io.PrintWriter getWriter()
PrintWriter
to which this CodeWriter
outputs code.
public CodeWriter write(java.lang.String code)
Writer
.
code
- the code to write
public CodeWriter write(java.lang.String code1, java.lang.String code2)
Writer
.
code1
- the first piece of code to writecode2
- the second piece of code to write
public CodeWriter write(java.lang.String code1, java.lang.String code2, java.lang.String code3)
Writer
.
code1
- the first piece of code to writecode2
- the second piece of code to writecode3
- the third piece of code to write
public CodeWriter space()
public CodeWriter writeSpace(java.lang.String code)
CodeWriter
,
followed by a space
code
- the code to write
public CodeWriter writeSpace(java.lang.String code1, java.lang.String code2)
Writer
,
with a space after each one.
code1
- the first piece of code to writecode2
- the second piece of code to write
public CodeWriter writeSpace(java.lang.String code1, java.lang.String code2, java.lang.String code3)
Writer
,
with a space after each one.
code1
- the first piece of code to writecode2
- the second piece of code to writecode3
- the third piece of code to write
public CodeWriter spaceWrite(java.lang.String code)
CodeWriter
,
followed by a piece of code.
code
- the code to write after the space
public CodeWriter spaceWrite(java.lang.String code1, java.lang.String code2)
Writer
,
with a space before each one.
code1
- the first piece of code to writecode2
- the second piece of code to write
public CodeWriter spaceWrite(java.lang.String code1, java.lang.String code2, java.lang.String code3)
Writer
,
with a space before each one.
code1
- the first piece of code to writecode2
- the second piece of code to writecode3
- the third piece of code to write
public CodeWriter writeSpaced(java.lang.String code)
CodeWriter
,
preceded and followed by a space
code
- the code to write
public CodeWriter writeSpaced(java.lang.String code1, java.lang.String code2)
Writer
,
with a space before the first, between each and after the last.
code1
- the first piece of code to writecode2
- the second piece of code to write
public CodeWriter writeSpaced(java.lang.String code1, java.lang.String code2, java.lang.String code3)
Writer
,
with a space before the first, between each and after the last.
code1
- the first piece of code to writecode2
- the second piece of code to writecode3
- the third piece of code to write
public CodeWriter newline()
Writer
.
public CodeWriter newline(int nLines)
Writer
.
nLines
- the number of newlines - must be zero or more
public CodeWriter line(java.lang.String line)
line
- the line of code
public CodeWriter startLine()
public CodeWriter startLine(java.lang.String code)
public CodeWriter endLine(java.lang.String code)
Writer
with a new line after it.
code
- the code to write
public CodeWriter begin()
public CodeWriter end()
end(String)
public CodeWriter end(java.lang.String comment)
comment
- the text of the comment - may be null if no comment is needed
out()
public CodeWriter in()
public CodeWriter out()
java.lang.IllegalStateException
- if the indent level is already zeropublic CodeWriter commaList(java.util.Collection tokens)
tokens
- the list of tokens whose string values are written
public static java.lang.String quote(java.lang.String s)
s
- the String to quote
public CodeWriter commaDoubleList(java.util.Collection tokens1, java.util.Collection tokens2)
tokens1
- the first list of tokens whose string values are written
- a null is treated as an empty collection
public void copyWithIndent(java.io.Reader r) throws java.io.IOException
Reader
into the code, placing the current indent before each line,
in addition to any indenting in the lines read from the Reader
.
r
- the source of the text
java.io.IOException
public void copyNoIndent(java.io.Reader r) throws java.io.IOException
Reader
into the code, without any extra indenting,
but keeping any indenting in the lines read from the Reader
.
r
- the source of the text
java.io.IOException
public void flush()
Writer
used by this CodeWriter
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |