// Path: src/main/java/com/codefork/refine/parsers/ParseState.java
// public class ParseState {
// 
//     public boolean captureChars = false;
// 
//     public final List<Result> results = new ArrayList<>();
//     public Result result = null;
// 
//     /** buffer for collecting contents of an Element as parser does processing */
//     public StringBuilder buf = new StringBuilder();
// 
// }
// 
// Path: src/main/java/com/codefork/refine/resources/Result.java
// public class Result {
//     
//     private String id;
//     private String name;
// 
//     /**
//      * It's weird that this is a list but that's what OpenRefine expects.
//      * A VIAF result only ever has one type, but maybe other reconciliation
//      * services return multiple types for a name?
//      */
//     private List<NameType> type;
//     private double score;
//     private boolean match;
// 
//     public Result() {
//     }
// 
//     public Result(String id, String name, NameType nameType, double score, boolean match) {
//         this.id = id;
//         this.name = name;
//         this.type = new ArrayList<>();
//         this.type.add(nameType);
//         this.score = score;
//         this.match = match;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public List<NameType> getType() {
//         return type;
//     }
// 
//     public void setType(List<NameType> resultType) {
//         this.type = resultType;
//     }
// 
//     public double getScore() {
//         return score;
//     }
// 
//     public void setScore(double score) {
//         this.score = score;
//     }
// 
//     public boolean isMatch() {
//         return match;
//     }
// 
//     public void setMatch(boolean match) {
//         this.match = match;
//     }
// 
// }


import com.codefork.refine.parsers.ParseState;
import com.codefork.refine.resources.Result;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
package com.codefork.refine.parsers.xml;



/**
 * SAX parser handler. We use SAX b/c it's faster than loading a whole DOM.
 */
public abstract class XMLParser<R extends ParseState> extends DefaultHandler {

    protected Map<String, StartElementHandler<R>> startElementHandlers = new HashMap<>();
    protected Map<String, EndElementHandler<R>> endElementHandlers = new HashMap<>();

    public final Stack<String> path = new Stack<>();

    protected R parseState;

    public XMLParser() {
        parseState = createParseState();
    }

    /**
     * XMLParser subclasses should override this if they want to create their
     * own ParseState subclasses.
     * @return
     */
    public abstract R createParseState();

// Path: src/main/java/com/codefork/refine/parsers/ParseState.java
// public class ParseState {
// 
//     public boolean captureChars = false;
// 
//     public final List<Result> results = new ArrayList<>();
//     public Result result = null;
// 
//     /** buffer for collecting contents of an Element as parser does processing */
//     public StringBuilder buf = new StringBuilder();
// 
// }
// 
// Path: src/main/java/com/codefork/refine/resources/Result.java
// public class Result {
//     
//     private String id;
//     private String name;
// 
//     /**
//      * It's weird that this is a list but that's what OpenRefine expects.
//      * A VIAF result only ever has one type, but maybe other reconciliation
//      * services return multiple types for a name?
//      */
//     private List<NameType> type;
//     private double score;
//     private boolean match;
// 
//     public Result() {
//     }
// 
//     public Result(String id, String name, NameType nameType, double score, boolean match) {
//         this.id = id;
//         this.name = name;
//         this.type = new ArrayList<>();
//         this.type.add(nameType);
//         this.score = score;
//         this.match = match;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public List<NameType> getType() {
//         return type;
//     }
// 
//     public void setType(List<NameType> resultType) {
//         this.type = resultType;
//     }
// 
//     public double getScore() {
//         return score;
//     }
// 
//     public void setScore(double score) {
//         this.score = score;
//     }
// 
//     public boolean isMatch() {
//         return match;
//     }
// 
//     public void setMatch(boolean match) {
//         this.match = match;
//     }
// 
// }


// Path: src/main/java/com/codefork/refine/parsers/xml/XMLParser.java
import com.codefork.refine.parsers.ParseState;
import com.codefork.refine.resources.Result;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;

package com.codefork.refine.parsers.xml;



/**
 * SAX parser handler. We use SAX b/c it's faster than loading a whole DOM.
 */
public abstract class XMLParser<R extends ParseState> extends DefaultHandler {

    protected Map<String, StartElementHandler<R>> startElementHandlers = new HashMap<>();
    protected Map<String, EndElementHandler<R>> endElementHandlers = new HashMap<>();

    public final Stack<String> path = new Stack<>();

    protected R parseState;

    public XMLParser() {
        parseState = createParseState();
    }

    /**
     * XMLParser subclasses should override this if they want to create their
     * own ParseState subclasses.
     * @return
     */
    public abstract R createParseState();

    public List<Result> getResults() {