1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
21 public class TmfFilterContainsNode
extends TmfFilterTreeNode
{
23 public static final String NODE_NAME
= "CONTAINS"; //$NON-NLS-1$
24 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
25 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
26 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
27 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
29 private boolean fNot
= false;
30 private String fField
;
31 private String fValue
;
32 private String fValueUpperCase
;
33 private boolean fIgnoreCase
= false;
35 public TmfFilterContainsNode(ITmfFilterTreeNode parent
) {
39 public boolean isNot() {
43 public void setNot(boolean not
) {
47 public String
getField() {
51 public void setField(String field
) {
55 public String
getValue() {
59 public void setValue(String value
) {
61 fValueUpperCase
= value
.toUpperCase();
64 public boolean isIgnoreCase() {
68 public void setIgnoreCase(boolean ignoreCase
) {
69 this.fIgnoreCase
= ignoreCase
;
73 public String
getNodeName() {
78 public boolean matches(ITmfEvent event
) {
79 Object value
= getFieldValue(event
, fField
);
83 String valueString
= value
.toString();
85 return valueString
.toUpperCase().contains(fValueUpperCase
) ^ fNot
;
87 return valueString
.contains(fValue
) ^ fNot
;
92 public List
<String
> getValidChildren() {
93 return new ArrayList
<String
>(0);
97 public String
toString() {
98 return fField
+ (fNot ?
" not" : "") + " contains \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
102 public ITmfFilterTreeNode
clone() {
103 TmfFilterContainsNode clone
= (TmfFilterContainsNode
) super.clone();
104 clone
.fField
= fField
;
105 clone
.setValue(fValue
);