Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contains and ends-with Metapath functions #168

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# broken plugin and dependency references
https://bytebuddy.net/byte-buddy
https://checkstyle.org/checks/indentation/indentation.html
https://chronicle.software/java-parent-pom/compiler
http://code.google.com/p/.*
https://code.revelc.net/revelc/formatter-maven-plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ public static List<ISequence<?>> convertArguments(
@NonNull List<ISequence<?>> retval = new ArrayList<>(parameters.size());

Iterator<IArgument> argumentIterator = function.getArguments().iterator();
Iterator<? extends ISequence<?>> parametersIterator = parameters.iterator();

IArgument argument = null;
while (parametersIterator.hasNext()) {
for (ISequence<?> parameter : parameters) {
if (argumentIterator.hasNext()) {
argument = argumentIterator.next();
} else if (!function.isArityUnbounded()) {
Expand All @@ -173,7 +171,6 @@ public static List<ISequence<?>> convertArguments(
String.format("argument signature doesn't match '%s'", function.toSignature()));
}

ISequence<?> parameter = parametersIterator.next();
assert argument != null;
assert parameter != null;

Expand Down Expand Up @@ -316,10 +313,7 @@ public boolean equals(Object obj) {
if (this == obj) {
return true; // NOPMD - readability
}
if (obj == null) {
return false; // NOPMD - readability
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false; // NOPMD - readability
}
DefaultFunction other = (DefaultFunction) obj;
Expand Down Expand Up @@ -389,19 +383,15 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getFunction().hashCode();
result = prime * result + Objects.hash(contextItem, arguments);
return result;
return prime * result + Objects.hash(contextItem, arguments);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true; // NOPMD - readability
}
if (obj == null) {
return false; // NOPMD - readability
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false; // NOPMD - readability
}
CallingContext other = (CallingContext) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayAppend {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "append";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("append")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayFlatten {
private static final String NAME = "flatten";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("flatten")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayGet {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "get";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("get")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import edu.umd.cs.findbugs.annotations.Nullable;

public final class ArrayHead {
private static final String NAME = "head";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("head")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayInsertBefore {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "insert-before";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("insert-before")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayJoin {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "join";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("join")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayPut {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "put";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("put")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayRemove {
private static final String NAME = "remove";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("remove")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArrayReverse {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "reverse";
@NonNull
public static final IFunction SIGNATURE = IFunction.builder()
.name("reverse")
static final IFunction SIGNATURE = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

import edu.umd.cs.findbugs.annotations.NonNull;

public class ArraySize {
public final class ArraySize {
aj-stein-gsa marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "size";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("size")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down Expand Up @@ -56,4 +57,8 @@ private static ISequence<IIntegerItem> execute(@NonNull IFunction function,

return ISequence.of(IIntegerItem.valueOf(array.size()));
}

private ArraySize() {
// disable
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class ArraySubarray {
private static final String NAME = "subarray";
@NonNull
public static final IFunction SIGNATURE_TWO_ARG = IFunction.builder()
.name("subarray")
static final IFunction SIGNATURE_TWO_ARG = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand All @@ -46,8 +47,8 @@ public final class ArraySubarray {
.functionHandler(ArraySubarray::executeTwoArg)
.build();
@NonNull
public static final IFunction SIGNATURE_THREE_ARG = IFunction.builder()
.name("subarray")
static final IFunction SIGNATURE_THREE_ARG = IFunction.builder()
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import edu.umd.cs.findbugs.annotations.Nullable;

public final class ArrayTail {
private static final String NAME = "tail";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("tail")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS_ARRAY)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public DefaultFunctionLibrary() { // NOPMD - intentional
registerFunction(FnCompare.SIGNATURE);
// https://www.w3.org/TR/xpath-functions-31/#func-concat
registerFunction(FnConcat.SIGNATURE);
// P1: https://www.w3.org/TR/xpath-functions-31/#func-contains
// https://www.w3.org/TR/xpath-functions-31/#func-contains
registerFunction(FnContains.SIGNATURE);
// https://www.w3.org/TR/xpath-functions-31/#func-count
registerFunction(FnCount.SIGNATURE);
// P2: https://www.w3.org/TR/xpath-functions-31/#func-current-date
Expand All @@ -74,7 +75,8 @@ public DefaultFunctionLibrary() { // NOPMD - intentional
// https://www.w3.org/TR/xpath-functions-31/#func-empty
registerFunction(FnEmpty.SIGNATURE);
// https://www.w3.org/TR/xpath-functions-31/#func-encode-for-uri
// P1: https://www.w3.org/TR/xpath-functions-31/#func-ends-with
// https://www.w3.org/TR/xpath-functions-31/#func-ends-with
registerFunction(FnEndsWith.SIGNATURE);
// P2: https://www.w3.org/TR/xpath-functions-31/#func-exactly-one
// https://www.w3.org/TR/xpath-functions-31/#func-exists
registerFunction(FnExists.SIGNATURE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* document-uri function.
*/
public final class FnBaseUri {

private static final String NAME = "base-uri";
@NonNull
static final IFunction SIGNATURE_NO_ARG = IFunction.builder()
.name("base-uri")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS)
.deterministic()
.contextDependent()
Expand All @@ -42,7 +42,7 @@ public final class FnBaseUri {

@NonNull
static final IFunction SIGNATURE_ONE_ARG = IFunction.builder()
.name("base-uri")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;

public final class FnBoolean {
private static final String NAME = "boolean";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("boolean")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS)
.deterministic()
.contextIndependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
* "https://www.w3.org/TR/xpath-functions-31/#func-compare">fn:compare</a>.
*/
public final class FnCompare {

private static final String NAME = "compare";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("compare")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS)
.deterministic()
.contextDependent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
* "https://www.w3.org/TR/xpath-functions-31/#func-concat">fn:concat</a>.
*/
public final class FnConcat {
private static final String NAME = "concat";
@NonNull
static final IFunction SIGNATURE = IFunction.builder()
.name("concat")
.name(NAME)
.namespace(MetapathConstants.NS_METAPATH_FUNCTIONS)
.deterministic()
.contextIndependent()
Expand Down Expand Up @@ -106,9 +107,7 @@ public static IStringItem concat(@NonNull List<? extends IAnyAtomicItem> items)
@NonNull
public static IStringItem concat(@NonNull Stream<? extends IAnyAtomicItem> items) {
return IStringItem.valueOf(ObjectUtils.notNull(items
.map(item -> {
return item == null ? "" : IStringItem.cast(item).asString();
})
.map(item -> (item == null ? "" : IStringItem.cast(item).asString()))
.collect(Collectors.joining())));
}
}
Loading