📄 xmlserialization.html
字号:
<HR><A NAME="writeToXML(org.w3c.dom.Element, java.lang.Object, java.lang.String)"><!-- --></A><H3>writeToXML</H3><PRE>public void <B>writeToXML</B>(org.w3c.dom.Element parent, java.lang.Object o, java.lang.String name) throws java.lang.Exception</PRE><DL><DD>adds the given Object to a DOM structure. (only public due to reflection).<br> <b>Note:</b> <code>overrideClassname(Object)</code> is not invoked in case of arrays, since the array class could be a superclass, whereas the elements of the array can be specialized subclasses. In case of an array the method <code>overrideClassname(String)</code> is invoked, which searches for an exact match of the classname in the override hashtable.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>parent</CODE> - the parent of this object, e.g. the class this object is a member of<DD><CODE>o</CODE> - the Object to describe in XML<DD><CODE>name</CODE> - the name of the object<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the DOM creation fails<DT><B>See Also:</B><DD><CODE>#overrideClassname(Object)</CODE>, <CODE>#overrideClassname(String)</CODE>, <CODE>#m_ClassnameOverride</CODE></DL></DD></DL><HR><A NAME="toXML(java.lang.Object)"><!-- --></A><H3>toXML</H3><PRE>public <A HREF="../../../weka/core/xml/XMLDocument.html" title="class in weka.core.xml">XMLDocument</A> <B>toXML</B>(java.lang.Object o) throws java.lang.Exception</PRE><DL><DD>extracts all accesible properties from the given object<P><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - the object to turn into an XML representation<DT><B>Returns:</B><DD>the generated DOM document<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if XML generation fails</DL></DD></DL><HR><A NAME="readFromXML(org.w3c.dom.Element)"><!-- --></A><H3>readFromXML</H3><PRE>public java.lang.Object <B>readFromXML</B>(org.w3c.dom.Element node) throws java.lang.Exception</PRE><DL><DD>builds the object from the given DOM node. (only public due to reflection)<P><DD><DL><DT><B>Parameters:</B><DD><CODE>node</CODE> - the associated XML node<DT><B>Returns:</B><DD>the instance created from the XML description<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if instantiation fails</DL></DD></DL><HR><A NAME="fromXML(org.w3c.dom.Document)"><!-- --></A><H3>fromXML</H3><PRE>public java.lang.Object <B>fromXML</B>(org.w3c.dom.Document document) throws java.lang.Exception</PRE><DL><DD>returns the given DOM document as an instance of the specified class<P><DD><DL><DT><B>Parameters:</B><DD><CODE>document</CODE> - the parsed DOM document representing the object<DT><B>Returns:</B><DD>the XML as object<DT><B>Throws:</B><DD><CODE>if</CODE> - object instantiation fails<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="read(java.lang.String)"><!-- --></A><H3>read</H3><PRE>public java.lang.Object <B>read</B>(java.lang.String xml) throws java.lang.Exception</PRE><DL><DD>parses the given XML string (can be XML or a filename) and returns an Object generated from the representation<P><DD><DL><DT><B>Parameters:</B><DD><CODE>xml</CODE> - the xml to parse (if "<?xml" is not found then it is considered a file)<DT><B>Returns:</B><DD>the generated instance<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="read(java.io.File)"><!-- --></A><H3>read</H3><PRE>public java.lang.Object <B>read</B>(java.io.File file) throws java.lang.Exception</PRE><DL><DD>parses the given file and returns a DOM document<P><DD><DL><DT><B>Parameters:</B><DD><CODE>file</CODE> - the XML file to parse<DT><B>Returns:</B><DD>the parsed DOM document<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="read(java.io.InputStream)"><!-- --></A><H3>read</H3><PRE>public java.lang.Object <B>read</B>(java.io.InputStream stream) throws java.lang.Exception</PRE><DL><DD>parses the given stream and returns a DOM document<P><DD><DL><DT><B>Parameters:</B><DD><CODE>stream</CODE> - the XML stream to parse<DT><B>Returns:</B><DD>the parsed DOM document<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="read(java.io.Reader)"><!-- --></A><H3>read</H3><PRE>public java.lang.Object <B>read</B>(java.io.Reader reader) throws java.lang.Exception</PRE><DL><DD>parses the given reader and returns a DOM document<P><DD><DL><DT><B>Parameters:</B><DD><CODE>reader</CODE> - the XML reader to parse<DT><B>Returns:</B><DD>the parsed DOM document<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="write(java.lang.String, java.lang.Object)"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(java.lang.String file, java.lang.Object o) throws java.lang.Exception</PRE><DL><DD>writes the given object into the file<P><DD><DL><DT><B>Parameters:</B><DD><CODE>file</CODE> - the filename to write to<DD><CODE>o</CODE> - the object to serialize as XML<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="write(java.io.File, java.lang.Object)"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(java.io.File file, java.lang.Object o) throws java.lang.Exception</PRE><DL><DD>writes the given object into the file<P><DD><DL><DT><B>Parameters:</B><DD><CODE>file</CODE> - the filename to write to<DD><CODE>o</CODE> - the object to serialize as XML<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="write(java.io.OutputStream, java.lang.Object)"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(java.io.OutputStream stream, java.lang.Object o) throws java.lang.Exception</PRE><DL><DD>writes the given object into the stream<P><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - the object to serialize as XML<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="write(java.io.Writer, java.lang.Object)"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(java.io.Writer writer, java.lang.Object o) throws java.lang.Exception</PRE><DL><DD>writes the given object into the writer<P><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - the object to serialize as XML<DT><B>Throws:</B><DD><CODE>if</CODE> - something goes wrong with the parsing<DD><CODE>java.lang.Exception</CODE></DL></DD></DL><HR><A NAME="main(java.lang.String[])"><!-- --></A><H3>main</H3><PRE>public static void <B>main</B>(java.lang.String[] args) throws java.lang.Exception</PRE><DL><DD>for testing only. if the first argument is a filename with ".xml" as extension it tries to generate an instance from the XML description and does a <code>toString()</code> of the generated object.<P><DD><DL><DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_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="../../../../Tutorial.pdf"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="http://www.cs.waikato.ac.nz/ml/weka/index.html"><FONT CLASS="NavBarFont1"><B>Weka's home</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="../../../weka/core/xml/XMLOptions.html" title="class in weka.core.xml"><B>PREV CLASS</B></A> <A HREF="../../../weka/core/xml/XMLSerializationMethodHandler.html" title="class in weka.core.xml"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="XMLSerialization.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 | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -