X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fcore%2Ffilter%2Fmodel%2FTmfFilterContainsNode.java;h=97410f98f34bf8d107f4f259d7baa75c8fc799de;hb=be222f56a3ba9b24e29a53c38a6d43db300bf880;hp=df52789b8038de3dcf4dd53689bbb94248f5a12a;hpb=a96d48046fe74bb5d123bd1fd63087f89beda24b;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java index df52789b80..97410f98f3 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java @@ -1,108 +1,140 @@ -/******************************************************************************* - * Copyright (c) 2010 Ericsson - * - * 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: - * Patrick Tasse - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.filter.model; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; - - -public class TmfFilterContainsNode extends TmfFilterTreeNode { - - public static final String NODE_NAME = "CONTAINS"; //$NON-NLS-1$ - public static final String NOT_ATTR = "not"; //$NON-NLS-1$ - public static final String FIELD_ATTR = "field"; //$NON-NLS-1$ - public static final String VALUE_ATTR = "value"; //$NON-NLS-1$ - public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$ - - private boolean fNot = false; - private String fField; - private String fValue; - private String fValueUpperCase; - private boolean fIgnoreCase = false; - - public TmfFilterContainsNode(ITmfFilterTreeNode parent) { - super(parent); - } - - public boolean isNot() { - return fNot; - } - - public void setNot(boolean not) { - this.fNot = not; - } - - public String getField() { - return fField; - } - - public void setField(String field) { - this.fField = field; - } - - public String getValue() { - return fValue; - } - - public void setValue(String value) { - this.fValue = value; - fValueUpperCase = value.toUpperCase(); - } - - public boolean isIgnoreCase() { - return fIgnoreCase; - } - - public void setIgnoreCase(boolean ignoreCase) { - this.fIgnoreCase = ignoreCase; - } - - @Override - public String getNodeName() { - return NODE_NAME; - } - - @Override - public boolean matches(ITmfEvent event) { - Object value = getFieldValue(event, fField); - if (value == null) { - return false ^ fNot; - } - String valueString = value.toString(); - if (fIgnoreCase) { - return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot; - } else { - return valueString.contains(fValue) ^ fNot; - } - } - - @Override - public List getValidChildren() { - return new ArrayList(0); - } - - @Override - public String toString() { - return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - - @Override - public ITmfFilterTreeNode clone() { - TmfFilterContainsNode clone = (TmfFilterContainsNode) super.clone(); - clone.fField = new String(fField); - clone.setValue(new String(fValue)); - return clone; - } -} +/******************************************************************************* + * Copyright (c) 2010 Ericsson + * + * 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: + * Patrick Tasse - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.core.filter.model; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; + +/** + * Filter node for the 'contains' operation + * + * @version 1.0 + * @author Patrick Tasse + */ +@SuppressWarnings("javadoc") +public class TmfFilterContainsNode extends TmfFilterTreeNode { + + public static final String NODE_NAME = "CONTAINS"; //$NON-NLS-1$ + public static final String NOT_ATTR = "not"; //$NON-NLS-1$ + public static final String FIELD_ATTR = "field"; //$NON-NLS-1$ + public static final String VALUE_ATTR = "value"; //$NON-NLS-1$ + public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$ + + private boolean fNot = false; + private String fField; + private String fValue; + private String fValueUpperCase; + private boolean fIgnoreCase = false; + + /** + * @param parent the parent node + */ + public TmfFilterContainsNode(ITmfFilterTreeNode parent) { + super(parent); + } + + /** + * @return the NOT state + */ + public boolean isNot() { + return fNot; + } + + /** + * @param not the NOT state + */ + public void setNot(boolean not) { + this.fNot = not; + } + + /** + * @return the field name + */ + public String getField() { + return fField; + } + + /** + * @param field the field name + */ + public void setField(String field) { + this.fField = field; + } + + /** + * @return the contains value + */ + public String getValue() { + return fValue; + } + + /** + * @param value the contains value + */ + public void setValue(String value) { + this.fValue = value; + fValueUpperCase = value.toUpperCase(); + } + + /** + * @return the ignoreCase state + */ + public boolean isIgnoreCase() { + return fIgnoreCase; + } + + /** + * @param ignoreCase the ignoreCase state + */ + public void setIgnoreCase(boolean ignoreCase) { + this.fIgnoreCase = ignoreCase; + } + + @Override + public String getNodeName() { + return NODE_NAME; + } + + @Override + public boolean matches(ITmfEvent event) { + Object value = getFieldValue(event, fField); + if (value == null) { + return false ^ fNot; + } + String valueString = value.toString(); + if (fIgnoreCase) { + return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot; + } + return valueString.contains(fValue) ^ fNot; + } + + @Override + public List getValidChildren() { + return new ArrayList(0); + } + + @Override + public String toString() { + return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + } + + @Override + public ITmfFilterTreeNode clone() { + TmfFilterContainsNode clone = (TmfFilterContainsNode) super.clone(); + clone.fField = fField; + clone.setValue(fValue); + return clone; + } +}