package nokogiri.internals; import java.util.ArrayList; import java.util.List; import nokogiri.XmlSyntaxError; import org.apache.xerces.xni.parser.XMLErrorHandler; import org.jruby.Ruby; import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; import org.xml.sax.ErrorHandler; /** * * @author sergio */ public abstract class NokogiriErrorHandler implements ErrorHandler, XMLErrorHandler { protected List errors; public NokogiriErrorHandler() { this.errors = new ArrayList(); } void addError(Exception e) { errors.add(e); } public List getErrors() { return this.errors; } public List getErrorsReadyForRuby(ThreadContext context){ Ruby ruby = context.getRuntime(); List res = new ArrayList(); for(int i = 0; i < this.errors.size(); i++) { res.add(new XmlSyntaxError(ruby, this.errors.get(i))); } return res; } }