View Javadoc
1   /**
2    * I waive copyright and related rights in the this work worldwide through the CC0 1.0 Universal
3    * public domain dedication. https://creativecommons.org/publicdomain/zero/1.0/legalcode
4    */
5   
6   package gov.usgs.volcanoes.winston.server.http.cmd.fdsnws.constraint;
7   
8   import java.util.Map;
9   
10  import gov.usgs.volcanoes.winston.Channel;
11  
12  /**
13   * A constraint on results returned from a FDSN WS query.
14   * 
15   * @author Tom Parker
16   *
17   */
18  public abstract class FdsnConstraint {
19    
20    /**
21     * Match channel.
22     * @param chan channel
23     * @return true if channel matches this constraint
24     */
25    public abstract boolean matches(Channel chan);
26    
27    /**
28     * Non-matching objects should be pruned.
29     * 
30     * @return if true, non-matching objects should be pruned
31     */
32    public boolean isTerminal() {
33      return true;
34    }
35    
36    protected static String getArg(Map<String, String> arguments, final String s1, final String s2) {
37      String arg = arguments.get(s1);
38      if (arg == null)
39        arg = arguments.get(s2);
40  
41      return arg;
42    }
43  }