org.progeeks.graph
Class MetaObjectSubstringPredicate

java.lang.Object
  extended by org.progeeks.graph.MetaObjectRegexPredicate
      extended by org.progeeks.graph.MetaObjectSubstringPredicate
All Implemented Interfaces:
java.io.Serializable, org.apache.commons.collections.Predicate

public class MetaObjectSubstringPredicate
extends MetaObjectRegexPredicate
implements org.apache.commons.collections.Predicate, java.io.Serializable

A predicate that will perform a substring search on a MetaClass field value. It is actually based on the MetaObjectRegexPredicate, but allows for simpler programming by the user, and concievably easier predicate transforms into thing like SQL "like" expressions.

metaClass and metaClassName are mutually exclusive.

If a field is not provided, all fields will be searched. Alternatively, a wildcard (*) could be provided. To narrow the scope, the name of the object's field should be supplied.

The valoes of substring, startsWith and endsWith are converted into a regex expression and handled by the super

Version:
$Revision: 1.9 $
Author:
J. Dave Sheremata
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.progeeks.graph.MetaObjectRegexPredicate
WILDCARD
 
Constructor Summary
MetaObjectSubstringPredicate()
           
MetaObjectSubstringPredicate(MetaClass metaClass, java.lang.String field, java.lang.String substring)
          Constructor to create a MetaObjectSubstringPredicate from a MetaClass, field and substring.
MetaObjectSubstringPredicate(MetaClass metaClass, java.lang.String field, java.lang.String substring, boolean startsWith, boolean endsWith)
          Constructor to create a MetaObjectSubstringPredicate from a MetaClass, field and substring.
MetaObjectSubstringPredicate(MetaClass metaClass, java.lang.String metaClassName, java.lang.String field, java.lang.String substring, boolean start, boolean end)
           
MetaObjectSubstringPredicate(java.lang.String metaClassName, java.lang.String field, java.lang.String substring)
          Constructor to create a MetaObjectSubstringPredicate from a meta class name, field and substring.
MetaObjectSubstringPredicate(java.lang.String metaClassName, java.lang.String field, java.lang.String substring, boolean startsWith, boolean endsWith)
           
 
Method Summary
protected  java.lang.String createRegex(java.lang.String value, boolean start, boolean end)
           
 boolean equals(java.lang.Object obj)
           
 boolean evaluate(java.lang.Object object)
          Returns true if the specified node is a meta-object and it's field value is matched with the search expression provided.
 java.lang.String getSubstring()
           
 int hashCode()
           
 boolean isEndsWith()
          Returns whether we're need the endings of our substring and the predicated value to match from the beginning
 boolean isStartsWith()
          Returns whether we're need the beginnings of our substring and the predicated value to match from the beginning
protected  void processSettings()
           
 void setEndsWith(boolean endsWith)
          Controls whether we're need the endings of our substring and the predicated value to match from the beginning
 void setStartsWith(boolean startsWith)
          Controls whether we're need the beginnings of our substring and the predicated value to match from the beginning
 void setSubstring(java.lang.String substring)
           
 
Methods inherited from class org.progeeks.graph.MetaObjectRegexPredicate
getExpression, getField, getFieldExpression, getMetaClass, getMetaClassName, setExpression, setField, setFieldExpression, setMetaClass, setMetaClassName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaObjectSubstringPredicate

public MetaObjectSubstringPredicate()

MetaObjectSubstringPredicate

public MetaObjectSubstringPredicate(java.lang.String metaClassName,
                                    java.lang.String field,
                                    java.lang.String substring)
Constructor to create a MetaObjectSubstringPredicate from a meta class name, field and substring.


MetaObjectSubstringPredicate

public MetaObjectSubstringPredicate(MetaClass metaClass,
                                    java.lang.String field,
                                    java.lang.String substring)
Constructor to create a MetaObjectSubstringPredicate from a MetaClass, field and substring.


MetaObjectSubstringPredicate

public MetaObjectSubstringPredicate(java.lang.String metaClassName,
                                    java.lang.String field,
                                    java.lang.String substring,
                                    boolean startsWith,
                                    boolean endsWith)

MetaObjectSubstringPredicate

public MetaObjectSubstringPredicate(MetaClass metaClass,
                                    java.lang.String field,
                                    java.lang.String substring,
                                    boolean startsWith,
                                    boolean endsWith)
Constructor to create a MetaObjectSubstringPredicate from a MetaClass, field and substring.


MetaObjectSubstringPredicate

public MetaObjectSubstringPredicate(MetaClass metaClass,
                                    java.lang.String metaClassName,
                                    java.lang.String field,
                                    java.lang.String substring,
                                    boolean start,
                                    boolean end)
Method Detail

getSubstring

public java.lang.String getSubstring()

setSubstring

public void setSubstring(java.lang.String substring)

isStartsWith

public boolean isStartsWith()
Returns whether we're need the beginnings of our substring and the predicated value to match from the beginning


setStartsWith

public void setStartsWith(boolean startsWith)
Controls whether we're need the beginnings of our substring and the predicated value to match from the beginning


isEndsWith

public boolean isEndsWith()
Returns whether we're need the endings of our substring and the predicated value to match from the beginning


setEndsWith

public void setEndsWith(boolean endsWith)
Controls whether we're need the endings of our substring and the predicated value to match from the beginning


createRegex

protected java.lang.String createRegex(java.lang.String value,
                                       boolean start,
                                       boolean end)

processSettings

protected void processSettings()

hashCode

public int hashCode()
Overrides:
hashCode in class MetaObjectRegexPredicate

equals

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

evaluate

public boolean evaluate(java.lang.Object object)
Description copied from class: MetaObjectRegexPredicate
Returns true if the specified node is a meta-object and it's field value is matched with the search expression provided. Evaluation happens as follows:

Specified by:
evaluate in interface org.apache.commons.collections.Predicate
Overrides:
evaluate in class MetaObjectRegexPredicate


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