| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| @Xml(childName) Annotation |
| |
| <p> |
| The {@link oaj.xml.annotation.Xml#childName() @Xml(childName)} annotation can be used to |
| specify the name of XML child elements for bean properties of type collection or array. |
| </p> |
| |
| <h5 class='figure'>Example</h5> |
| <table class='styled w800'> |
| <tr> |
| <th>Data type</th> |
| <th>JSON example</th> |
| <th>Without annotation</th> |
| <th>With annotation</th> |
| </tr> |
| <tr> |
| <td class='code'> |
| <jk>class</jk> MyBean { |
| <ja>@Xml</ja>(childName=<js>"X"</js>) |
| <jk>public</jk> String[] a; |
| <ja>@Xml</ja>(childName=<js>"Y"</js>) |
| <jk>public</jk> int[] b; |
| } |
| </td> |
| <td class='code'> |
| { |
| a: [<js>'foo'</js>,<js>'bar'</js>], |
| b: [123,456] |
| } |
| </td> |
| <td class='code'><xt> |
| <object> |
| <a> |
| <string><xv>foo</xv></string> |
| <string><xv>bar</xv></string> |
| </a> |
| <b> |
| <number><xv>123</xv></number> |
| <number><xv>456</xv></number> |
| </b> |
| </object> |
| </xt></td> |
| <td class='code'><xt> |
| <object> |
| <a> |
| <X><xv>foo</xv></X> |
| <X><xv>bar</xv></X> |
| </a> |
| <b> |
| <Y><xv>123</xv></Y> |
| <Y><xv>456</xv></Y> |
| </b> |
| </object> |
| </xt></td> |
| </tr> |
| <tr> |
| <td class='code'> |
| <jk>class</jk> MyBean { |
| <ja>@Xml</ja>(childName=<js>"child"</js>) |
| <jk>public</jk> int[] a; |
| } |
| </td> |
| <td class='code'> |
| { |
| a: [123,456] |
| } |
| </td> |
| <td class='code'><xt> |
| <object> |
| <a> |
| <string><xv>foo</xv></string> |
| <string><xv>bar</xv></string> |
| </a> |
| </object> |
| </xt></td> |
| <td class='code'><xt> |
| <object> |
| <a> |
| <child><xv>foo</xv></child> |
| <child><xv>bar</xv></child> |
| </a> |
| </object> |
| </xt></td> |
| </tr> |
| </table> |