KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > flow > AbstractListItemPart


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: AbstractListItemPart.java 488960 2006-12-20 08:34:28Z spepping $ */
19
20 package org.apache.fop.fo.flow;
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 import org.apache.fop.fo.properties.CommonAccessibility;
30 import org.apache.fop.fo.properties.KeepProperty;
31
32 /**
33  * Class modelling the fo:list-item-body object.
34  */

35 public abstract class AbstractListItemPart extends FObj {
36     // The value of properties relevant for fo:list-item-label and fo:list-item-body.
37
private String JavaDoc id;
38     private KeepProperty keepTogether;
39     // Valid properties, commented out for performance:
40
// private CommonAccessibility commonAccessibility;
41
// End of property values
42

43     /** used for FO validation */
44     private boolean blockItemFound = false;
45
46     /**
47      * @param parent FONode that is the parent of this object
48      */

49     public AbstractListItemPart(FONode parent) {
50         super(parent);
51     }
52
53     /**
54      * @see org.apache.fop.fo.FObj#bind(PropertyList)
55      */

56     public void bind(PropertyList pList) throws FOPException {
57         id = pList.get(PR_ID).getString();
58         keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
59     }
60
61     /**
62      * @see org.apache.fop.fo.FONode#startOfNode
63      */

64     protected void startOfNode() throws FOPException {
65         checkId(id);
66     }
67
68     /**
69      * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
70      * XSL Content Model: marker* (%block;)+
71      */

72     protected void validateChildNode(Locator JavaDoc loc, String JavaDoc nsURI, String JavaDoc localName)
73         throws ValidationException {
74         if (FO_URI.equals(nsURI) && localName.equals("marker")) {
75             if (blockItemFound) {
76                nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
77             }
78         } else if (!isBlockItem(nsURI, localName)) {
79             invalidChildError(loc, nsURI, localName);
80         } else {
81             blockItemFound = true;
82         }
83     }
84
85     /**
86      * @see org.apache.fop.fo.FONode#endOfNode
87      */

88     protected void endOfNode() throws FOPException {
89         if (!this.blockItemFound) {
90             String JavaDoc contentModel = "marker* (%block;)+";
91             if (getUserAgent().validateStrictly()) {
92                 missingChildElementError(contentModel);
93             } else {
94                 StringBuffer JavaDoc message = new StringBuffer JavaDoc(
95                         errorText(getLocator()));
96                 message.append(getName())
97                     .append(" is missing child elements. ")
98                     .append("Required Content Model: ")
99                     .append(contentModel);
100                 getLogger().warn(message.toString());
101             }
102         }
103     }
104
105     /** @return the "keep-together" property. */
106     public KeepProperty getKeepTogether() {
107         return keepTogether;
108     }
109
110     /** @return the "id" property. */
111     public String JavaDoc getId() {
112         return id;
113     }
114     
115 }
116
117
Popular Tags