2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.util.matcher;
23 import jalview.util.MessageManager;
26 * An enumeration for binary conditions that a user might choose from when
27 * setting filter or match conditions for values
31 Contains(false, true, "Contains"),
32 NotContains(false, true, "NotContains"), Matches(false, true, "Matches"),
33 NotMatches(false, true, "NotMatches"), Present(false, false, "Present"),
34 NotPresent(false, false, "NotPresent"), EQ(true, true, "EQ"),
35 NE(true, true, "NE"), LT(true, true, "LT"), LE(true, true, "LE"),
36 GT(true, true, "GT"), GE(true, true, "GE");
38 private boolean numeric;
40 private boolean needsAPattern;
43 * value used to save a Condition to the
44 * Jalview project file or restore it from project;
45 * it should not be changed even if enum names change in future
47 private String stableName;
50 * Answers the enum value whose 'stable name' matches the argument (not case
51 * sensitive), or null if no match
56 public static Condition fromString(String stableName)
58 for (Condition c : values())
60 if (c.stableName.equalsIgnoreCase(stableName))
75 Condition(boolean isNumeric, boolean needsPattern, String stablename)
78 needsAPattern = needsPattern;
79 stableName = stablename;
83 * Answers true if the condition does a numerical comparison, else false
88 public boolean isNumeric()
94 * Answers true if the condition requires a pattern to compare against, else
99 public boolean needsAPattern()
101 return needsAPattern;
104 public String getStableName()
110 * Answers a display name for the match condition, suitable for showing in
111 * drop-down menus. The value may be internationalized using the resource key
112 * "label.matchCondition_" with the enum name appended.
117 public String toString()
119 return MessageManager.getStringOrReturn("label.matchCondition_",