org.gcube.data.trees.patterns
Class OnePattern

java.lang.Object
  extended by org.gcube.data.trees.patterns.EdgePattern
      extended by org.gcube.data.trees.patterns.OnePattern
All Implemented Interfaces:
Serializable

public class OnePattern
extends EdgePattern

A Pattern that matches Nodes that have a single edge with a given label and a target that matches a given Pattern.

Nodes that have many edges with the given label do not match this pattern, even if there is at most one edge whose target matches the given pattern.

Author:
Fabio Simeoni
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.data.trees.patterns.EdgePattern
EdgePattern.Range
 
Constructor Summary
OnePattern(QName l, Pattern predicate)
          Creates an instance for a given label and pattern.
 
Method Summary
 boolean matches(List<Edge> edges)
          Indicates whether the pattern matches some of the edges in a given list.
 String name()
          Returns the name of the pattern.
 List<Edge> prune(List<Edge> edges)
          Returns the edges from a given list which match the pattern.
 EdgePattern.Range range()
          Returns the EdgePattern.Range of the pattern.
 
Methods inherited from class org.gcube.data.trees.patterns.EdgePattern
equals, hashCode, isCondition, label, matchLabels, pattern, setAsCondition, setPattern, toString, unsetAsCondition
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OnePattern

public OnePattern(QName l,
                  Pattern predicate)
Creates an instance for a given label and pattern.

Parameters:
l - the label
predicate - the pattern
Method Detail

matches

public boolean matches(List<Edge> edges)
Indicates whether the pattern matches some of the edges in a given list.

Parameters:
edges - the list.
Returns:
true if it does, false otherwise.

prune

public List<Edge> prune(List<Edge> edges)
                 throws Exception
Returns the edges from a given list which match the pattern.

Parameters:
edges - the list.
Returns:
the matching edges.
Throws:
Exception - if an attempt to match an edge fails with an error.

range

public EdgePattern.Range range()
Returns the EdgePattern.Range of the pattern.

Specified by:
range in class EdgePattern
Returns:
the range.

name

public String name()
Returns the name of the pattern.

Specified by:
name in class EdgePattern
Returns:
the name


Copyright © 2013. All Rights Reserved.