01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.text.toc;
11:
12: /**
13: * The TocAnchor class represents an anchor, which is used as a point
14: * of inclusion for other tables of contents.
15: * For instance, if TOC A contains the anchor with ID "PDE"
16: * and TOC B has the "PDE" ID in its link_to attribute,
17: * then the contents of TOC B will replace the anchor specified by
18: * TOC A at runtime.
19: *
20: * TOC anchors cannot have any content within them, so they are leaf objects.
21: */
22: public class TocAnchor extends TocObject {
23:
24: private static final long serialVersionUID = 1L;
25:
26: /**
27: * Constructs an anchor with the given model and parent.
28: *
29: * @param parent The parent TocObject of the new anchor.
30: */
31: public TocAnchor(TocModel model) {
32: super (model, ELEMENT_ANCHOR);
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.pde.internal.core.text.toc.TocObject#canBeParent()
37: */
38: public boolean canBeParent() {
39: return false;
40: }
41:
42: /* (non-Javadoc)
43: * @see org.eclipse.pde.internal.core.toc.TocObject#getType()
44: */
45: public int getType() {
46: return TYPE_ANCHOR;
47: }
48:
49: /* (non-Javadoc)
50: * @see org.eclipse.pde.internal.core.toc.TocObject#getName()
51: */
52: public String getName() {
53: return getFieldAnchorId();
54: }
55:
56: public String getPath() {
57: // Since the anchor is never associated with any file,
58: // the path is null.
59: return null;
60: }
61:
62: /**
63: * @return the ID of this anchor
64: */
65: public String getFieldAnchorId() {
66: return getXMLAttributeValue(ATTRIBUTE_ID);
67: }
68:
69: /**
70: * Change the value of the anchor ID and
71: * signal a model change if needed.
72: *
73: * @param id The new ID to associate with the anchor
74: */
75: public void setFieldAnchorId(String id) {
76: setXMLAttribute(ATTRIBUTE_ID, id);
77: }
78: }
|