KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > extension > ContentExtension


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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.extension;
12
13 import org.eclipse.help.IContentExtension;
14 import org.eclipse.help.internal.UAElement;
15 import org.w3c.dom.Element JavaDoc;
16
17 public class ContentExtension extends UAElement implements IContentExtension {
18     
19     public static final String JavaDoc NAME_CONTRIBUTION = "contribution"; //$NON-NLS-1$
20
public static final String JavaDoc NAME_CONTRIBUTION_LEGACY = "topicExtension"; //$NON-NLS-1$
21
public static final String JavaDoc NAME_REPLACEMENT = "replacement"; //$NON-NLS-1$
22
public static final String JavaDoc NAME_REPLACEMENT_LEGACY = "topicReplace"; //$NON-NLS-1$
23
public static final String JavaDoc ATTRIBUTE_CONTENT = "content"; //$NON-NLS-1$
24
public static final String JavaDoc ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
25

26     public ContentExtension(IContentExtension src) {
27         super(src.getType() == IContentExtension.CONTRIBUTION ? NAME_CONTRIBUTION : NAME_REPLACEMENT, src);
28         setContent(src.getContent());
29         setPath(src.getPath());
30     }
31     
32     public ContentExtension(Element src) {
33         super(src);
34     }
35
36     public String JavaDoc getContent() {
37         return getAttribute(ATTRIBUTE_CONTENT);
38     }
39     
40     public String JavaDoc getPath() {
41         return getAttribute(ATTRIBUTE_PATH);
42     }
43     
44     public int getType() {
45         String JavaDoc name = element.getNodeName();
46         return (NAME_CONTRIBUTION.equals(name) || NAME_CONTRIBUTION_LEGACY.equals(name)) ? CONTRIBUTION : REPLACEMENT;
47     }
48     
49     public void setContent(String JavaDoc content) {
50         setAttribute(ATTRIBUTE_CONTENT, content);
51     }
52     
53     public void setPath(String JavaDoc path) {
54         setAttribute(ATTRIBUTE_PATH, path);
55     }
56 }
57
Popular Tags