public interface IModel
Interface representing all model objects.
Models are sequences of events (ITemplateEvent
) normally representing a specific element
with all its body and nested elements, or even an entire document.
IModel
implementations are the classes used at the template engine for representing
templates or fragments.
From the user's code (e.g. custom processors), implementations of IModel
are created using an
IModelFactory
, obtained from ITemplateContext.getModelFactory()
.
TemplateModel
,
IModelFactory
,
IElementModelProcessor
Modifier and Type | Method and Description |
---|---|
void |
accept(IModelVisitor visitor)
Accept a visitor implementing
IModelVisitor . |
void |
add(ITemplateEvent event)
Adds an event at the end of the sequence.
|
void |
addModel(IModel model)
Add an entire model at the end of the sequence.
|
IModel |
cloneModel()
Clones the model and all its events.
|
ITemplateEvent |
get(int pos)
Retrieves a specific event from the model sequence.
|
IEngineConfiguration |
getConfiguration()
Returns the engine configuration that was used for creating this model.
|
TemplateMode |
getTemplateMode()
Returns the template mode used for creating this model.
|
void |
insert(int pos,
ITemplateEvent event)
Inserts an event into a specific position in the sequence.
|
void |
insertModel(int pos,
IModel model)
Inserts an entire model into a specific position in this model's sequence.
|
void |
remove(int pos)
Remove an event from the sequence.
|
void |
replace(int pos,
ITemplateEvent event)
Replaces the event at the specified position with the one passed
as argument.
|
void |
reset()
Remove all events from the model sequence.
|
int |
size()
The size of the model (number of
ITemplateEvent objects contained). |
void |
write(Writer writer)
Write this model (its events) through the specified writer.
|
IEngineConfiguration getConfiguration()
Returns the engine configuration that was used for creating this model.
TemplateMode getTemplateMode()
Returns the template mode used for creating this model.
int size()
The size of the model (number of ITemplateEvent
objects contained).
ITemplateEvent get(int pos)
Retrieves a specific event from the model sequence.
pos
- the position (zero-based) of the event to be retrieved.void add(ITemplateEvent event)
Adds an event at the end of the sequence.
event
- the event to be added.void insert(int pos, ITemplateEvent event)
Inserts an event into a specific position in the sequence.
pos
- the position to insert the event (zero-based).event
- the event to be inserted.void replace(int pos, ITemplateEvent event)
Replaces the event at the specified position with the one passed as argument.
pos
- the position of the event to be replaced (zero-based).event
- the event to serve as replacement.void addModel(IModel model)
Add an entire model at the end of the sequence. This effectively appends the model argument's sequence to this one.
model
- the model to be appended.void insertModel(int pos, IModel model)
Inserts an entire model into a specific position in this model's sequence.
pos
- the position to insert the mdoel (zero-based).model
- the model to be inserted.void remove(int pos)
Remove an event from the sequence.
pos
- the position (zero-based) of the event to be removed.void reset()
Remove all events from the model sequence.
IModel cloneModel()
Clones the model and all its events.
void accept(IModelVisitor visitor)
Accept a visitor implementing IModelVisitor
. This visitor will be executed
for each event in the sequence.
visitor
- the visitor object.void write(Writer writer) throws IOException
Write this model (its events) through the specified writer.
writer
- the writer that will be used for writing the model.IOException
- should any exception happen.Copyright © 2016 The THYMELEAF team. All rights reserved.