Java Doc for PredicateUtils.java in  » Library » Apache-common-Collections » org » apache » commons » collections » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common Collections » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.collections.PredicateUtils

PredicateUtils
public class PredicateUtils (Code)
PredicateUtils provides reference implementations and utilities for the Predicate functor interface. The supplied predicates are:
  • Invoker - returns the result of a method call on the input object
  • InstanceOf - true if the object is an instanceof a class
  • Equal - true if the object equals() a specified object
  • Identity - true if the object == a specified object
  • Null - true if the object is null
  • NotNull - true if the object is not null
  • Unique - true if the object has not already been evaluated
  • And/All - true if all of the predicates are true
  • Or/Any - true if any of the predicates is true
  • Either/One - true if only one of the predicate is true
  • Neither/None - true if none of the predicates are true
  • Not - true if the predicate is false, and vice versa
  • Transformer - wraps a Transformer as a Predicate
  • True - always return true
  • False - always return false
  • Exception - always throws an exception
  • NullIsException/NullIsFalse/NullIsTrue - check for null input
  • Transformed - transforms the input before calling the predicate
All the supplied predicates are Serializable.
since:
   Commons Collections 3.0
version:
   $Revision: 377508 $ $Date: 2006-02-13 22:12:33 +0000 (Mon, 13 Feb 2006) $
author:
   Stephen Colebourne
author:
   Ola Berg



Constructor Summary
public  PredicateUtils()
     This class is not normally instantiated.

Method Summary
public static  PredicateallPredicate(Predicate[] predicates)
     Create a new Predicate that returns true only if all of the specified predicates are true.
public static  PredicateallPredicate(Collection predicates)
     Create a new Predicate that returns true only if all of the specified predicates are true.
public static  PredicateandPredicate(Predicate predicate1, Predicate predicate2)
     Create a new Predicate that returns true only if both of the specified predicates are true.
public static  PredicateanyPredicate(Predicate[] predicates)
     Create a new Predicate that returns true if any of the specified predicates are true.
public static  PredicateanyPredicate(Collection predicates)
     Create a new Predicate that returns true if any of the specified predicates are true.
public static  PredicateasPredicate(Transformer transformer)
     Create a new Predicate that wraps a Transformer.
public static  PredicateeitherPredicate(Predicate predicate1, Predicate predicate2)
     Create a new Predicate that returns true if one, but not both, of the specified predicates are true.
public static  PredicateequalPredicate(Object value)
     Creates a Predicate that checks if the input object is equal to the specified object using equals().
public static  PredicateexceptionPredicate()
     Gets a Predicate that always throws an exception.
public static  PredicatefalsePredicate()
     Gets a Predicate that always returns false.
public static  PredicateidentityPredicate(Object value)
     Creates a Predicate that checks if the input object is equal to the specified object by identity.
public static  PredicateinstanceofPredicate(Class type)
     Creates a Predicate that checks if the object passed in is of a particular type, using instanceof.
public static  PredicateinvokerPredicate(String methodName)
     Creates a Predicate that invokes a method on the input object. The method must return either a boolean or a non-null Boolean, and have no parameters.
public static  PredicateinvokerPredicate(String methodName, Class[] paramTypes, Object[] args)
     Creates a Predicate that invokes a method on the input object. The method must return either a boolean or a non-null Boolean, and have no parameters.
public static  PredicateneitherPredicate(Predicate predicate1, Predicate predicate2)
     Create a new Predicate that returns true if neither of the specified predicates are true.
public static  PredicatenonePredicate(Predicate[] predicates)
     Create a new Predicate that returns true if none of the specified predicates are true.
public static  PredicatenonePredicate(Collection predicates)
     Create a new Predicate that returns true if none of the specified predicates are true.
public static  PredicatenotNullPredicate()
     Gets a Predicate that checks if the input object passed in is not null.
public static  PredicatenotPredicate(Predicate predicate)
     Create a new Predicate that returns true if the specified predicate returns false and vice versa.
public static  PredicatenullIsExceptionPredicate(Predicate predicate)
     Gets a Predicate that throws an exception if the input object is null, otherwise it calls the specified Predicate.
public static  PredicatenullIsFalsePredicate(Predicate predicate)
     Gets a Predicate that returns false if the input object is null, otherwise it calls the specified Predicate.
