001 package com.thaiopensource.relaxng.jarv;
002
003 import com.thaiopensource.relaxng.impl.Pattern;
004 import com.thaiopensource.relaxng.impl.PatternValidator;
005 import com.thaiopensource.relaxng.impl.ValidatorPatternBuilder;
006 import com.thaiopensource.xml.sax.CountingErrorHandler;
007 import org.iso_relax.verifier.VerifierHandler;
008 import org.xml.sax.ErrorHandler;
009
010 class VerifierHandlerImpl extends PatternValidator implements VerifierHandler {
011 private boolean complete = false;
012 private final CountingErrorHandler ceh;
013
014 VerifierHandlerImpl(Pattern pattern, ValidatorPatternBuilder builder, CountingErrorHandler ceh) {
015 super(pattern, builder, ceh);
016 this.ceh = ceh;
017 }
018
019 public void endDocument() {
020 super.endDocument();
021 complete = true;
022 }
023
024 public boolean isValid() throws IllegalStateException {
025 if (!complete)
026 throw new IllegalStateException();
027 return !ceh.getHadErrorOrFatalError();
028 }
029
030 void setErrorHandler(ErrorHandler eh) {
031 ceh.setErrorHandler(eh);
032 }
033
034 public void reset() {
035 super.reset();
036 ceh.reset();
037 }
038 }