KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jsptags > navigation > pager > PageTagExtraInfo


1 /*
2  * Pager Tag Library
3  *
4  * Copyright (C) 2002 James Klicman <james@jsptags.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

20
21 package com.jsptags.navigation.pager;
22
23 import javax.servlet.jsp.*;
24 import javax.servlet.jsp.tagext.*;
25 import com.jsptags.navigation.pager.parser.*;
26
27 public class PageTagExtraInfo extends TagExtraInfo {
28
29     public VariableInfo[] getVariableInfo(TagData tagData) {
30         String JavaDoc export = tagData.getAttributeString("export");
31         if (export != null) {
32             try {
33                 PageTagExport pageTagExport =
34                     TagExportParser.parsePageTagExport(export);
35                 int len = 0;
36                 if (pageTagExport.getPageUrl() != null)
37                     len++;
38                 if (pageTagExport.getPageNumber() != null)
39                     len++;
40                 if (pageTagExport.getFirstItem() != null)
41                     len++;
42                 if (pageTagExport.getLastItem() != null)
43                     len++;
44
45                 VariableInfo[] varinfo = new VariableInfo[len];
46                 int i = 0;
47
48                 String JavaDoc name;
49                 if ((name = pageTagExport.getPageUrl()) != null)
50                     varinfo[i++] = new VariableInfo(name,
51                             java.lang.String JavaDoc.class.getName(),
52                             true, VariableInfo.NESTED);
53                 if ((name = pageTagExport.getPageNumber()) != null)
54                     varinfo[i++] = new VariableInfo(name,
55                             java.lang.Integer JavaDoc.class.getName(),
56                             true, VariableInfo.NESTED);
57                 if ((name = pageTagExport.getFirstItem()) != null)
58                     varinfo[i++] = new VariableInfo(name,
59                             java.lang.Integer JavaDoc.class.getName(),
60                             true, VariableInfo.NESTED);
61                 if ((name = pageTagExport.getLastItem()) != null)
62                     varinfo[i++] = new VariableInfo(name,
63                             java.lang.Integer JavaDoc.class.getName(),
64                             true, VariableInfo.NESTED);
65
66                 return varinfo;
67             } catch (ParseException ex) {
68                 return new VariableInfo[0];
69             }
70         } else {
71             return new VariableInfo[] {
72                     new VariableInfo(PageTagExport.PAGE_URL,
73                         java.lang.String JavaDoc.class.getName(),
74                         true, VariableInfo.NESTED),
75                     new VariableInfo(PageTagExport.PAGE_NUMBER,
76                         java.lang.Integer JavaDoc.class.getName(),
77                         true, VariableInfo.NESTED)
78                 };
79         }
80     }
81
82     public boolean isValid(TagData tagData) {
83         String JavaDoc export = tagData.getAttributeString("export");
84         if (export != null) {
85             try {
86                 TagExportParser.parsePageTagExport(export);
87             } catch (ParseException ex) {
88                 return false;
89             }
90         }
91         return true;
92     }
93 }
94
95 /* vim:set ts=4 sw=4: */
96
Popular Tags