1 package com.thaiopensource.relaxng.jarv; 2 3 import com.thaiopensource.relaxng.impl.Pattern; 4 import com.thaiopensource.relaxng.impl.PatternValidator; 5 import com.thaiopensource.relaxng.impl.ValidatorPatternBuilder; 6 import com.thaiopensource.xml.sax.CountingErrorHandler; 7 import org.iso_relax.verifier.VerifierHandler; 8 import org.xml.sax.ErrorHandler ; 9 10 class VerifierHandlerImpl extends PatternValidator implements VerifierHandler { 11 private boolean complete = false; 12 private final CountingErrorHandler ceh; 13 14 VerifierHandlerImpl(Pattern pattern, ValidatorPatternBuilder builder, CountingErrorHandler ceh) { 15 super(pattern, builder, ceh); 16 this.ceh = ceh; 17 } 18 19 public void endDocument() { 20 super.endDocument(); 21 complete = true; 22 } 23 24 public boolean isValid() throws IllegalStateException { 25 if (!complete) 26 throw new IllegalStateException (); 27 return !ceh.getHadErrorOrFatalError(); 28 } 29 30 void setErrorHandler(ErrorHandler eh) { 31 ceh.setErrorHandler(eh); 32 } 33 34 public void reset() { 35 super.reset(); 36 ceh.reset(); 37 } 38 } 39 | Popular Tags |