Interface IModel
-
- All Known Implementing Classes:
TemplateModel
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 anIModelFactory
, obtained fromITemplateContext.getModelFactory()
.- Since:
- 3.0.0
- Author:
- Daniel Fernández
- See Also:
TemplateModel
,IModelFactory
,IElementModelProcessor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
accept(IModelVisitor visitor)
Accept a visitor implementingIModelVisitor
.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 ofITemplateEvent
objects contained).void
write(Writer writer)
Write this model (its events) through the specified writer.
-
-
-
Method Detail
-
getConfiguration
IEngineConfiguration getConfiguration()
Returns the engine configuration that was used for creating this model.
- Returns:
- the engine configuration.
-
getTemplateMode
TemplateMode getTemplateMode()
Returns the template mode used for creating this model.
- Returns:
- the template mode.
-
size
int size()
The size of the model (number of
ITemplateEvent
objects contained).- Returns:
- the size of the model.
-
get
ITemplateEvent get(int pos)
Retrieves a specific event from the model sequence.
- Parameters:
pos
- the position (zero-based) of the event to be retrieved.- Returns:
- the retrieved event.
-
add
void add(ITemplateEvent event)
Adds an event at the end of the sequence.
- Parameters:
event
- the event to be added.
-
insert
void insert(int pos, ITemplateEvent event)
Inserts an event into a specific position in the sequence.
- Parameters:
pos
- the position to insert the event (zero-based).event
- the event to be inserted.
-
replace
void replace(int pos, ITemplateEvent event)
Replaces the event at the specified position with the one passed as argument.
- Parameters:
pos
- the position of the event to be replaced (zero-based).event
- the event to serve as replacement.
-
addModel
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.- Parameters:
model
- the model to be appended.
-
insertModel
void insertModel(int pos, IModel model)
Inserts an entire model into a specific position in this model's sequence.
- Parameters:
pos
- the position to insert the mdoel (zero-based).model
- the model to be inserted.
-
remove
void remove(int pos)
Remove an event from the sequence.
- Parameters:
pos
- the position (zero-based) of the event to be removed.
-
reset
void reset()
Remove all events from the model sequence.
-
cloneModel
IModel cloneModel()
Clones the model and all its events.
- Returns:
- the new model.
-
accept
void accept(IModelVisitor visitor)
Accept a visitor implementing
IModelVisitor
. This visitor will be executed for each event in the sequence.- Parameters:
visitor
- the visitor object.
-
write
void write(Writer writer) throws IOException
Write this model (its events) through the specified writer.
- Parameters:
writer
- the writer that will be used for writing the model.- Throws:
IOException
- should any exception happen.
-
-