Home of: [Atelier "FUJIGURUMA"] >> [PageMixer hosted by SourceForge.net]

SEE "For Readers of English Version",
or Japanese version of this page

Inset data into sequence

This section explains how to inset your data instead of part of HTML page in PageMixer framework. Explanation uses the filter which insets user-name string between "<span>" and corresponding "</span>" in HTML page.

<span class="Auth-UserName"></span>

Before processing

<span class="Auth-UserName">foozy</span>

After processing


Class diagram

Class diagram in this section is shown below:

Class diagram
Class diagram (click for large figure)

Classes which you must define are colored, and other are already defined.

Object diagram

Object diagram in this section is shown below:

Object diagram
Object diagram (click for large figure)

Sequence diagram

Sequence diagram in this section is shown below:

Sequence diagram
Sequence diagram (click for large figure)

Class names

In this tutorial, abbreviated class names are used. Complete names are shown below.

Classes of PageMixer framework

NotationFull name
ConsumerContext jp.ne.dti.lares.foozy.pagemixer.mixer.ConsumerContext
HTMLSymbolSet jp.ne.dti.lares.foozy.pagemixer.HTMLSymbolSet
SequenceDataInsetFilter jp.ne.dti.lares.foozy.pagemixer.mixer.SequenceDataInsetFilter
SequenceWatcher jp.ne.dti.lares.foozy.pagemixer.mixer.SequenceWatcher
TokenDataInsetFilter jp.ne.dti.lares.foozy.pagemixer.mixer.TokenDataInsetFilter
TokenWatcher jp.ne.dti.lares.foozy.pagemixer.mixer.TokenWatcher

Tutorial specific classes

NotationFull name
Bootstrap pagemixer.filter.Bootstrap
UsernameTextInsetFilter pagemixer.filter.UsernameTextInsetFilter

Create SequenceWatcher

As described above, this section let the filter inset user-name string between "<span>" and corresponding "</span>" in HTML page. But, it is not good idea to inset it into all parts between them in given HTML page.

Then, condition of target sub-sequence are:

In this case, "SequenceWatcher.NameAttr" is used as "SequenceWatcher". It is "Sequence Watcher watching at Name and Attribute of first token".

new SequenceWatcher.NameAttr(HTMLSymbolSet.SET.SPAN,

SequenceWatcher to inset text into between "span"

Concretize SequenceDataInsetFilter

PageMixer framework provides the utility classes which provide the template to inset data instead of sub-sequence found by SequenceWatcher given on construction, and these are SequenceDataInsetFilter and its derived classes.

In the situation of this section, you must inset data as "HTML-Safe" TextToken, because:

and, "SequenceDataInsetFilter.HTMLSafeTextInside" is good for this purpose.

public class UsernameTextInsetFilter
    extends SequenceDataInsetFilter.HTMLSafeTextInside
    final static
    private HTMLSymbolSet SET = HTMLSymbolSet.SET;

    final static
    private String ATTR_VALUE = "Auth-UserName";


    public UsernameTextInsetFilter(Object key){
        super(new SequenceWatcher.NameAttr(SET.SPAN,

    // Concretization of class HTMLSafeTextInside

    protected String getText(Object data){
        return (null != data ? data.toString() : "");

Concretize SequenceDataInsetFilter.HTMLSafeTextInside

Differences between samples of "Inset data into token" and this section are:

Connect and mix

Now, everything needed are ready to use. Execution code is as below (see UsernameTextInsetFilter for detail).

    // key to set/get user name
    final Object key = "Auth.Login";
    // user name
    final String name = "foozy";

    Bootstrap bootstrap =
    new Bootstrap.Default(filename)
        protected void prepare(ConsumerContext context)
            // put user name into context
            context.setValue(key, name);

    // apply the filter
    bootstrap.execute(new UsernameTextInsetFilter(key));
catch(Exception e){
Connect and Mix

Sample HTML file as input is "auth.en.html" (or "index.en.html") under "src/demo/servlet/war/WEB-INF/page/demosite" in distribution.

To next section "Iterate sub-sequence"