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.StringBuffer
buffer
protected boolean
contentTypeSet
protected IEglContext
context
protected java.util.List<CommentBlockPartitioner>
customPartitioners
protected boolean
hasControlledRegions
protected boolean
hasProtectedRegions
protected java.lang.String
lastLine
-
Constructor Summary
Constructors Constructor Description OutputBuffer()
OutputBuffer(IEglContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertNoMixedRegions(RegionType regionType)
protected java.lang.String
calculateIndentationToMatch(java.lang.String previousLine)
void
chop(int chars)
Removes the specified number of characters from the end of the buffer.void
formatWith(Formatter formatter)
Reformats the contents of the buffer with the givenFormatter
.int
getCurrentLineNumber()
Returns the line number of the last character in the buffer.protected java.lang.String
getLastLineInBuffer()
int
getOffset()
Returns the size of the buffer.void
print(java.lang.Object o)
Appends a string representation of the given object to the buffer.void
printdyn(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.void
println()
Appends a new line the buffer.protected void
replaceContentsWith(java.lang.String newContents)
void
setContentType(java.lang.String name)
Specifies the type of output in the buffer, such as Java or HTML.java.lang.String
startControl(java.lang.String id, boolean enabled)
Appends the starting tag for a controlled region to the buffer.java.lang.String
startControl(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.String
startLocate(java.lang.String id, boolean enabled, RegionType regionType)
java.lang.String
startLocate(java.lang.String startComment, java.lang.String endComment, java.lang.String id, boolean enabled, RegionType regionType)
java.lang.String
startPreserve(java.lang.String id, boolean enabled)
Appends the starting tag for a protected region to the buffer.java.lang.String
startPreserve(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.void
stop()
Halts execution of the current template.java.lang.String
stopControl()
Appends a closing tag for a protected region to the buffer.java.lang.String
stopLocate()
java.lang.String
stopPreserve()
Appends a closing tag for a protected region to the buffer.java.lang.String
toString()
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:IOutputBuffer
Removes the specified number of characters from the end of the buffer.- Specified by:
chop
in interfaceIOutputBuffer
-
print
public void print(java.lang.Object o)
Description copied from interface:IOutputBuffer
Appends a string representation of the given object to the buffer.- Specified by:
print
in interfaceIOutputBuffer
-
printdyn
public void printdyn(java.lang.Object o)
Description copied from interface:IOutputBuffer
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.- Specified by:
printdyn
in 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:IOutputBuffer
Appends a new line the buffer.- Specified by:
println
in interfaceIOutputBuffer
-
setContentType
public void setContentType(java.lang.String name) throws EglRuntimeException
Description copied from interface:IOutputBuffer
Specifies the type of output in the buffer, such as Java or HTML.- Specified by:
setContentType
in interfaceIOutputBuffer
- Throws:
EglRuntimeException
- if the content type is not supported.
-
startPreserve
public java.lang.String startPreserve(java.lang.String id, boolean enabled) throws EglRuntimeException
Description copied from interface:IOutputBuffer
Appends the starting tag for a protected region to the buffer.- Specified by:
startPreserve
in 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 EglRuntimeException
Description copied from interface:IOutputBuffer
Appends the starting tag for a controlled region to the buffer.- Specified by:
startControl
in 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 EglRuntimeException
Description copied from interface:IOutputBuffer
Appends the starting tag for a protected region to the buffer.- Specified by:
startControl
in 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 EglRuntimeException
Description copied from interface:IOutputBuffer
Appends the starting tag for a protected region to the buffer.- Specified by:
startPreserve
in 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 EglRuntimeException
Description copied from interface:IOutputBuffer
Appends a closing tag for a protected region to the buffer.- Specified by:
stopControl
in interfaceIOutputBuffer
- Throws:
EglRuntimeException
- if there is no unclosed protected region in the buffer.
-
stopPreserve
public java.lang.String stopPreserve() throws EglRuntimeException
Description copied from interface:IOutputBuffer
Appends a closing tag for a protected region to the buffer.- Specified by:
stopPreserve
in 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 EglStoppedException
Description copied from interface:IOutputBuffer
Halts execution of the current template.- Specified by:
stop
in interfaceIOutputBuffer
- Throws:
EglStoppedException
-
getCurrentLineNumber
public int getCurrentLineNumber()
Description copied from interface:IOutputBuffer
Returns the line number of the last character in the buffer.- Specified by:
getCurrentLineNumber
in interfaceIOutputBuffer
-
getOffset
public int getOffset()
Description copied from interface:IOutputBuffer
Returns the size of the buffer.- Specified by:
getOffset
in interfaceIOutputBuffer
-
formatWith
public void formatWith(Formatter formatter)
Description copied from interface:IOutputBuffer
Reformats the contents of the buffer with the givenFormatter
.- Specified by:
formatWith
in interfaceIOutputBuffer
-
replaceContentsWith
protected void replaceContentsWith(java.lang.String newContents)
-
toString
public java.lang.String toString()
Description copied from interface:IOutputBuffer
Converts the contents of the buffer to a string.- Specified by:
toString
in interfaceIOutputBuffer
- Overrides:
toString
in classjava.lang.Object
-
-