Update of 
/cvsroot/xdoclet/xdoclet/modules/apache/src/xdoclet/modules/apache/tapestry
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15155/xdoclet/modules/apache/tapestry

Added Files:
        ComponentSpecificationSubTask.java 
        PageSpecificationSubTask.java TapestryDocletTask.java 
        TapestryTagsHandler.java 
Log Message:
- added support for Tapestry (http://jakarta.apache.org/tapestry)


--- NEW FILE: ComponentSpecificationSubTask.java ---
/*
 * Copyright (c) 2001, 2002 The XDoclet team
 * All rights reserved.
 */
package xdoclet.modules.apache.tapestry;

import org.apache.commons.logging.Log;

import xjavadoc.XClass;
import xdoclet.TemplateSubTask;

import xdoclet.XDocletException;

/**
 * Generates component-specifications for Tapestry applications.
 *
 * @author        Michael Newcomb ([EMAIL PROTECTED])
 * @created       February 4, 2005
 * @version       $Revision: 1.1 $
 * @ant.element   name="component-specification" 
display-name="Component-Specification SubTask"
 *      parent="xdoclet.modules.apache.tapestry.TapestryDocletTask"
 */
public class ComponentSpecificationSubTask extends TemplateSubTask
{
    protected final static String DEFAULT_TEMPLATE_FILE = 
"resources/component-specification.xdt";

    /**
     */
    public ComponentSpecificationSubTask()
    {
        setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
        setDestinationFile("{0}.jwc");
        setPrefixWithPackageStructure(false);
    }

    /**
     * Describe what the method does
     *
     * @param clazz                 Describe what the parameter does
     * @return                      Describe the return value
     * @exception XDocletException
     */
    protected boolean matchesGenerationRules(XClass clazz) throws 
XDocletException
    {
        return clazz.getDoc().getTag("tapestry.component-specification") != 
null;
    }
}

--- NEW FILE: PageSpecificationSubTask.java ---
/*
 * Copyright (c) 2001, 2002 The XDoclet team
 * All rights reserved.
 */
package xdoclet.modules.apache.tapestry;

import org.apache.commons.logging.Log;

import xjavadoc.XClass;
import xdoclet.TemplateSubTask;

import xdoclet.XDocletException;

/**
 * Generates page-specifications for Tapestry applications.
 *
 * @author        Michael Newcomb ([EMAIL PROTECTED])
 * @created       February 4, 2005
 * @version       $Revision: 1.1 $
 * @ant.element   name="page-specification" display-name="Page-Specification 
SubTask"
 *      parent="xdoclet.modules.apache.tapestry.TapestryDocletTask"
 */
public class PageSpecificationSubTask extends TemplateSubTask
{
    protected final static String DEFAULT_TEMPLATE_FILE = 
"resources/page-specification.xdt";

    /**
     */
    public PageSpecificationSubTask()
    {
        setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
        setDestinationFile("{0}.page");
        setPrefixWithPackageStructure(false);
    }

    /**
     * Describe what the method does
     *
     * @param clazz                 Describe what the parameter does
     * @return                      Describe the return value
     * @exception XDocletException
     */
    protected boolean matchesGenerationRules(XClass clazz) throws 
XDocletException
    {
        return clazz.getDoc().getTag("tapestry:page-specification") != null;
    }
}

--- NEW FILE: TapestryDocletTask.java ---
/*
 * Copyright (c) 2001, 2002 The XDoclet team
 * All rights reserved.
 */
package xdoclet.modules.apache.tapestry;

import org.apache.tools.ant.BuildException;

import xdoclet.DocletTask;

/**
 * This task builds various Tapestry configuration files. Make sure to include 
the jar file containing the Tapestry
 * classes is on the taskdef's classpath.
 *
 * @author        Michael Newcomb ([EMAIL PROTECTED])
 * @created       February 4, 2005
 * @version       $Revision: 1.1 $
 * @ant.element   name="tapestrydoclet" display-name="Tapestry Task"
 */
public class TapestryDocletTask extends DocletTask
{
    protected void validateOptions() throws BuildException
    {
        super.validateOptions();
        checkClass("org.apache.tapestry.Tapestry");
    }
}

--- NEW FILE: TapestryTagsHandler.java ---
/*
 * Copyright (c) 2001, 2002 The XDoclet team
 * All rights reserved.
 */
package xdoclet.modules.apache.tapestry;

import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;

import org.apache.commons.logging.Log;

import xjavadoc.XTag;

import xdoclet.XDocletException;
import xdoclet.XDocletTagSupport;

import xdoclet.util.LogUtil;

/**
 * @author               Michael Newcomb ([EMAIL PROTECTED])
 * @created              February 4, 2005
 * @version              $Revision: 1.1 $
 * @xdoclet.taghandler   namespace="Tapestry"
 */
public class TapestryTagsHandler extends XDocletTagSupport
{
    private XTag    currentBean;
    private XTag    currentComponent;
    private XTag    currentContextAsset;
    private XTag    currentExternalAsset;
    private XTag    currentPrivateAsset;

    private XTag    currentTag;

    public String currentTagValue(Properties attributes) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "currentTagValue");

        String attrName = attributes.getProperty("attrName");

        return currentTag.getAttributeValue(attrName);
    }

    public void forAllComponents(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllComponents");

        Collection components =
            getCurrentClass().getDoc().getTags("tapestry:component", true);

        for (Iterator i = components.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();
            currentComponent = currentTag;

            generate(template);
        }
        currentComponent = null;
    }

    public void forAllProperties(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllProperties");

        Collection properties =
            getCurrentClass().getDoc().getTags("tapestry:property", true);

        for (Iterator i = properties.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            if (currentTag.getAttributeNames().contains("name") &&
                currentTag.getAttributeNames().contains("value") &&
                currentTag.getAttributeNames().size() == 2) {
                generate(template);
            }
        }
    }

    public void forAllComponentItems(String template, Properties attributes) 
throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllComponentItems");

        String tagName = attributes.getProperty("tagName");

        Collection items = getCurrentClass().getDoc().getTags(tagName, true);

        for (Iterator i = items.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            if (currentComponent.getAttributeValue("id").equals(
                currentTag.getAttributeValue("component"))) {
                generate(template);
            }
        }
    }

    public void forAllBeans(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllBeans");

        Collection beans =
            getCurrentClass().getDoc().getTags("tapestry:bean", true);

        for (Iterator i = beans.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();
            currentBean = currentTag;

            generate(template);
        }
        currentBean = null;
    }

    public void forAllBeanItems(String template, Properties attributes) throws 
XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllBeanItems");

        String tagName = attributes.getProperty("tagName");

        Collection items = getCurrentClass().getDoc().getTags(tagName, true);

        for (Iterator i = items.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            if (currentBean.getAttributeValue("name").equals(
                currentTag.getAttributeValue("bean"))) {
                generate(template);
            }
        }
    }

    public void forAllExternalAssets(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllExternalAssets");

        Collection externalAssets =
            getCurrentClass().getDoc().getTags("tapestry:external-asset", true);

        for (Iterator i = externalAssets.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();
            currentExternalAsset = currentTag;

            generate(template);
        }
        currentExternalAsset = null;
    }

    public void forAllExternalAssetItems(String template, Properties 
attributes) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllExternalAssetItems");

        String tagName = attributes.getProperty("tagName");

        Collection items = getCurrentClass().getDoc().getTags(tagName, true);

        for (Iterator i = items.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            if (currentExternalAsset.getAttributeValue("name").equals(
                currentTag.getAttributeValue("external-asset"))) {
                generate(template);
            }
        }
    }

    public void forAllContextAssets(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllContextAssets");

        Collection contextAssets =
            getCurrentClass().getDoc().getTags("tapestry:context-asset", true);

        for (Iterator i = contextAssets.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();
            currentContextAsset = currentTag;

            generate(template);
        }
        currentContextAsset = null;
    }

    public void forAllContextAssetItems(String template, Properties attributes) 
throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllContextAssetItems");

        String tagName = attributes.getProperty("tagName");

        Collection items = getCurrentClass().getDoc().getTags(tagName, true);

        for (Iterator i = items.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            if (currentContextAsset.getAttributeValue("name").equals(
                currentTag.getAttributeValue("context-asset"))) {
                generate(template);
            }
        }
    }

    public void forAllPrivateAssets(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllPrivateAssets");

        Collection privateAssets =
            getCurrentClass().getDoc().getTags("tapestry:private-asset", true);

        for (Iterator i = privateAssets.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();
            currentPrivateAsset = currentTag;

            generate(template);
        }
        currentPrivateAsset = null;
    }

    public void forAllPrivateAssetItems(String template, Properties attributes) 
throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllPrivateAssetItems");

        String tagName = attributes.getProperty("tagName");

        Collection items = getCurrentClass().getDoc().getTags(tagName, true);

        for (Iterator i = items.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            if (currentPrivateAsset.getAttributeValue("name").equals(
                currentTag.getAttributeValue("private-asset"))) {
                generate(template);
            }
        }
    }

    public void forAllPropertySpecifications(String template) throws 
XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllPropertySpecifications");

        Collection propertySpecifications =
            getCurrentClass().getDoc().getTags(
            "tapestry:property-specification", true);

        for (Iterator i = propertySpecifications.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            generate(template);
        }
    }

    public void forAllParameters(String template) throws XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllParameters");

        Collection parameters =
            getCurrentClass().getDoc().getTags("tapestry:parameter", true);

        for (Iterator i = parameters.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            generate(template);
        }
    }

    public void forAllReservedParameters(String template) throws 
XDocletException
    {
        Log log = LogUtil.getLog(TapestryTagsHandler.class,
            "forAllReservedParameters");

        Collection parameters =
            getCurrentClass().getDoc().getTags(
            "tapestry:reserved-parameter", true);

        for (Iterator i = parameters.iterator(); i.hasNext(); ) {
            currentTag = (XTag) i.next();

            generate(template);
        }
    }

    public void ifCurrentTagHasAttribute(String template, Properties 
attributes) throws XDocletException
    {
        if (currentTagValue(attributes) != null) {
            generate(template);
        }
    }
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
xdoclet-devel mailing list
xdoclet-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to