KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > xml > impl > XsGIdentityConstraintImpl


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.xs.xml.impl;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.ws.jaxme.xs.xml.*;
23
24
25 /** <p>Implementation of the group <code>xs:identityConstraint</code>,
26  * specified as follows:
27  * <pre>
28  * <xs:group name="identityConstraint">
29  * <xs:annotation>
30  * <xs:documentation>
31  * The three kinds of identity constraints, all with
32  * type of or derived from 'keybase'.
33  * </xs:documentation>
34  * </xs:annotation>
35  * <xs:choice>
36  * <xs:element ref="xs:unique"/>
37  * <xs:element ref="xs:key"/>
38  * <xs:element ref="xs:keyref"/>
39  * </xs:choice>
40  * </xs:group>
41  * </pre></p>
42  *
43  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
44  */

45 public class XsGIdentityConstraintImpl implements XsGIdentityConstraint {
46   private final XsObject owner;
47   private List JavaDoc constraints;
48
49   protected XsGIdentityConstraintImpl(XsObject pOwner) {
50     owner = pOwner;
51   }
52
53   protected void addIdentityConstraint(XsTIdentityConstraint pConstraint) {
54     if (constraints == null) {
55       constraints = new ArrayList JavaDoc();
56     }
57     constraints.add(pConstraint);
58   }
59
60   public XsEUnique createUnique() {
61     XsEUnique unique = owner.getObjectFactory().newXsEUnique(owner);
62     addIdentityConstraint(unique);
63     return unique;
64   }
65
66   public XsEKey createKey() {
67     XsEKey key = owner.getObjectFactory().newXsEKey(owner);
68     addIdentityConstraint(key);
69     return key;
70   }
71
72   public XsEKeyref createKeyref() {
73     XsEKeyref keyref = owner.getObjectFactory().newXsEKeyref(owner);
74     addIdentityConstraint(keyref);
75     return keyref;
76   }
77
78   public XsTIdentityConstraint[] getIdentityConstraints() {
79     if (constraints == null) {
80       return new XsTIdentityConstraint[0];
81     }
82     return (XsTIdentityConstraint[]) constraints.toArray(new XsTIdentityConstraint[constraints.size()]);
83   }
84 }
85
Popular Tags