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: FOTreeBuilderContext.java 1610839 2014-07-15 20:25:58Z vhennebert $ */
19 
20 package org.apache.fop.fo;
21 
22 import java.util.HashSet;
23 import java.util.Set;
24 
25 /**
26  * Context class providing information needed while building the FO tree.
27  */
28 public class FOTreeBuilderContext {
29 
30     /**
31      * The current set of id's in the FO tree.
32      * This is used so we know if the FO tree contains duplicates.
33      */
34     private Set idReferences = new HashSet();
35 
36     /**
37      * The property list maker.
38      */
39     protected PropertyListMaker propertyListMaker;
40 
41     /**
42      * The XMLWhitespaceHandler for this tree
43      */
44     protected XMLWhiteSpaceHandler whiteSpaceHandler = new XMLWhiteSpaceHandler();
45 
46     /**
47      * Indicates whether processing descendants of a marker
48      */
49     private boolean inMarker;
50 
51     /**
52      * Returns the set of ID references.
53      * @return the ID references
54      */
getIDReferences()55     public Set getIDReferences() {
56         return idReferences;
57     }
58 
59     /**
60      * Return the propertyListMaker.
61      *
62      * @return the currently active {@link PropertyListMaker}
63      */
getPropertyListMaker()64     public PropertyListMaker getPropertyListMaker() {
65         return propertyListMaker;
66     }
67 
68     /**
69      * Set a new propertyListMaker.
70      *
71      * @param propertyListMaker the new {@link PropertyListMaker} to use
72      */
setPropertyListMaker(PropertyListMaker propertyListMaker)73     public void setPropertyListMaker(PropertyListMaker propertyListMaker) {
74         this.propertyListMaker = propertyListMaker;
75     }
76 
77     /**
78      * Return the XMLWhiteSpaceHandler
79      * @return the whiteSpaceHandler
80      */
getXMLWhiteSpaceHandler()81     public XMLWhiteSpaceHandler getXMLWhiteSpaceHandler() {
82         return whiteSpaceHandler;
83     }
84 
85     /**
86      * Switch to or from marker context
87      * (used by FOTreeBuilder when processing
88      *  a marker)
89      *
90      * @param inMarker  true if a marker is being processed;
91      *                  false otherwise
92      *
93      */
switchMarkerContext(boolean inMarker)94     protected void switchMarkerContext(boolean inMarker) {
95         this.inMarker = inMarker;
96     }
97 
98     /**
99      * Check whether in marker context
100      *
101      * @return true if a marker is being processed
102      */
inMarker()103     protected boolean inMarker() {
104         return this.inMarker;
105     }
106 
107 }
108