KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > pagination > bookmarks > BookmarkTree


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: BookmarkTree.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.fo.pagination.bookmarks;
21
22 // Java
23
import java.util.ArrayList JavaDoc;
24
25 import org.xml.sax.Locator JavaDoc;
26
27 import org.apache.fop.apps.FOPException;
28 import org.apache.fop.fo.FONode;
29 import org.apache.fop.fo.FObj;
30 import org.apache.fop.fo.ValidationException;
31 import org.apache.fop.fo.pagination.Root;
32
33 /**
34  * The fo:bookmark-tree formatting object, first introduced in the
35  * XSL 1.1 WD. Prototype version only, subject to change as XSL 1.1 WD
36  * evolves.
37  */

38 public class BookmarkTree extends FObj {
39     private ArrayList JavaDoc bookmarks = new ArrayList JavaDoc();
40
41     /**
42      * @see org.apache.fop.fo.FONode#FONode(FONode)
43      */

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

51     protected void addChildNode(FONode obj) {
52         if (obj instanceof Bookmark) {
53             bookmarks.add(obj);
54         }
55     }
56
57     /**
58      * @see org.apache.fop.fo.FONode#endOfNode
59      */

60     protected void endOfNode() throws FOPException {
61         if (bookmarks == null) {
62            missingChildElementError("(fo:bookmark+)");
63         }
64         ((Root) parent).setBookmarkTree(this);
65     }
66
67     /**
68      * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
69         XSL/FOP: (bookmark+)
70      */

71     protected void validateChildNode(Locator JavaDoc loc, String JavaDoc nsURI, String JavaDoc localName)
72         throws ValidationException {
73         if (!(FO_URI.equals(nsURI) &&
74             localName.equals("bookmark"))) {
75                 invalidChildError(loc, nsURI, localName);
76         }
77     }
78
79     public ArrayList JavaDoc getBookmarks() {
80         return bookmarks;
81     }
82
83     /** @see org.apache.fop.fo.FONode#getLocalName() */
84     public String JavaDoc getLocalName() {
85         return "bookmark-tree";
86     }
87
88     /**
89      * @see org.apache.fop.fo.FObj#getNameId()
90      */

91     public int getNameId() {
92         return FO_BOOKMARK_TREE;
93     }
94 }
95
Popular Tags