Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 94b23c0d63d56e5eb463d7f227c0d56e8350c6c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*******************************************************************************
 * Copyright (c) 2004, 2016 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ui.internal.intro.impl.model;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
import org.osgi.framework.Bundle;
import org.w3c.dom.Element;

/**
 * An intro Head element. Head elements are only interpreted for HTML case. They
 * are always inlined. Ignored in UI Forms case.
 */
public class IntroHead extends AbstractIntroElement {

    protected static final String TAG_HEAD = "head"; //$NON-NLS-1$

    private static final String ATT_SRC = "src"; //$NON-NLS-1$
    // default encoding is UTF-8
    private static final String ATT_ENCODING = "encoding"; //$NON-NLS-1$

    private String src;
    private String encoding;

    IntroHead(IConfigurationElement element) {
        super(element);
        src = element.getAttribute(ATT_SRC);
        encoding = element.getAttribute(ATT_ENCODING);
        if (encoding == null)
            encoding = "UTF-8"; //$NON-NLS-1$

        // Resolve.
        src = BundleUtil.getResourceLocation(src, element);
    }


    IntroHead(Element element, Bundle bundle, String base) {
        super(element, bundle);
        src = getAttribute(element, ATT_SRC);
        encoding = getAttribute(element, ATT_ENCODING);
        if (encoding == null)
            encoding = "UTF-8"; //$NON-NLS-1$

        // Resolve.
        src = BundleUtil.getResolvedResourceLocation(base, src, bundle);
    }


    /**
     * @return Returns the src.
     */
    public String getSrc() {
        return src;
    }

    /**
     * @return Returns the encoding of the inlined file. Default is UTF-8.
     */
    public String getInlineEncoding() {
        return encoding;
    }

    @Override
	public int getType() {
        return AbstractIntroElement.HEAD;
    }

}

Back to the top