~ubuntu-branches/ubuntu/wily/xslthl/wily

« back to all changes in this revision

Viewing changes to src/main/java/net/sf/xslthl/WholeHighlighter.java

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-05-16 08:59:07 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130516085907-ujk9f81x8w344ch1
Tags: 2.1.0-2
Upload to sid

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * xslthl - XSLT Syntax Highlighting
 
3
 * https://sourceforge.net/projects/xslthl/
 
4
 * Copyright (C) 2005-2008 Michal Molhanec, Jirka Kosek, Michiel Hendriks
 
5
 * 
 
6
 * This software is provided 'as-is', without any express or implied
 
7
 * warranty.  In no event will the authors be held liable for any damages
 
8
 * arising from the use of this software.
 
9
 * 
 
10
 * Permission is granted to anyone to use this software for any purpose,
 
11
 * including commercial applications, and to alter it and redistribute it
 
12
 * freely, subject to the following restrictions:
 
13
 * 
 
14
 * 1. The origin of this software must not be misrepresented; you must not
 
15
 *    claim that you wrote the original software. If you use this software
 
16
 *    in a product, an acknowledgment in the product documentation would be
 
17
 *    appreciated but is not required.
 
18
 * 2. Altered source versions must be plainly marked as such, and must not be
 
19
 *    misrepresented as being the original software.
 
20
 * 3. This notice may not be removed or altered from any source distribution.
 
21
 * 
 
22
 * Michal Molhanec <mol1111 at users.sourceforge.net>
 
23
 * Jirka Kosek <kosek at users.sourceforge.net>
 
24
 * Michiel Hendriks <elmuerte at users.sourceforge.net>
 
25
 */
 
26
package net.sf.xslthl;
 
27
 
 
28
import java.util.Collection;
 
29
import java.util.HashSet;
 
30
 
 
31
/**
 
32
 * 
 
33
 */
 
34
public abstract class WholeHighlighter extends Highlighter {
 
35
        private Collection<String> styles = new HashSet<String>();
 
36
        private boolean emptyStyle = true;
 
37
        private boolean allStyles = false;
 
38
 
 
39
        void loadStyles(Params params) {
 
40
                if (!params.isSet("empty")) {
 
41
                        emptyStyle = false;
 
42
                }
 
43
                if (params.isSet("all")) {
 
44
                        allStyles = true;
 
45
                        return;
 
46
                }
 
47
                params.getMutliParams("style", styles);
 
48
        }
 
49
 
 
50
        boolean appliesOnEmptyStyle() {
 
51
                return emptyStyle;
 
52
        }
 
53
 
 
54
        boolean appliesOnAllStyles() {
 
55
                return allStyles;
 
56
        }
 
57
 
 
58
        boolean appliesOnStyle(String style) {
 
59
                return styles.contains(style);
 
60
        }
 
61
 
 
62
        /*
 
63
         * (non-Javadoc)
 
64
         * 
 
65
         * @see net.sf.xslthl.Highlighter#init(net.sf.xslthl.Params)
 
66
         */
 
67
        @Override
 
68
        public void init(Params params) throws HighlighterConfigurationException {
 
69
                super.init(params);
 
70
                if (params != null && params.isSet("applyOnStyles")) {
 
71
                        loadStyles(params.getParams("applyOnStyles"));
 
72
                }
 
73
        }
 
74
 
 
75
}