Java Doc for Validator.java in  » 6.0-JDK-Modules » jaxb-api » javax » xml » bind » 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 » 6.0 JDK Modules » jaxb api » javax.xml.bind 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.xml.bind.Validator

Validator
public interface Validator (Code)
As of JAXB 2.0, this class is deprecated and optional.

The Validator class is responsible for controlling the validation of content trees during runtime.

Three Forms of Validation

Unmarshal-Time Validation
This form of validation enables a client application to receive information about validation errors and warnings detected while unmarshalling XML data into a Java content tree and is completely orthogonal to the other types of validation. To enable or disable it, see the javadoc for Unmarshaller.setValidating(boolean) Unmarshaller.setValidating . All JAXB 1.0 Providers are required to support this operation.
On-Demand Validation
This form of validation enables a client application to receive information about validation errors and warnings detected in the Java content tree. At any point, client applications can call the Validator.validate(Object) Validator.validate method on the Java content tree (or any sub-tree of it). All JAXB 1.0 Providers are required to support this operation.
Fail-Fast Validation
This form of validation enables a client application to receive immediate feedback about modifications to the Java content tree that violate type constraints on Java Properties as defined in the specification. JAXB Providers are not required support this type of validation. Of the JAXB Providers that do support this type of validation, some may require you to decide at schema compile time whether or not a client application will be allowed to request fail-fast validation at runtime.

The Validator class is responsible for managing On-Demand Validation. The Unmarshaller class is responsible for managing Unmarshal-Time Validation during the unmarshal operations. Although there is no formal method of enabling validation during the marshal operations, the Marshaller may detect errors, which will be reported to the ValidationEventHandler registered on it.

Using the Default EventHandler

If the client application does not set an event handler on their Validator, Unmarshaller, or Marshaller prior to calling the validate, unmarshal, or marshal methods, then a default event handler will receive notification of any errors or warnings encountered. The default event handler will cause the current operation to halt after encountering the first error or fatal error (but will attempt to continue after receiving warnings).

Handling Validation Events

There are three ways to handle events encountered during the unmarshal, validate, and marshal operations:
Use the default event handler
The default event handler will be used if you do not specify one via the setEventHandler API's on Validator, Unmarshaller, or Marshaller.
Implement and register a custom event handler
Client applications that require sophisticated event processing can implement the ValidationEventHandler interface and register it with the Unmarshaller and/or Validator.
Use the javax.xml.bind.util.ValidationEventCollector ValidationEventCollector utility
For convenience, a specialized event handler is provided that simply collects any ValidationEvent objects created during the unmarshal, validate, and marshal operations and returns them to the client application as a java.util.Collection.

Validation and Well-Formedness

Validation events are handled differently depending on how the client application is configured to process them as described in the previous section. However, there are certain cases where a JAXB Provider indicates that it is no longer able to reliably detect and report errors. In these cases, the JAXB Provider will set the severity of the ValidationEvent to FATAL_ERROR to indicate that the unmarshal, validate, or marshal operations should be terminated. The default event handler and ValidationEventCollector utility class must terminate processing after being notified of a fatal error. Client applications that supply their own ValidationEventHandler should also terminate processing after being notified of a fatal error. If not, unexpected behaviour may occur.

Supported Properties

There currently are not any properties required to be supported by all JAXB Providers on Validator. However, some providers may support their own set of provider specific properties.


author:
  
  • Ryan Shoemaker, Sun Microsystems, Inc.
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
  • Joe Fialli, Sun Microsystems, Inc.

version:
   $Revision: 1.4 $ $Date: 2005/07/29 20:56:02 $
See Also:   JAXBContext
See Also:   Unmarshaller
See Also:   ValidationEventHandler
See Also:   ValidationEvent
See Also:   javax.xml.bind.util.ValidationEventCollector
since:
   JAXB1.0




Method Summary
public  ValidationEventHandlergetEventHandler()
     Return the current event handler or the default event handler if one hasn't been set.
public  ObjectgetProperty(String name)
     Get the particular property in the underlying implementation of Validator.
