Skip to content

Commit

Permalink
Match int->Decimal argument types for metaschema-framework#132
Browse files Browse the repository at this point in the history
We fixed some of that in early PR review, the function signatures will
obviously need those corrected too.
  • Loading branch information
aj-stein-gsa committed Oct 8, 2024
1 parent 89fc5f1 commit a83404f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gov.nist.secauto.metaschema.core.metapath.function.IFunction;
import gov.nist.secauto.metaschema.core.metapath.item.IItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IDecimalItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IIntegerItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
Expand Down Expand Up @@ -93,8 +94,8 @@ private static ISequence<IStringItem> execute(
IItem focus) {

IStringItem sourceString = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(0).getFirstItem(true)));
IIntegerItem start = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true)));
IIntegerItem length = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(2).getFirstItem(true)));
IDecimalItem start = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(1).getFirstItem(true)));
IDecimalItem length = FunctionUtils.asType(ObjectUtils.requireNonNull(arguments.get(2).getFirstItem(true)));
return ISequence.of(substring(sourceString, start, length));
}

Expand All @@ -111,7 +112,7 @@ private static ISequence<IStringItem> execute(
* @return the atomized result
*/
@NonNull
public static IStringItem substring(@NonNull IStringItem sourceString, @NonNull IIntegerItem start, @NonNull IIntegerItem length) {
public static IStringItem substring(@NonNull IStringItem sourceString, @NonNull IDecimalItem start, @NonNull IDecimalItem length) {
int startIndex = start.asInteger().intValue() - 1;
int endIndex = startIndex + length.asInteger().intValue();
return IStringItem.valueOf(sourceString.toString().substring(startIndex, endIndex));
Expand Down

0 comments on commit a83404f

Please sign in to comment.