org.gcube.contentmanagement.contentmanager.stubs.model.predicates
Class TreePredicate

java.lang.Object
  extended by org.gcube.contentmanagement.contentmanager.stubs.model.predicates.TreePredicate
All Implemented Interfaces:
java.io.Serializable, Predicate
Direct Known Subclasses:
CutTreePredicate

public class TreePredicate
extends java.lang.Object
implements Predicate

An implementation of Predicate for InnerNodes.

Author:
Fabio Simeoni (University of Strathclyde)
See Also:
Serialized Form

Constructor Summary
TreePredicate(java.util.List<EdgePredicate> predicates)
          Creates and instance with a list of EdgePredicates.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 LeafPredicate<?,?> getIdPredicate()
          Returns the predicate on the node identifier.
 EdgePredicate getPredicate(javax.xml.namespace.QName label)
          Returns a predicate with a given label, if one exists.
 java.util.List<EdgePredicate> getPredicates()
          Return the predicates.
 int hashCode()
          
 boolean matches(Node n)
          Indicates whether a node matches a predicate.
 void prune(Node n)
          Prunes a node of all the descendants that are not required to match the predicate.
 void setIdPredicate(LeafPredicate<?,?> idp)
          Set a predicate on the node identifier.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreePredicate

public TreePredicate(java.util.List<EdgePredicate> predicates)
Creates and instance with a list of EdgePredicates.

Parameters:
predicates - the predicates
Method Detail

matches

public boolean matches(Node n)
Indicates whether a node matches a predicate.

Specified by:
matches in interface Predicate
Parameters:
n - the node.
Returns:
true if it does, false otherwise.

prune

public void prune(Node n)
           throws java.lang.Exception
Prunes a node of all the descendants that are not required to match the predicate.

Specified by:
prune in interface Predicate
Parameters:
n - the node.
Throws:
java.lang.Exception - if the node does not match the predicate.

getPredicates

public java.util.List<EdgePredicate> getPredicates()
Return the predicates.

Returns:
the predicates.

getPredicate

public EdgePredicate getPredicate(javax.xml.namespace.QName label)
Returns a predicate with a given label, if one exists.

Parameters:
label - the label.
Returns:
the predicate, or null.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

setIdPredicate

public void setIdPredicate(LeafPredicate<?,?> idp)
Set a predicate on the node identifier.

Parameters:
idp - the predicate.

getIdPredicate

public LeafPredicate<?,?> getIdPredicate()
Returns the predicate on the node identifier.

Returns:
the predicate.