cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF > cxf-xjc-dv
Date Fri, 22 Oct 2010 17:32:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/15/_/styles/combined.css?spaceKey=CXF&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF/cxf-xjc-dv">cxf-xjc-dv</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~dkulp">Daniel
Kulp</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         
<h2><a name="cxf-xjc-dv-CXFXJCDefaultValuePlugin"></a>CXF XJC Default Value
Plugin</h2>

<p>The CXF XJC Default Value Plugin provides and XJC plugin that updates the generated
beans to return the default value defined  in the schema for fields that are unset in the
instance.   </p>

<p>For example, if the schema contains:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;xs:complexType name=<span class="code-quote">"pageColor"</span>&gt;</span>
  	<span class="code-tag">&lt;xs:sequence&gt;</span>
	    <span class="code-tag">&lt;xs:element name=<span class="code-quote">"background"</span>
type=<span class="code-quote">"xs:string"</span> default=<span class="code-quote">"red"</span>/&gt;</span>
	    <span class="code-tag">&lt;xs:element name=<span class="code-quote">"foreground"</span>
type=<span class="code-quote">"xs:string"</span> default=<span class="code-quote">"blue"</span>/&gt;</span>
   <span class="code-tag">&lt;/xs:sequence&gt;</span>
<span class="code-tag">&lt;/xs:complexType&gt;</span>
</pre>
</div></div>

<p>it would generate getter methods like:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    <span class="code-keyword">public</span> <span class="code-object">String</span>
getBackground() {
        <span class="code-keyword">if</span> (<span class="code-keyword">null</span>
== background) {
            <span class="code-keyword">return</span> <span class="code-quote">"red"</span>;
        }
        <span class="code-keyword">return</span> background;
    }

    <span class="code-keyword">public</span> <span class="code-object">String</span>
getForeground() {
        <span class="code-keyword">if</span> (<span class="code-keyword">null</span>
== foreground) {
            <span class="code-keyword">return</span> <span class="code-quote">"blue"</span>;
        }
        <span class="code-keyword">return</span> foreground;
    }


</pre>
</div></div>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://cwiki.apache.org/confluence/display/CXF/cxf-xjc-dv">View Online</a>
              |
       <a href="https://cwiki.apache.org/confluence/display/CXF/cxf-xjc-dv?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message