~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to j2ee/platform/javahelp/org/netbeans/modules/j2ee/platform/docs/webservice/jaxb/marshall_unmarshall.html

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
Import upstream version 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
<!-- * Copyright © 2007 Sun Microsystems,
 
3
Inc.  All rights reserved.  
 
4
Use is subject to license terms.  *--> 
 
5
<html> 
 
6
    <head> 
 
7
        <title>Marshalling Java Classes to XML Elements</title>
 
8
        <link rel="stylesheet" href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css" type="text/css">
 
9
    </head> 
 
10
    <body>
 
11
        <h2>Marshalling Java Classes to XML Elements</h2>
 
12
        <p> <small><a href="#seealso">See Also</a>&nbsp; </small>
 
13
       <p>The <a href="about_jaxb.html">Java Architecture for XML Binding API (JAXB)</a> provides a client application 
 
14
        the ability to convert Java classes into a
 
15
        hierarchy of XML elements. The IDE provides a code template
 
16
        that you can use to generate a code
 
17
        snippet as the basis for this task.
 
18
        
 
19
        <p><b>To marshall Java classes to XML elements:</b>
 
20
        
 
21
       <ol>
 
22
             
 
23
            <li>Type <tt>jaxbm</tt> in
 
24
            the Source Editor for Java files
 
25
            and then press Tab. The snippet is
 
26
            created, as follows:
 
27
<pre>try {    
 
28
    javax.xml.bind.JAXBContext jaxbCtx= javax.xml.bind.JAXBContext.newInstance( Object.class.getClass().getPackage().getName());
 
29
    javax.xml.bind.Marshaller marshaller = jaxbCtx.createMarshaller();
 
30
    marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8"); //NOI18N
 
31
    marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
 
32
    marshaller.marshal(Object.class , System.out);
 
33
} catch (javax.xml.bind.JAXBException ex) {
 
34
    // XXXTODO Handle exception
 
35
    java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex); //NOI18N
 
36
}</pre>
 
37
            <li>Now
 
38
            incorporate it in the rest of your code.
 
39
            
 
40
        </ol>
 
41
         
 
42
        
 
43
        <dl>
 
44
            <dt><a name="seealso">See Also</a></dt>
 
45
            <dd><a href="about_jaxb.html">About Mapping XML to Java</a></dd>
 
46
            <dd><a href="jaxb_wizard.html">Generating Java Classes from XML Schema Documents</a></dd>
 
47
        </dl>
 
48
        
 
49
        <hr>
 
50
        <small><a href="../../credits.html">Legal Notices</a> 
 
51
            <table cellpadding="20" border="0"> 
 
52
                <tr><td>&nbsp;</td></tr> 
 
53
                <tr><td>&nbsp;</td></tr> 
 
54
                <tr><td>&nbsp;</td></tr> 
 
55
            </table> 
 
56
</small></body></html>