001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.jxpath.ri.compiler; 019 020import org.apache.commons.jxpath.ri.QName; 021 022/** 023 * Node name test. 024 */ 025public class NodeNameTest extends NodeTest { 026 027 private final QName qname; 028 private String namespaceURI; 029 030 /** 031 * Constructs a new NodeNameTest. 032 * 033 * @param qname name to match 034 */ 035 public NodeNameTest(final QName qname) { 036 this.qname = qname; 037 } 038 039 /** 040 * Constructs a new NodeNameTest. 041 * 042 * @param qname name to match 043 * @param namespaceURI uri to match 044 */ 045 public NodeNameTest(final QName qname, final String namespaceURI) { 046 this.qname = qname; 047 this.namespaceURI = namespaceURI; 048 } 049 050 /** 051 * Gets the ns URI. 052 * 053 * @return String 054 */ 055 public String getNamespaceURI() { 056 return namespaceURI; 057 } 058 059 /** 060 * Gets the node name. 061 * 062 * @return QName 063 */ 064 public QName getNodeName() { 065 return qname; 066 } 067 068 /** 069 * Tests whether this is a wildcard test. 070 * 071 * @return {@code true} if the node name is "*". 072 */ 073 public boolean isWildcard() { 074 return qname.getName().equals("*"); 075 } 076 077 @Override 078 public String toString() { 079 return qname.toString(); 080 } 081}