org.exist.xquery.AnyNodeTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of exist-core Show documentation
Show all versions of exist-core Show documentation
eXist-db NoSQL Database Core
/*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
* [email protected]
* http://www.exist-db.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.exist.xquery;
import org.exist.dom.persistent.NodeProxy;
import org.exist.dom.QName;
import org.exist.xquery.util.ExpressionDumper;
import org.exist.xquery.value.Type;
import org.w3c.dom.Node;
import javax.xml.stream.XMLStreamReader;
/**
* The class AnyNodeTest
*
* @author Wolfgang Meier
*
*/
public class AnyNodeTest implements NodeTest {
/* (non-Javadoc)
* @see org.exist.xquery.NodeTest#getName()
*/
public QName getName() {
return null;
}
/* (non-Javadoc)
* @see org.exist.xquery.NodeTest#isWildcardTest()
*/
public boolean isWildcardTest() {
return true;
}
/* (non-Javadoc)
* @see org.exist.xquery.NodeTest#matches(org.w3c.dom.Node)
*/
public boolean matches(Node node) {
return (node.getNodeType() != Node.ATTRIBUTE_NODE);
}
/* (non-Javadoc)
* @see org.exist.xquery.NodeTest#matches(org.exist.dom.persistent.NodeProxy)
*/
public boolean matches(NodeProxy proxy) {
final int type = proxy.getType();
if (type == Type.ITEM || type == Type.NODE) {
if (proxy.getNodeType() != NodeProxy.UNKNOWN_NODE_TYPE) {
return matches(proxy.getNode());
}
return proxy.getNodeType() != Node.ATTRIBUTE_NODE;
} else if (type == Type.ATTRIBUTE &&
proxy.getNodeType() == Node.ATTRIBUTE_NODE) {
return true;
} else {
return type != Node.ATTRIBUTE_NODE;
}
}
public boolean matches(XMLStreamReader reader) {
return reader.getEventType() != XMLStreamReader.ATTRIBUTE;
}
public boolean matches(QName name) {
return false;
}
public void dump(ExpressionDumper dumper) {
if (dumper.verbosity() > 1) {
dumper.display("node()");
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return "node()";
}
/* (non-Javadoc)
* @see org.exist.xquery.NodeTest#setType(int)
*/
public void setType(int nodeType) {
//Nothing to do
}
public int getType() {
return Type.NODE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy