[core] XPathHandler: Avoid direct dependency on saxon, Part 1
This commit is contained in:
@ -18,7 +18,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall;
|
||||
import net.sf.saxon.om.Sequence;
|
||||
import net.sf.saxon.trans.XPathException;
|
||||
import net.sf.saxon.value.BooleanValue;
|
||||
import net.sf.saxon.value.SequenceType;
|
||||
|
||||
/**
|
||||
* XPath function {@code pmd-java:typeIs(typeName as xs:string) as xs:boolean}
|
||||
@ -30,7 +29,7 @@ import net.sf.saxon.value.SequenceType;
|
||||
*/
|
||||
public class BaseContextNodeTestFun<T extends JavaNode> extends BaseJavaXPathFunction {
|
||||
|
||||
static final SequenceType[] SINGLE_STRING_SEQ = {SequenceType.SINGLE_STRING};
|
||||
static final Type[] SINGLE_STRING_SEQ = {Type.SINGLE_STRING};
|
||||
private final Class<T> klass;
|
||||
private final BiPredicate<String, T> checker;
|
||||
|
||||
@ -45,17 +44,17 @@ public class BaseContextNodeTestFun<T extends JavaNode> extends BaseJavaXPathFun
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType[] getArgumentTypes() {
|
||||
public Type[] getArgumentTypes() {
|
||||
return SINGLE_STRING_SEQ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
|
||||
return SequenceType.SINGLE_BOOLEAN;
|
||||
public Type getResultType(Type[] suppliedArgumentTypes) {
|
||||
return Type.SINGLE_BOOLEAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dependsOnFocus() {
|
||||
public boolean dependsOnContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
package net.sourceforge.pmd.lang.java.rule.xpath.internal;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.impl.AbstractXPathFunctionDef;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.impl.XPathFunctionDefinition;
|
||||
|
||||
abstract class BaseJavaXPathFunction extends AbstractXPathFunctionDef {
|
||||
abstract class BaseJavaXPathFunction extends XPathFunctionDefinition {
|
||||
|
||||
protected BaseJavaXPathFunction(String localName) {
|
||||
super(localName, JavaLanguageModule.getInstance());
|
||||
|
@ -17,7 +17,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall;
|
||||
import net.sf.saxon.om.Sequence;
|
||||
import net.sf.saxon.trans.XPathException;
|
||||
import net.sf.saxon.value.BooleanValue;
|
||||
import net.sf.saxon.value.SequenceType;
|
||||
|
||||
|
||||
/**
|
||||
@ -39,17 +38,17 @@ abstract class BaseRewrittenFunction<S, N extends Node> extends BaseJavaXPathFun
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType[] getArgumentTypes() {
|
||||
public Type[] getArgumentTypes() {
|
||||
return SINGLE_STRING_SEQ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
|
||||
return SequenceType.SINGLE_BOOLEAN;
|
||||
public Type getResultType(Type[] suppliedArgumentTypes) {
|
||||
return Type.SINGLE_BOOLEAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dependsOnFocus() {
|
||||
public boolean dependsOnContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import net.sf.saxon.expr.XPathContext;
|
||||
import net.sf.saxon.lib.ExtensionFunctionCall;
|
||||
import net.sf.saxon.om.EmptyAtomicSequence;
|
||||
import net.sf.saxon.om.Sequence;
|
||||
import net.sf.saxon.value.SequenceType;
|
||||
import net.sf.saxon.value.StringValue;
|
||||
|
||||
|
||||
@ -36,19 +35,13 @@ public class GetCommentOnFunction extends BaseJavaXPathFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType[] getArgumentTypes() {
|
||||
return new SequenceType[0];
|
||||
public Type getResultType(Type[] suppliedArgumentTypes) {
|
||||
return Type.OPTIONAL_STRING;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
|
||||
return SequenceType.OPTIONAL_STRING;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dependsOnFocus() {
|
||||
public boolean dependsOnContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ import net.sf.saxon.lib.ExtensionFunctionCall;
|
||||
import net.sf.saxon.om.Sequence;
|
||||
import net.sf.saxon.value.EmptySequence;
|
||||
import net.sf.saxon.value.SequenceExtent;
|
||||
import net.sf.saxon.value.SequenceType;
|
||||
import net.sf.saxon.value.StringValue;
|
||||
|
||||
/**
|
||||
@ -26,7 +25,6 @@ import net.sf.saxon.value.StringValue;
|
||||
*/
|
||||
public final class GetModifiersFun extends BaseJavaXPathFunction {
|
||||
|
||||
private static final SequenceType[] ARGTYPES = {};
|
||||
private final boolean explicit;
|
||||
|
||||
public static final GetModifiersFun GET_EFFECTIVE = new GetModifiersFun("modifiers", false);
|
||||
@ -38,17 +36,12 @@ public final class GetModifiersFun extends BaseJavaXPathFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType[] getArgumentTypes() {
|
||||
return ARGTYPES;
|
||||
public Type getResultType(Type[] suppliedArgumentTypes) {
|
||||
return Type.STRING_SEQUENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
|
||||
return SequenceType.STRING_SEQUENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dependsOnFocus() {
|
||||
public boolean dependsOnContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import net.sf.saxon.om.Sequence;
|
||||
import net.sf.saxon.trans.XPathException;
|
||||
import net.sf.saxon.value.BigDecimalValue;
|
||||
import net.sf.saxon.value.EmptySequence;
|
||||
import net.sf.saxon.value.SequenceType;
|
||||
|
||||
|
||||
/**
|
||||
@ -38,19 +37,19 @@ public final class MetricFunction extends BaseJavaXPathFunction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceType[] getArgumentTypes() {
|
||||
return new SequenceType[] {SequenceType.SINGLE_STRING};
|
||||
public Type[] getArgumentTypes() {
|
||||
return new Type[] {Type.SINGLE_STRING};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
|
||||
return SequenceType.OPTIONAL_DECIMAL;
|
||||
public Type getResultType(Type[] suppliedArgumentTypes) {
|
||||
return Type.OPTIONAL_DECIMAL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dependsOnFocus() {
|
||||
public boolean dependsOnContext() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user