Sha256: e2c542c68cab232f86f9f07d453671d899b609369b4e01e7143a5801a92a4e09

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

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<Exception> errors;

    public NokogiriErrorHandler() {
        this.errors = new ArrayList<Exception>();
    }

    void addError(Exception e) {
        errors.add(e);
    }

    public List<Exception> getErrors() { return this.errors; }

    public List<IRubyObject> getErrorsReadyForRuby(ThreadContext context){
        Ruby ruby = context.getRuntime();
        List<IRubyObject> res = new ArrayList<IRubyObject>();
        for(int i = 0; i < this.errors.size(); i++) {
            res.add(new XmlSyntaxError(ruby, this.errors.get(i)));
        }
        return res;
    }

}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nokogiri-1.5.0.beta.2 ext/java/nokogiri/internals/NokogiriErrorHandler.java
nokogiri-1.5.0.beta.2-java ext/java/nokogiri/internals/NokogiriErrorHandler.java