KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > pagination > Flow


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: Flow.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.fo.pagination;
21
22 import org.xml.sax.Locator JavaDoc;
23
24 import org.apache.fop.apps.FOPException;
25 import org.apache.fop.fo.FONode;
26 import org.apache.fop.fo.FObj;
27 import org.apache.fop.fo.PropertyList;
28 import org.apache.fop.fo.ValidationException;
29
30 /**
31  * Class modelling the fo:flow object.
32  */

33 public class Flow extends FObj {
34     // The value of properties relevant for fo:flow.
35
private String JavaDoc flowName;
36     // End of property values
37

38     /** used for FO validation */
39     private boolean blockItemFound = false;
40
41     /**
42      * @param parent FONode that is the parent of this object
43      */

44     public Flow(FONode parent) {
45         super(parent);
46     }
47
48     /**
49      * @see org.apache.fop.fo.FObj#bind(PropertyList)
50      */

51     public void bind(PropertyList pList) throws FOPException {
52         flowName = pList.get(PR_FLOW_NAME).getString();
53     }
54     
55     /**
56      * @see org.apache.fop.fo.FONode#startOfNode
57      */

58     protected void startOfNode() throws FOPException {
59         if (flowName == null || flowName.equals("")) {
60             missingPropertyError("flow-name");
61         }
62
63         // according to communication from Paul Grosso (XSL-List,
64
// 001228, Number 406), confusion in spec section 6.4.5 about
65
// multiplicity of fo:flow in XSL 1.0 is cleared up - one (1)
66
// fo:flow per fo:page-sequence only.
67

68         /* if (pageSequence.isFlowSet()) {
69                     if (this.name.equals("fo:flow")) {
70                         throw new FOPException("Only a single fo:flow permitted"
71                                                + " per fo:page-sequence");
72                     } else {
73                         throw new FOPException(this.name
74                                                + " not allowed after fo:flow");
75                     }
76                 }
77          */

78         // Now done in addChild of page-sequence
79
//pageSequence.addFlow(this);
80
getFOEventHandler().startFlow(this);
81     }
82
83     /**
84      * Make sure content model satisfied, if so then tell the
85      * FOEventHandler that we are at the end of the flow.
86      * @see org.apache.fop.fo.FONode#endOfNode
87      */

88     protected void endOfNode() throws FOPException {
89         if (!blockItemFound) {
90             missingChildElementError("marker* (%block;)+");
91         }
92         getFOEventHandler().endFlow(this);
93     }
94
95     /**
96      * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
97      * XSL Content Model: marker* (%block;)+
98      */

99     protected void validateChildNode(Locator JavaDoc loc, String JavaDoc nsURI, String JavaDoc localName)
100         throws ValidationException {
101         if (FO_URI.equals(nsURI) && localName.equals("marker")) {
102             if (blockItemFound) {
103                nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
104             }
105         } else if (!isBlockItem(nsURI, localName)) {
106             invalidChildError(loc, nsURI, localName);
107         } else {
108             blockItemFound = true;
109         }
110     }
111
112     /**
113      * @return true (Flow can generate reference areas)
114      */

115     public boolean generatesReferenceAreas() {
116         return true;
117     }
118
119     /** @return "flow-name" property. */
120     public String JavaDoc getFlowName() {
121         return flowName;
122     }
123
124     /** @see org.apache.fop.fo.FONode#getLocalName() */
125     public String JavaDoc getLocalName() {
126         return "flow";
127     }
128     
129     /**
130      * @see org.apache.fop.fo.FObj#getNameId()
131      */

132     public int getNameId() {
133         return FO_FLOW;
134     }
135 }
136
Popular Tags