public static  PredicatenullIsTruePredicate(Predicate predicate)
     Gets a Predicate that returns true if the input object is null, otherwise it calls the specified Predicate.
public static  PredicatenullPredicate()
     Gets a Predicate that checks if the input object passed in is null.
public static  PredicateonePredicate(Predicate[] predicates)
     Create a new Predicate that returns true if only one of the specified predicates are true.
public static  PredicateonePredicate(Collection predicates)
     Create a new Predicate that returns true if only one of the specified predicates are true.
public static  PredicateorPredicate(Predicate predicate1, Predicate predicate2)
     Create a new Predicate that returns true if either of the specified predicates are true.
public static  PredicatetransformedPredicate(Transformer transformer, Predicate predicate)
     Creates a predicate that transforms the input object before passing it to the predicate.
public static  PredicatetruePredicate()
     Gets a Predicate that always returns true.
public static  PredicateuniquePredicate()
     Creates a Predicate that returns true the first time an object is encountered, and false if the same object is received again.


Constructor Detail
PredicateUtils
public PredicateUtils()(Code)
This class is not normally instantiated.




Method Detail
allPredicate
public static Predicate allPredicate(Predicate[] predicates)(Code)
Create a new Predicate that returns true only if all of the specified predicates are true. If the array of predicates is empty, then this predicate returns true.
See Also:   org.apache.commons.collections.functors.AllPredicate
Parameters:
  predicates - an array of predicates to check, may not be null the all predicate
throws:
  IllegalArgumentException - if the predicates array is null
throws:
  IllegalArgumentException - if any predicate in the array is null



allPredicate
public static Predicate allPredicate(Collection predicates)(Code)
Create a new Predicate that returns true only if all of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns true.
See Also:   org.apache.commons.collections.functors.AllPredicate
Parameters:
  predicates - a collection of predicates to check, may not be null the all predicate
throws:
  IllegalArgumentException - if the predicates collection is null
throws:
  IllegalArgumentException - if any predicate in the collection is null



andPredicate
public static Predicate andPredicate(Predicate predicate1, Predicate predicate2)(Code)
Create a new Predicate that returns true only if both of the specified predicates are true.
See Also:   org.apache.commons.collections.functors.AndPredicate
Parameters:
  predicate1 - the first predicate, may not be null
Parameters:
  predicate2 - the second predicate, may not be null the and predicate
throws:
  IllegalArgumentException - if either predicate is null



anyPredicate
public static Predicate anyPredicate(Predicate[] predicates)(Code)
Create a new Predicate that returns true if any of the specified predicates are true. If the array of predicates is empty, then this predicate returns false.
See Also:   org.apache.commons.collections.functors.AnyPredicate
Parameters:
  predicates - an array of predicates to check, may not be null the any predicate
throws:
  IllegalArgumentException - if the predicates array is null
throws:
  IllegalArgumentException - if any predicate in the array is null



anyPredicate
public static Predicate anyPredicate(Collection predicates)(Code)
Create a new Predicate that returns true if any of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns false.
See Also:   org.apache.commons.collections.functors.AnyPredicate
Parameters:
  predicates - a collection of predicates to check, may not be null the any predicate
throws:
  IllegalArgumentException - if the predicates collection is null
throws:
  IllegalArgumentException - if any predicate in the collection is null



asPredicate
public static Predicate asPredicate(Transformer transformer)(Code)
Create a new Predicate that wraps a Transformer. The Transformer must return either Boolean.TRUE or Boolean.FALSE otherwise a PredicateException will be thrown.
See Also:   org.apache.commons.collections.functors.TransformerPredicate
Parameters:
  transformer - the transformer to wrap, may not be null the transformer wrapping predicate
throws:
  IllegalArgumentException - if the transformer is null



eitherPredicate
public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2)(Code)
Create a new Predicate that returns true if one, but not both, of the specified predicates are true.
See Also:   org.apache.commons.collections.functors.OnePredicate
Parameters:
  predicate1 - the first predicate, may not be null
Parameters:
  predicate2 - the second predicate, may not be null the either predicate
throws:
  IllegalArgumentException - if either predicate is null



