public void addRule(TagRule rule) {
defaultState.addRule(rule);
}
public void process() throws IOException {
TagTokenizer tokenizer = new TagTokenizer(sitemeshBuffer.getCharArray(), sitemeshBuffer.getBufferLength());
final HTMLProcessorContext context = new HTMLProcessorContext() {
public SitemeshBuffer getSitemeshBuffer() {
return sitemeshBuffer;
}
public State currentState() {
return currentState;
}
public void changeState(State newState) {
currentState = newState;
}
private SitemeshBufferFragment.Builder[] buffers = new SitemeshBufferFragment.Builder[10];
private int size;
public void pushBuffer(SitemeshBufferFragment.Builder buffer) {
if(size == buffers.length) {
SitemeshBufferFragment.Builder[] newBuffers = new SitemeshBufferFragment.Builder[buffers.length * 2];
System.arraycopy(buffers, 0, newBuffers, 0, buffers.length);
buffers = newBuffers;
}
buffers[size++] = buffer;
}
public SitemeshBufferFragment.Builder currentBuffer() {
return buffers[size - 1];
}
public SitemeshBufferFragment.Builder popBuffer() {
SitemeshBufferFragment.Builder last = buffers[size - 1];
buffers[--size] = null;
return last;
}
};
context.pushBuffer(body);
tokenizer.start(new TokenHandler() {
public boolean shouldProcessTag(String name) {
return currentState.shouldProcessTag(name.toLowerCase());
}