1 17 package org.apache.ws.jaxme.xs.xml.impl; 18 19 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 20 import org.apache.ws.jaxme.xs.xml.XsAGDefRef; 21 import org.apache.ws.jaxme.xs.xml.XsNCName; 22 import org.apache.ws.jaxme.xs.xml.XsObject; 23 import org.apache.ws.jaxme.xs.xml.XsQName; 24 import org.xml.sax.SAXException ; 25 26 27 46 public class XsAGDefRefImpl implements XsAGDefRef { 47 private final XsObject owner; 48 private XsNCName name; 49 private XsQName ref; 50 51 53 public XsAGDefRefImpl(XsObject pOwner) { 54 owner = pOwner; 55 } 56 57 public void setName(XsNCName pName) { 58 if (ref != null) { 59 throw new IllegalStateException ("The 'name' and 'ref' attributes are mutually exclusive."); 60 } 61 name = pName; 62 } 63 64 public XsNCName getName() { 65 return name; 66 } 67 68 public void setRef(XsQName pRef) { 69 if (name != null) { 70 throw new IllegalStateException ("The 'name' and 'ref' attributes are mutually exclusive."); 71 } 72 ref = pRef; 73 } 74 75 public void setRef(String pRef) throws SAXException { 76 setRef(((XsObjectImpl) owner).asXsQName(pRef)); 77 } 78 79 public XsQName getRef() { 80 return ref; 81 } 82 83 public void validate() throws SAXException { 84 if (name == null && ref == null) { 85 throw new LocSAXException("You must set either of the attributes 'name' or 'ref'.", owner.getLocator()); 86 } 87 } 88 } 89 | Popular Tags |