1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JiBX: BindGen Customizations</title>
<style type="text/css">
@import url("../style/tigris.css");
@import url("../style/maven.css");
.dtd-comment {
color: #993399;
font-weight: bold;
</style>
<script type="text/javascript">
if (document.layers) {
document.writeln('<link rel="stylesheet" type="text/css" href="../style/ns4_only.css" media="screen" /><link rel="stylesheet" type="text/css" href="../style/maven_ns4_only.css" media="screen" />')
}
</script>
<link rel="stylesheet" type="text/css" href="../style/print.css" media="print" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body class="composite">
<div id="banner">
<table border="0" cellspacing="0" cellpadding="8" width="100%">
<tbody>
<tr>
<td><h1>JiBX: BindGen Customizations</h1>
</td>
<td>
<div align="right" id="login"><a href="http://sourceforge.net/projects/jibx"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=69358&type=16" width="150" height="40" border="0" alt="Get JiBX - XML Data Binding for Java at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a></div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="breadcrumbs">
<table border="0" cellspacing="0" cellpadding="4" width="100%">
<tbody>
<tr>
<td>
<div align="right">
<a href="../index.html">Home Page</a> |
<a href="http://www.sourceforge.net/projects/jibx/">SourceForge Page</a> |
<a href="../mail-lists.html">Mailing Lists</a> |
<a href="../bugs.html">Bugs</a> |
<a href="http://sourceforge.net/project/showfiles.php?group_id=69358">Downloads</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<table border="0" cellspacing="0" cellpadding="8" width="100%" id="main">
<tbody>
<tr valign="top">
<td id="leftcol" width="20%">
<div id="navcolumn">
<div>
<strong>JiBX Basics</strong>
<div>
<small>
<a href="../index.html">Overview</a>
</small>
<div>
<small>
<a href="../getting-started.html">Getting Started</a>
</small>
</div>
<div>
<small>
<a href="../bindcomp.html">Binding Compiler</a>
</small>
</div>
<div>
<small>
<a href="../bindonload.html">Binding on Load</a>
</small>
</div>
<div>
<small>
<a href="../runtime.html">Runtime</a>
</small>
</div>
<div>
<small>
<a href="../extras.html">Extras</a>
</small>
</div>
<div>
<small>
<a href="../building.html">Building JiBX</a>
</small>
</div>
<div>
<small>
<a href=".././jibx-maven-plugin/index.html">Maven</a>
</small>
</div>
<div>
<small>
<a href="../contributing.html">Contributing</a>
</small>
</div>
<div>
<small>
<a href="../jibx-license.html">License</a>
</small>
</div>
</div>
<div>
<small>
<a href="../status.html">News and Status</a>
</small>
</div>
<div>
<small>
<a href="../support.html">Support</a>
</small>
<div>
<small>
<a href="../faq.html">FAQ</a>
</small>
</div>
<div>
<small>
<a href="../mail-lists.html">Mailing Lists</a>
</small>
</div>
<div>
<small>
<a href="../bugs.html">Bugs</a>
</small>
</div>
</div>
<div>
<small>
<a href="../comments.html">User Comments</a>
</small>
</div>
<div>
<small>
<a href="../sponsors.html">Sponsors</a>
</small>
</div>
</div>
<div>
<strong>Start from Code</strong>
<div>
<small>
<a href="index.html">Start from Code</a>
</small>
</div>
<div>
<small>
<a href="bindgen.html">BindGen</a>
</small>
<div>
<small>
<a href="bindgen-examples.html">Example Code</a>
</small>
<div>
<small>
<a href="bindgen-example1.html">Example 1</a>
</small>
</div>
<div>
<small>
<a href="bindgen-example2.html">Example 2</a>
</small>
</div>
<div>
<small>
<a href="bindgen-example3.html">Example 3</a>
</small>
</div>
<div>
<small>
<a href="bindgen-example4.html">Example 4</a>
</small>
</div>
</div>
<div>
<small>
<span class="menu-selection">Customizations Reference</span>
</small>
</div>
</div>
<div>
<small>
<a href="schemagen.html">SchemaGen</a>
</small>
</div>
<div>
<small>
<a href="jibx2wsdl.html">Jibx2Wsdl</a>
</small>
<div>
<small>
<a href="jibx2wsdl-examples.html">Examples</a>
</small>
</div>
<div>
<small>
<a href="jibx2wsdl-customs.html">Customizations</a>
</small>
</div>
</div>
</div>
<div>
<strong>Start from Schema</strong>
<div>
<small>
<a href="../fromschema/index.html">Start from Schema</a>
</small>
</div>
<div>
<small>
<a href="../fromschema/codegen.html">CodeGen</a>
</small>
<div>
<small>
<a href="../fromschema/codegen-types.html">Schema Datatype Handling</a>
</small>
</div>
<div>
<small>
<a href="../fromschema/codegen-examples.html">Example Code</a>
</small>
<div>
<small>
<a href="../fromschema/example-default.html">Default Generation</a>
</small>
</div>
<div>
<small>
<a href="../fromschema/example-custom1.html">Simple Customizations</a>
</small>
</div>
<div>
<small>
<a href="../fromschema/example-custom2.html">More Customizations</a>
</small>
</div>
<div>
<small>
<a href="../fromschema/example-modular.html">Modular Generation</a>
</small>
</div>
</div>
<div>
<small>
<a href="../fromschema/codegen-customs.html">Customizations Reference</a>
</small>
<div>
<small>
<a href="../fromschema/codegen-extends.html">Extensions Reference</a>
</small>
</div>
</div>
</div>
</div>
<div>
<strong>Binding Definition</strong>
<div>
<small>
<a href="../binding/tutorial/binding-tutorial.html">Binding Tutorial</a>
</small>
<div>
<small>
<a href="../binding/tutorial/binding-start.html">A basic binding</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-extras.html">Binding extras</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-structures.html">Structure mapping</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-collects.html">Collections and arrays</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-mappings.html">Using mappings</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-advanced.html">Advanced binding</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-extend.html">Method hooks</a>
</small>
</div>
<div>
<small>
<a href="../binding/tutorial/binding-custom.html">Custom code</a>
</small>
</div>
</div>
<div>
<small>
<a href="../binding/precompiled.html">Precompiled Bindings</a>
</small>
</div>
<div>
<small>
<a href="../binding/binding-overview.html">Definition details</a>
</small>
<div>
<small>
<a href="../binding/contexts.html">Definition contexts</a>
</small>
</div>
<div>
<small>
<a href="../binding/conversions.html">Conversions</a>
</small>
<div>
<small>
<a href="../binding/date-time.html">Date/time conversions</a>
</small>
</div>
</div>
<div>
<small>
<a href="../binding/xml-summary.html">XML summary</a>
</small>
</div>
<div>
<small>
<a href="../binding/binding-element.html"><binding> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/include-element.html"><include> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/format-element.html"><format> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/namespace-element.html"><namespace> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/mapping-element.html"><mapping> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/value-element.html"><value> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/structure-element.html"><structure> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/collection-element.html"><collection> element</a>
</small>
</div>
<div>
<small>
<a href="../binding/binding-attributes.html">Attribute groups</a>
</small>
</div>
</div>
</div>
<div>
<strong>Usage API</strong>
<div>
<small>
<a href=".././api/index.html">Runtime JavaDocs</a>
</small>
</div>
</div>
<div>
<strong>Subprojects</strong>
<div>
<small>
<a href="../eclipse/index.html">Eclipse Plug-in</a>
</small>
<div>
<small>
<a href="../eclipse/index.html">Introduction</a>
</small>
</div>
<div>
<small>
<a href="../eclipse/install.html">Install</a>
</small>
</div>
<div>
<small>
<a href="../eclipse/usage.html">Usage</a>
</small>
</div>
</div>
<div>
<small>
<a href="../jibxws/index.html">JiBX/WS</a>
</small>
</div>
<div>
<small>
<a href="../axis2/index.html">Axis2 Usage</a>
</small>
</div>
<div>
<small>
<a href="../jibxota/index.html">JiBX/OTA</a>
</small>
</div>
<div>
<small>
<a href=".././schema-library/index.html">Schema Library</a>
</small>
</div>
</div>
</div>
</td>
<td>
<div id="bodycol">
<div class="app">
<div class="h3">
<h3><a name="intro"></a>Introduction to customizations</h3>
<p>BindGen supports extensive customizations for modifying the default conversions
between Java data structures and XML schema representations. The customizations use
an XML representation with a nested structure that matches how your Java classes are
organized into packages. Here's a simple example:</p>
<div id="source"><pre><custom force-mapping="true" strip-prefixes="m_">
<package name="org.jibx.starter2" namespace="http://www.jibx.org/starters/fromcode">
<class name="Address" requireds="street1 city"/>
<class name="Customer" requireds="lastName firstName customerNumber">
<value field="m_customerNumber" attribute="customerNumber"/>
</class>
<class name="Item" requireds="id quantity price">
<value get-method="getId" set-method="setId" attribute="id"/>
<value property-name="quantity" attribute="quantity"/>
</class>
</package>
</custom></pre></div>
<p>This example defines four levels of customizations. The top level, those defined as
attributes of the <custom> element, apply to <b class="bold">all</b> classes which
BindGen will process. In this case the first option, <i>force-mapping="true"</i>,
tells BindGen to use global xs:complexType definitions for all classes other than simple
text values, while the second one, <i>strip-prefixes="m_"</i> tells BindGen
to ignore the prefix "m_" when converting Java field names to value names.</p>
<p>The second level of customizations are defined by the <package> element in the
example. On this element, the required <i>name</i> attribute gives the
name of the package, while the <i>namespace</i> attribute defines a
namespace to be used for classes within that package.</p>
<p>The third level of customizations are defined by the <class> elements nested within
the <package> element. On these elements, the required <i>name</i>
attribute gives the name of the class (relative to the containing <package> element,
if any), while the other attributes set options that apply to that class. In this
example, the only options used at this level are telling BindGen that some of the values
defined by the classes are required.</p>
<p>Finally, the fourth level of customizations are defined by the <value> elements
within some of the <class> elements. The <i>field</i>,
<i>get-method</i>/<i>set-method</i> pair, or <i>property-name</i> attributes both
identify the value and tell BindGen how it is to be accessed, while the <i>attribute</i>
attributes tell BindGen to use attribute to represent the values in XML, with the
supplied names. If it seems like a lot of effort to have these separate elements just to
say that a value is to be an attribute rather than an element, you'll be relieved to know
that there's actually a simpler approach to do the same thing, using flag characters on
names in the <i>requireds</i> list (or <i>optionals</i> list, if appropriate) of the
containing <class> element - but the <value> element is also useful for other
purposes, and this usage is a way to include them in this simple example.</p>
</div>
<div class="h3">
<h3><a name="nesting"></a>Nesting in customizations</h3>
<p><package> elements can be nested inside other <package> elements. When
<package> and <class> elements are nested within the customizations, the
names used are always relative to the containing <package> element. You can also
use a <class> element directly as a child of the <custom> element, but in
this case you need to specify the fully-qualified class name.</p>
<p>You might expect inner classes to be handled the same way, nesting the <class>
element for the inner class within that for the containing class - but at least for now,
that's not the case. BindGen instead requires a separate <class> element as a
sibling of that for the containing class, using a '$' separator for the inner class name
(with the inner class name given as "Outer$Inner", for instance).</p>
<p>There are three nesting customization elements: The <custom> element
itself, the <package> element, and the <class> element. As mentioned in the
last section, the <custom> element is always the root element of a customization
document, and can have <package> child elements, <class> child elements,
or both. <package> elements can in turn contain other <package> and/or
<class> child elements. The only restriction is that you need to nest these in
a way that reflects the package structure - so if you have a <package> element
present for a particular package, any <package> elements referring to subpackages
and any <class> elements referring to classes in that package or in subpackages
must be nested inside the original <package> element.</p>
<p>An example might help explain this part: If you have a <package> element
referencing the "com.sosnoski.ws.library" package, and another <package> element
referencing the "com.sosnoski.ws.library.data" package, and a <class> element
referencing the "com.sosnoski.ws.library.data.Book" class, then these elements would
need to be nested in that order. If you have another <class> element referencing
the "com.sosnoski.ws.store.Item" class, that's outside the package hierarchy for the
first three elements. So these would be structured as:</p>
<div id="source"><pre> <package name="com.sosnoski.ws.library" ...>
<package name="data" ...>
<class name="Book" .../>
</package>
</package>
<class name="com.sosnoski.ws.store.Item" .../>
</pre></div>
<p>Note again that the names used for these nested <package> and <class> elements
are always relative to the containing <package>, if any.</p>
</div>
<div class="h3">
<h3><a name="attrs"></a>Customization attributes</h3>
<p>All the different nesting customization elements share a common basic set of attributes,
and any values set for these attributes are inherited by child elements (unless overridden
by a new setting at the child level). Here's the list:</p>
<a name="nesting-attributes"></a>
<h4>Nesting customization attributes</h4>
<table border="1" width="100%">
<tr class="b">
<td><p><a name="force-mapping"></a>force-mapping</p></td>
<td><p>Control whether mapping definitions (and corresponding schema xs:complexType
or xs:simpleType definitions) are generated for each class. Normally BindGen only
generates mapping definitions for classes specified on the command line, and for
referenced classes used in more than one place in the data structure; this flag lets
you change this behavior. Allowed values are "true" (meaning all classes should be
handled as global schema types) and "false" (the default).</p></td>
</tr>
<tr class="a">
<td><p><a name="force-names"></a>force-names</p></td>
<td><p>Control whether element names are used as wrappers around the content of every
class reference. By default, wrapper element names are not used when the reference is
a required value unless the referenced class has a mapping definition, so classes which
are only referenced in one place may be effectively inlined into the XML representation
of the referencing class. Allowed values are "true" (meaning always use a wrapper
element, the default) and "false".</p></td>
</tr>
<tr class="b">
<td><p><a name="javadoc-formatter"></a>javadoc-formatter</p></td>
<td><p>Fully-qualified class name for JavaDoc formatter to be used, which must implement
the <code>org.jibx.custom.classes.IDocumentFormatter</code>. The function of the
formatter is to retrieve JavaDoc text from classes, fields, or methods, and to format
the text for use in schema documentation, so by using your own formatter you can make
selective changes in cases where JavaDoc conventions (such as the standard "Get the XXX
value" text generally used at the start of read access method JavaDocs) don't match the
form of documentation needed in schema definitions. The default implementation is
<code>org.jibx.schema.generator.DocumentFormatter</code>, which can easily be used as
a base class for your own customized implementation.</p></td>
</tr>
<tr class="a">
<td><p><a name="map-abstract"></a>map-abstract</p></td>
<td><p>Use abstract mappings (corresponding to xs:complexType definitions) for classes
if "true", or concrete mappings (corresponding to xs:element definitions) if "false".</p></td>
</tr>
<tr class="b">
<td><p><a name="namespace"></a>namespace</p></td>
<td><p>Basic namespace URI used for definitions. Note that by default, this will just be
a base value which will be extended for child packages (see <b class="bold">namespace-style</b>
attribute, below).</p></td>
</tr>
<tr class="a">
<td><p><a name="namespace-style"></a>namespace-style</p></td>
<td><p>Technique used to derive namespace URIs. Values are "none", "package", or "fixed".
The default is "package", meaning namespaces are derived from package names. To set a
fixed namespace for a package and all child packages, you need to both specify the
namespace (see <b class="bold">namespace</b> attribute, above) and set this values "fixed".</p></td>
</tr>
<tr class="b">
<td><p><a name="name-style"></a>name-style</p></td>
<td><p>Technique used to derive XML names from Java value names. This can be "camel-case",
"upper-camel-case", "hyphenated", "dotted", or "underscored" (all hopefully somewhat
self-explanatory). "camel-case" is the default.</p></td>
</tr>
<tr class="a">
<td><p><a name="property-access"></a>property-access</p></td>
<td><p>Control how values within a class are found by BindGen and accessed by the
generated binding. Allowed values are "true" (meaning to use get/set access methods,
as defined for JavaBean properties) and "false" (meaning use fields directly, the
default).</p></td>
</tr>
<tr class="b">
<td><p><a name="require"></a>require</p></td>
<td><p>Types to be treated as required values (unless otherwise specified). This can be
"none", "primitives", "objects", or "all". The default is "primitives".</p></td>
</tr>
<tr class="a">
<td><p><a name="strip-prefixes"></a>strip-prefixes</p></td>
<td><p>Prefix strings to be stripped from Java field names before converting to XML
element or attribute names. The value is a list of prefix strings, separated by whitespace
characters.</p></td>
</tr>
<tr class="b">
<td><p><a name="strip-suffixes"></a>strip-suffixes</p></td>
<td><p>Suffix strings to be stripped from Java field names before converting to XML
element or attribute names. The value is a list of suffix strings, separated by whitespace
characters.</p></td>
</tr>
<tr class="a">
<td><p><a name="use-javadocs"></a>use-javadocs</p></td>
<td><p>Control whether JavaDocs are exported to generated schemas. Possible values are
"true" (the default) and "false".</p></td>
</tr>
<tr class="b">
<td><p><a name="value-style"></a>value-style</p></td>
<td><p>Set the type of representation to be used for simple text values. The allowed
values are "attribute" and "element". The default is to use attribute representation for
primitive values and a few selected object types (the standard <code>java.lang</code>
wrapper classes for primitive values, along with <code>java.math.BigDecimal</code> and
<code>java.math.BigInteger</code> and date/time types), while using element representation
for all other object types.</p></td>
</tr>
<tr class="a">
<td><p><a name="wrap-collections"></a>wrap-collections</p></td>
<td><p>Control whether wrapper elements (an element which contains the repeating child
elements representing individual items in the collection) should be used for collection
values. Possible values are "true" and "false" (the default).</p></td>
</tr>
</table>
<p>Besides these common nesting customization attributes, each of the nesting elements
defines its own customization attributes. The <custom> element itself defines the
following attributes, which are passed through to the generated binding definition as
the corresponding attributes of the binding definition <a href="../binding/binding-element.html"><binding>
root element</a>:</p>
<a name="custom-attributes"></a>
<h4><custom> customization attributes</h4>
<table border="1" width="100%">
<tr class="b">
<td><p><a name="add-constructors"></a>add-constructors</p></td>
<td><p>If the value of this customization attribute is "true", the binding compiler will
add a default constructor to a bound class when necessary to make it usable in the
binding. The allowed values are "true" and "false", with no default.</p></td>
</tr>
<tr class="a">
<td><p><a name="direction"></a>direction</p></td>
<td><p>This customization attribute is passed through to the generated binding to specify
the types of conversions to and from XML to be supported. The allowed values are "input"
(unmarshalling only), "output" (marshalling only), or "both" (both marshalling and
unmarshalling). There is no default for this customization attribute, but the generated
binding will by default operate as though the value "both" were set.</p></td>
</tr>
<tr class="b">
<td><p><a name="force-classes"></a>force-classes</p></td>
<td><p>If the value of this customization attribute is "true", it forces generation of
marshaller/unmarshaller classes for top-level abstract mappings which are not extended
by other mappings. Normally these classes would not be generated, since such mappings
are never used directly within the binding. The generated classes can be used at runtime
by custom code, though, as the equivalent of type mappings. The allowed values are
"true" and "false", with no default.</p></td>
</tr>
<tr class="a">
<td><p><a name="track-source"></a>track-source</p></td>
<td><p>When this customization attribute is present with value "true", the binding
compiler will add code to each bound object class to implement the
<code>org.jibx.runtime.ITrackSource</code> interface and store source position
information when instance objects are unmarshalled. This interface lets you retrieve
information about the source document and specific line and column location of the
document component associated with that object. The allowed values are "true" and
"false", with no default.</p></td>
</tr>
</table>
<p>The <package> element defines only one attribute, besides the nesting attributes
defined above:</p>
<a name="package-attributes"></a>
<h4><package> customization attributes</h4>
<table border="1" width="100%">
<tr class="b">
<td><p><a name="package-name"></a>name</p></td>
<td><p>This required attribute gives the package name, relative to the containing
<package> element (if any).</p></td>
</tr>
</table>
<p>The <class> element defines the following attributes, in addition to the standard
nesting customization attributes:</p>
<a name="class-attributes"></a>
<h4><class> customization attributes</h4>
<table border="1" width="100%">
<tr class="b">
<td><p><a name="create-type"></a>create-type</p></td>
<td><p>Gives the type to be used when creating an instance of the class, as a
fully-qualified class name. This customization is mostly useful in cases where the
class is abstract or an interface, in which case some way of constructing instances
of the class must be defined if the generated binding is going to be used for
unmarshalling XML.</p></td>
</tr>
<tr class="a">
<td><p><a name="deserializer"></a>deserializer</p></td>
<td><p>Fully-qualifed class and method name for a static method used to deserialize a
text string representing an instance of the class (see the corresponding
attribute in the binding definition <a href="../binding/binding-attributes.html#string">string attribute
group</a> for details). This may only be used in combination
with the attribute <a href="#form">form="simple"</a>.</p></td>
</tr>
<tr class="b">
<td><p><a name="element-name"></a>element-name</p></td>
<td><p>Element name to be used for this class when generating a concrete mapping,
corresponding to a schema global element definition.</p></td>
</tr>
<tr class="a">
<td><p><a name="enum-value-method"></a>enum-value-method</p></td>
<td><p>This attribute is only relevant for Java 5 enum classes which have XML text values
different from the enum value names. The value of the attribute must be the name of a
method in the enum class which returns the XML text value. See the corresponding
attribute in the binding definition <a href="../binding/binding-attributes.html#string">string attribute
group</a> for details.</p></td>
</tr>
<tr class="b">
<td><p><a name="excludes"></a>excludes</p></td>
<td><p>List of value names to be excluded from the XML representation of the class. Names
in the list are separated by whitespace characters.</p></td>
</tr>
<tr class="a">
<td><p><a name="factory"></a>factory</p></td>
<td><p>Gives a factory method to be used for creating an instance of the class, as a
fully-qualified class and method name. This customization is mostly useful in cases
where the class is abstract or an interface, in which case some way of constructing
instances of the class must be defined if the generated binding is going to be used for
unmarshalling XML.</p></td>
</tr>
<tr class="b">
<td><p><a name="form"></a>form</p></td>
<td><p>Form of XML representation to be used for the class. The allowed values are
"default" (meaning a concrete mapping corresponding to a schema global element definition
for classes specified as input to BindGen, and an abstract mapping corresponding to a
schema complex type definition for referenced classes), "abstract-mapping" (meaning an
abstract mapping is required), "concrete-mapping" (meaning a concrete mapping is
required), and "simple" (meaning the class represents a simple text value corresponding
to a schema simple type).</p></td>
</tr>
<tr class="a">
<td><p><a name="includes"></a>includes</p></td>
<td><p>List of value names to be included in the XML representation of the class. Names
in the list are separated by whitespace characters, and optionally prefixed with leading
'@' (to indicate an attribute representation) or '/' (to indicate an element
representation) characters. When this attribute is used, only the
values in the list will be included in the XML representation.</p></td>
</tr>
<tr class="b">
<td><p><a name="name"></a>name</p></td>
<td><p>This required attribute gives the class name, relative to the containing
<package> element (if any).</p></td>
</tr>
<tr class="a">
<td><p><a name="optionals"></a>optionals</p></td>
<td><p>List of value names to be treated as optional in the XML representation of the
class. Names in the list are separated by whitespace characters, and optionally prefixed
with leading '@' (to indicate an attribute representation) or '/' (to indicate an element
representation) characters.</p></td>
</tr>
<tr class="b">
<td><p><a name="requireds"></a>requireds</p></td>
<td><p>List of value names to be treated as required in the XML representation of the
class. Names in the list are separated by whitespace characters, and optionally prefixed
with leading '@' (to indicate an attribute representation) or '/' (to indicate an element
representation) characters.</p></td>
</tr>
<tr class="a">
<td><p><a name="serializer"></a>serializer</p></td>
<td><p>Fully-qualifed class and method name for a static method used to serialize an
instance of the class to a text string (see the corresponding
attribute in the binding definition <a href="../binding/binding-attributes.html#string">string attribute
group</a> for details). This may only be used in combination
with the attribute <a href="#form">form="simple"</a>.</p></td>
</tr>
<tr class="b">
<td><p><a name="type-name"></a>type-name</p></td>
<td><p>Complex type name to be used for this class when generating an abstract mapping,
corresponding to a schema global complex type definition.</p></td>
</tr>
<tr class="a">
<td><p><a name="use-super"></a>use-super</p></td>
<td><p>Controls whether the values from the superclass will be included in the XML
representation of this class. The allowed values are "true" (the default) and "false".</p></td>
</tr>
</table>
<p>The <value> element uses a separate set of customization attributes. Here's the
list of those attributes:</p>
<a name="value-attributes"></a>
<h4><value> customization attributes</h4>
<table border="1" width="100%">
<tr class="b">
<td><p><a name="actual-type"></a>actual-type</p></td>
<td><p>Gives the type of a value, as a fully-qualified class name. This overrides the
declared type for a field or property.</p></td>
</tr>
<tr class="a">
<td><p><a name="attribute"></a>attribute</p></td>
<td><p>This customization makes the XML representation of the value an attribute. The
value of this attribute is the name to be used for the value. If this attribute is
used, the <a href="#element">element</a> attribute cannot be used.</p></td>
</tr>
<tr class="b">
<td><p><a name="value-create"></a>create-type</p></td>
<td><p>Gives the type to be used when creating an instance of the value, as a
fully-qualified class name. This customization is mostly useful in cases where the
value type is an abstract class or interface which cannot be created directly, in
which case some alternative way of constructing instances of the class must be defined
(which may be done at the point of reference, by using this attribute to specify an
implementation class or the <a href="#value-factory">factory</a> attribute to specify a
constuction method, or at the class level by the <class> customization attribute
<a href="#create-type">create-type</a> or <a href="#factory">factory</a>). As a
convenience, the special case of values of type <code>java.util.List</code> by default
use the create-type <code>java.util.ArrayList.</code>.</p></td>
</tr>
<tr class="a">
<td><p><a name="element"></a>element</p></td>
<td><p>This customization makes the XML representation of the value an element. The
value of this attribute is the name to be used for the value. If this attribute is
used, the <a href="#attribute">attribute</a> attribute cannot be used.</p></td>
</tr>
<tr class="b">
<td><p><a name="value-factory"></a>factory</p></td>
<td><p>Gives a static factory method to be used for creating an instance of the value,
as a fully-qualified class and method name. As with the <a href="value-create">create-type</a>
customization, this is mostly useful in cases where the value type is an abstract class
or interface which cannot be created directly. See the corresponding
attribute in the binding definition <a href="../binding/binding-attributes.html#object">object attribute
group</a> for details.</p></td>
</tr>
<tr class="a">
<td><p><a name="field"></a>field</p></td>
<td><p>Defines the value as a field of the class. Either this attribute, a
<a href="#property-name">property-name attribute</a>, or a
<a href="#get-method">get-method</a>/<a href="#set-method">set-method</a> attribute
pair is required.</p></td>
</tr>
<tr class="b">
<td><p><a name="get-method"></a>get-method</p></td>
<td><p>Defines the value by a read access method name. When this attribute is used,
a <a href="#set-method">set-method</a> attribute must also be used unless the XML
conversions are output-only (see the <a href="#direction">direction attribute</a>).
Either this attribute pair, a <a href="#field">field attribute</a>, or a
<a href="#property-name">property-name attribute</a> is required.</p></td>
</tr>
<tr class="a">
<td><p><a name="item-name"></a>item-name</p></td>
<td><p>This attribute only applies when the value is an array or collection. In this
case, the attribute value is the name used for each item in the collection. If not
specified, the name "item" is used by default.</p></td>
</tr>
<tr class="b">
<td><p><a name="item-type"></a>item-type</p></td>
<td><p>This attribute only applies when the value is an array or collection. In this
case, the attribute value is the actual type of items in the collection (as a
fully-qualified class name). This attribute is mainly useful when working with untyped
(pre-Java 5) collection classes, where the item type cannot be found by examination of
the Java code.</p></td>
</tr>
<tr class="a">
<td><p><a name="property-name"></a>property-name</p></td>
<td><p>Defines the value by property name, which must have matching "get"/"set" (or
"is"/"set", in the case of a boolean value) methods. Either this attribute, a
<a href="#field">field attribute</a>, or a
<a href="#get-method">get-method</a>/<a href="#set-method">set-method</a> attribute
pair is required.</p></td>
</tr>
<tr class="b">
<td><p><a name="required"></a>required</p></td>
<td><p>Specifies whether the value is treated as a required component ("true") or
optional component ("false") of the XML representation.</p></td>
</tr>
<tr class="a">
<td><p><a name="set-method"></a>set-method</p></td>
<td><p>Defines the value by a write access method name. When this attribute is used,
a <a href="#get-method">get-method</a> attribute must also be used unless the XML
conversions are input-only (see the <a href="#direction">direction attribute</a>).
Either this attribute pair, a <a href="#field">field attribute</a>, or a
<a href="#property-name">property-name attribute</a> is required.</p></td>
</tr>
</table>
</div>
<div class="h3">
<h3><a name="command"></a>Command line customizations</h3>
<p>You can also pass global customizations to BindGen as command-line parameters,
without the need to create a customizations file, by using "--" as a special prefix to
the customization attribute value. So to set the same global options as used in the
<a href="#intro">introductory example</a> customizations, you'd use <code>--strip-prefixes=m_</code>
and <code>--force-mapping=true</code> on the BindGen command line. No quotes are needed for
the attribute value when you use this technique. If you want to set a customization
that takes a list of multiple values, just use commas rather than spaces as
separators between the individual values (so to ignore the prefixes "m_" and "s_" on
field names, for instance, you'd use the command line parameter <code>--strip-prefixes=m_,s_</code>).
This technique only allows you to set global customizations,
though, so if you're doing anything at the individual package or class level you'll
still need to use a customizations file.</p>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div id="footer">
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<td> © 2003-2011, Dennis M. Sosnoski (<a href="http://www.sosnoski.co.nz">Sosnoski Software Associates Ltd</a>).
Licensed to the JiBX Project for free distribution and use. </td>
</tr>
</tbody>
</table>
</div>
<br>
</body>
</html>
|