Java Doc for Validate.java in  » Library » Apache-common-lang » org » apache » commons » lang » 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 lang » org.apache.commons.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.lang.Validate

Validate
public class Validate (Code)

Assists in validating arguments.

The class is based along the lines of JUnit. If an argument value is deemed invalid, an IllegalArgumentException is thrown. For example:

 Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
 Validate.notNull( surname, "The surname must not be null");
 

author:
   Ola Berg
author:
   Stephen Colebourne
author:
   Gary Gregory
author:
   Norm Deane
since:
   2.0
version:
   $Id: Validate.java 437554 2006-08-28 06:21:41Z bayard $



Constructor Summary
public  Validate()
     Constructor.

Method Summary
public static  voidallElementsOfType(Collection collection, Class clazz, String message)
    
public static  voidallElementsOfType(Collection collection, Class clazz)
    

Validate an argument, throwing IllegalArgumentException if the argument collection is null or has elements that are not of type clazz or a subclass.

public static  voidisTrue(boolean expression, String message, Object value)
    
public static  voidisTrue(boolean expression, String message, long value)
    
public static  voidisTrue(boolean expression, String message, double value)
    
public static  voidisTrue(boolean expression, String message)
    
public static  voidisTrue(boolean expression)
    
public static  voidnoNullElements(Object[] array, String message)
    
public static  voidnoNullElements(Object[] array)
    
public static  voidnoNullElements(Collection collection, String message)
    
public static  voidnoNullElements(Collection collection)
    
public static  voidnotEmpty(Object[] array, String message)
    
public static  voidnotEmpty(Object[] array)
    

Validate an argument, throwing IllegalArgumentException if the argument array is empty (null or no elements).

 Validate.notEmpty(myArray);
 

The message in the exception is 'The validated array is empty'.

public static  voidnotEmpty(Collection collection, String message)
    
public static  voidnotEmpty(Collection collection)
    
public static  voidnotEmpty(Map map, String message)
    
public static  voidnotEmpty(Map map)
    
public static  voidnotEmpty(String string, String message)
    
public static  voidnotEmpty(String string)
    
public static  voidnotNull(Object object, String message)
    
public static  voidnotNull(Object object)
    


Constructor Detail
Validate
public Validate()(Code)
Constructor. This class should not normally be instantiated.




Method Detail
allElementsOfType
public static void allElementsOfType(Collection collection, Class clazz, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument collection is null or has elements that are not of type clazz or a subclass.

 Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
 

Parameters:
  collection - the collection to check, not null
Parameters:
  clazz - the Class which the collection's elements are expected to be, not null
Parameters:
  message - the exception message if the Collection has elements not of type clazz
since:
   2.1



allElementsOfType
public static void allElementsOfType(Collection collection, Class clazz)(Code)

Validate an argument, throwing IllegalArgumentException if the argument collection is null or has elements that are not of type clazz or a subclass.

 Validate.allElementsOfType(collection, String.class);
 

The message in the exception is 'The validated collection contains an element not of type clazz at index: '.


Parameters:
  collection - the collection to check, not null
Parameters:
  clazz - the Class which the collection's elements are expected to be, not null
since:
   2.1



isTrue
public static void isTrue(boolean expression, String message, Object value)(Code)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( myObject.isOk(), "The object is not OK: ", myObject);
 

For performance reasons, the object is passed as a separate parameter and appended to the message string only in the case of an error.


Parameters:
  expression - a boolean expression
Parameters:
  message - the exception message you would like to see if theexpression is false
Parameters:
  value - the value to append to the message in case of error
throws:
  IllegalArgumentException - if expression is false



isTrue
public static void isTrue(boolean expression, String message, long value)(Code)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
 

For performance reasons, the long value is passed as a separate parameter and appended to the message string only in the case of an error.


Parameters:
  expression - a boolean expression
Parameters:
  message - the exception message you would like to see if the expression is false
Parameters:
  value - the value to append to the message in case of error
throws:
  IllegalArgumentException - if expression is false



isTrue
public static void isTrue(boolean expression, String message, double value)(Code)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d);
 

For performance reasons, the double value is passed as a separate parameter and appended to the message string only in the case of an error.


Parameters:
  expression - a boolean expression
Parameters:
  message - the exception message you would like to see if the expressionis false
Parameters:
  value - the value to append to the message in case of error
throws:
  IllegalArgumentException - if expression is false



