validator.html
来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 535 行 · 第 1/2 页
HTML
535 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_14) on Mon Jan 28 05:46:59 PST 2008 --><TITLE>Validator (Java EE 5)</TITLE><META NAME="keywords" CONTENT="javax.xml.bind.Validator interface"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="Validator (Java EE 5)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/xml/bind/ValidationException.html" title="class in javax.xml.bind"><B>PREV CLASS</B></A> NEXT CLASS</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?javax/xml/bind/Validator.html" target="_top"><B>FRAMES</B></A> <A HREF="Validator.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.xml.bind</FONT><BR>Interface Validator</H2><HR><B>Deprecated.</B> <I>since JAXB 2.0</I><P><DL><DT><PRE>public interface <B>Validator</B></DL></PRE><P>As of JAXB 2.0, this class is deprecated and optional. <p> The <tt>Validator</tt> class is responsible for controlling the validation of content trees during runtime. <p> <a name="validationtypes"></a> <b>Three Forms of Validation</b><br> <blockquote> <dl> <dt><b>Unmarshal-Time Validation</b></dt> <dd>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 <A HREF="../../../javax/xml/bind/Unmarshaller.html#setValidating(boolean)"><CODE>Unmarshaller.setValidating</CODE></A>. All JAXB 1.0 Providers are required to support this operation. </dd> <dt><b>On-Demand Validation</b></dt> <dd> 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 <A HREF="../../../javax/xml/bind/Validator.html#validate(java.lang.Object)"><CODE>Validator.validate</CODE></A> method on the Java content tree (or any sub-tree of it). All JAXB 1.0 Providers are required to support this operation. </dd> <dt><b>Fail-Fast Validation</b></dt> <dd> 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. </dd> </dl> </blockquote> <p> The <tt>Validator</tt> class is responsible for managing On-Demand Validation. The <tt>Unmarshaller</tt> 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 <tt>Marshaller</tt> may detect errors, which will be reported to the <tt>ValidationEventHandler</tt> registered on it. <p> <a name="defaulthandler"></a> <b>Using the Default EventHandler</b><br> <blockquote> If the client application does not set an event handler on their <tt>Validator</tt>, <tt>Unmarshaller</tt>, or <tt>Marshaller</tt> 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). </blockquote> <p> <a name="handlingevents"></a> <b>Handling Validation Events</b><br> <blockquote> There are three ways to handle events encountered during the unmarshal, validate, and marshal operations: <dl> <dt>Use the default event handler</dt> <dd>The default event handler will be used if you do not specify one via the <tt>setEventHandler</tt> API's on <tt>Validator</tt>, <tt>Unmarshaller</tt>, or <tt>Marshaller</tt>. </dd> <dt>Implement and register a custom event handler</dt> <dd>Client applications that require sophisticated event processing can implement the <tt>ValidationEventHandler</tt> interface and register it with the <tt>Unmarshaller</tt> and/or <tt>Validator</tt>. </dd> <dt>Use the <A HREF="../../../javax/xml/bind/util/ValidationEventCollector.html" title="class in javax.xml.bind.util"><CODE>ValidationEventCollector</CODE></A> utility</dt> <dd>For convenience, a specialized event handler is provided that simply collects any <tt>ValidationEvent</tt> objects created during the unmarshal, validate, and marshal operations and returns them to the client application as a <tt>java.util.Collection</tt>. </dd> </dl> </blockquote> <p> <b>Validation and Well-Formedness</b><br> <blockquote> <p> 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 <tt>ValidationEventCollector</tt> utility class must terminate processing after being notified of a fatal error. Client applications that supply their own <tt>ValidationEventHandler</tt> should also terminate processing after being notified of a fatal error. If not, unexpected behaviour may occur. </blockquote> <p> <a name="supportedProps"></a> <b>Supported Properties</b><br> <blockquote> <p> 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. </blockquote><P><P><DL><DT><B>Since:</B></DT> <DD>JAXB1.0</DD><DT><B>Version:</B></DT> <DD>$Revision: 1.4 $ $Date: 2005/07/29 20:56:02 $</DD><DT><B>Author:</B></DT> <DD><ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul></DD><DT><B>See Also:</B><DD><A HREF="../../../javax/xml/bind/JAXBContext.html" title="class in javax.xml.bind"><CODE>JAXBContext</CODE></A>, <A HREF="../../../javax/xml/bind/Unmarshaller.html" title="interface in javax.xml.bind"><CODE>Unmarshaller</CODE></A>, <A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind"><CODE>ValidationEventHandler</CODE></A>, <A HREF="../../../javax/xml/bind/ValidationEvent.html" title="interface in javax.xml.bind"><CODE>ValidationEvent</CODE></A>, <A HREF="../../../javax/xml/bind/util/ValidationEventCollector.html" title="class in javax.xml.bind.util"><CODE>ValidationEventCollector</CODE></A></DL><HR><P><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Method Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind">ValidationEventHandler</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/bind/Validator.html#getEventHandler()">getEventHandler</A></B>()</CODE><BR> <B>Deprecated.</B> <I>since JAXB2.0</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/bind/Validator.html#getProperty(java.lang.String)">getProperty</A></B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> name)</CODE><BR> <B>Deprecated.</B> <I>since JAXB2.0</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/bind/Validator.html#setEventHandler(javax.xml.bind.ValidationEventHandler)">setEventHandler</A></B>(<A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind">ValidationEventHandler</A> handler)</CODE><BR> <B>Deprecated.</B> <I>since JAXB2.0</I></TD></TR>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?