java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/CompoundVariableResolver.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:56:03 +0200
changeset 111 e4900596abdb
parent 97 a72d55ff30c9
permissions -rw-r--r--
fix license version: GNU GPLv3
franta-hg@97
     1
/**
franta-hg@97
     2
 * Alt2XML
franta-hg@97
     3
 * Copyright © 2014 František Kučera (frantovo.cz)
franta-hg@97
     4
 *
franta-hg@97
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@97
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@111
     7
 * the Free Software Foundation, version 3 of the License.
franta-hg@97
     8
 *
franta-hg@97
     9
 * This program is distributed in the hope that it will be useful,
franta-hg@97
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@97
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@97
    12
 * GNU General Public License for more details.
franta-hg@97
    13
 *
franta-hg@97
    14
 * You should have received a copy of the GNU General Public License
franta-hg@97
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@97
    16
 */
franta-hg@97
    17
package cz.frantovo.alt2xml.out.xpath;
franta-hg@97
    18
franta-hg@97
    19
import javax.xml.namespace.QName;
franta-hg@97
    20
import javax.xml.xpath.XPathVariableResolver;
franta-hg@97
    21
franta-hg@97
    22
/**
franta-hg@97
    23
 *
franta-hg@97
    24
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@97
    25
 */
franta-hg@97
    26
public class CompoundVariableResolver implements XPathVariableResolver {
franta-hg@97
    27
franta-hg@97
    28
	private final XPathVariableResolver[] resolvers;
franta-hg@97
    29
franta-hg@97
    30
	public CompoundVariableResolver(XPathVariableResolver... resolvers) {
franta-hg@97
    31
		this.resolvers = resolvers;
franta-hg@97
    32
	}
franta-hg@97
    33
franta-hg@97
    34
	@Override
franta-hg@97
    35
	public Object resolveVariable(QName variableName) {
franta-hg@97
    36
		for (XPathVariableResolver r : resolvers) {
franta-hg@97
    37
			Object value = r.resolveVariable(variableName);
franta-hg@97
    38
			if (value != null) {
franta-hg@97
    39
				return value;
franta-hg@97
    40
			}
franta-hg@97
    41
		}
franta-hg@97
    42
		return null;
franta-hg@97
    43
	}
franta-hg@97
    44
}