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)
IOutputBufferchop in interface IOutputBufferpublic void print(Object o)
IOutputBufferprint in interface IOutputBufferpublic void printdyn(Object o)
IOutputBufferprintdyn in interface IOutputBufferpublic 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 IOutputBufferEglPreprocessorModule.updateRegionsOfStaticTextASTs(org.eclipse.epsilon.common.parse.AST)protected String getLastLineInBuffer()
public String getSpaces(int howMany)
IOutputBuffergetSpaces in interface IOutputBufferpublic void println()
IOutputBufferprintln in interface IOutputBufferpublic void println(Object o)
IOutputBufferprintln in interface IOutputBufferpublic String preserve(String id, boolean enabled, String contents) throws EglRuntimeException
IOutputBufferpreserve in interface IOutputBufferid - - 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
IOutputBuffercontrol in interface IOutputBufferid - - 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
IOutputBufferpreserve in interface IOutputBufferstartComment - - 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 regionEglRuntimeExceptionpublic String control(String startComment, String endComment, String id, boolean enabled, String contents) throws EglRuntimeException
IOutputBuffercontrol in interface IOutputBufferstartComment - - 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 regionEglRuntimeExceptionpublic void setContentType(String name) throws EglRuntimeException
IOutputBuffersetContentType in interface IOutputBufferEglRuntimeException - if the content type is not supported.public String startPreserve(String id, boolean enabled) throws EglRuntimeException
IOutputBufferstartPreserve in interface IOutputBufferid - - 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
IOutputBufferstartControl in interface IOutputBufferid - - 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
EglRuntimeExceptionpublic String startControl(String startComment, String endComment, String id, boolean enabled) throws EglRuntimeException
IOutputBufferstartControl in interface IOutputBufferstartComment - - 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 notEglRuntimeExceptionpublic String startPreserve(String startComment, String endComment, String id, boolean enabled) throws EglRuntimeException
IOutputBufferstartPreserve in interface IOutputBufferstartComment - - 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 notEglRuntimeExceptionpublic String startLocate(String startComment, String endComment, String id, boolean enabled, RegionType regionType) throws EglRuntimeException
EglRuntimeExceptionprotected void assertNoMixedRegions(RegionType regionType) throws EglRuntimeException
EglRuntimeExceptionpublic String stopControl() throws EglRuntimeException
IOutputBufferstopControl in interface IOutputBufferEglRuntimeException - if there is no unclosed protected region in the buffer.public String stopPreserve() throws EglRuntimeException
IOutputBufferstopPreserve in interface IOutputBufferEglRuntimeException - if there is no unclosed protected region in the buffer.public String stopLocate() throws EglRuntimeException
EglRuntimeExceptionpublic void stop()
throws EglStoppedException
IOutputBufferstop in interface IOutputBufferEglStoppedExceptionpublic int getCurrentLineNumber()
IOutputBuffergetCurrentLineNumber in interface IOutputBufferpublic int getCurrentColumnNumber()
IOutputBuffergetCurrentColumnNumber in interface IOutputBufferpublic int getOffset()
IOutputBuffergetOffset in interface IOutputBufferpublic void formatWith(Formatter formatter)
IOutputBufferFormatter.formatWith in interface IOutputBufferprotected void replaceContentsWith(String newContents)
public String toString()
IOutputBuffertoString in interface IOutputBuffertoString in class ObjectCopyright © 2016. All rights reserved.