KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layoutengine > ElementListCollector


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 /* $Id: ElementListCollector.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.layoutengine;
21
22 import java.util.List JavaDoc;
23
24 import org.apache.fop.layoutmgr.ElementListObserver.Observer;
25
26 /**
27  * This class collects element list generated during a FOP processing run. These lists are later
28  * used to perform automated checks.
29  */

30 public class ElementListCollector implements Observer {
31
32     private List JavaDoc elementLists = new java.util.ArrayList JavaDoc();
33     
34     /**
35      * Resets the collector.
36      */

37     public void reset() {
38         elementLists.clear();
39     }
40     
41     /**
42      * @return the list of ElementList instances.
43      */

44     public List JavaDoc getElementLists() {
45         return this.elementLists;
46     }
47     
48     /** @see org.apache.fop.layoutmgr.ElementListObserver.Observer */
49     public void observe(List JavaDoc elementList, String JavaDoc category, String JavaDoc id) {
50         elementLists.add(new ElementList(elementList, category, id));
51     }
52
53     /**
54      * Data object representing an element list along with additional information.
55      */

56     public static class ElementList {
57         
58         private List JavaDoc elementList;
59         private String JavaDoc category;
60         private String JavaDoc id;
61         
62         /**
63          * Creates a new ElementList instance
64          * @param elementList the element list
65          * @param category the category for the element list
66          * @param id an optional ID
67          */

68         public ElementList(List JavaDoc elementList, String JavaDoc category, String JavaDoc id) {
69             this.elementList = elementList;
70             this.category = category;
71             this.id = id;
72         }
73         
74         /** @return the element list */
75         public List JavaDoc getElementList() {
76             return elementList;
77         }
78         
79         /** @return the category */
80         public String JavaDoc getCategory() {
81             return category;
82         }
83         
84         /** @return the ID, may be null */
85         public String JavaDoc getID() {
86             return id;
87         }
88     }
89     
90 }
Popular Tags