KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > xhtml > AbstractUAElement


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

9
10 package org.eclipse.help.internal.xhtml;
11
12 import org.eclipse.help.internal.util.StringUtil;
13 import org.osgi.framework.Bundle;
14 import org.w3c.dom.Element JavaDoc;
15
16
17 public abstract class AbstractUAElement {
18
19     private Bundle bundle;
20
21     AbstractUAElement() {
22     }
23
24
25     /**
26      * Constructor used when model elements are being loaded from an xml content file. Bundle is
27      * propagated down the model to enable resolving resources relative to the base of the bundle.
28      *
29      * @param element
30      * @param pd
31      */

32     AbstractUAElement(Element JavaDoc element, Bundle bundle) {
33         this.bundle = bundle;
34     }
35
36
37
38     /**
39      * DOM getAttribute retruns an empty string (not null) if attribute is not defined. Override
40      * this behavior.
41      *
42      * @param element
43      * @param att
44      * @return
45      */

46     protected String JavaDoc getAttribute(Element JavaDoc element, String JavaDoc att) {
47         if (element.hasAttribute(att))
48             return element.getAttribute(att);
49         return null;
50     }
51
52     /**
53      * Util method to parse a comma separated list of values
54      *
55      * @param element
56      * @param att
57      * @return
58      */

59     protected String JavaDoc[] getAttributeList(Element JavaDoc element, String JavaDoc att) {
60         if (element.hasAttribute(att))
61             return StringUtil.split(element.getAttribute(att), ","); //$NON-NLS-1$
62
return null;
63     }
64
65
66     /**
67      * Returns the plugin descriptor of the plugin from which this element was loaded. In the case
68      * of extension, returns the plugin descriptor of the plugin defining the extension.
69      *
70      * @return
71      */

72     public Bundle getBundle() {
73         return bundle;
74     }
75
76
77
78
79 }
80
Popular Tags