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 static methods for timezone accessor Metapath functions #376

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

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

/**
* Implements the XPath 3.1 <a href=
Expand Down Expand Up @@ -56,8 +57,22 @@ private static ISequence<IDayTimeDurationItem> execute(@NonNull IFunction functi
IItem focus) {
IDateItem arg = FunctionUtils.asTypeOrNull(ObjectUtils.requireNonNull(arguments.get(0).getFirstItem(true)));

return arg == null || !arg.hasTimezone()
return arg == null
? ISequence.empty()
: ISequence.of(arg.getOffset());
: ISequence.of(fnTimezoneFromDate(arg));
}

/**
* Implements <a href=
* "https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-date">fn:timezone-from-date</a>.
*
* @param arg
* the meta:date item from which to extract the timezone component
* @return the timezone component from the date or {@code null} if no timezone
* is present
*/
@Nullable
public static IDayTimeDurationItem fnTimezoneFromDate(@NonNull IDateItem arg) {
return arg.getOffset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

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

/**
* Implements the XPath 3.1 <a href=
Expand Down Expand Up @@ -56,8 +57,23 @@ private static ISequence<IDayTimeDurationItem> execute(@NonNull IFunction functi
IItem focus) {
IDateTimeItem arg = FunctionUtils.asTypeOrNull(ObjectUtils.requireNonNull(arguments.get(0).getFirstItem(true)));

return arg == null || !arg.hasTimezone()
return arg == null
? ISequence.empty()
: ISequence.of(arg.getOffset());
: ISequence.of(fnTimezoneFromDate(arg));
}

/**
* Implements <a href=
* "https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-dateTime">fn:timezone-from-dateTime</a>.
*
* @param arg
* the meta:date-time item from which to extract the timezone component
* @return the timezone component from the date/time or {@code null} if no
* timezone is present
*/
@Nullable
public static IDayTimeDurationItem fnTimezoneFromDate(@NonNull IDateTimeItem arg) {
return arg.getOffset();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

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

/**
* Implements the XPath 3.1 <a href=
Expand Down Expand Up @@ -56,8 +57,22 @@ private static ISequence<IDayTimeDurationItem> execute(@NonNull IFunction functi
IItem focus) {
ITimeItem arg = FunctionUtils.asTypeOrNull(ObjectUtils.requireNonNull(arguments.get(0).getFirstItem(true)));

return arg == null || !arg.hasTimezone()
return arg == null
? ISequence.empty()
: ISequence.of(arg.getOffset());
: ISequence.of(fnTimezoneFromDate(arg));
}

/**
* Implements <a href=
* "https://www.w3.org/TR/xpath-functions-31/#func-timezone-from-time">fn:timezone-from-time</a>.
*
* @param arg
* the meta:time item from which to extract the timezone component
* @return the timezone component from the date/time or {@code null} if no
* timezone is present
*/
@Nullable
public static IDayTimeDurationItem fnTimezoneFromDate(@NonNull ITimeItem arg) {
return arg.getOffset();
}
}
Loading