org.gcube.data.trees.patterns
Class LeafPattern<T,C extends Constraint<? super T>>

java.lang.Object
  extended by org.gcube.data.trees.patterns.AbstractPattern
      extended by org.gcube.data.trees.patterns.LeafPattern<T,C>
Type Parameters:
C - the type of the constraint associated with the pattern.
T - the type of the value constrained by the pattern.
All Implemented Interfaces:
Serializable, Pattern
Direct Known Subclasses:
BoolPattern, CalendarPattern, DatePattern, NumPattern, TextPattern, URIPattern

public abstract class LeafPattern<T,C extends Constraint<? super T>>
extends AbstractPattern

A Patterns over Leafs.

Author:
Fabio Simeoni
See Also:
Serialized Form

Field Summary
protected  C constraint
           
 
Constructor Summary
LeafPattern(C c)
          Creates and instance with a given constraint.
 
Method Summary
 C constraint()
           
 boolean equals(Object obj)
           
 int hashCode()
           
 boolean matches(Node n)
          Indicates whether a node matches a pattern.
abstract  String name()
          Returns the name of the pattern.
 void prune(Node n)
          Prunes a node of all the descendants that are not required to match the pattern.
 String toString()
          
protected abstract  T valueOf(String s)
          Returns the typed equivalent of a leaf's value.
 
Methods inherited from class org.gcube.data.trees.patterns.AbstractPattern
idPattern, setIdPattern
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

constraint

protected C extends Constraint<? super T> constraint
Constructor Detail

LeafPattern

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

Parameters:
c - the constraint
Method Detail

prune

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

Specified by:
prune in interface Pattern
Overrides:
prune in class AbstractPattern
Parameters:
n - the node.
Throws:
Exception - if the node does not match the pattern.

constraint

public C constraint()

matches

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

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

valueOf

protected abstract T valueOf(String s)
                      throws Exception
Returns the typed equivalent of a leaf's value.

Parameters:
s - the value
Returns:
the typed value
Throws:
Exception

name

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

Returns:
the name

toString

public String toString()

Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractPattern

equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractPattern


Copyright © 2013. All Rights Reserved.