equalPredicate
public static Predicate equalPredicate(Object value)(Code)
Creates a Predicate that checks if the input object is equal to the specified object using equals().
See Also:   org.apache.commons.collections.functors.EqualPredicate
Parameters:
  value - the value to compare against the predicate



exceptionPredicate
public static Predicate exceptionPredicate()(Code)
Gets a Predicate that always throws an exception. This could be useful during testing as a placeholder.
See Also:   org.apache.commons.collections.functors.ExceptionPredicate the predicate



falsePredicate
public static Predicate falsePredicate()(Code)
Gets a Predicate that always returns false.
See Also:   org.apache.commons.collections.functors.FalsePredicate the predicate



identityPredicate
public static Predicate identityPredicate(Object value)(Code)
Creates a Predicate that checks if the input object is equal to the specified object by identity.
See Also:   org.apache.commons.collections.functors.IdentityPredicate
Parameters:
  value - the value to compare against the predicate



instanceofPredicate
public static Predicate instanceofPredicate(Class type)(Code)
Creates a Predicate that checks if the object passed in is of a particular type, using instanceof. A null input object will return false.
See Also:   org.apache.commons.collections.functors.InstanceofPredicate
Parameters:
  type - the type to check for, may not be null the predicate
throws:
  IllegalArgumentException - if the class is null



invokerPredicate
public static Predicate invokerPredicate(String methodName)(Code)
Creates a Predicate that invokes a method on the input object. The method must return either a boolean or a non-null Boolean, and have no parameters. If the input object is null, a PredicateException is thrown.

For example, PredicateUtils.invokerPredicate("isEmpty"); will call the isEmpty method on the input object to determine the predicate result.
See Also:   org.apache.commons.collections.functors.InvokerTransformer
See Also:   org.apache.commons.collections.functors.TransformerPredicate
Parameters:
  methodName - the method name to call on the input object, may not be null the predicate
throws:
  IllegalArgumentException - if the methodName is null.




invokerPredicate
public static Predicate invokerPredicate(String methodName, Class[] paramTypes, Object[] args)(Code)
Creates a Predicate that invokes a method on the input object. The method must return either a boolean or a non-null Boolean, and have no parameters. If the input object is null, a PredicateException is thrown.

For example, PredicateUtils.invokerPredicate("isEmpty"); will call the isEmpty method on the input object to determine the predicate result.
See Also:   org.apache.commons.collections.functors.InvokerTransformer
See Also:   org.apache.commons.collections.functors.TransformerPredicate
Parameters:
  methodName - the method name to call on the input object, may not be null
Parameters:
  paramTypes - the parameter types
Parameters:
  args - the arguments the predicate
throws:
  IllegalArgumentException - if the method name is null
throws:
  IllegalArgumentException - if the paramTypes and args don't match




neitherPredicate
public static Predicate neitherPredicate(Predicate predicate1, Predicate predicate2)(Code)
Create a new Predicate that returns true if neither of the specified predicates are true.
See Also:   org.apache.commons.collections.functors.NonePredicate
Parameters:
  predicate1 - the first predicate, may not be null
Parameters:
  predicate2 - the second predicate, may not be null the neither predicate
throws:
  IllegalArgumentException - if either predicate is null



nonePredicate
public static Predicate nonePredicate(Predicate[] predicates)(Code)
Create a new Predicate that returns true if none of the specified predicates are true. If the array of predicates is empty, then this predicate returns true.
See Also:   org.apache.commons.collections.functors.NonePredicate
Parameters:
  predicates - an array of predicates to check, may not be null the none predicate
throws:
  IllegalArgumentException - if the predicates array is null
throws:
  IllegalArgumentException - if any predicate in the array is null



nonePredicate
public static Predicate nonePredicate(Collection predicates)(Code)
Create a new Predicate that returns true if none of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns true.
See Also:   org.apache.commons.collections.functors.NonePredicate
Parameters:
  predicates - a collection of predicates to check, may not be null the none predicate
throws:
  IllegalArgumentException - if the predicates collection is null
throws:
  IllegalArgumentException - if any predicate in the collection is null



notNullPredicate
public static Predicate notNullPredicate()(Code)
Gets a Predicate that checks if the input object passed in is not null.
See Also:   org.apache.commons.collections.functors.NotNullPredicate the predicate



