com.googlecode.whatswrong
Class EdgeTypeFilter

java.lang.Object
  extended by com.googlecode.whatswrong.EdgeFilter
      extended by com.googlecode.whatswrong.EdgeTypeFilter
All Implemented Interfaces:
NLPInstanceFilter

public class EdgeTypeFilter
extends EdgeFilter

An EdgeTypeFilter filters out edges that do not have certain (prefix or postfix) types.

Author:
Sebastian Riedel

Nested Class Summary
static interface EdgeTypeFilter.Listener
          Am EdgeTypeFilter.Listener is notified of changes to the set of allowed edge type strings.
 
Constructor Summary
EdgeTypeFilter(java.util.Set<java.lang.String> allowedPrefixTypes)
          Creates a new EdgeTypeFilter with the given allowed edge prefix types.
EdgeTypeFilter(java.lang.String... allowedPrefixTypes)
          Creates a new EdgeTypeFilter with the given allowed edge prefix types.
 
Method Summary
 void addAllowedPostfixType(java.lang.String type)
          Adds an allowed prefix type.
 void addAllowedPrefixType(java.lang.String type)
          Adds an allowed prefix type.
 void addListener(EdgeTypeFilter.Listener listener)
          Adds a listener.
 boolean allowsPostfix(java.lang.String type)
          Does the filter allow the given postfix.
 boolean allowsPrefix(java.lang.String type)
          Does the filter allow the given prefix.
 java.util.Collection<Edge> filterEdges(java.util.Collection<Edge> original)
          Filters out all edges that don't have an allowed prefix and postfix type.
 java.util.Set<java.lang.String> getAllowedPostfixTypes()
          Returns the set of allowed postfix types for edges.
 java.util.Set<java.lang.String> getAllowedPrefixTypes()
          Returns the set of allowed prefix types for edges.
 void removeAllowedPostfixType(java.lang.String type)
          Disallows the given postfix type.
 void removeAllowedPrefixType(java.lang.String type)
          Disallows the given prefix type.
 
Methods inherited from class com.googlecode.whatswrong.EdgeFilter
filter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeTypeFilter

public EdgeTypeFilter(java.lang.String... allowedPrefixTypes)
Creates a new EdgeTypeFilter with the given allowed edge prefix types.

Parameters:
allowedPrefixTypes - the allowed prefix types.

EdgeTypeFilter

public EdgeTypeFilter(java.util.Set<java.lang.String> allowedPrefixTypes)
Creates a new EdgeTypeFilter with the given allowed edge prefix types.

Parameters:
allowedPrefixTypes - the allowed prefix types.
Method Detail

addListener

public void addListener(EdgeTypeFilter.Listener listener)
Adds a listener.

Parameters:
listener - the listener to add.

getAllowedPrefixTypes

public java.util.Set<java.lang.String> getAllowedPrefixTypes()
Returns the set of allowed prefix types for edges.

Returns:
an unmodifiable set of allowed prefix types for edges.

getAllowedPostfixTypes

public java.util.Set<java.lang.String> getAllowedPostfixTypes()
Returns the set of allowed postfix types for edges.

Returns:
an unmodifiable set of allowed postfix types for edges.

addAllowedPrefixType

public void addAllowedPrefixType(java.lang.String type)
Adds an allowed prefix type. This causes the filter to accept edges with the given prefix type.

Parameters:
type - the allowed prefix type.

addAllowedPostfixType

public void addAllowedPostfixType(java.lang.String type)
Adds an allowed prefix type. This causes the filter to accept edges with the given postfix type.

Parameters:
type - the allowed postfix type.

removeAllowedPrefixType

public void removeAllowedPrefixType(java.lang.String type)
Disallows the given prefix type. This causes the filter to stop accepting edges with the given prefix type.

Parameters:
type - the prefix type to disallow.

removeAllowedPostfixType

public void removeAllowedPostfixType(java.lang.String type)
Disallows the given postfix type. This causes the filter to stop accepting edges with the given postfix type.

Parameters:
type - the postfix type to disallow.

filterEdges

public java.util.Collection<Edge> filterEdges(java.util.Collection<Edge> original)
Filters out all edges that don't have an allowed prefix and postfix type.

Specified by:
filterEdges in class EdgeFilter
Parameters:
original - the original set of edges.
Returns:
the filtered set of edges.
See Also:
EdgeFilter#filterEdges(Collection)

allowsPrefix

public boolean allowsPrefix(java.lang.String type)
Does the filter allow the given prefix.

Parameters:
type - the type to check whether it is allowed as prefix.
Returns:
true iff the given type is allowed as prefix.

allowsPostfix

public boolean allowsPostfix(java.lang.String type)
Does the filter allow the given postfix.

Parameters:
type - the type to check whether it is allowed as postfix.
Returns:
true iff the given type is allowed as postfix.


Copyright © 2010. All Rights Reserved.