KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > jaxb > impl > JAXBAttributeImpl


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.jaxb.impl;
18
19 import org.apache.ws.jaxme.xs.XSObject;
20 import org.apache.ws.jaxme.xs.impl.XSAttributeImpl;
21 import org.apache.ws.jaxme.xs.impl.XSUtil;
22 import org.apache.ws.jaxme.xs.jaxb.JAXBAttribute;
23 import org.apache.ws.jaxme.xs.jaxb.JAXBProperty;
24 import org.apache.ws.jaxme.xs.jaxb.JAXBSchemaBindings;
25 import org.apache.ws.jaxme.xs.jaxb.JAXBXsSchema;
26 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException;
27 import org.apache.ws.jaxme.xs.xml.XsTAttribute;
28 import org.xml.sax.SAXException JavaDoc;
29
30
31 /**
32  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
33  */

34 public class JAXBAttributeImpl extends XSAttributeImpl implements JAXBAttribute {
35   private JAXBProperty jaxbProperty;
36
37   /** <p>Creates a new instance of JAXBAttributeImpl.</p>
38    */

39   protected JAXBAttributeImpl(XSObject pParent, XsTAttribute pBaseAttribute)
40       throws SAXException {
41     super(pParent, pBaseAttribute);
42   }
43
44   public JAXBSchemaBindings getJAXBSchemaBindings() {
45     return ((JAXBXsSchema) getXsObject().getXsESchema()).getJAXBSchemaBindings();
46   }
47
48   public JAXBProperty getJAXBProperty() { return jaxbProperty; }
49
50   public void validate() throws SAXException {
51     if (isValidated()) {
52       return;
53     } else {
54       super.validate();
55       jaxbProperty = (JAXBProperty) XSUtil.getSingleAppinfo(getAnnotations(), JAXBProperty.class);
56     }
57
58     if (jaxbProperty == null) {
59       XsTAttribute attr = (XsTAttribute) getXsObject();
60       if (attr.getRef() != null) {
61         JAXBAttribute refAttr = (JAXBAttribute) getXSSchema().getAttribute(attr.getRef());
62         if (refAttr != null) {
63           jaxbProperty = refAttr.getJAXBProperty();
64         }
65       }
66     } else {
67       if (isGlobal() && jaxbProperty != null && jaxbProperty.getBaseType() != null) {
68         throw new LocSAXException("The element jaxb:property/jaxb:baseType is forbidden in global attributes." +
69                                    " You may set it in the reference using the attribute locally. [JAXB 6.8.1.2.1]",
70                                    jaxbProperty.getLocator());
71       }
72     }
73   }
74 }
75
Popular Tags