KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > dbtags > resultset > BaseGetterTEI


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.taglibs.dbtags.resultset;
17
18 import javax.servlet.jsp.tagext.TagData JavaDoc;
19 import javax.servlet.jsp.tagext.TagExtraInfo JavaDoc;
20
21 /**
22  * TagExtraInfo for all getter tags. Insures that each
23  * getter tag uses <i>either</i> the position attribute
24  * or the colName attribute.
25  *
26  * @author Marius Scurtescu
27  */

28 public class BaseGetterTEI extends TagExtraInfo JavaDoc {
29
30   public boolean isValid (TagData JavaDoc data)
31   {
32     boolean bPosition = false;
33     boolean bName = false;
34
35     if (data.getAttribute("position") != null) {
36       bPosition = true;
37     }
38
39     if (data.getAttribute("colName") != null) {
40       bName = true;
41     }
42
43     if (bPosition && bName) {
44       System.out.println("Error: Get tags must not set _both_ the colName and position attributes");
45       return false;
46     }
47
48     if (!bPosition && !bName) {
49       System.out.println("Error: Get tags must set _either_ the colName or the position attribute");
50       return false;
51     }
52
53     return true;
54   }
55 }
56
57
Popular Tags