xpather.XpathPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xpather Show documentation
Show all versions of xpather Show documentation
Xpather is a simple DSL for generating xpath expressions, including specific support for creating xpath
expression for xHtml
The newest version!
/**
* Copyright (C) 2011 timt http://github.com/timt/xpather
*
* Licensed 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 xpather;
public class XpathPredicate extends XpathExpression{
public XpathPredicate(final String predicate) {
super(new XpathFragment() {
@Override
public String toXpath() {
return "["+predicate+"]";
}
});
}
public static XpathDecorator containing(final String value){
return new XpathDecorator() {
@Override
public XpathPredicate decorate(XpathFragment xpathFragment) {
return predicate("contains(" + xpathFragment.toXpath() + ",'" + value + "')");
}
};
}
public static XpathDecorator equalTo(final String value){
return new EqualToXpathDecorator(value);
}
public static XpathDecorator index(final int index){
return new XpathDecorator() {
@Override
public XpathExpression decorate(XpathFragment xpathFragment) {
return xpathExpression(xpathFragment, predicate("" + index));
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy