KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > toc > Anchor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.toc;
12
13 import java.util.List JavaDoc;
14
15 import org.eclipse.help.internal.model.*;
16 import org.xml.sax.*;
17 /**
18  * Anchor. Place holder that Toc objects can atatch to.
19  */

20 class Anchor extends TocNode implements IAnchorElement {
21     protected Toc parentToc;
22     protected String JavaDoc id;
23     protected TocFile tocFile;
24     /**
25      * Constructor.
26      */

27     protected Anchor(TocFile tocFile, Attributes attrs) {
28         this.tocFile = tocFile;
29         if (attrs == null)
30             return;
31         id = attrs.getValue("id"); //$NON-NLS-1$
32
id = HrefUtil.normalizeHref(tocFile.getPluginID(), tocFile.getHref()
33                 + "#" + id); //$NON-NLS-1$
34
parentToc = tocFile.getToc();
35     }
36     /**
37      * Implements abstract method.
38      */

39     public void build(TocBuilder builder) {
40         builder.buildAnchor(this);
41     }
42     /**
43      * Obtains the ID
44      */

45     protected String JavaDoc getID() {
46         return id;
47     }
48     /**
49      * Returns the toc file
50      */

51     public TocFile getTocFile() {
52         return tocFile;
53     }
54     /**
55      * Adds another element as child of this element Modifies parents of a child
56      * as well
57      */

58     public void addChild(ITocNode child) {
59         super.addChild(child);
60         if (child instanceof Toc && parentToc != null) {
61             parentToc.getChildrenTocs().add(child);
62         }
63     }
64
65     /**
66      * @return ITopic list
67      */

68     public List JavaDoc getChildTopics() {
69         // after build, release TocFile
70
tocFile = null;
71         return super.getChildTopics();
72     }
73
74 }
75
Popular Tags