You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2003/08/14 23:26:03 UTC
cvs commit: jakarta-commons/betwixt/xdocs/guide reading.xml
rdonkin 2003/08/14 14:26:03
Added: betwixt/xdocs/guide reading.xml
Log:
Split Overview into separate documents in guide directory.
Revision Changes Path
1.1 jakarta-commons/betwixt/xdocs/guide/reading.xml
Index: reading.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<title>Reading Beans (Advanced)</title>
<author email="jstrachan@apache.org">James Strachan</author>
</properties>
<body>
<section name='Reading Beans (Advanced)'>
<subsection name='Adding Custom Digestion Rules'>
<p>
Betwixt builds on <code>Apache Digester</code> for bean reading.
<code>BeanReader</code> extends <code>Digester</code>
and this makes a wide range of functionality available.
</p>
<p>
Digester uses <code>Rule</code>'s to specify the xml mapping (for more details see the
<a href='http://jakarta.apache.org/commons/digester.html'>Digester documentation</a>).
Betwixt provides a custom ruleset (<code>BeanRuleSet</code>). This creates <code>Rule</code>'s that
implement the standard Betwixt mapping for a class. <code>BeanReader.registerBeanClass</code>
uses this <code>RuleSet</code> to add these standard betwixt mapping <code>Rule</code>'s
for the bean class.
</p>
<p>
These standard Betwixt mapping rules can be integrated with other Digester <code>Rule</code>'s.
<code>Rule</code>'s added before <code>registerBeanClass</code> is called will come before (in a
Digester sense) the standard betwixt <code>Rule</code>'s. Those added after will come afterwards.
</p>
<p>
<strong>Note</strong> that care must be taken with the patterns for additional <code>Rule</code>'s.
The standard Betwixt mapping will only work if all it's <code>Rule</code>'s are matched.
</p>
</subsection>
<subsection name='Advanced Updaters'>
<p>
Betwixt by default uses the property write method for standard properties
and matched stems for composite properties (for more details, see
<a href="#Using adder methods for composite properties">here</a>)
to update property values when reading beans.
These approaches should be sufficient for most cases.
But this can be overruled on a per element basis.
</p>
<p>
By using a .betwixt file, the method used to update the bean can be controlled on a per element basis.
When the value of the <code>updater</code> attribute of an <code><element></code> element is set,
Betwixt will try to find a bean method with a matching name which takes a single parameter.
When such a matching method exists, this will be called to update the property value.
</p>
<p>
For example, the following betwixt file fragment:
<source><![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
<element name="bean">
...
<element name='name' property='name' updater='nameSetter'/>
...
</element>
</info>
]]></source>
will look for a method called 'nameSetter' and use that to update the value mapped to the 'name' element.
</p>
</subsection>
</section>
</body>
</document>