marshaller.html

来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 1,114 行 · 第 1/5 页

HTML
1,114
字号
</DL><HR><A NAME="marshal(java.lang.Object, javax.xml.stream.XMLStreamWriter)"><!-- --></A><H3>marshal</H3><PRE>void <B>marshal</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>&nbsp;jaxbElement,             <A HREF="../../../javax/xml/stream/XMLStreamWriter.html" title="interface in javax.xml.stream">XMLStreamWriter</A>&nbsp;writer)             throws <A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></PRE><DL><DD>Marshal the content tree rooted at <tt>jaxbElement</tt> into a <A HREF="../../../javax/xml/stream/XMLStreamWriter.html" title="interface in javax.xml.stream"><CODE>XMLStreamWriter</CODE></A>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>jaxbElement</CODE> - The content tree to be marshalled.<DD><CODE>writer</CODE> - XML will be sent to this writer.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></CODE> - If any unexpected problem occurs during the marshalling.<DD><CODE><A HREF="../../../javax/xml/bind/MarshalException.html" title="class in javax.xml.bind">MarshalException</A></CODE> - If the <A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind"><CODE>ValidationEventHandler</CODE></A>      returns false from its <tt>handleEvent</tt> method or the       <tt>Marshaller</tt> is unable to marshal <tt>obj</tt> (or any       object reachable from <tt>obj</tt>).  See <a href="#elementMarshalling">      Marshalling a JAXB element</a>.<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - If any of the method parameters are null<DT><B>Since:</B></DT>  <DD>JAXB 2.0</DD></DL></DD></DL><HR><A NAME="marshal(java.lang.Object, javax.xml.stream.XMLEventWriter)"><!-- --></A><H3>marshal</H3><PRE>void <B>marshal</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>&nbsp;jaxbElement,             <A HREF="../../../javax/xml/stream/XMLEventWriter.html" title="interface in javax.xml.stream">XMLEventWriter</A>&nbsp;writer)             throws <A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></PRE><DL><DD>Marshal the content tree rooted at <tt>jaxbElement</tt> into a <A HREF="../../../javax/xml/stream/XMLEventWriter.html" title="interface in javax.xml.stream"><CODE>XMLEventWriter</CODE></A>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>jaxbElement</CODE> - The content tree rooted at jaxbElement to be marshalled.<DD><CODE>writer</CODE> - XML will be sent to this writer.<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></CODE> - If any unexpected problem occurs during the marshalling.<DD><CODE><A HREF="../../../javax/xml/bind/MarshalException.html" title="class in javax.xml.bind">MarshalException</A></CODE> - If the <A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind"><CODE>ValidationEventHandler</CODE></A>      returns false from its <tt>handleEvent</tt> method or the       <tt>Marshaller</tt> is unable to marshal <tt>obj</tt> (or any       object reachable from <tt>obj</tt>).  See <a href="#elementMarshalling">      Marshalling a JAXB element</a>.<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - If any of the method parameters are null<DT><B>Since:</B></DT>  <DD>JAXB 2.0</DD></DL></DD></DL><HR><A NAME="getNode(java.lang.Object)"><!-- --></A><H3>getNode</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/org/w3c/dom/Node.html" title="class or interface in org.w3c.dom">Node</A> <B>getNode</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>&nbsp;contentTree)             throws <A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></PRE><DL><DD>Get a DOM tree view of the content tree(Optional).  If the returned DOM tree is updated, these changes are also  visible in the content tree.  Use <A HREF="../../../javax/xml/bind/Marshaller.html#marshal(java.lang.Object, org.w3c.dom.Node)"><CODE>marshal(Object, org.w3c.dom.Node)</CODE></A> to force a deep copy of the content tree to a DOM representation.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>contentTree</CODE> - - JAXB Java representation of XML content<DT><B>Returns:</B><DD>the DOM tree view of the contentTree<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang">UnsupportedOperationException</A></CODE> - If the JAXB provider implementation does not support a      DOM view of the content tree<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - If any of the method parameters are null<DD><CODE><A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></CODE> - If any unexpected problem occurs</DL></DD></DL><HR><A NAME="setProperty(java.lang.String, java.lang.Object)"><!-- --></A><H3>setProperty</H3><PRE>void <B>setProperty</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>&nbsp;name,                 <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A>&nbsp;value)                 throws <A HREF="../../../javax/xml/bind/PropertyException.html" title="class in javax.xml.bind">PropertyException</A></PRE><DL><DD>Set the particular property in the underlying implementation of  <tt>Marshaller</tt>.  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 <a href="#supportedProps"> Supported Properties</a>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the property to be set. This value can either              be specified using one of the constant fields or a user               supplied string.<DD><CODE>value</CODE> - the value of the property to be set<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/bind/PropertyException.html" title="class in javax.xml.bind">PropertyException</A></CODE> - when there is an error processing the given                            property or value<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - If the name parameter is null</DL></DD></DL><HR><A NAME="getProperty(java.lang.String)"><!-- --></A><H3>getProperty</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> <B>getProperty</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>&nbsp;name)                   throws <A HREF="../../../javax/xml/bind/PropertyException.html" title="class in javax.xml.bind">PropertyException</A></PRE><DL><DD>Get the particular property in the underlying implementation of  <tt>Marshaller</tt>.  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 <a href="#supportedProps"> Supported Properties</a>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the property to retrieve<DT><B>Returns:</B><DD>the value of the requested property<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/bind/PropertyException.html" title="class in javax.xml.bind">PropertyException</A></CODE> - when there is an error retrieving the given property or value      property name<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - If the name parameter is null</DL></DD></DL><HR><A NAME="setEventHandler(javax.xml.bind.ValidationEventHandler)"><!-- --></A><H3>setEventHandler</H3><PRE>void <B>setEventHandler</B>(<A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind">ValidationEventHandler</A>&nbsp;handler)                     throws <A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></PRE><DL><DD>Allow an application to register a validation event handler. <p> The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to any of the marshal API's.  If the client application does not register a validation event  handler before invoking one of the marshal methods, then validation  events will be handled by the default event handler which will terminate  the marshal operation after the first error or fatal error is encountered. <p> Calling this method with a null parameter will cause the Marshaller to revert back to the default default event handler.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>handler</CODE> - the validation event handler<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></CODE> - if an error was encountered while setting the         event handler</DL></DD></DL><HR><A NAME="getEventHandler()"><!-- --></A><H3>getEventHandler</H3><PRE><A HREF="../../../javax/xml/bind/ValidationEventHandler.html" title="interface in javax.xml.bind">ValidationEventHandler</A> <B>getEventHandler</B>()                                       throws <A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></PRE><DL><DD>Return the current event handler or the default event handler if one hasn't been set.<P><DD><DL><DT><B>Returns:</B><DD>the current ValidationEventHandler or the default event handler         if it hasn't been set<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/bind/JAXBException.html" title="class in javax.xml.bind">JAXBException</A></CODE> - if an error was encountered while getting the          current event handler</DL></DD></DL><HR><A NAME="setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)"><!-- --></A><H3>setAdapter</H3><PRE>void <B>setAdapter</B>(<A HREF="../../../javax/xml/bind/annotation/adapters/XmlAdapter.html" title="class in javax.xml.bind.annotation.adapters">XmlAdapter</A>&nbsp;adapter)</PRE><DL><DD>Associates a configured instance of <A HREF="../../../javax/xml/bind/annotation/adapters/XmlAdapter.html" title="class in javax.xml.bind.annotation.adapters"><CODE>XmlAdapter</CODE></A> with this marshaller. <p> This is a convenience method that invokes <code>setAdapter(adapter.getClass(),adapter);</code>.<P><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if the adapter parameter is null.<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang">UnsupportedOperationException</A></CODE> - if invoked agains a JAXB 1.0 implementation.<DT><B>Since:</B></DT>  <DD>JAXB 2.0</DD><DT><B>See Also:</B><DD><A HREF="../../../javax/xml/bind/Marshaller.html#setAdapter(java.lang.Class, A)"><CODE>setAdapter(Class,XmlAdapter)</CODE></A></DL></DD></DL><HR><A NAME="setAdapter(java.lang.Class,javax.xml.bind.annotation.adapters.XmlAdapter)"><!-- --></A><A NAME="setAdapter(java.lang.Class, A)"><!-- --></A><H3>setAdapter</H3><PRE>&lt;A extends <A HREF="../../../javax/xml/bind/annotation/adapters/XmlAdapter.html" title="class in javax.xml.bind.annotation.adapters">XmlAdapter</A>&gt; void <B>setAdapter</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A>&lt;A&gt;&nbsp;type,                                       A&nbsp;adapter)</PRE><DL><DD>Associates a configured instance of <A HREF="../../../javax/xml/bind/annotation/adapters/XmlAdapter.html" title="class in javax.xml.bind.annotation.adapters"><CODE>XmlAdapter</CODE></A> with this marshaller. <p> Every marshaller internally maintains a <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Map.html" title="class or interface in java.util"><CODE>Map</CODE></A>&lt;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Class.html" title="class or interface in java.lang"><CODE>Class</CODE></A>,<A HREF="../../../javax/xml/bind/annotation/adapters/XmlAdapter.html" title="class in javax.xml.bind.annotation.adapters"><CODE>XmlAdapter</CODE></A>>, which it uses for marshalling classes whose fields/methods are annotated with <A HREF="../../../javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.html" title="annotation in javax.xml.bind.annotation.adapters"><CODE>XmlJavaTypeAdapter</CODE></A>. <p> This method allows applications to use a configured instance of <A HREF="../../../javax/xml/bind/annotation/adapters/XmlAdapter.html" title="class in javax.xml.bind.annotation.adapters"><CODE>XmlAdapter</CODE></A>. When an instance of an adapter is not given, a marshaller will create one by invoking its default constructor.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>type</CODE> - The type of the adapter. The specified instance will be used when      <A HREF="../../../javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.html#value()"><CODE>XmlJavaTypeAdapter.value()</CODE></A>      refers to this type.<DD><CODE>adapter</CODE> - The instance of the adapter to be used. If null, it will un-register      the current adapter set for this typ

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?