KickJava   Java API By Example, From Geeks To Geeks.

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


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.server.webapp.WebApp;
32
33 import java.util.ArrayList JavaDoc;
34
35 /**
36  * Configuration from the web.xml.
37  *
38  * <pre>
39  * element jsp-config { taglib*
40                         jsp-property-group* }
41  * </pre>
42  */

43 public class JspConfig {
44   private ArrayList JavaDoc<JspTaglib> _taglibList = new ArrayList JavaDoc<JspTaglib>();
45
46   private WebApp _webApp;
47   
48   private ArrayList JavaDoc<JspPropertyGroup> _propertyGroupList
49     = new ArrayList JavaDoc<JspPropertyGroup>();
50
51   public JspConfig(WebApp webApp)
52   {
53     _webApp = webApp;
54   }
55
56   /**
57    * Adds a new taglib to the configuration.
58    */

59   public void addTaglib(JspTaglib taglib)
60   {
61     _taglibList.add(taglib);
62   }
63
64   /**
65    * Returns the taglibs.
66    */

67   public ArrayList JavaDoc<JspTaglib> getTaglibList()
68   {
69     return _taglibList;
70   }
71
72   public JspPropertyGroup createJspPropertyGroup()
73   {
74     return new JspPropertyGroup(_webApp);
75   }
76
77   /**
78    * Adds a new JspPropertyGroup to the configuration.
79    */

80   public void addJspPropertyGroup(JspPropertyGroup propertyGroup)
81   {
82     _propertyGroupList.add(propertyGroup);
83   }
84
85   /**
86    * Returns the JspPropertyGroup list from the configuration.
87    */

88   public ArrayList JavaDoc getJspPropertyGroupList()
89   {
90     return _propertyGroupList;
91   }
92
93   /**
94    * Returns the first matching property group.
95    */

96   public JspPropertyGroup findJspPropertyGroup(String JavaDoc url)
97   {
98     for (int i = 0; i < _propertyGroupList.size(); i++) {
99       JspPropertyGroup group = _propertyGroupList.get(i);
100
101       if (group.match(url)) {
102     return group;
103       }
104     }
105
106     return null;
107   }
108
109   /**
110    * Returns the first matching property group.
111    */

112   public ArrayList JavaDoc<JspPropertyGroup> findJspPropertyGroupList(String JavaDoc url)
113   {
114     ArrayList JavaDoc<JspPropertyGroup> list = new ArrayList JavaDoc<JspPropertyGroup>();
115     
116     for (int i = 0; i < _propertyGroupList.size(); i++) {
117       JspPropertyGroup group = _propertyGroupList.get(i);
118
119       if (group.match(url)) {
120     list.add(group);
121       }
122     }
123
124     return list;
125   }
126 }
127
Popular Tags