<commit_before>package org.exist.xquery;

import org.exist.dom.NodeProxy;
import org.exist.dom.QName;
import org.exist.xquery.value.Type;
import org.w3c.dom.Node;

/**
 * Tests if a node is of a given node type.
 * 
 * @author <NAME> (<EMAIL>)
 */
public class TypeTest implements NodeTest {

	protected int nodeType = 0;
	
	public TypeTest(int nodeType) {
		setType(nodeType);
	}

	public void setType(int nodeType) {
	    this.nodeType = nodeType;
	}
	
	public int getType() {
		return nodeType;
	}
	
	public QName getName() {
		return null;
	}
	
	protected boolean isOfType(short type) {
		int domType;
		switch (nodeType) {
			case Type.ELEMENT :
				domType = Node.ELEMENT_NODE;
				break;
			case Type.TEXT :
				domType = Node.TEXT_NODE;
				break;
			case Type.ATTRIBUTE :
				domType = Node.ATTRIBUTE_NODE;
				break;
			case Type.COMMENT :
				domType = Node.COMMENT_NODE;
				break;
			case Type.PROCESSING_INSTRUCTION :
				domType = Node.PROCESSING_INSTRUCTION_NODE;
				break;
			case Type.NODE :
			default :
				return true;
		}
		return (type == domType);
	}

	public String toString() {
		return nodeType == -1 ? "node()" : Type.NODETYPES[nodeType] + "()";
	}
	
	/* (non-Javadoc)
	 * @see org.exist.xquery.NodeTest#matches(org.exist.dom.NodeProxy)
	 */
	public boolean matches(NodeProxy proxy) {
		int type = proxy.getType();
		if(type == Type.ITEM || type == Type.NODE) {
			if(type == Type.NODE)
				return true;
			Node node = proxy.getNode();<commit_msg>Reverted a change dating back to... 20 months that made NodeKind tests too permissive<commit_after>package org.exist.xquery;

import org.exist.dom.NodeProxy;
import org.exist.dom.QName;
import org.exist.xquery.value.Type;
import org.w3c.dom.Node;

/**
 * Tests if a node is of a given node type.
 * 
 * @author <NAME> (<EMAIL>)
 */
public class TypeTest implements NodeTest {

	protected int nodeType = 0;
	
	public TypeTest(int nodeType) {
		setType(nodeType);
	}

	public void setType(int nodeType) {
	    this.nodeType = nodeType;
	}
	
	public int getType() {
		return nodeType;
	}
	
	public QName getName() {
		return null;
	}
	
	protected boolean isOfType(short type) {
		int domType;
		switch (nodeType) {
			case Type.ELEMENT :
				domType = Node.ELEMENT_NODE;
				break;
			case Type.TEXT :
				domType = Node.TEXT_NODE;
				break;
			case Type.ATTRIBUTE :
				domType = Node.ATTRIBUTE_NODE;
				break;
			case Type.COMMENT :
				domType = Node.COMMENT_NODE;
				break;
			case Type.PROCESSING_INSTRUCTION :
				domType = Node.PROCESSING_INSTRUCTION_NODE;
				break;
			case Type.NODE :
			default :
				return true;
		}
		return (type == domType);
	}

	public String toString() {
		return nodeType == -1 ? "node()" : Type.NODETYPES[nodeType] + "()";
	}
	
	/* (non-Javadoc)
	 * @see org.exist.xquery.NodeTest#matches(org.exist.dom.NodeProxy)
	 */
	public boolean matches(NodeProxy proxy) {		
		if(proxy.nodeType == Type.ITEM || proxy.nodeType == Type.NODE) {
			if (this.nodeType == Type.NODE)
				return true;			
			Node node = proxy.getNode();
{'fraction_non_alphanumeric': 0.12182238362495873, 'fraction_numerical': 0.002641135688345989, 'mean_word_length': 3.1336971350613916, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4104414', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1059, 'n_words': 254}