org.iges.grads.server
Class MetadataFilter

java.lang.Object
  |
  +--org.iges.grads.server.MetadataFilter
All Implemented Interfaces:
java.io.Serializable

public class MetadataFilter
extends java.lang.Object
implements java.io.Serializable

A filter for whether metadata extracted from a dataset should be sent to the client. The filter tests pairs of the form (variable-name, attribute-name), with one of three possible results: the attribute should be included in the client metadata, removed from the client metadata, or neither, if the filter does not match.

See Also:
Serialized Form

Field Summary
protected  java.lang.String attName
           
protected  java.lang.String attPrefix
           
protected  java.lang.String attSuffix
           
static java.util.List COARDS_FILTERS
          Filters to remove all COARDS metadata.
protected  boolean globalOnly
           
protected  boolean sendIfMatch
           
protected  java.lang.String varName
           
protected  java.lang.String varPrefix
           
protected  java.lang.String varSuffix
           
 
Constructor Summary
MetadataFilter(java.lang.String varPrefix, java.lang.String varSuffix, java.lang.String varName, boolean globalOnly, java.lang.String attPrefix, java.lang.String attSuffix, java.lang.String attName, boolean sendIfMatch)
          Creates a filter.
 
Method Summary
static boolean attributePassesFilters(MetadataAttribute attribute, java.util.List filters, boolean defaultVal)
          If any of the filters in the given list recommends removing the attribute, returns false.
 boolean equals(java.lang.Object obj)
           
protected  boolean match(MetadataAttribute attribute)
          Returns true if the variable name and attribute name match the prefixes, suffixes, and names given.
 boolean shouldInclude(MetadataAttribute attribute)
           
 boolean shouldRemove(MetadataAttribute attribute)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

varPrefix

protected java.lang.String varPrefix

varSuffix

protected java.lang.String varSuffix

varName

protected java.lang.String varName

globalOnly

protected boolean globalOnly

attPrefix

protected java.lang.String attPrefix

attSuffix

protected java.lang.String attSuffix

attName

protected java.lang.String attName

sendIfMatch

protected boolean sendIfMatch

COARDS_FILTERS

public static java.util.List COARDS_FILTERS
Filters to remove all COARDS metadata. Exceptions are the 'units' and 'long_name' attributes, since these are not supplied by GrADS.

Constructor Detail

MetadataFilter

public MetadataFilter(java.lang.String varPrefix,
                      java.lang.String varSuffix,
                      java.lang.String varName,
                      boolean globalOnly,
                      java.lang.String attPrefix,
                      java.lang.String attSuffix,
                      java.lang.String attName,
                      boolean sendIfMatch)
               throws AnagramException
Creates a filter.

Parameters:
varPrefix - The filter will match only when the variable name starts with the string specified. The value of "" always matches.
varSuffix - The filter will match only when the variable name ends with the string specified. The value of "" always matches.
varName - The filter will match only when the variable name is exactly equal to the string specified. The value of "" always matches.
sendIfMatch - If true, the filter "includes" pairs that match. If false, it "removes" pairs that match.
Method Detail

shouldRemove

public boolean shouldRemove(MetadataAttribute attribute)
Returns:
True if the (var, attribute) pair should be removed from the client metadata. A false result does not imply that the metadata should be included; a separate call to include() should be made.

shouldInclude

public boolean shouldInclude(MetadataAttribute attribute)
Returns:
True if the (var, attribute) pair should be include from the client metadata. A false result does not imply that the metadata should be included; a separate call to include() should be made.

match

protected boolean match(MetadataAttribute attribute)
Returns true if the variable name and attribute name match the prefixes, suffixes, and names given.


attributePassesFilters

public static boolean attributePassesFilters(MetadataAttribute attribute,
                                             java.util.List filters,
                                             boolean defaultVal)
If any of the filters in the given list recommends removing the attribute, returns false. Otherwise, if any filter in the list recommends including the attribute, returns true. If no filters recommend anything, returns the default value given.


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object