View Javadoc
1   package net.logAnalyzer.gui.messages.filters;
2   
3   import net.logAnalyzer.converters.LAConverter;
4   import net.logAnalyzer.handlers.LAMessage;
5   
6   /***
7    * This class implements a string filter checking if the messageLabel value starts
8    * with the specified string.
9    * 
10   * @author Karim REFEYTON
11   * @version 0.1
12   */
13  public final class StartWithFilter extends CompareFilter {
14      /***
15       * Constructs a new filter.
16       * 
17       * @param converter
18       *            Converter to compare.
19       * @param value
20       *            Value used to accept or not the messageLabel (depending of
21       *            {@link #accept(LAMessage)} implementation).
22       */
23      public StartWithFilter(LAConverter converter, String value) {
24          super(converter, value);
25      }
26  
27      /***
28       * Returns <tt>true</tt> if the messageLabel value starts with the accepted
29       * value.
30       * 
31       * @param message
32       *            Message to check
33       * @return <tt>true</tt> if the messageLabel is accepted.
34       * @see net.logAnalyzer.gui.messages.filters.LAMessagesFilter#accept(net.logAnalyzer.handlers.LAMessage)
35       */
36      public boolean accept(LAMessage message) {
37          return message.getStringValue(getConverterIndex(message)).startsWith(
38                  ((String) getValue()));
39      }
40  
41      /***
42       * Returns a string representation of the filter. Used to display filter.
43       * 
44       * @return String representation of the filter.
45       */
46      public String toString() {
47          return getConverter().getLabel() + " STARTS WITH " + getValue();
48      }
49  }