| Constructor and description |
|---|
IModelExtensions() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static boolean |
asBoolean(IModel self)Set that a model evaluates to 'false' if it has no events. |
|
static Iterator<IModel> |
childModelIterator(IModel self)If this model represents an element, then this method returns an iterator over any potential child items as models of their own. |
|
static void |
each(IModel self, Closure closure)Iterate through each event in the model. |
|
static boolean |
equals(IModel self, Object other)Compare 2 models, returning true if all of the model's events
are equal. |
|
static boolean |
everyWithIndex(IModel self, Closure<Boolean> closure)Return true only if all the events in the model return
true for the given closure. |
|
static ITemplateEvent |
find(IModel self, Closure<Boolean> closure)Returns the first event in the model that meets the criteria of the given closure. |
|
static List<ITemplateEvent> |
findAll(IModel self, Closure<Boolean> closure)Find all events in the model that match the given closure. |
|
static int |
findIndexOf(IModel self, Closure<Boolean> closure)Returns the index of the first event in the model that meets the criteria of the given closure. |
|
static int |
findIndexOfModel(IModel self, IModel model)A special variant of findIndexOf that uses models, as I seem to
be using those a lot. |
|
static IModel |
findModel(IModel self, Closure<Boolean> closure)Returns the first instance of a model that meets the given closure criteria. |
|
static ITemplateEvent |
first(IModel self)Returns the first event on the model. |
|
static IModel |
getModel(IModel self, int pos)Returns the model at the given index. |
|
static void |
insertModelWithWhitespace(IModel self, int pos, IModel model, IModelFactory modelFactory)Inserts a model, creating whitespace events around it so that it appears in line with all the existing events. |
|
static void |
insertWithWhitespace(IModel self, int pos, ITemplateEvent event, IModelFactory modelFactory)Inserts an event, creating a whitespace event before it so that it appears in line with all the existing events. |
|
static boolean |
isElement(IModel self)Returns whether or not this model represents a single HTML element. |
|
static boolean |
isWhitespace(IModel self)Returns whether or not this model represents collapsible whitespace. |
|
static Iterator<ITemplateEvent> |
iterator(IModel self)Used to make this class iterable as an event queue. |
|
static ITemplateEvent |
last(IModel self)Returns the last event on the model. |
|
static void |
removeAllModels(IModel self, Closure<Boolean> closure)Remove a model identified by an event matched by the given closure. |
|
static void |
removeChildren(IModel self)If the model represents an element open to close tags, then this method removes all of the inner events. |
|
static void |
removeFirst(IModel self)Removes the first event on the model. |
|
static void |
removeLast(IModel self)Removes the last event on the model. |
|
static void |
removeModel(IModel self, int pos)Removes a models-worth of events from the specified position. |
|
static void |
replaceModel(IModel self, int pos, IModel model)Replaces the model at the specified index with the given model. |
|
static int |
sizeOfModelAt(IModel self, int index)If an opening element exists at the given position, this method will return the 'size' of that element (number of events from here to its matching closing tag). |
|
static void |
trim(IModel self)Removes whitespace events from the head and tail of the model's underlying event queue. |
Set that a model evaluates to 'false' if it has no events.
true if this model has events.If this model represents an element, then this method returns an iterator over any potential child items as models of their own.
Iterate through each event in the model.
Compare 2 models, returning true if all of the model's events
are equal.
true if this model is the same as the other one. Return true only if all the events in the model return
true for the given closure.
true if every event satisfies the closure.Returns the first event in the model that meets the criteria of the given closure.
null
if nothing matched.Find all events in the model that match the given closure.
Returns the index of the first event in the model that meets the criteria of the given closure.
-1 if nothing matched. A special variant of findIndexOf that uses models, as I seem to
be using those a lot.
This doesn't use an equality check, but an object reference check, so
if a submodel is ever located from a parent (eg: any of the find
methods, you can use this method to find the location of that submodel
within the event queue.
Returns the first instance of a model that meets the given closure criteria.
null if nothing matched.Returns the first event on the model.
Returns the model at the given index. If the event at the index is an opening element, then the returned model will consist of that element and all the way through to the matching closing element.
pos - A valid index within the current model.Inserts a model, creating whitespace events around it so that it appears in line with all the existing events.
This is currently only targeting uses in the layout dialect so doesn't work very well as a general-purpose whitespace generator.
pos - A valid index within the current model.Inserts an event, creating a whitespace event before it so that it appears in line with all the existing events.
pos - A valid index within the current model.Returns whether or not this model represents a single HTML element.
true if the first event in this model is an opening tag
and the last event is the matching closing tag.Returns whether or not this model represents collapsible whitespace.
true if this is a collapsible text model.Used to make this class iterable as an event queue.
Returns the last event on the model.
Remove a model identified by an event matched by the given closure. Note that this closure can match any event in the model, including the top-level model itself.
If the model represents an element open to close tags, then this method removes all of the inner events.
Removes the first event on the model.
Removes the last event on the model.
Removes a models-worth of events from the specified position. What this means is that, if the event at the position is an opening element, then it, and everything up to and including its matching end element, is removed.
pos - A valid index within the current model.Replaces the model at the specified index with the given model.
pos - A valid index within the current model.If an opening element exists at the given position, this method will return the 'size' of that element (number of events from here to its matching closing tag).
Removes whitespace events from the head and tail of the model's underlying event queue.