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
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.event
.TmfNoSuchFieldException
;
22 public class TmfFilterContainsNode
extends TmfFilterTreeNode
{
24 public static final String NODE_NAME
= "CONTAINS"; //$NON-NLS-1$
25 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
26 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
27 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
28 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
30 private boolean fNot
= false;
31 private String fField
;
32 private String fValue
;
33 private String fValueUpperCase
;
34 private boolean fIgnoreCase
= false;
36 public TmfFilterContainsNode(ITmfFilterTreeNode parent
) {
40 public boolean isNot() {
44 public void setNot(boolean not
) {
48 public String
getField() {
52 public void setField(String field
) {
56 public String
getValue() {
60 public void setValue(String value
) {
62 fValueUpperCase
= value
.toUpperCase();
65 public boolean isIgnoreCase() {
69 public void setIgnoreCase(boolean ignoreCase
) {
70 this.fIgnoreCase
= ignoreCase
;
74 public String
getNodeName() {
79 public boolean matches(TmfEvent event
) {
81 Object value
= event
.getContent().getField(fField
);
85 String valueString
= value
.toString();
87 return valueString
.toUpperCase().contains(fValueUpperCase
) ^ fNot
;
89 return valueString
.contains(fValue
) ^ fNot
;
91 } catch (TmfNoSuchFieldException e
) {
97 public List
<String
> getValidChildren() {
98 return new ArrayList
<String
>(0);
102 public String
toString() {
103 return fField
+ (fNot ?
" not" : "") + " contains \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
107 public ITmfFilterTreeNode
clone() {
108 TmfFilterContainsNode clone
= (TmfFilterContainsNode
) super.clone();
109 clone
.fField
= new String(fField
);
110 clone
.setValue(new String(fValue
));