~ubuntu-branches/ubuntu/wily/eclipse-linuxtools/wily

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterAndNode.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
@SuppressWarnings("javadoc")
25
25
public class TmfFilterAndNode extends TmfFilterTreeNode {
26
26
 
27
 
        public static final String NODE_NAME = "AND"; //$NON-NLS-1$
28
 
        public static final String NOT_ATTR = "not"; //$NON-NLS-1$
29
 
 
30
 
        private boolean fNot = false;
31
 
 
32
 
        /**
33
 
         * @param parent the parent node
34
 
         */
35
 
        public TmfFilterAndNode(ITmfFilterTreeNode parent) {
36
 
                super(parent);
37
 
        }
38
 
 
39
 
        /**
40
 
         * @return the NOT state
41
 
         */
42
 
        public boolean isNot() {
43
 
                return fNot;
44
 
        }
45
 
 
46
 
        /**
47
 
         * @param not the NOT state
48
 
         */
49
 
        public void setNot(boolean not) {
50
 
                this.fNot = not;
51
 
        }
52
 
 
53
 
        @Override
54
 
        public String getNodeName() {
55
 
                return NODE_NAME;
56
 
        }
57
 
 
58
 
        @Override
59
 
        public boolean matches(ITmfEvent event) {
60
 
                for (ITmfFilterTreeNode node : getChildren()) {
61
 
                        if (! node.matches(event)) {
62
 
                                return false ^ fNot;
63
 
                        }
64
 
                }
65
 
                return true ^ fNot;
66
 
        }
67
 
 
68
 
        @Override
69
 
        public String toString() {
70
 
                StringBuffer buf = new StringBuffer();
71
 
                if (fNot) {
72
 
                        buf.append("not "); //$NON-NLS-1$
73
 
                }
74
 
                if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
75
 
                        buf.append("( "); //$NON-NLS-1$
76
 
                }
77
 
                for (int i = 0; i < getChildrenCount(); i++) {
78
 
                        ITmfFilterTreeNode node = getChildren()[i];
79
 
                        buf.append(node.toString());
80
 
                        if (i < getChildrenCount() - 1) {
81
 
                                buf.append(" and "); //$NON-NLS-1$
82
 
                        }
83
 
                }
84
 
                if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
85
 
                        buf.append(" )"); //$NON-NLS-1$
86
 
                }
87
 
                return buf.toString();
88
 
        }
 
27
    public static final String NODE_NAME = "AND"; //$NON-NLS-1$
 
28
    public static final String NOT_ATTR = "not"; //$NON-NLS-1$
 
29
 
 
30
    private boolean fNot = false;
 
31
 
 
32
    /**
 
33
     * @param parent the parent node
 
34
     */
 
35
    public TmfFilterAndNode(ITmfFilterTreeNode parent) {
 
36
        super(parent);
 
37
    }
 
38
 
 
39
    /**
 
40
     * @return the NOT state
 
41
     */
 
42
    public boolean isNot() {
 
43
        return fNot;
 
44
    }
 
45
 
 
46
    /**
 
47
     * @param not the NOT state
 
48
     */
 
49
    public void setNot(boolean not) {
 
50
        this.fNot = not;
 
51
    }
 
52
 
 
53
    @Override
 
54
    public String getNodeName() {
 
55
        return NODE_NAME;
 
56
    }
 
57
 
 
58
    @Override
 
59
    public boolean matches(ITmfEvent event) {
 
60
        for (ITmfFilterTreeNode node : getChildren()) {
 
61
            if (! node.matches(event)) {
 
62
                return false ^ fNot;
 
63
            }
 
64
        }
 
65
        return true ^ fNot;
 
66
    }
 
67
 
 
68
    @Override
 
69
    public String toString() {
 
70
        StringBuffer buf = new StringBuffer();
 
71
        if (fNot) {
 
72
            buf.append("not "); //$NON-NLS-1$
 
73
        }
 
74
        if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
 
75
            buf.append("( "); //$NON-NLS-1$
 
76
        }
 
77
        for (int i = 0; i < getChildrenCount(); i++) {
 
78
            ITmfFilterTreeNode node = getChildren()[i];
 
79
            buf.append(node.toString());
 
80
            if (i < getChildrenCount() - 1) {
 
81
                buf.append(" and "); //$NON-NLS-1$
 
82
            }
 
83
        }
 
84
        if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
 
85
            buf.append(" )"); //$NON-NLS-1$
 
86
        }
 
87
        return buf.toString();
 
88
    }
 
89
 
 
90
    @Override
 
91
    public int hashCode() {
 
92
        final int prime = 31;
 
93
        int result = super.hashCode();
 
94
        result = prime * result + (fNot ? 1231 : 1237);
 
95
        return result;
 
96
    }
 
97
 
 
98
    @Override
 
99
    public boolean equals(Object obj) {
 
100
        if (this == obj) {
 
101
            return true;
 
102
        }
 
103
        if (!super.equals(obj)) {
 
104
            return false;
 
105
        }
 
106
        if (getClass() != obj.getClass()) {
 
107
            return false;
 
108
        }
 
109
        TmfFilterAndNode other = (TmfFilterAndNode) obj;
 
110
        if (fNot != other.fNot) {
 
111
            return false;
 
112
        }
 
113
        return true;
 
114
    }
89
115
 
90
116
}