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


java.lang.Object
   org.apache.commons.validator.UrlValidator

UrlValidator
public class UrlValidator implements Serializable(Code)

Validates URLs.

Behavour of validation is modified by passing in options:
  • ALLOW_2_SLASHES - [FALSE] Allows double '/' characters in the path component.
  • NO_FRAGMENT- [FALSE] By default fragments are allowed, if this option is included then fragments are flagged as illegal.
  • ALLOW_ALL_SCHEMES - [FALSE] By default only http, https, and ftp are considered valid schemes. Enabling this option will let any scheme pass validation.
  • Originally based in on php script by Debbie Dyer, validation.php v1.2b, Date: 03/07/02, http://javascript.internet.com. However, this validation now bears little resemblance to the php original.

     Example of usage:
     Construct a UrlValidator with valid schemes of "http", and "https".
     String[] schemes = {"http","https"}.
     UrlValidator urlValidator = new UrlValidator(schemes);
     if (urlValidator.isValid("ftp://foo.bar.com/")) {
     System.out.println("url is valid");
     } else {
     System.out.println("url is invalid");
     }
     prints "url is invalid"
     If instead the default constructor is used.
     UrlValidator urlValidator = new UrlValidator();
     if (urlValidator.isValid("ftp://foo.bar.com/")) {
     System.out.println("url is valid");
     } else {
     System.out.println("url is invalid");
     }
     prints out "url is valid"
     

    See Also:    *
    See Also:   Uniform Resource Identifiers (URI): Generic Syntax
    See Also:   

    version:
       $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
    since:
       Validator 1.1


    Field Summary
    final public static  intALLOW_2_SLASHES
         Allow two slashes in the path component of the URL.
    final public static  intALLOW_ALL_SCHEMES
         Allows all validly formatted schemes to pass validation instead of supplying a set of valid schemes.
    final public static  intNO_FRAGMENTS
         Enabling this options disallows any URL fragments.
    protected  String[]defaultSchemes
         If no schemes are provided, default to this set.

    Constructor Summary
    public  UrlValidator()
         Create a UrlValidator with default properties.
    public  UrlValidator(String[] schemes)
         Behavior of validation is modified by passing in several strings options:
    Parameters:
      schemes - Pass in one or more url schemes to consider valid, passing ina null will default to "http,https,ftp" being valid.If a non-null schemes is specified then all valid schemes mustbe specified.
    public  UrlValidator(int options)
         Initialize a UrlValidator with the given validation options.
    Parameters:
      options - The options should be set using the public constants declared inthis class.
    public  UrlValidator(String[] schemes, int options)
         Behavour of validation is modified by passing in options:
    Parameters:
      schemes - The set of valid schemes.
    Parameters:
      options - The options should be set using the public constants declared inthis class.

    Method Summary
    protected  intcountToken(String token, String target)
         Returns the number of times the token appears in the target.
    Parameters:
      token - Token value to be counted.
    Parameters:
      target - Target value to count tokens in.
    public  booleanisValid(String value)
        

    Checks if a field has a valid url address.


    Parameters:
      value - The value validation is being performed on.
    protected  booleanisValidAuthority(String authority)
         Returns true if the authority is properly formatted.
    protected  booleanisValidFragment(String fragment)
         Returns true if the given fragment is null or fragments are allowed.
    Parameters:
      fragment - Fragment value to validate.
    protected  booleanisValidPath(String path)
         Returns true if the path is valid.
    protected  booleanisValidQuery(String query)
         Returns true if the query is null or it's a properly formatted query string.
    Parameters:
      query - Query value to validate.
    protected  booleanisValidScheme(String scheme)
         Validate scheme.

    Field Detail
    ALLOW_2_SLASHES
    final public static int ALLOW_2_SLASHES(Code)
    Allow two slashes in the path component of the URL.



    ALLOW_ALL_SCHEMES
    final public static int ALLOW_ALL_SCHEMES(Code)
    Allows all validly formatted schemes to pass validation instead of supplying a set of valid schemes.



    NO_FRAGMENTS
    final public static int NO_FRAGMENTS(Code)
    Enabling this options disallows any URL fragments.



    defaultSchemes
    protected String[] defaultSchemes(Code)
    If no schemes are provided, default to this set.




    Constructor Detail
    UrlValidator
    public UrlValidator()(Code)
    Create a UrlValidator with default properties.



    UrlValidator
    public UrlValidator(String[] schemes)(Code)
    Behavior of validation is modified by passing in several strings options:
    Parameters:
      schemes - Pass in one or more url schemes to consider valid, passing ina null will default to "http,https,ftp" being valid.If a non-null schemes is specified then all valid schemes mustbe specified. Setting the ALLOW_ALL_SCHEMES option willignore the contents of schemes.



    UrlValidator
    public UrlValidator(int options)(Code)
    Initialize a UrlValidator with the given validation options.
    Parameters:
      options - The options should be set using the public constants declared inthis class. To set multiple options you simply add them together. For example,ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.



    UrlValidator
    public UrlValidator(String[] schemes, int options)(Code)
    Behavour of validation is modified by passing in options:
    Parameters:
      schemes - The set of valid schemes.
    Parameters:
      options - The options should be set using the public constants declared inthis class. To set multiple options you simply add them together. For example,ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.




    Method Detail
    countToken
    protected int countToken(String token, String target)(Code)
    Returns the number of times the token appears in the target.
    Parameters:
      token - Token value to be counted.
    Parameters:
      target - Target value to count tokens in. the number of tokens.



    isValid
    public boolean isValid(String value)(Code)

    Checks if a field has a valid url address.


    Parameters:
      value - The value validation is being performed on. A nullvalue is considered invalid. true if the url is valid.



    isValidAuthority
    protected boolean isValidAuthority(String authority)(Code)
    Returns true if the authority is properly formatted. An authority is the combination of hostname and port. A null authority value is considered invalid.
    Parameters:
      authority - Authority value to validate. true if authority (hostname and port) is valid.



    isValidFragment
    protected boolean isValidFragment(String fragment)(Code)
    Returns true if the given fragment is null or fragments are allowed.
    Parameters:
      fragment - Fragment value to validate. true if fragment is valid.



    isValidPath
    protected boolean isValidPath(String path)(Code)
    Returns true if the path is valid. A null value is considered invalid.
    Parameters:
      path - Path value to validate. true if path is valid.



    isValidQuery
    protected boolean isValidQuery(String query)(Code)
    Returns true if the query is null or it's a properly formatted query string.
    Parameters:
      query - Query value to validate. true if query is valid.



    isValidScheme
    protected boolean isValidScheme(String scheme)(Code)
    Validate scheme. If schemes[] was initialized to a non null, then only those scheme's are allowed. Note this is slightly different than for the constructor.
    Parameters:
      scheme - The scheme to validate. A null value is consideredinvalid. true if valid.



    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.