isTrue
public static void isTrue(boolean expression, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( (i > 0), "The value must be greater than zero");
 Validate.isTrue( myObject.isOk(), "The object is not OK");
 

For performance reasons, the message string should not involve a string append, instead use the Validate.isTrue(boolean,String,Object) method.


Parameters:
  expression - a boolean expression
Parameters:
  message - the exception message you would like to see if the expressionis false
throws:
  IllegalArgumentException - if expression is false



isTrue
public static void isTrue(boolean expression)(Code)

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( i > 0 );
 Validate.isTrue( myObject.isOk() );
 

The message in the exception is 'The validated expression is false'.


Parameters:
  expression - a boolean expression
throws:
  IllegalArgumentException - if expression is false



noNullElements
public static void noNullElements(Object[] array, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument array has null elements or is null.

 Validate.noNullElements(myArray, "The array must not contain null elements");
 

If the array is null then the message in the exception is 'The validated object is null'.


Parameters:
  array - the array to check
Parameters:
  message - the exception message if the array hasnull elements
throws:
  IllegalArgumentException - if the array has nullelements or is null



noNullElements
public static void noNullElements(Object[] array)(Code)

Validate an argument, throwing IllegalArgumentException if the argument array has null elements or is null.

 Validate.noNullElements(myArray);
 

If the array has a null element the message in the exception is 'The validated array contains null element at index: '.

If the array is null then the message in the exception is 'The validated object is null'.


Parameters:
  array - the array to check
throws:
  IllegalArgumentException - if the array has nullelements or is null



noNullElements
public static void noNullElements(Collection collection, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument Collection has null elements or is null.

 Validate.noNullElements(myCollection, "The collection must not contain null elements");
 

If the collection is null then the message in the exception is 'The validated object is null'.


Parameters:
  collection - the collection to check
Parameters:
  message - the exception message if the collection hasnull elements
throws:
  IllegalArgumentException - if the collection hasnull elements or is null



noNullElements
public static void noNullElements(Collection collection)(Code)

Validate an argument, throwing IllegalArgumentException if the argument Collection has null elements or is null.

 Validate.noNullElements(myCollection);
 

The message in the exception is 'The validated collection contains null element at index: '.

If the collection is null then the message in the exception is 'The validated object is null'.


Parameters:
  collection - the collection to check
throws:
  IllegalArgumentException - if the collection hasnull elements or is null



notEmpty
public static void notEmpty(Object[] array, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument array is empty (null or no elements).

 Validate.notEmpty(myArray, "The array must not be empty");
 

Parameters:
  array - the array to check is not empty
Parameters:
  message - the exception message you would like to see if the array is empty
throws:
  IllegalArgumentException - if the array is empty



notEmpty
public static void notEmpty(Object[] array)(Code)

Validate an argument, throwing IllegalArgumentException if the argument array is empty (null or no elements).

 Validate.notEmpty(myArray);
 

The message in the exception is 'The validated array is empty'.
Parameters:
  array - the array to check is not empty
throws:
  IllegalArgumentException - if the array is empty




notEmpty
public static void notEmpty(Collection collection, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument Collection is empty (null or no elements).

 Validate.notEmpty(myCollection, "The collection must not be empty");
 

Parameters:
  collection - the collection to check is not empty
Parameters:
  message - the exception message you would like to see if the collection is empty
throws:
  IllegalArgumentException - if the collection is empty



notEmpty
public static void notEmpty(Collection collection)(Code)

Validate an argument, throwing IllegalArgumentException if the argument Collection is empty (null or no elements).

 Validate.notEmpty(myCollection);
 

The message in the exception is 'The validated collection is empty'.


Parameters:
  collection - the collection to check is not empty
throws:
  IllegalArgumentException - if the collection is empty



notEmpty
public static void notEmpty(Map map, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument Map is empty (null or no elements).

 Validate.notEmpty(myMap, "The map must not be empty");
 

Parameters:
  map - the map to check is not empty
Parameters:
  message - the exception message you would like to see if the map is empty
throws:
  IllegalArgumentException - if the map is empty



notEmpty
public static void notEmpty(Map map)(Code)

Validate an argument, throwing IllegalArgumentException if the argument Map is empty (null or no elements).

 Validate.notEmpty(myMap);
 

The message in the exception is 'The validated map is empty'.


Parameters:
  map - the map to check is not empty
throws:
  IllegalArgumentException - if the map is empty



notEmpty
public static void notEmpty(String string, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString, "The string must not be empty");
 

Parameters:
  string - the string to check is not empty
Parameters:
  message - the exception message you would like to see if the string is empty
throws:
  IllegalArgumentException - if the string is empty



notEmpty
public static void notEmpty(String string)(Code)

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString);
 

The message in the exception is 'The validated string is empty'.


Parameters:
  string - the string to check is not empty
throws:
  IllegalArgumentException - if the string is empty



notNull
public static void notNull(Object object, String message)(Code)

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject, "The object must not be null");
 

Parameters:
  object - the object to check is not null
Parameters:
  message - the exception message you would like to seeif the object is null
throws:
  IllegalArgumentException - if the object is null



notNull
public static void notNull(Object object)(Code)

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject);
 

The message in the exception is 'The validated object is null'.


Parameters:
  object - the object to check is not null
throws:
  IllegalArgumentException - if the object is null



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.