Package org.eclipse.epsilon.egl.output
Class OutputBuffer
- java.lang.Object
-
- org.eclipse.epsilon.egl.output.OutputBuffer
-
- All Implemented Interfaces:
IOutputBuffer
public class OutputBuffer extends java.lang.Object implements IOutputBuffer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBufferbufferprotected booleancontentTypeSetprotected IEglContextcontextprotected java.util.List<CommentBlockPartitioner>customPartitionersprotected booleanhasControlledRegionsprotected booleanhasProtectedRegionsprotected java.lang.StringlastLine
-
Constructor Summary
Constructors Constructor Description OutputBuffer()OutputBuffer(IEglContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertNoMixedRegions(RegionType regionType)protected java.lang.StringcalculateIndentationToMatch(java.lang.String previousLine)voidchop(int chars)Removes the specified number of characters from the end of the buffer.voidformatWith(Formatter formatter)Reformats the contents of the buffer with the givenFormatter.intgetCurrentLineNumber()Returns the line number of the last character in the buffer.protected java.lang.StringgetLastLineInBuffer()intgetOffset()Returns the size of the buffer.voidprint(java.lang.Object o)Appends a string representation of the given object to the buffer.voidprintdyn(java.lang.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.voidprintln()Appends a new line the buffer.protected voidreplaceContentsWith(java.lang.String newContents)voidsetContentType(java.lang.String name)Specifies the type of output in the buffer, such as Java or HTML.java.lang.StringstartControl(java.lang.String id, boolean enabled)Appends the starting tag for a controlled region to the buffer.java.lang.StringstartControl(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled)Appends the starting tag for a protected region to the buffer.java.lang.StringstartLocate(java.lang.String id, boolean enabled, RegionType regionType)java.lang.StringstartLocate(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled, RegionType regionType)java.lang.StringstartPreserve(java.lang.String id, boolean enabled)Appends the starting tag for a protected region to the buffer.java.lang.StringstartPreserve(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled)Appends the starting tag for a protected region to the buffer.voidstop()Halts execution of the current template.java.lang.StringstopControl()Appends a closing tag for a protected region to the buffer.java.lang.StringstopLocate()java.lang.StringstopPreserve()Appends a closing tag for a protected region to the buffer.java.lang.StringtoString()Converts the contents of the buffer to a string.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.epsilon.egl.output.IOutputBuffer
control, control, getCurrentColumnNumber, getNewline, getSpaces, preserve, preserve, println, prinx
-
-
-
-
Field Detail
-
buffer
protected java.lang.StringBuffer buffer
-
context
protected IEglContext context
-
customPartitioners
protected java.util.List<CommentBlockPartitioner> customPartitioners
-
contentTypeSet
protected boolean contentTypeSet
-
lastLine
protected java.lang.String lastLine
-
hasProtectedRegions
protected boolean hasProtectedRegions
-
hasControlledRegions
protected boolean hasControlledRegions
-
-
Constructor Detail
-
OutputBuffer
public OutputBuffer(IEglContext context)
-
OutputBuffer
public OutputBuffer()
-
-
Method Detail
-
chop
public void chop(int chars)
Description copied from interface:IOutputBufferRemoves the specified number of characters from the end of the buffer.- Specified by:
chopin interfaceIOutputBuffer
-
print
public void print(java.lang.Object o)
Description copied from interface:IOutputBufferAppends a string representation of the given object to the buffer.- Specified by:
printin interfaceIOutputBuffer
-
printdyn
public void printdyn(java.lang.Object o)
Description copied from interface:IOutputBufferAppends 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.- Specified by:
printdynin interfaceIOutputBuffer
-
getLastLineInBuffer
protected java.lang.String getLastLineInBuffer()
-
calculateIndentationToMatch
protected java.lang.String calculateIndentationToMatch(java.lang.String previousLine)
-
println
public void println()
Description copied from interface:IOutputBufferAppends a new line the buffer.- Specified by:
printlnin interfaceIOutputBuffer
-
setContentType
public void setContentType(java.lang.String name) throws EglRuntimeExceptionDescription copied from interface:IOutputBufferSpecifies the type of output in the buffer, such as Java or HTML.- Specified by:
setContentTypein interfaceIOutputBuffer- Throws:
EglRuntimeException- if the content type is not supported.
-
startPreserve
public java.lang.String startPreserve(java.lang.String id, boolean enabled) throws EglRuntimeExceptionDescription copied from interface:IOutputBufferAppends the starting tag for a protected region to the buffer.- Specified by:
startPreservein interfaceIOutputBuffer- 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- ifIOutputBuffer.setContentType(String)has not been called
-
startControl
public java.lang.String startControl(java.lang.String id, boolean enabled) throws EglRuntimeExceptionDescription copied from interface:IOutputBufferAppends the starting tag for a controlled region to the buffer.- Specified by:
startControlin interfaceIOutputBuffer- 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- ifIOutputBuffer.setContentType(String)has not been called
-
startLocate
public java.lang.String startLocate(java.lang.String id, boolean enabled, RegionType regionType) throws EglRuntimeException- Throws:
EglRuntimeException
-
startControl
public java.lang.String startControl(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled) throws EglRuntimeExceptionDescription copied from interface:IOutputBufferAppends the starting tag for a protected region to the buffer.- Specified by:
startControlin interfaceIOutputBuffer- 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
-
startPreserve
public java.lang.String startPreserve(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled) throws EglRuntimeExceptionDescription copied from interface:IOutputBufferAppends the starting tag for a protected region to the buffer.- Specified by:
startPreservein interfaceIOutputBuffer- 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
-
startLocate
public java.lang.String startLocate(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled, RegionType regionType) throws EglRuntimeException- Throws:
EglRuntimeException
-
assertNoMixedRegions
protected void assertNoMixedRegions(RegionType regionType) throws EglRuntimeException
- Throws:
EglRuntimeException
-
stopControl
public java.lang.String stopControl() throws EglRuntimeExceptionDescription copied from interface:IOutputBufferAppends a closing tag for a protected region to the buffer.- Specified by:
stopControlin interfaceIOutputBuffer- Throws:
EglRuntimeException- if there is no unclosed protected region in the buffer.
-
stopPreserve
public java.lang.String stopPreserve() throws EglRuntimeExceptionDescription copied from interface:IOutputBufferAppends a closing tag for a protected region to the buffer.- Specified by:
stopPreservein interfaceIOutputBuffer- Throws:
EglRuntimeException- if there is no unclosed protected region in the buffer.
-
stopLocate
public java.lang.String stopLocate() throws EglRuntimeException- Throws:
EglRuntimeException
-
stop
public void stop() throws EglStoppedExceptionDescription copied from interface:IOutputBufferHalts execution of the current template.- Specified by:
stopin interfaceIOutputBuffer- Throws:
EglStoppedException
-
getCurrentLineNumber
public int getCurrentLineNumber()
Description copied from interface:IOutputBufferReturns the line number of the last character in the buffer.- Specified by:
getCurrentLineNumberin interfaceIOutputBuffer
-
getOffset
public int getOffset()
Description copied from interface:IOutputBufferReturns the size of the buffer.- Specified by:
getOffsetin interfaceIOutputBuffer
-
formatWith
public void formatWith(Formatter formatter)
Description copied from interface:IOutputBufferReformats the contents of the buffer with the givenFormatter.- Specified by:
formatWithin interfaceIOutputBuffer
-
replaceContentsWith
protected void replaceContentsWith(java.lang.String newContents)
-
toString
public java.lang.String toString()
Description copied from interface:IOutputBufferConverts the contents of the buffer to a string.- Specified by:
toStringin interfaceIOutputBuffer- Overrides:
toStringin classjava.lang.Object
-
-