Package io.ciera.runtime.template.util
Interface T
-
- All Known Implementing Classes:
TImpl
public interface T
The T utility provides tools for working with RSL templates. The utility maintains a stack of String buffers. Each buffer accumulates content asappend
andinclude
calls are made. The buffer is cleared whenclear
andbody
calls are made. Multiple buffers can be managed at once on the stack usingpush_buffer
andpop_buffer
calls.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
append(Object o)
Append an object to the current buffer.void
append(String s)
Append a string to the current buffer.String
body()
Clear the current buffer and return the contents as a String.void
clear()
Clear the current buffervoid
emit(String file)
Clear the current buffer and emit the contents to a file specified byfile
.void
include(String file, Object... symbols)
Include an RSL template.void
pop_buffer()
Remove the current buffer and replace it with the next buffer on the buffer stack.void
push_buffer()
Store the current buffer on the buffer stack and replace it with a new buffer.void
set_output_directory(String dir)
Set the root directory for emitting files.default String
sub(String format, Object o)
Perform a format substitution.String
sub(String format, String s)
Perform a format substitution.
-
-
-
Method Detail
-
append
void append(String s)
Append a string to the current buffer.- Parameters:
s
- the string value to append
-
append
default void append(Object o)
Append an object to the current buffer. By default, the object gets converted to a String using the standardtoString
method before being added to the buffer.- Parameters:
o
- the object to append
-
body
String body()
Clear the current buffer and return the contents as a String.- Returns:
- the contents of the buffer
-
clear
void clear()
Clear the current buffer
-
emit
void emit(String file) throws XtumlException
Clear the current buffer and emit the contents to a file specified byfile
.- Parameters:
file
- the name of the output file relative to the configured output directory- Throws:
XtumlException
- if the file cannot be opened for writing- See Also:
set_output_directory(java.lang.String)
-
include
void include(String file, Object... symbols) throws XtumlException
Include an RSL template. The in-scope variables in the location where invoked will be captured and passed as the list ofsymbols
.- Parameters:
file
- the template file to include relative to the root template directorysymbols
- the list of symbols to pass to the template. When invoked from OAL, this list is composed by capturing all in-scope variables in the context where it was invoked.- Throws:
XtumlException
- if an error occurs during template evaluation
-
pop_buffer
void pop_buffer()
Remove the current buffer and replace it with the next buffer on the buffer stack.
-
push_buffer
void push_buffer()
Store the current buffer on the buffer stack and replace it with a new buffer.
-
set_output_directory
void set_output_directory(String dir)
Set the root directory for emitting files.- Parameters:
dir
- the root location for template output
-
sub
String sub(String format, String s) throws XtumlException
Perform a format substitution. The following format characters are supported:u
(upper) - make all characters upper casec
(capitalize) - make the first character of each word capitalized and all other characters of a word lowercasel
(lower) - make all characters lowercase_
(underscore) - change all whitespace characters to underscore charactersr
(remove) - remove all whitespaceo
(corba) - make the first word all lowercase, make the first character of each following word capitalized and all other characters of the words lowercase. Characters other than a-Z a-z 0-9 are ignoredt
(pass-through)
format
parameter will be evaluated as a format character sequentially left to right.- Parameters:
format
- the string of format characters representing operations to performs
- the string to format- Returns:
- a formatted string
- Throws:
XtumlException
- if an invalid format character is passed
-
sub
default String sub(String format, Object o) throws XtumlException
Perform a format substitution. By default, the object gets converted to a String using the standardtoString
method before being passed to thesub
method.- Parameters:
format
- the string of format characters representing operations to performo
- the object to format- Returns:
- a formatted string
- Throws:
XtumlException
- if an invalid format character is passed
-
-