public class OutputBuffer extends Object implements IOutputBuffer
Modifier and Type | Field and Description |
---|---|
protected StringBuilder |
buffer |
protected ColumnCounter |
columnCounter |
protected boolean |
contentTypeSet |
protected IEglContext |
context |
protected List<CommentBlockPartitioner> |
customPartitioners |
protected boolean |
hasControlledRegions |
protected boolean |
hasProtectedRegions |
protected String |
lastLine |
protected LineCounter |
lineCounter |
Constructor and Description |
---|
OutputBuffer() |
OutputBuffer(IEglContext context) |
Modifier and Type | Method and Description |
---|---|
protected void |
assertNoMixedRegions(RegionType regionType) |
protected String |
calculateIndentationToMatch(String previousLine) |
void |
chop(int chars)
Removes the specified number of characters from the end of the buffer.
|
String |
control(String id,
boolean enabled,
String contents)
Appends a controlled region to the buffer.
|
String |
control(String startComment,
String endComment,
String id,
boolean enabled,
String contents)
Appends a controlled region to the buffer.
|
void |
formatWith(Formatter formatter)
Reformats the contents of the buffer with the given
Formatter . |
int |
getCurrentColumnNumber()
Returns the character number of the last character in the buffer.
|
int |
getCurrentLineNumber()
Returns the line number of the last character in the buffer.
|
protected String |
getLastLineInBuffer() |
int |
getOffset()
Returns the size of the buffer.
|
String |
getSpaces(int howMany)
Returns a string comprised of the specificed number of spaces.
|
String |
preserve(String id,
boolean enabled,
String contents)
Appends a protected region to the buffer.
|
String |
preserve(String startComment,
String endComment,
String id,
boolean enabled,
String contents)
Appends a protected region to the buffer.
|
void |
print(Object o)
Appends a string representation of the given object to the buffer.
|
void |
printdyn(Object o)
Appends a string representation of the given object to the buffer, correcting
the indentation of the string representation to match the indentation level of
the previous line in the buffer.
|
void |
println()
Appends a new line the buffer.
|
void |
println(Object o)
Appends a string representation of the given object and a new line to the buffer.
|
void |
prinx(Object o)
An alias for
print(Object) that should only be called
internally, by code generated by the Preprocessor . |
protected void |
replaceContentsWith(String newContents) |
void |
setContentType(String name)
Specifies the type of output in the buffer, such as Java or HTML.
|
String |
startControl(String id,
boolean enabled)
Appends the starting tag for a controlled region to the buffer.
|
String |
startControl(String startComment,
String endComment,
String id,
boolean enabled)
Appends the starting tag for a protected region to the buffer.
|
String |
startLocate(String id,
boolean enabled,
RegionType regionType) |
String |
startLocate(String startComment,
String endComment,
String id,
boolean enabled,
RegionType regionType) |
String |
startPreserve(String id,
boolean enabled)
Appends the starting tag for a protected region to the buffer.
|
String |
startPreserve(String startComment,
String endComment,
String id,
boolean enabled)
Appends the starting tag for a protected region to the buffer.
|
void |
stop()
Halts execution of the current template.
|
String |
stopControl()
Appends a closing tag for a protected region to the buffer.
|
String |
stopLocate() |
String |
stopPreserve()
Appends a closing tag for a protected region to the buffer.
|
String |
toString()
Converts the contents of the buffer to a string.
|
protected StringBuilder buffer
protected IEglContext context
protected LineCounter lineCounter
protected ColumnCounter columnCounter
protected List<CommentBlockPartitioner> customPartitioners
protected boolean contentTypeSet
protected String lastLine
protected boolean hasProtectedRegions
protected boolean hasControlledRegions
public OutputBuffer(IEglContext context)
public OutputBuffer()
public void chop(int chars)
IOutputBuffer
chop
in interface IOutputBuffer
public void print(Object o)
IOutputBuffer
print
in interface IOutputBuffer
public void printdyn(Object o)
IOutputBuffer
printdyn
in interface IOutputBuffer
public void prinx(Object o)
print(Object)
that should only be called
internally, by code generated by the Preprocessor
. This
is a workaround to allow us to identify, in the preprocessed EOL,
statements that were generated from an EGL static section. We then
adjust these ASTs to allow better traceability in the AST outline
view.prinx
in interface IOutputBuffer
EglPreprocessorModule.updateRegionsOfStaticTextASTs(org.eclipse.epsilon.common.parse.AST)
protected String getLastLineInBuffer()
public String getSpaces(int howMany)
IOutputBuffer
getSpaces
in interface IOutputBuffer
public void println()
IOutputBuffer
println
in interface IOutputBuffer
public void println(Object o)
IOutputBuffer
println
in interface IOutputBuffer
public String preserve(String id, boolean enabled, String contents) throws EglRuntimeException
IOutputBuffer
preserve
in interface IOutputBuffer
id
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notcontents
- - the contents for this protected regionEglRuntimeException
- if IOutputBuffer.setContentType(String)
has not been called.public String control(String id, boolean enabled, String contents) throws EglRuntimeException
IOutputBuffer
control
in interface IOutputBuffer
id
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notcontents
- - the contents for this protected regionEglRuntimeException
- if IOutputBuffer.setContentType(String)
has not been called.public String preserve(String startComment, String endComment, String id, boolean enabled, String contents) throws EglRuntimeException
IOutputBuffer
preserve
in interface IOutputBuffer
startComment
- - the character sequence used to denote the start of a comment for the type of output in the bufferendComment
- - the character sequence used to denote the end of a comment for the type of output in the bufferid
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notcontents
- - the contents for this protected regionEglRuntimeException
public String control(String startComment, String endComment, String id, boolean enabled, String contents) throws EglRuntimeException
IOutputBuffer
control
in interface IOutputBuffer
startComment
- - the character sequence used to denote the start of a comment for the type of output in the bufferendComment
- - the character sequence used to denote the end of a comment for the type of output in the bufferid
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notcontents
- - the contents for this protected regionEglRuntimeException
public void setContentType(String name) throws EglRuntimeException
IOutputBuffer
setContentType
in interface IOutputBuffer
EglRuntimeException
- if the content type is not supported.public String startPreserve(String id, boolean enabled) throws EglRuntimeException
IOutputBuffer
startPreserve
in interface IOutputBuffer
id
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notEglRuntimeException
- if IOutputBuffer.setContentType(String)
has not been calledpublic String startControl(String id, boolean enabled) throws EglRuntimeException
IOutputBuffer
startControl
in interface IOutputBuffer
id
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notEglRuntimeException
- if IOutputBuffer.setContentType(String)
has not been calledpublic String startLocate(String id, boolean enabled, RegionType regionType) throws EglRuntimeException
EglRuntimeException
public String startControl(String startComment, String endComment, String id, boolean enabled) throws EglRuntimeException
IOutputBuffer
startControl
in interface IOutputBuffer
startComment
- - the character sequence used to denote the start of a comment for the type of output in the bufferendComment
- - the character sequence used to denote the end of a comment for the type of output in the bufferid
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notEglRuntimeException
public String startPreserve(String startComment, String endComment, String id, boolean enabled) throws EglRuntimeException
IOutputBuffer
startPreserve
in interface IOutputBuffer
startComment
- - the character sequence used to denote the start of a comment for the type of output in the bufferendComment
- - the character sequence used to denote the end of a comment for the type of output in the bufferid
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or notEglRuntimeException
public String startLocate(String startComment, String endComment, String id, boolean enabled, RegionType regionType) throws EglRuntimeException
EglRuntimeException
protected void assertNoMixedRegions(RegionType regionType) throws EglRuntimeException
EglRuntimeException
public String stopControl() throws EglRuntimeException
IOutputBuffer
stopControl
in interface IOutputBuffer
EglRuntimeException
- if there is no unclosed protected region in the buffer.public String stopPreserve() throws EglRuntimeException
IOutputBuffer
stopPreserve
in interface IOutputBuffer
EglRuntimeException
- if there is no unclosed protected region in the buffer.public String stopLocate() throws EglRuntimeException
EglRuntimeException
public void stop() throws EglStoppedException
IOutputBuffer
stop
in interface IOutputBuffer
EglStoppedException
public int getCurrentLineNumber()
IOutputBuffer
getCurrentLineNumber
in interface IOutputBuffer
public int getCurrentColumnNumber()
IOutputBuffer
getCurrentColumnNumber
in interface IOutputBuffer
public int getOffset()
IOutputBuffer
getOffset
in interface IOutputBuffer
public void formatWith(Formatter formatter)
IOutputBuffer
Formatter
.formatWith
in interface IOutputBuffer
protected void replaceContentsWith(String newContents)
public String toString()
IOutputBuffer
toString
in interface IOutputBuffer
toString
in class Object
Copyright © 2016. All rights reserved.