001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.jsp.cfg;
030:
031: import com.caucho.server.webapp.WebApp;
032:
033: import java.util.ArrayList;
034:
035: /**
036: * Configuration from the web.xml.
037: *
038: * <pre>
039: * element jsp-config { taglib*
040: jsp-property-group* }
041: * </pre>
042: */
043: public class JspConfig {
044: private ArrayList<JspTaglib> _taglibList = new ArrayList<JspTaglib>();
045:
046: private WebApp _webApp;
047:
048: private ArrayList<JspPropertyGroup> _propertyGroupList = new ArrayList<JspPropertyGroup>();
049:
050: public JspConfig(WebApp webApp) {
051: _webApp = webApp;
052: }
053:
054: /**
055: * Adds a new taglib to the configuration.
056: */
057: public void addTaglib(JspTaglib taglib) {
058: _taglibList.add(taglib);
059: }
060:
061: /**
062: * Returns the taglibs.
063: */
064: public ArrayList<JspTaglib> getTaglibList() {
065: return _taglibList;
066: }
067:
068: public JspPropertyGroup createJspPropertyGroup() {
069: return new JspPropertyGroup(_webApp);
070: }
071:
072: /**
073: * Adds a new JspPropertyGroup to the configuration.
074: */
075: public void addJspPropertyGroup(JspPropertyGroup propertyGroup) {
076: _propertyGroupList.add(propertyGroup);
077: }
078:
079: /**
080: * Returns the JspPropertyGroup list from the configuration.
081: */
082: public ArrayList getJspPropertyGroupList() {
083: return _propertyGroupList;
084: }
085:
086: /**
087: * Returns the first matching property group.
088: */
089: public JspPropertyGroup findJspPropertyGroup(String url) {
090: for (int i = 0; i < _propertyGroupList.size(); i++) {
091: JspPropertyGroup group = _propertyGroupList.get(i);
092:
093: if (group.match(url)) {
094: return group;
095: }
096: }
097:
098: return null;
099: }
100:
101: /**
102: * Returns the first matching property group.
103: */
104: public ArrayList<JspPropertyGroup> findJspPropertyGroupList(
105: String url) {
106: ArrayList<JspPropertyGroup> list = new ArrayList<JspPropertyGroup>();
107:
108: for (int i = 0; i < _propertyGroupList.size(); i++) {
109: JspPropertyGroup group = _propertyGroupList.get(i);
110:
111: if (group.match(url)) {
112: list.add(group);
113: }
114: }
115:
116: return list;
117: }
118: }
|