public  voidsetEventHandler(ValidationEventHandler handler)
     Allow an application to register a validation event handler.

The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to Validator.validate(Object) validate .

public  voidsetProperty(String name, Object value)
     Set the particular property in the underlying implementation of Validator.
public  booleanvalidate(Object subrootObj)
     Validate the Java content tree starting at subrootObj.

Client applications can use this method to validate Java content trees on-demand at runtime.

public  booleanvalidateRoot(Object rootObj)
     Validate the Java content tree rooted at rootObj.

Client applications can use this method to validate Java content trees on-demand at runtime.




Method Detail
getEventHandler
public ValidationEventHandler getEventHandler() throws JAXBException(Code)
Return the current event handler or the default event handler if one hasn't been set. the current ValidationEventHandler or the default event handlerif it hasn't been set
throws:
  JAXBException - if an error was encountered while getting the current event handler



getProperty
public Object getProperty(String name) throws PropertyException(Code)
Get the particular property in the underlying implementation of Validator. This method can only be used to get one of the standard JAXB defined properties above or a provider specific property. Attempting to get an undefined property will result in a PropertyException being thrown. See Supported Properties.
Parameters:
  name - the name of the property to retrieve the value of the requested property
throws:
  PropertyException - when there is an error retrieving the given property or valueproperty name
throws:
  IllegalArgumentException - If the name parameter is null



setEventHandler
public void setEventHandler(ValidationEventHandler handler) throws JAXBException(Code)
Allow an application to register a validation event handler.

The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to Validator.validate(Object) validate . If the client application does not register a validation event handler before invoking the validate method, then validation events will be handled by the default event handler which will terminate the validate operation after the first error or fatal error is encountered.

Calling this method with a null parameter will cause the Validator to revert back to the default default event handler.
Parameters:
  handler - the validation event handler
throws:
  JAXBException - if an error was encountered while setting theevent handler




setProperty
public void setProperty(String name, Object value) throws PropertyException(Code)
Set the particular property in the underlying implementation of Validator. This method can only be used to set one of the standard JAXB defined properties above or a provider specific property. Attempting to set an undefined property will result in a PropertyException being thrown. See Supported Properties.
Parameters:
  name - the name of the property to be set. This value can eitherbe specified using one of the constant fields or a user supplied string.
Parameters:
  value - the value of the property to be set
throws:
  PropertyException - when there is an error processing the givenproperty or value
throws:
  IllegalArgumentException - If the name parameter is null



validate
public boolean validate(Object subrootObj) throws JAXBException(Code)
Validate the Java content tree starting at subrootObj.

Client applications can use this method to validate Java content trees on-demand at runtime. This method can be used to validate any arbitrary subtree of the Java content tree. Global constraint checking will not be performed as part of this operation (i.e. ID/IDREF constraints).
Parameters:
  subrootObj - the obj to begin validation at
throws:
  JAXBException - if any unexpected problem occurs during validation
throws:
  ValidationException - If the ValidationEventHandler ValidationEventHandlerreturns false from its handleEvent method or the Validator is unable to validate the content tree rooted at subrootObj
throws:
  IllegalArgumentException - If the subrootObj parameter is null true if the subtree rooted at subrootObj is valid, falseotherwise




validateRoot
public boolean validateRoot(Object rootObj) throws JAXBException(Code)
Validate the Java content tree rooted at rootObj.

Client applications can use this method to validate Java content trees on-demand at runtime. This method is used to validate an entire Java content tree. Global constraint checking will be performed as part of this operation (i.e. ID/IDREF constraints).
Parameters:
  rootObj - the root obj to begin validation at
throws:
  JAXBException - if any unexpected problem occurs during validation
throws:
  ValidationException - If the ValidationEventHandler ValidationEventHandlerreturns false from its handleEvent method or the Validator is unable to validate the content tree rooted at rootObj
throws:
  IllegalArgumentException - If the rootObj parameter is null true if the tree rooted at rootObj is valid, falseotherwise




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