KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jag > template > TemplateHeaderCollection


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * JAG is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with JAG; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */

17
18 package com.finalist.jag.template;
19
20
21 import java.util.*;
22
23 import com.finalist.jag.*;
24
25
26 /**
27  * Class TemplateHeaderCollection
28  *
29  *
30  * @author Wendel D. de Witte
31  * @version %I%, %G%
32  */

33 public class TemplateHeaderCollection {
34
35    /** Field headerLines */
36    private HeaderLine[] headerLines = null;
37
38
39    /**
40     * Constructor TemplateHeaderCollection
41     *
42     *
43     * @param headerLines
44     *
45     */

46    public TemplateHeaderCollection(HeaderLine[] headerLines) {
47       this.headerLines = headerLines;
48    }
49
50
51    /**
52     * Method getHeaderUrl
53     *
54     *
55     * @param s
56     *
57     * @return
58     *
59     * @throws JagException
60     *
61     */

62    public UrlHeaderLine getHeaderUrl(String JavaDoc s) throws JagException {
63
64       UrlHeaderLine line = findHeaderUrl(s);
65
66       if (line == null) {
67          throw new JagException(
68             "Missing header definition for the taglibrary " + s);
69       }
70
71       return line;
72    }
73
74
75    /**
76     * Method findHeaderUrl
77     *
78     *
79     * @param s
80     *
81     * @return
82     *
83     */

84    public UrlHeaderLine findHeaderUrl(String JavaDoc s) {
85
86       for (int i = 0; i < headerLines.length; i++) {
87          HeaderLine headerLine = headerLines[i];
88
89          if (!(headerLine instanceof UrlHeaderLine)) {
90             continue;
91          }
92
93          UrlHeaderLine urlHeader = (UrlHeaderLine) headerLine;
94
95          if (s.equals(urlHeader.getPrefix())) {
96             return urlHeader;
97          }
98       }
99
100       return null;
101    }
102 }
103
104 ;
Popular Tags