01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.transformation.pagination;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: /**
24: * Container class for the immutable pagination rules for each page.
25: *
26: * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
27: * @author <a href="mailto:bhtek@yahoo.com">Boon Hian Tek</a>
28: * @version CVS $Id: PageRules.java 433543 2006-08-22 06:22:54Z crossley $
29: */
30: public class PageRules {
31:
32: public String elementName;
33: public String elementURI;
34: public int elementCount = 0;
35: public int charCount = 0;
36: public int unitLinks = 0;
37: private List rangeLinks = new ArrayList();
38:
39: public boolean match(String element, String namespace) {
40: boolean elementMatches = ((this .elementName != null) && this .elementName
41: .equals(element));
42:
43: if (this .elementURI == null) {
44: return elementMatches;
45: } else {
46: return elementMatches && this .elementURI.equals(namespace);
47: }
48: }
49:
50: public boolean match(String namespace) {
51: return ((this .elementURI != null) && (this .elementURI
52: .equals(namespace)));
53: }
54:
55: public Integer[] getRangeLinks() {
56: return (Integer[]) this .rangeLinks
57: .toArray(new Integer[this .rangeLinks.size()]);
58: }
59:
60: public void addRangeLink(Integer rangeLink) {
61: this .rangeLinks.add(rangeLink);
62: }
63:
64: public void addRangeLink(int rangeLink) {
65: this .addRangeLink(new Integer(rangeLink));
66: }
67:
68: public void addRangeLink(String rangeLink) {
69: this .addRangeLink(new Integer(rangeLink));
70: }
71: }
|