KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > transformation > pagination > PageRules


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
17 package org.apache.cocoon.transformation.pagination;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 /**
23  * Container class for the immutable pagination rules for each page.
24  *
25  * @author <a HREF="mailto:stefano@apache.org">Stefano Mazzocchi</a>
26  * @author <a HREF="mailto:bhtek@yahoo.com">Boon Hian Tek</a>
27  * @version CVS $Id: PageRules.java 30932 2004-07-29 17:35:38Z vgritsenko $
28  */

29 public class PageRules {
30
31     public String JavaDoc elementName;
32     public String JavaDoc elementURI;
33     public int elementCount = 0;
34     public int charCount = 0;
35     public int unitLinks = 0;
36     private List JavaDoc rangeLinks = new ArrayList JavaDoc();
37
38     public boolean match(String JavaDoc element, String JavaDoc namespace) {
39         boolean elementMatches = ((this.elementName!=null) &&
40                                   this.elementName.equals(element));
41
42         if (this.elementURI==null) {
43             return elementMatches;
44         } else {
45             return elementMatches && this.elementURI.equals(namespace);
46         }
47     }
48
49     public boolean match(String JavaDoc namespace) {
50         return ((this.elementURI!=null) &&
51                 (this.elementURI.equals(namespace)));
52     }
53
54     public Integer JavaDoc[] getRangeLinks() {
55         return (Integer JavaDoc[]) this.rangeLinks.toArray(new Integer JavaDoc[this.rangeLinks.size()]);
56     }
57
58     public void addRangeLink(Integer JavaDoc rangeLink) {
59         this.rangeLinks.add(rangeLink);
60     }
61
62     public void addRangeLink(int rangeLink) {
63         this.addRangeLink(new Integer JavaDoc(rangeLink));
64     }
65
66     public void addRangeLink(String JavaDoc rangeLink) {
67         this.addRangeLink(new Integer JavaDoc(rangeLink));
68     }
69 }
70
Popular Tags