File: conMethodsForGeneratedJavaTypes.html

package info (click to toggle)
xmlbeans 2.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,076 kB
  • sloc: java: 90,788; xml: 3,177; sh: 108; sql: 48; makefile: 29
file content (275 lines) | stat: -rw-r--r-- 10,954 bytes parent folder | download | duplicates (2)
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
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">

<!-- Copyright 2004 The Apache Software Foundation

     Licensed 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. -->
<html>
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Methods for Types Generated From Schema</title>
<!-- InstanceEndEditable -->
<!--(Meta)==========================================================-->

<meta http-equiv=Content-Type content="text/html; charset=$CHARSET;">


<!-- InstanceBeginEditable name="metatags" -->

<meta name="component" content="">
<!-- In the description metatag, please provide a BRIEF description of the topic contents. -->
<meta name="description" content="">
<!-- In the component metatag, please list keywords that will help a user search for this topic. -->
<meta name="keywords" content="">
<!-- InstanceEndEditable -->

<!--(Links)=========================================================-->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="../xmlbeans.css" rel="stylesheet" type="text/css">
<a href="../../../core/index.html" id="index"></a>
<script language="JavaScript" src="../../../core/topicInfo.js"></script>
<script language="JavaScript" src="../../../core/CookieClass.js"></script>
<script language="JavaScript" src="../../../core/displayContent.js"></script>
</head>

<!--(Body)==========================================================-->
<body>
<script language="JavaScript">

</script>
<!-- InstanceBeginEditable name="body" -->
<div id=topictitle>
  <p class=Title>Methods for Types Generated From Schema</p>
</div>
<div id=topictext>
  <p>As you may have seen in <a href="conGettingStartedwithXMLBeans.html">Getting
    Started with XMLBeans</a>, you use the types generated from schema to access
    XML instances based on the schema. If you're familiar with the JavaBeans technology,
    the conventions used in the generated API will be recognizable. </p>
  <p>In general, elements and attributes are treated as &quot;properties&quot;
    in the JavaBeans sense. In other words, as you would with JavaBeans properties,
    you manipulate parts of the XML through accessor methods such as getCustomer()
    (where you have a &quot;customer&quot; element), setId(String) (where you
    have an &quot;id&quot; attribute), and so on. However, because schema structures
    can be somewhat complex, XMLBeans provides several other method styles for
    handling those structures in XML instances.</p>
  <div>
    <h2>Prototypes for Methods in Generated Interfaces</h2>
    <p>Several methods are generated for each element or attribute within the
      complex type. This topic lists each method that could be generated for a
      given element or attribute. </p>
    <p>Note that whether or not a given method is generated is based on how the
      element or attribute is defined in schema. For example, a customer element
      definition with a <span class="langinline">maxOccurs</span> attribute value
      of 1 will result in a getCustomer method, but not a getCustomerArray method
      &#8212; after all, only one customer element is possible in an instance
      document.</p>
    <p>Note, too, that there may be two sets of parallel methods: one whose prototype
      starts with an &quot;x&quot;. An &quot;x&quot; method such as xgetName or
      xsetName would be generated for elements or attribute whose type is a simple
      type. A simple type may be one of the 44 built-in simple types or may be
      a restriction in schema of one of those built-in types. Of course, an attribute
      will always be of a simple type. For built-in simple types, an &quot;x&quot;
      method will get or set one of the types provided with XMLBeans, such as
      <span class="langinline"><a href="../reference/org/apache/xmlbeans/XmlString.html">XmlString</a></span>,
      <span class="langinline"><a href="../reference/org/apache/xmlbeans/XmlInteger.html">XmlInteger</a></span>,
      <span class="langinline"><a href="../reference/org/apache/xmlbeans/XmlGDay.html">XmlGDay</a></span>,
      and so on. For derived types, the &quot;x&quot; method will get or set a
      generated type.</p>
    <h3>Single Occurrence Methods</h3>
    <p>Methods generated for elements or attributes that allow a single occurrence.
      An element is singular if it was declared with maxOccurs=&quot;1&quot;.
      An attribute is singular if it was not declared with use=&quot;prohibited&quot;.</p>
    <pre>
Type getFoo()
void setFoo(Type newValue)
</pre>
  </div>
  <blockquote>
    <div>Returns or sets the value of Foo. Generated when Foo is an attribute,
      or is an element that can occur only once as a child.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>XmlType xgetFoo()
void xsetFoo(XmlType newValue)</pre>
  </div>
  <blockquote>
    <div>Returns or sets the value of Foo as an XMLBean simple type. These methods
      are generated if Foo's type is defined in schema as a simpleType.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>boolean isNilFoo()
