KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > impl > XSIdentityConstraintImpl


1 /*
2  * Copyright 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.impl;
18
19 import org.apache.ws.jaxme.xs.XSAnnotation;
20 import org.apache.ws.jaxme.xs.XSIdentityConstraint;
21 import org.apache.ws.jaxme.xs.XSElement;
22 import org.apache.ws.jaxme.xs.XSElementOrAttrRef;
23 import org.apache.ws.jaxme.xs.XPathMatcher;
24 import org.apache.ws.jaxme.xs.xml.XsEKey;
25 import org.apache.ws.jaxme.xs.xml.XsTKeybase;
26 import org.apache.ws.jaxme.xs.xml.XsEUnique;
27 import org.xml.sax.SAXException JavaDoc;
28
29 /**
30  * Default implementation of the XSIdentityConstraint.
31  *
32  * @author <a HREF="mailto:mrck1996@yahoo.co.uk">Chris Kirk</a>
33  */

34 public class XSIdentityConstraintImpl extends XSOpenAttrsImpl
35   implements XSIdentityConstraint
36 {
37   private XSAnnotation[] annotations;
38   private String JavaDoc name;
39   private boolean isUnique;
40   private XsTKeybase keyBase;
41   private XSElementOrAttrRef[][] matchCriteria;
42
43   protected XSIdentityConstraintImpl( XSElement pParent, XsEKey key )
44     throws SAXException JavaDoc
45   {
46     super( pParent, key );
47
48     initSelf( pParent, key, false );
49   }
50
51   protected XSIdentityConstraintImpl( XSElement pParent, XsEUnique unique )
52     throws SAXException JavaDoc
53   {
54     super( pParent, unique );
55
56     initSelf( pParent, unique, true );
57   }
58
59   public XSAnnotation[] getAnnotations() {
60     return annotations;
61   }
62
63   /**
64    * @see XSIdentityConstraintImpl#getName
65    */

66   public String JavaDoc getName() {
67     return name;
68   }
69
70   /**
71    * @see XSIdentityConstraintImpl#isUnique
72    */

73   public boolean isUnique() {
74     return isUnique;
75   }
76
77   /**
78    * @see XSIdentityConstraintImpl#getMatchCriteria
79    */

80   public XSElementOrAttrRef[][] getMatchCriteria() {
81     return matchCriteria;
82   }
83
84   public void validate() throws SAXException JavaDoc {
85     matchCriteria = XPathMatcher.match(
86       keyBase,
87       (XSElement) getParentObject()
88     );
89
90     validateAllIn( annotations );
91   }
92
93   private void initSelf(
94     XSElement pParent,
95     XsTKeybase keyBase,
96     boolean isUnique
97   ) throws SAXException JavaDoc {
98     this.isUnique = isUnique;
99     this.name = keyBase.getName().getValue();
100     this.keyBase = keyBase;
101
102     this.annotations = getXSSchema().getXSObjectFactory().newXSAnnotations(
103       this,
104       keyBase.getAnnotation()
105     );
106   }
107 }
108
Popular Tags