01: package com.sun.xml.xsom.impl.parser;
02:
03: import com.sun.xml.xsom.impl.Ref;
04: import com.sun.xml.xsom.XSContentType;
05: import com.sun.xml.xsom.XSType;
06: import org.xml.sax.Locator;
07: import org.xml.sax.SAXException;
08:
09: public final class BaseContentRef implements Ref.ContentType, Patch {
10: private final Ref.Type baseType;
11: private final Locator loc;
12:
13: public BaseContentRef(final NGCCRuntimeEx $runtime,
14: Ref.Type _baseType) {
15: this .baseType = _baseType;
16: $runtime.addPatcher(this );
17: $runtime.addErrorChecker(new Patch() {
18: public void run() throws SAXException {
19: XSType t = baseType.getType();
20: if (t.isComplexType()
21: && t.asComplexType().getContentType()
22: .asParticle() != null) {
23: $runtime
24: .reportError(
25: Messages
26: .format(
27: Messages.ERR_SIMPLE_CONTENT_EXPECTED,
28: t
29: .getTargetNamespace(),
30: t.getName()), loc);
31: }
32: }
33: });
34: this .loc = $runtime.copyLocator();
35: }
36:
37: public XSContentType getContentType() {
38: XSType t = baseType.getType();
39: if (t.asComplexType() != null)
40: return t.asComplexType().getContentType();
41: else
42: return t.asSimpleType();
43: }
44:
45: public void run() throws SAXException {
46: if (baseType instanceof Patch)
47: ((Patch) baseType).run();
48: }
49: }
|