KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > ant > AntPropertyTagsHandler


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.ant;
6
7 import java.util.Hashtable JavaDoc;
8 import java.util.Properties JavaDoc;
9
10 import xdoclet.XDocletException;
11 import xdoclet.template.TemplateTagHandler;
12
13 /**
14  * Extracts properties from Ant.
15  *
16  * @author <a HREF="mailto:aslak.nospam@users.sf.net">Aslak Hellesøy</a>
17  * @created 5. januar 2002
18  * @xdoclet.taghandler namespace="Ant"
19  * @version $Revision: 1.8 $
20  */

21 public class AntPropertyTagsHandler extends TemplateTagHandler
22 {
23     private Hashtable JavaDoc antProperties;
24
25     /**
26      * Describe what the AntPropertyTagsHandler constructor does
27      *
28      * @param antProperties Describe what the parameter does
29      */

30     public AntPropertyTagsHandler(Hashtable JavaDoc antProperties)
31     {
32         this.antProperties = antProperties;
33     }
34
35
36     /**
37      * Returns the values of a configuration parameter with the name paramName.
38      *
39      * @param attributes The attributes of the template tag
40      * @return The value of the ant property
41      * @exception XDocletException Description of Exception
42      * @doc.tag type="content"
43      * @doc.param name="name" optional="false" description="The ant property name, without enclosing
44      * ${}"
45      */

46     public String JavaDoc property(Properties JavaDoc attributes) throws XDocletException
47     {
48         String JavaDoc propertyName = attributes.getProperty("name");
49         String JavaDoc propertyValue = (String JavaDoc) antProperties.get(propertyName);
50
51         if (propertyValue == null) {
52             throw new XDocletException("The referenced property " + propertyName + " is not defined.");
53         }
54         return propertyValue;
55     }
56 }
57
Popular Tags