org.progeeks.graph
Class PredicateRegistry

java.lang.Object
  extended by org.progeeks.graph.PredicateRegistry

public class PredicateRegistry
extends java.lang.Object

A registry where the lookup is done by matching predicates against a supplied object. Predicate mappings are kept in order and searched first to last when looking up values.

Version:
$Revision: 1.5 $
Author:
Paul Speed

Nested Class Summary
static class PredicateRegistry.PredicateMapping
          A single entry that maps a predicate to an associated value.
 
Constructor Summary
PredicateRegistry()
          Creates a new PredicateRegistry.
PredicateRegistry(PredicateRegistry parent)
          Creates a new PredicateRegistry that will delegate to the specified registry when a local match isn't found.
 
Method Summary
 java.util.List getMappings()
          Returns the list of mappings from Predicates to their respective values.
 PredicateRegistry getParentRegistry()
          Returns a parent registry to which this registry will delegate when it doesn't find a local match.
 PredicateRegistry getRootRegistry()
          Returns the root registry for this PredicateRegistry by traversing up the parentRegistry chain.
 java.lang.Object getValue(java.lang.Object search)
          Returns the value associated with the first predicate that matches the specified search value.
 void setMappings(java.util.List mappings)
          Sets the mappings from Predicates to their respective values.
 void setParentRegistry(PredicateRegistry parent)
          Sets a parent registry to which this registry will delegate when it doesn't find a local match.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PredicateRegistry

public PredicateRegistry()
Creates a new PredicateRegistry.


PredicateRegistry

public PredicateRegistry(PredicateRegistry parent)
Creates a new PredicateRegistry that will delegate to the specified registry when a local match isn't found.

Method Detail

setMappings

public void setMappings(java.util.List mappings)
Sets the mappings from Predicates to their respective values.


getMappings

public java.util.List getMappings()
Returns the list of mappings from Predicates to their respective values.


setParentRegistry

public void setParentRegistry(PredicateRegistry parent)
Sets a parent registry to which this registry will delegate when it doesn't find a local match.


getParentRegistry

public PredicateRegistry getParentRegistry()
Returns a parent registry to which this registry will delegate when it doesn't find a local match.


getRootRegistry

public PredicateRegistry getRootRegistry()
Returns the root registry for this PredicateRegistry by traversing up the parentRegistry chain. If there is no parent registry then this registry is returned... since it is the root after all.


getValue

public java.lang.Object getValue(java.lang.Object search)
Returns the value associated with the first predicate that matches the specified search value.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2003 Paul Speed. All Rights Reserved.