org.gcube.contentmanagement.contentmanager.stubs.model.predicates
Class LeafPredicate<T,C extends Constraint<? super T>>

java.lang.Object
  extended by org.gcube.contentmanagement.contentmanager.stubs.model.predicates.LeafPredicate<T,C>
Type Parameters:
C - the type of the constraint associated with the predicate.
T - the type of the value constrained by the predicate.
All Implemented Interfaces:
java.io.Serializable, Predicate
Direct Known Subclasses:
Bool, Calendar, Date, Num, RID, Text

public abstract class LeafPredicate<T,C extends Constraint<? super T>>
extends java.lang.Object
implements Predicate

Abstract implementation of Predicate for predicates that apply to Leafs.

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

Constructor Summary
LeafPredicate(C c)
          Creates and instance with a given constraint.
 
Method Summary
 C constraint()
           
 boolean equals(java.lang.Object obj)
           
 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.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LeafPredicate

public LeafPredicate(C c)
Creates and instance with a given constraint.

Parameters:
c - the constraint.
Method Detail

prune

public final 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.

constraint

public C constraint()

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.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

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