<commit_before>/*
 * @(#)XMLPeerBuilder.java      0.1 99/10/18
 *
 * (c) <NAME>
 */

package org.biojava.utils.xml;

import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.util.*;

/**
 * SAX DocumentHandler which uses an XMLPeerFactory to construct
 * Java objects reflecting an XML document.  The XMLPeerBuilder
 * system takes a depth-first approach to constructing the Object
 * tree.  This means that, before attempting to construct an
 * Object to represent a particular element, it first constructs
 * Objects for all child elelments.
 *
 * <P>
 * Currently, Text nodes are automatically converted to Java strings
 * and treated as normal children.  Treatment of Text may be
 * configurable in a future release.
 * </P>
 *
 * @author <NAME>
 */

public class XMLPeerBuilder implements DocumentHandler {
    private static AttributeList emptyAttributes = new AttributeListImpl();

    private XMLPeerFactory peerFactory;
    private boolean isComplete = true;
    private List stack;
    private StackEntry stackTop = null;
    private Object topLevel = null;

    /**
     * Construct a new XMLPeerBuilder, using the specified XMLPeerFactory
     *
     */

    public XMLPeerBuilder(XMLPeerFactory f) {
	peerFactory = f;
	stack = new LinkedList();
    }

    /**
     * Once the XMLPeerBuilder has been used, return an Object
     * which represents the whole document.
     *
     * @return an Object reflecting the document, or <code>null</code>
     *         if none is available.
     */

    public Object getTopLevelObject() {
	if (isComplete)
	    return topLevel;
	return null;
    }

    public void characters(char[] ch, int start, int len) {
	String child = new String(ch, start, len);
	stacktop.objs.add(child);
    }

    public void ignorableWhitespace(char[] ch, int start, int len) {
    }

    public void startDocument() {
	isComplete = false;<commit_msg>Fixed minor typo.<commit_after>/*
 * @(#)XMLPeerBuilder.java      0.1 99/10/18
 *
 * (c) <NAME>
 */

package org.biojava.utils.xml;

import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.util.*;

/**
 * SAX DocumentHandler which uses an XMLPeerFactory to construct
 * Java objects reflecting an XML document.  The XMLPeerBuilder
 * system takes a depth-first approach to constructing the Object
 * tree.  This means that, before attempting to construct an
 * Object to represent a particular element, it first constructs
 * Objects for all child elelments.
 *
 * <P>
 * Currently, Text nodes are automatically converted to Java strings
 * and treated as normal children.  Treatment of Text may be
 * configurable in a future release.
 * </P>
 *
 * @author <NAME>
 */

public class XMLPeerBuilder implements DocumentHandler {
    private static AttributeList emptyAttributes = new AttributeListImpl();

    private XMLPeerFactory peerFactory;
    private boolean isComplete = true;
    private List stack;
    private StackEntry stackTop = null;
    private Object topLevel = null;

    /**
     * Construct a new XMLPeerBuilder, using the specified XMLPeerFactory
     *
     */

    public XMLPeerBuilder(XMLPeerFactory f) {
	peerFactory = f;
	stack = new LinkedList();
    }

    /**
     * Once the XMLPeerBuilder has been used, return an Object
     * which represents the whole document.
     *
     * @return an Object reflecting the document, or <code>null</code>
     *         if none is available.
     */

    public Object getTopLevelObject() {
	if (isComplete)
	    return topLevel;
	return null;
    }

    public void characters(char[] ch, int start, int len) {
	String child = new String(ch, start, len);
	stackTop.objs.add(child);
    }

    public void ignorableWhitespace(char[] ch, int start, int len) {
    }

    public void startDocument() {
	isComplete = false;
{'fraction_non_alphanumeric': 0.0890121500264131, 'fraction_numerical': 0.004226096143687269, 'mean_word_length': 3.1524122807017543, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7311745', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1040, 'n_words': 397}