1 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.XSElementImpl; 21 import org.apache.ws.jaxme.xs.impl.XSUtil; 22 import org.apache.ws.jaxme.xs.jaxb.JAXBClass; 23 import org.apache.ws.jaxme.xs.jaxb.JAXBElement; 24 import org.apache.ws.jaxme.xs.jaxb.JAXBProperty; 25 import org.apache.ws.jaxme.xs.jaxb.JAXBSchemaBindings; 26 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 27 import org.apache.ws.jaxme.xs.xml.XsTElement; 28 import org.xml.sax.SAXException ; 29 30 31 34 public class JAXBElementImpl extends XSElementImpl implements JAXBElement { 35 private JAXBClass jaxbClass; 36 private JAXBProperty jaxbProperty; 37 38 40 protected JAXBElementImpl(XSObject pParent, XsTElement pBaseElement) 41 throws SAXException { 42 super(pParent, pBaseElement); 43 } 44 45 public JAXBSchemaBindings getJAXBSchemaBindings() { 46 return ((JAXBXsSchemaImpl) getXsObject().getXsESchema()).getJAXBSchemaBindings(); 47 } 48 49 50 public JAXBClass getJAXBClass() { return jaxbClass; } 51 public JAXBProperty getJAXBProperty() { return jaxbProperty; } 52 53 public void validate() throws SAXException { 54 if (isValidated()) { 55 return; 56 } 57 super.validate(); 58 jaxbClass = (JAXBClass) XSUtil.getSingleAppinfo(getAnnotations(), JAXBClass.class); 59 jaxbProperty = (JAXBProperty) XSUtil.getSingleAppinfo(getAnnotations(), JAXBProperty.class); 60 61 if (jaxbProperty == null) { 62 XsTElement elem = (XsTElement) getXsObject(); 63 if (elem.getRef() != null) { 64 JAXBElement refElem = (JAXBElement) getXSSchema().getElement(elem.getRef()); 65 if (refElem != null) { 66 jaxbProperty = refElem.getJAXBProperty(); 67 } 68 } 69 } else { 70 if (isGlobal()) { 71 if (jaxbProperty != null && jaxbProperty.getBaseType() != null) { 72 throw new LocSAXException("The element jaxb:property/jaxb:baseType is forbidden in global elements." + 73 " You may set it in the reference using the element locally. [JAXB 6.8.1.2.1]", 74 jaxbProperty.getLocator()); 75 } 76 } 77 } 78 79 if (jaxbClass != null && jaxbClass.getImplClass() != null) { 80 if (isGlobal()) { 81 if (jaxbClass != null && jaxbClass.getImplClass() != null) { 82 throw new LocSAXException("The implClass attribute is invalid for global elements. [JAXB 6.7.3.4]", 83 jaxbClass.getLocator()); 84 } 85 } else { 86 if (jaxbClass != null && jaxbClass.getImplClass() != null) { 87 throw new LocSAXException("The implClass attribute is invalid for local elements. [JAXB 6.7.3.5]", 88 jaxbClass.getLocator()); 89 } 90 } 91 } 92 } 93 } 94 | Popular Tags |