Package org.eclipse.epsilon.egl.output
Interface IOutputBuffer
-
- All Known Implementing Classes:
OutputBuffer
public interface IOutputBuffer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
chop(int numberOfCharacters)
Removes the specified number of characters from the end of the buffer.default String
control(String id, boolean enabled, String contents)
Appends a controlled region to the buffer.default 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 givenFormatter
.default 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.Collection<String>
getIndenters()
default String
getNewline()
int
getOffset()
Returns the size of the buffer.OutdentationFormatter
getOutdentationFormatter()
Returns the outdentation formatterIOutputBuffer
getParent()
default String
getSpaces(int howMany)
Returns a string comprised of the specified number of spaces.default String
preserve(String id, boolean enabled, String contents)
Appends a protected region to the buffer.default 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.default void
println(Object o)
Appends a string representation of the given object and a new line to the buffer.default void
prinx(Object o)
An alias forprint(Object)
that should only be called internally, by code generated by thePreprocessor
.void
setContentType(String name)
Specifies the type of output in the buffer, such as Java or HTML.void
setIndenters(Collection<String> indentation)
void
setParent(IOutputBuffer parent)
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
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
stopPreserve()
Appends a closing tag for a protected region to the buffer.String
toString()
Converts the contents of the buffer to a string.
-
-
-
Method Detail
-
chop
void chop(int numberOfCharacters)
Removes the specified number of characters from the end of the buffer.
-
print
void print(Object o)
Appends a string representation of the given object to the buffer.
-
println
void println()
Appends a new line the buffer.
-
println
default void println(Object o)
Appends a string representation of the given object and a new line to the buffer.
-
printdyn
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. Used to output EGL dynamic sections.
-
prinx
default void prinx(Object o)
An alias forprint(Object)
that should only be called internally, by code generated by thePreprocessor
. 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.- See Also:
EglPreprocessorModule#updateRegionsOfStaticTextASTs
-
getSpaces
default String getSpaces(int howMany)
Returns a string comprised of the specified number of spaces.
-
setContentType
void setContentType(String name) throws EglRuntimeException
Specifies the type of output in the buffer, such as Java or HTML.- Throws:
EglRuntimeException
- if the content type is not supported.
-
preserve
default String preserve(String id, boolean enabled, String contents) throws EglRuntimeException
Appends a protected region to the buffer.- Parameters:
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 region- Throws:
EglRuntimeException
- ifsetContentType(String)
has not been called.
-
preserve
default String preserve(String startComment, String endComment, String id, boolean enabled, String contents) throws EglRuntimeException
Appends a protected region to the buffer.- Parameters:
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 region- Throws:
EglRuntimeException
-
startPreserve
String startPreserve(String id, boolean enabled) throws EglRuntimeException
Appends the starting tag for a protected region to the buffer.- Parameters:
id
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or not- Throws:
EglRuntimeException
- ifsetContentType(String)
has not been called
-
startPreserve
String startPreserve(String startComment, String endComment, String id, boolean enabled) throws EglRuntimeException
Appends the starting tag for a protected region to the buffer.- Parameters:
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 not- Throws:
EglRuntimeException
-
stopPreserve
String stopPreserve() throws EglRuntimeException
Appends a closing tag for a protected region to the buffer.- Throws:
EglRuntimeException
- if there is no unclosed protected region in the buffer.
-
control
default String control(String id, boolean enabled, String contents) throws EglRuntimeException
Appends a controlled region to the buffer.- Parameters:
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 region- Throws:
EglRuntimeException
- ifsetContentType(String)
has not been called.
-
control
default String control(String startComment, String endComment, String id, boolean enabled, String contents) throws EglRuntimeException
Appends a controlled region to the buffer.- Parameters:
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 region- Throws:
EglRuntimeException
-
startControl
String startControl(String id, boolean enabled) throws EglRuntimeException
Appends the starting tag for a controlled region to the buffer.- Parameters:
id
- - a unique identifier for this protected regionenabled
- - a flag indicating whether protection of text in this region should be enabled or not- Throws:
EglRuntimeException
- ifsetContentType(String)
has not been called
-
startControl
String startControl(String startComment, String endComment, String id, boolean enabled) throws EglRuntimeException
Appends the starting tag for a protected region to the buffer.- Parameters:
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 not- Throws:
EglRuntimeException
-
stopControl
String stopControl() throws EglRuntimeException
Appends a closing tag for a protected region to the buffer.- Throws:
EglRuntimeException
- if there is no unclosed protected region in the buffer.
-
stop
void stop() throws EglStoppedException
Halts execution of the current template.- Throws:
EglStoppedException
-
getCurrentLineNumber
int getCurrentLineNumber()
Returns the line number of the last character in the buffer.
-
getCurrentColumnNumber
default int getCurrentColumnNumber()
Returns the character number of the last character in the buffer.
-
getOffset
int getOffset()
Returns the size of the buffer.
-
formatWith
void formatWith(Formatter formatter)
Reformats the contents of the buffer with the givenFormatter
.
-
getOutdentationFormatter
OutdentationFormatter getOutdentationFormatter()
Returns the outdentation formatter
-
toString
String toString()
Converts the contents of the buffer to a string.
-
getNewline
default String getNewline()
- Returns:
- The newline character.
- Since:
- 1.6
-
setIndenters
void setIndenters(Collection<String> indentation)
-
getIndenters
Collection<String> getIndenters()
-
getParent
IOutputBuffer getParent()
-
setParent
void setParent(IOutputBuffer parent)
-
-