Skip to content

Metabolomics Fiehn Lab

Sections
Personal tools
You are here: Home » Members » Gert Wohlgemuth » java » xdoclet - create a TagHandler

xdoclet - create a TagHandler

Document Actions
this is how you can actually extents xdoclete template engine by an own TagHandler
How to create a Taghandler wich provides the possibility to create switch/case statements in java files by using a template.

I skip the comments like ever, because is pretty simple...

code:

package edu.ucdavis.genomics.metabolomics.binbase.bdi.xdoclet.tag;

import xdoclet.XDocletTagSupport;
import xdoclet.loader.TagHandlerDefinition;

/**
 * @xdoclet.taghandler   namespace="Counter"
 */
public class CounterTagHandler extends XDocletTagSupport{
    int value = 0;
   
    public void increase(){
        value++;
    }
   
    public void decrease(){
        value--;
    }

    public String current(){
        return String.valueOf(value);
    }

    public void reset(){
        value = 0;
    }

    public CounterTagHandler() {
        super();
    }      
}

so what does it do:

  1. define our own namespace, called counter
  2. provides 4 methods to the template engine

the next step is to put it in a module

create a module

how to use

You just have to put your Module into the xdoclets Classpath, everything else does xdoclet for us!

now you can use these new methods in your xdt file

<XDtCounter:reset/>
<XDtCounter:increase/>
<XDtCounter:decrease/>
<XDtCounter:current/>

thats all,
Created by zwluxx
Last modified 2005-10-10 12:43 AM
 

Powered by Plone

This site conforms to the following standards: