/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.digester; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** *
Default implementation of the Rules interface that supports
* the standard rule matching behavior. This class can also be used as a
* base class for specialized Rules implementations.
The matching policies implemented by this class support two different * types of pattern matching rules:
*<c> element, nested inside a <b>
* element, which is nested inside an <a> element.<b> element, nested inside an <a>
* element, no matter how deeply the pair is nested.Rule
* objects are relevant, or null for matching independent
* of namespaces.
*
* @deprecated Unused. Will be removed in Tomcat 9.0.x
*/
@Deprecated
protected String namespaceURI = null;
/**
* The set of registered Rule instances, in the order that they were
* originally registered.
*/
protected ArrayListRule objects.
*/
@Override
public String getNamespaceURI() {
return this.namespaceURI;
}
/**
* Set the namespace URI that will be applied to all subsequently
* added Rule objects.
*
* @param namespaceURI Namespace URI that must match on all
* subsequently added rules, or null for matching
* regardless of the current namespace URI
*/
@Override
public void setNamespaceURI(String namespaceURI) {
this.namespaceURI = namespaceURI;
}
// --------------------------------------------------------- Public Methods
/**
* Register a new Rule instance matching the specified pattern.
*
* @param pattern Nesting pattern to be matched for this Rule
* @param rule Rule instance to be registered
*/
@Override
public void add(String pattern, Rule rule) {
// to help users who accidentally add '/' to the end of their patterns
int patternLength = pattern.length();
if (patternLength>1 && pattern.endsWith("/")) {
pattern = pattern.substring(0, patternLength-1);
}
Listadd()
* method.
*
* @param namespaceURI Namespace URI for which to select matching rules,
* or null to match regardless of namespace URI
* @param pattern Nesting pattern to be matched
*/
@Override
public Listadd()
* method.
*/
@Override
public Listnull.
*
* @param namespaceURI Namespace URI to match, or null to
* select matching rules regardless of namespace URI
* @param pattern Pattern to be matched
* @return a rules list
*/
protected List