KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsp > cfg > TldValidator


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.jsp.cfg;
30
31 import com.caucho.config.types.InitParam;
32 import com.caucho.util.BeanUtil;
33 import com.caucho.util.RegistryException;
34
35 import javax.servlet.jsp.tagext.TagLibraryValidator JavaDoc;
36 import java.util.HashMap JavaDoc;
37
38 /**
39  * Configuration for the taglib validator in the .tld
40  */

41 public class TldValidator {
42   private Class JavaDoc _validatorClass;
43   private HashMap JavaDoc<String JavaDoc,String JavaDoc> _initParamMap = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
44   private String JavaDoc _description;
45
46   /**
47    * Sets the validator class.
48    */

49   public void setValidatorClass(Class JavaDoc validatorClass)
50     throws RegistryException
51   {
52     _validatorClass = validatorClass;
53     
54     BeanUtil.validateClass(_validatorClass, TagLibraryValidator JavaDoc.class);
55   }
56
57   /**
58    * Gets the validator class.
59    */

60   public Class JavaDoc getValidatorClass()
61   {
62     return _validatorClass;
63   }
64
65   /**
66    * Adds an init-param.
67    */

68   public void addInitParam(String JavaDoc name, String JavaDoc value)
69   {
70     _initParamMap.put(name, value);
71   }
72
73   /**
74    * Sets an init-param
75    */

76   public void setInitParam(InitParam initParam)
77   {
78     _initParamMap.putAll(initParam.getParameters());
79   }
80
81   /**
82    * Gets the jsp version.
83    */

84   public HashMap JavaDoc getInitParamMap()
85   {
86     return _initParamMap;
87   }
88
89   /**
90    * Sets the description.
91    */

92   public void setDescription(String JavaDoc description)
93   {
94     _description = description;
95   }
96
97   /**
98    * Gets the description.
99    */

100   public String JavaDoc getDescription()
101   {
102     return _description;
103   }
104
105   /**
106    * Returns the validator.
107    */

108   public TagLibraryValidator JavaDoc getValidator()
109     throws Exception JavaDoc
110   {
111     TagLibraryValidator JavaDoc validator;
112
113     validator = (TagLibraryValidator JavaDoc) _validatorClass.newInstance();
114
115     validator.setInitParameters(_initParamMap);
116
117     return validator;
118   }
119 }
120
Popular Tags