1 17 package org.apache.ws.jaxme.xs.impl; 18 19 import org.apache.ws.jaxme.xs.XSObject; 20 import org.apache.ws.jaxme.xs.XSSchema; 21 import org.apache.ws.jaxme.xs.xml.XsObject; 22 import org.xml.sax.Locator ; 23 import org.xml.sax.SAXException ; 24 25 26 29 public abstract class XSObjectImpl implements XSObject { 30 private final XSObject parent; 31 private final XsObject baseObject; 32 33 protected XSObjectImpl(XSObject pParent, XsObject pBaseObject) { 34 if (pParent == null) { 35 if (!(this instanceof XSSchema)) { 36 throw new IllegalStateException ("Null parents are allowed for XSSchema objects only."); 37 } 38 } else { 39 if (this instanceof XSSchema) { 40 throw new IllegalStateException ("An XSSchema object must have a null parent."); 41 } 42 } 43 parent = pParent; 44 baseObject = pBaseObject; 45 } 46 47 public XSObject getParentObject() { return parent; } 48 public XSSchema getXSSchema() { 49 if (parent == null) { 50 return (XSSchema) this; 51 } else { 52 return parent.getXSSchema(); 53 } 54 } 55 public boolean isTopLevelObject() { return parent == null || parent instanceof XSSchema; } 56 public Locator getLocator() { return baseObject.getLocator(); } 57 protected XsObject getXsObject() { return baseObject; } 58 public void validate() throws SAXException {} 59 60 61 67 protected final void validateAllIn( XSObject[] objects ) 68 throws SAXException 69 { 70 if ( objects == null ) { 71 return; 72 } 73 74 int numObjects = objects.length; 75 76 for ( int i=0; i<numObjects; i++ ) { 77 objects[i].validate(); 78 } 79 } 80 } 81 | Popular Tags |