tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / dialogs / Criteria.java
index 65d804a8909ab07c64ede29c694c3834cd32ecb8..927078b3bf46cb501579ece96b0b347ee91582ef 100755 (executable)
@@ -1,16 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- * 
+ * Copyright (c) 2005, 2012 IBM Corporation, 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: 
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
 
 import java.util.ArrayList;
@@ -38,37 +37,37 @@ public class Criteria {
     /**
      * Flag whether lifeline is selected or not.
      */
-    protected boolean lifeLineSelected = false;
+    protected boolean fLifeLineSelected = false;
     /**
      * Flag whether synchronous message is selected or not.
      */
-    protected boolean syncMessageSelected = false;
+    protected boolean fSyncMessageSelected = false;
     /**
      * Flag whether synchronous message return is selected or not.
      */
-    protected boolean syncMessageReturnSelected = false;
+    protected boolean fSyncMessageReturnSelected = false;
     /**
      * Flag whether asynchronous message is selected or not.
      */
-    protected boolean asyncMessageSelected = false;
+    protected boolean fAsyncMessageSelected = false;
     /**
      * Flag whether asynchronous message return is selected or not.
      */
-    protected boolean asyncMessageReturnSelected = false;
+    protected boolean fAsyncMessageReturnSelected = false;
     /**
      * Flag whether case sensitive find is required or not.
      */
-    protected boolean caseSenstiveSelected = false;
+    protected boolean fCaseSenstiveSelected = false;
     /**
      * Flag whether stop graph node is selected or not.
      */
-    protected boolean stopSelected = false;
+    protected boolean fStopSelected = false;
     /**
-     * The find expression. 
+     * The find expression.
      */
-    protected String  expression = null;
+    protected String  fExpression = null;
     /**
-     * The find pattern as regular expression. 
+     * The find pattern as regular expression.
      */
     protected Pattern pattern = null;
 
@@ -84,64 +83,66 @@ public class Criteria {
 
     /**
      * Copy constructor
-     * 
+     *
      * @param other Criteria to create new criteria
      */
     public Criteria (Criteria other) {
-         this.lifeLineSelected = other.lifeLineSelected;
-         this.syncMessageSelected = other.syncMessageSelected;
-         this.syncMessageReturnSelected = other.syncMessageReturnSelected;
-         this.asyncMessageSelected = other.asyncMessageSelected;
-         this.asyncMessageReturnSelected = other.asyncMessageReturnSelected;
-         this.caseSenstiveSelected = other.caseSenstiveSelected;
-         this.stopSelected = other.stopSelected;
-         setExpression(other.expression);
+         this.fLifeLineSelected = other.fLifeLineSelected;
+         this.fSyncMessageSelected = other.fSyncMessageSelected;
+         this.fSyncMessageReturnSelected = other.fSyncMessageReturnSelected;
+         this.fAsyncMessageSelected = other.fAsyncMessageSelected;
+         this.fAsyncMessageReturnSelected = other.fAsyncMessageReturnSelected;
+         this.fCaseSenstiveSelected = other.fCaseSenstiveSelected;
+         this.fStopSelected = other.fStopSelected;
+         fExpression = other.fExpression;
+         updatePattern();
     }
-    
+
     // ------------------------------------------------------------------------
     // Methods
     // ------------------------------------------------------------------------
 
     /**
      * Returns true if the AsyncMessageReturn is selected, false otherwise.
-     * 
+     *
      * @return true if the AsyncMessageReturn is selected, false otherwise
      */
     public boolean isAsyncMessageReturnSelected() {
-        return asyncMessageReturnSelected;
+        return fAsyncMessageReturnSelected;
     }
 
     /**
      * Returns true if the AsyncMessage is selected, false otherwise.
-     * 
+     *
      * @return true if the AsyncMessage is selected, false otherwise
      */
     public boolean isAsyncMessageSelected() {
-        return asyncMessageSelected;
+        return fAsyncMessageSelected;
     }
 
     /**
      * Returns the text enter by the user.
-     * 
+     *
      * @return the expression text
      */
     public String getExpression() {
-        return expression;
+        return fExpression;
     }
 
     /**
      * Returns the regular expression pattern.
-     * 
+     *
      * @return the regular expression pattern
      */
     public Pattern getPattern() {
         return pattern;
     }
-    
+
     /**
      * Sets the regular expression pattern.
-     * 
-     * @param the pattern to set
+     *
+     * @param pattern
+     *            The pattern to set
      */
     public void setPattern(Pattern pattern) {
         this.pattern = pattern;
@@ -149,141 +150,127 @@ public class Criteria {
 
     /**
      * Returns true if the LifeLine is selected, false otherwise.
-     * 
+     *
      * @return true if the LifeLine is selected, false otherwise
      */
     public boolean isLifeLineSelected() {
-        return lifeLineSelected;
+        return fLifeLineSelected;
     }
 
     /**
      * Returns true if the Stop is selected, false otherwise.
-     * 
+     *
      * @return true if the Stop is selected, false otherwise
      */
     public boolean isStopSelected() {
-        return stopSelected;
+        return fStopSelected;
     }
 
     /**
      * Returns true if the SyncMessageReturn is selected, false otherwise.
-     * 
+     *
      * @return true if the SyncMessageReturn is selected, false otherwise
      */
     public boolean isSyncMessageReturnSelected() {
-        return syncMessageReturnSelected;
+        return fSyncMessageReturnSelected;
     }
 
     /**
      * Returns true if the SyncMessage is selected, false otherwise.
-     * 
+     *
      * @return true if the SyncMessage is selected, false otherwise
      */
     public boolean isSyncMessageSelected() {
-        return syncMessageSelected;
+        return fSyncMessageSelected;
     }
 
     /**
      * Sets the AsyncMessageReturn selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setAsyncMessageReturnSelected(boolean b) {
-        asyncMessageReturnSelected = b;
+        fAsyncMessageReturnSelected = b;
     }
 
     /**
      * Sets the AsyncMessage selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setAsyncMessageSelected(boolean b) {
-        asyncMessageSelected = b;
+        fAsyncMessageSelected = b;
     }
 
     /**
      * Sets the text entered by the user and compiles the regular expression.
-     * 
+     *
      * @param string the text
      */
     public void setExpression(String string) {
-        expression = string;
-        if (expression != null) {
-            try {
-                if (caseSenstiveSelected) {
-                    pattern = Pattern.compile(string);
-                }
-                else {
-                    pattern = Pattern.compile(string, Pattern.CASE_INSENSITIVE);   
-                }
-            } catch (PatternSyntaxException e) {
-                pattern = null;
-            }
-        }
-        else {
-            pattern = null;
-        }
+        fExpression = string;
+        updatePattern();
     }
 
     /**
      * Sets the Stop selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setLifeLineSelected(boolean b) {
-        lifeLineSelected = b;
+        fLifeLineSelected = b;
     }
 
     /**
      * Set Stop selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setStopSelected(boolean b) {
-        stopSelected = b;
+        fStopSelected = b;
     }
 
     /**
      * Sets the SyncMessageReturn selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setSyncMessageReturnSelected(boolean b) {
-        syncMessageReturnSelected = b;
+        fSyncMessageReturnSelected = b;
     }
 
     /**
      * Sets the SyncMessage selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setSyncMessageSelected(boolean b) {
-        syncMessageSelected = b;
+        fSyncMessageSelected = b;
     }
 
     /**
      * Returns true if the case sensitive is selected, false otherwise.
-     * 
+     *
      * @return true if the case sensitive is selected, false otherwise
      */
     public boolean isCaseSenstiveSelected() {
-        return caseSenstiveSelected;
+        return fCaseSenstiveSelected;
     }
 
     /**
      * Set case sensitive selection state.
-     * 
+     *
      * @param b true if selected, false otherwise
      */
     public void setCaseSenstiveSelected(boolean b) {
-        caseSenstiveSelected = b;
+        fCaseSenstiveSelected = b;
         // Make sure that pattern is set
-        setExpression(expression);
+        setExpression(fExpression);
     }
 
     /**
      * Compares this criteria with a given criteria.
-     *  
+     *
      * @param to The criteria to compare
      * @return usual comparison result (< 0, 0, > 0)
      */
@@ -293,14 +280,14 @@ public class Criteria {
             retVal = getExpression().equals(to.getExpression());
         } else if (to.getExpression() != null) {
             retVal = to.getExpression().equals(getExpression());
-        } 
+        }
         return retVal && isCaseSenstiveSelected() == to.isCaseSenstiveSelected() && isAsyncMessageReturnSelected() == to.isAsyncMessageReturnSelected() && isAsyncMessageSelected() == to.isAsyncMessageSelected()
                 && isLifeLineSelected() == to.isLifeLineSelected() && isStopSelected() == to.isStopSelected() && isSyncMessageReturnSelected() == to.isSyncMessageReturnSelected() && isSyncMessageSelected() == to.isSyncMessageSelected();
     }
 
     /**
      * Saves current criteria attributes in the dialog settings.
-     *  
+     *
      * @param settings The dialog settings
      */
     public void save(DialogSettings settings) {
@@ -316,7 +303,7 @@ public class Criteria {
 
     /**
      * Loads the criteria with values of the dialog settings.
-     * 
+     *
      * @param settings The dialog settings
      */
     public void load(DialogSettings settings) {
@@ -332,7 +319,7 @@ public class Criteria {
 
     /**
      * Gets the summary of supported graph nodes.
-     * 
+     *
      * @param provider A filter provider
      * @param loaderClassName A class loader
      * @return graph node summary
@@ -379,20 +366,21 @@ public class Criteria {
                 list.add(SDMessages._29);
             }
         }
-
-        String ret = "", prefix = "["; //$NON-NLS-1$ //$NON-NLS-2$
+        StringBuffer ret = new StringBuffer();
+        String prefix = "["; //$NON-NLS-1$
         for (Iterator<String> i = list.iterator(); i.hasNext();) {
-            String s = (String) i.next();
-            ret += prefix + s;
+            String s = i.next();
+            ret.append(prefix);
+            ret.append(s);
             prefix = " " + SDMessages._34 + " "; //$NON-NLS-1$ //$NON-NLS-2$
         }
-        ret += "]"; //$NON-NLS-1$
-        return ret;
+        ret.append("]"); //$NON-NLS-1$
+        return ret.toString();
     }
 
     /**
      * Matches given string using compiled pattern based on user expression.
-     * 
+     *
      * @param stringToMatch  A string to match
      * @return true if string matches expression
      */
@@ -402,4 +390,26 @@ public class Criteria {
         }
         return pattern.matcher(stringToMatch).matches();
     }
+
+    /**
+     * Updates the regular expression pattern based on the expression.
+     */
+    private void updatePattern() {
+        if (fExpression != null) {
+            try {
+                if (fCaseSenstiveSelected) {
+                    pattern = Pattern.compile(fExpression);
+                }
+                else {
+                    pattern = Pattern.compile(fExpression, Pattern.CASE_INSENSITIVE);
+                }
+            } catch (PatternSyntaxException e) {
+                pattern = null;
+            }
+        }
+        else {
+            pattern = null;
+        }
+    }
+
 }
This page took 0.028776 seconds and 5 git commands to generate.