void setNilFoo()</pre>
  </div>
  <blockquote>
    <div>Determines or specifies whether the Foo element is nil (in other words,
      &quot;null&quot; in schema terms), meaning it can be empty. A nil element
      looks something like this:</div>
    <div>
      <pre>&lt;foo/&gt;</pre>
    </div>
    <div>These methods are only generated when an element type is declared as
      nillable in schema &#8212; it has a nillable=&quot;true&quot; attribute.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>XmlType addNewFoo()</pre>
  </div>
  <blockquote>
    <div>Adds a new Foo as an XMLBean simple to the document, or returns Foo's
      value if one exists already.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>boolean isSetFoo()
void unSetFoo()</pre>
  </div>
  <blockquote>
    <div>Determines whether the Foo element or attribute exists in the document;
      removes Foo. These methods are generated for elements and attributes that
      are optional. In schema, and optional element has an <span class="langinline">minOccurs</span>
      attribute set to &quot;0&quot;; an optional attribute has a <span class="langinline">use</span>
      attribute set to &quot;optional&quot;.</div>
  </blockquote>
  <div>
    <hr size="1">
    <h3>Multiple Occurrence Methods</h3>
    <p>Methods generated for elements that allow multiple occurrences. </p>
    <p>An element may occur multiple times if it has a <span class="langinline">maxOccurs</span>
      attribute set to &quot;unbounded&quot; or greater than 1. Attributes can't
      occur multiple times.</p>
    <pre>Type[] getFooArray()
void setFooArray(Type[] newValue) </pre>
  </div>
  <blockquote>
    <div>Returns or sets all of the Foo elements. </div>
    <div>
      <pre>
// Get an array of the all of the purchase-order elements item children.
Item[] items = myPO.getItemArray();
</pre>
    </div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>Type getFooArray(int index)
void setFooArray(Type newValue, int index)</pre>
  </div>
  <blockquote>
    <div>Returns or sets the Foo child element at the specified index.</div>
    <div>
      <pre>// Sets the value of the third item child element.
myPO.setItem(newItem, 2);</pre>
    </div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>int sizeOfFooArray()</pre>
  </div>
  <blockquote>
    <div>Returns the number of Foo child elements.</div>
    <div>
      <pre>// Returns the number of item child elements.
int itemCount = myPO.sizeOfItemArray();</pre>
    </div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>void removeFoo(int index)</pre>
  </div>
  <blockquote>
    <div>Removes the Foo child element at the specified index.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>XmlType[] xgetFooArray()
void xsetFooArray(XmlType[] arrayOfNewValues)</pre>
  </div>
  <blockquote>
    <div>Returns or sets all of the Foo elements as XMLBeans simple types. Generated
      only when the Foo element is defined as a simple type.</div>
    <div>
      <pre>/*
 * Returns values of all the phone child elements of an employee element,
 * where the phone element has been defined as xs:string.
 */
XmlString[] empPhones = currentEmployee.xGetPhoneArray();
</pre>
    </div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>XmlType xgetFooArray(int index)
void xsetFooArray(int index, XmlType newValue)</pre>
  </div>
  <blockquote>
    <div>Returns or sets the Foo element at the specified index, using an XMLBeans
      simple type value. Generated for an element defined as a simple type in
      schema.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>void insertFoo(int index, FooType newValue)</pre>
  </div>
  <blockquote>
    <div>Inserts the specified Foo child element at the specified index.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>void addFoo(FooType newValue)</pre>
  </div>
  <blockquote>
    <div>Adds the specified Foo to the end of the list of Foo child elements.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>XmlType insertNewFoo(int index)</pre>
  </div>
  <blockquote>
    <div>Inserts a new Foo at the specified index, returning an XMLBeans simple
      type representing the new element; returns the existing Foo if there's already
      one at index.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>XmlType addNewFoo()</pre>
  </div>
  <blockquote>
    <div>Adds a new Foo element to the end of the list of Foo child elements,
      returning an XMLBeans simple type representing the newly added element.</div>
  </blockquote>
  <div>
    <hr size="1">
    <pre>boolean isNilFooArray(int index)
void setNilFooArray(int index)</pre>
  </div>
  <blockquote>
    <div>Determines or specifies whether the Foo element at the specified index
      is nil.</div>
  </blockquote>
  <div>
    <hr size="1">
  </div>
  <div id="topictext"></div>
  <p class=relatedtopics>Related Topics</p>
  <p><a href="conJavaTypesGeneratedFromUserDerived.html">Java Types Generated
    from User-Derived Schema Types</a></p>
</div>
<!-- InstanceEndEditable -->
<script language="JavaScript">

</script>
</body>
</html>