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 contains
8 * the specified string.
9 *
10 * @author David Vicente
11 * @version 0.1
12 */
13 public final class ContainsFilter 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 ContainsFilter(LAConverter converter, String value) {
24 super(converter, value);
25 }
26
27 /***
28 * Returns <tt>true</tt> if the messageLabel value contains the accepted value.
29 *
30 * @param message
31 * Message to check
32 * @return <tt>true</tt> if the messageLabel is accepted.
33 * @see net.logAnalyzer.gui.messages.filters.LAMessagesFilter#accept(net.logAnalyzer.handlers.LAMessage)
34 */
35 public boolean accept(LAMessage message) {
36 String value = message.getStringValue(getConverterIndex(message));
37 String test = (String) getValue();
38 return (value.indexOf(test) > -1);
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() + " CONTAINS " + getValue();
48 }
49 }