public abstract class BasicBlockRule<T> extends BasicRule
TagRule
helper class for dealing with blocks surrounded by an opening and closing tag.
e.g. <tag>...</tag>
.
Subclasses should implement processStart(Tag)
and processEnd(Tag, Object)
,
which get called at the start and end of the block, respectively. Optionally, data may be passed
between the two by returning an object from processStart(Tag)
which will get passed to
the matching processEnd(Tag, Object)
call, even if there are nested tags. The class type
of data used matches the generic type T of this class.
tagProcessorContext
Constructor and Description |
---|
BasicBlockRule() |
Modifier and Type | Method and Description |
---|---|
void |
process(Tag tag)
Implementations can use this to do any necessary work on the
Tag such as extracting
values or transforming it. |
protected abstract void |
processEnd(Tag tag,
T data)
Called when a block is ended (i.e.
|
protected abstract T |
processStart(Tag tag)
Called when a block is started (i.e.
|
setTagProcessorContext
protected abstract T processStart(Tag tag) throws IOException
<opening>
tag is encountered).tag
- Opening tag.processEnd(Tag, Object)
. May be null.IOException
protected abstract void processEnd(Tag tag, T data) throws IOException
</closing>
tag is encountered).tag
- Closing tag. This will not have any attributes available (as they are associated
with an opening tag. To get access to the attributes, the processStart(Tag)
method
should access them and return them as data.data
- Data returned from processStart(Tag)
. May be null.IOException
public void process(Tag tag) throws IOException
TagRule
Tag
such as extracting
values or transforming it.process
in interface TagRule
process
in class BasicRule
IOException
Copyright © 2015. All Rights Reserved.