notPredicate
public static Predicate notPredicate(Predicate predicate)(Code)
Create a new Predicate that returns true if the specified predicate returns false and vice versa.
See Also:   org.apache.commons.collections.functors.NotPredicate
Parameters:
  predicate - the predicate to not the not predicate
throws:
  IllegalArgumentException - if the predicate is null



nullIsExceptionPredicate
public static Predicate nullIsExceptionPredicate(Predicate predicate)(Code)
Gets a Predicate that throws an exception if the input object is null, otherwise it calls the specified Predicate. This allows null handling behaviour to be added to Predicates that don't support nulls.
See Also:   org.apache.commons.collections.functors.NullIsExceptionPredicate
Parameters:
  predicate - the predicate to wrap, may not be null the predicate
throws:
  IllegalArgumentException - if the predicate is null.



nullIsFalsePredicate
public static Predicate nullIsFalsePredicate(Predicate predicate)(Code)
Gets a Predicate that returns false if the input object is null, otherwise it calls the specified Predicate. This allows null handling behaviour to be added to Predicates that don't support nulls.
See Also:   org.apache.commons.collections.functors.NullIsFalsePredicate
Parameters:
  predicate - the predicate to wrap, may not be null the predicate
throws:
  IllegalArgumentException - if the predicate is null.



nullIsTruePredicate
public static Predicate nullIsTruePredicate(Predicate predicate)(Code)
Gets a Predicate that returns true if the input object is null, otherwise it calls the specified Predicate. This allows null handling behaviour to be added to Predicates that don't support nulls.
See Also:   org.apache.commons.collections.functors.NullIsTruePredicate
Parameters:
  predicate - the predicate to wrap, may not be null the predicate
throws:
  IllegalArgumentException - if the predicate is null.



nullPredicate
public static Predicate nullPredicate()(Code)
Gets a Predicate that checks if the input object passed in is null.
See Also:   org.apache.commons.collections.functors.NullPredicate the predicate



onePredicate
public static Predicate onePredicate(Predicate[] predicates)(Code)
Create a new Predicate that returns true if only one of the specified predicates are true. If the array of predicates is empty, then this predicate returns false.
See Also:   org.apache.commons.collections.functors.OnePredicate
Parameters:
  predicates - an array of predicates to check, may not be null the one predicate
throws:
  IllegalArgumentException - if the predicates array is null
throws:
  IllegalArgumentException - if any predicate in the array is null



onePredicate
public static Predicate onePredicate(Collection predicates)(Code)
Create a new Predicate that returns true if only one of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns false.
See Also:   org.apache.commons.collections.functors.OnePredicate
Parameters:
  predicates - a collection of predicates to check, may not be null the one predicate
throws:
  IllegalArgumentException - if the predicates collection is null
throws:
  IllegalArgumentException - if any predicate in the collection is null



orPredicate
public static Predicate orPredicate(Predicate predicate1, Predicate predicate2)(Code)
Create a new Predicate that returns true if either of the specified predicates are true.
See Also:   org.apache.commons.collections.functors.OrPredicate
Parameters:
  predicate1 - the first predicate, may not be null
Parameters:
  predicate2 - the second predicate, may not be null the or predicate
throws:
  IllegalArgumentException - if either predicate is null



transformedPredicate
public static Predicate transformedPredicate(Transformer transformer, Predicate predicate)(Code)
Creates a predicate that transforms the input object before passing it to the predicate.
See Also:   org.apache.commons.collections.functors.TransformedPredicate
Parameters:
  transformer - the transformer to call first
Parameters:
  predicate - the predicate to call with the result of the transform the predicate
throws:
  IllegalArgumentException - if the transformer or the predicate is null
since:
   Commons Collections 3.1



truePredicate
public static Predicate truePredicate()(Code)
Gets a Predicate that always returns true.
See Also:   org.apache.commons.collections.functors.TruePredicate the predicate



uniquePredicate
public static Predicate uniquePredicate()(Code)
Creates a Predicate that returns true the first time an object is encountered, and false if the same object is received again. The comparison is by equals(). A null input object is accepted and will return true the first time, and false subsequently as well.
See Also:   org.apache.commons.collections.functors.UniquePredicate the predicate



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.