Class Split
java.lang.Object
software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
software.amazon.smithy.rulesengine.language.syntax.expressions.functions.Split
- All Implemented Interfaces:
FromSourceLocation,ToNode,TypeCheck,ToCondition,ToExpression
Splits a string by a delimiter into parts.
The split function divides a string into an array of substrings based on a non-empty delimiter. The behavior is controlled by the limit parameter:
- limit = 0: Split all occurrences (unlimited)
- limit = 1: No split performed (returns original string as single element)
- limit > 1: Split into at most 'limit' parts (performs limit-1 splits)
Examples:
split("a--b--c", "--", 0)returns["a", "b", "c"]split("a--b--c", "--", 2)returns["a", "b--c"]split("--b--", "--", 0)returns["", "b", ""]split("abc", "x", 0)returns["abc"]split("", "--", 0)returns[""]split("----", "--", 0)returns["", "", ""]split("a--b--c--d", "--", 3)returns["a", "b", "c--d"]split("prefix", "--", 0)returns["prefix"]split("--", "--", 0)returns["", ""]split("a-b-c", "--", 0)returns["a-b-c"]split("mybucket", "--", 1)returns["mybucket"]split("--x-s3--azid--suffix", "--", 0)returns["", "x-s3", "azid", "suffix"]split("--x-s3--azid--suffix", "--", 4)returns["", "x-s3", "azid", "suffix"]split("--x-s3--azid--suffix", "--", 2)returns["", "x-s3--azid--suffix"]
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
definition, functionNode -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(ExpressionVisitor<T> visitor) Invoke theExpressionVisitorfunctions for this expression.Get the rules engine version that this syntax element is available since.static Split.DefinitionGets theFunctionDefinitionimplementation.static SplitofExpressions(ToExpression string, ToExpression delimiter, ToExpression limit) Creates aSplitfunction from the given expressions.Split a string by a delimiter.Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
calculateReferences, canonicalize, equals, expectOneArgument, getArguments, getFunctionDefinition, getName, getSourceLocation, hashCode, shouldSwapArgs, toConditionBuilder, toNode, toString, typeCheckLocalMethods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
fromNode, getLiteral, getReference, getReference, getReference, getReferences, of, of, of, parseShortform, toExpression, type, typeCheckMethods inherited from class software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
booleanEqual, getAttr, getAttr, isSet, isValidHostLabel, not, parseUrl, stringEqual, substring, templateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.smithy.rulesengine.language.syntax.ToCondition
toCondition, toCondition
-
Field Details
-
ID
- See Also:
-
-
Method Details
-
getDefinition
Gets theFunctionDefinitionimplementation.- Returns:
- the function definition.
-
ofExpressions
Creates aSplitfunction from the given expressions.- Parameters:
string- the string to split.delimiter- the delimiter.limit- the split limit (0 for unlimited, positive for max parts).- Returns:
- The resulting
Splitfunction.
-
accept
Description copied from class:ExpressionInvoke theExpressionVisitorfunctions for this expression.- Specified by:
acceptin classExpression- Type Parameters:
T- the visitor return type.- Parameters:
visitor- the visitor to be invoked.- Returns:
- the return value of the visitor.
-
availableSince
Description copied from class:SyntaxElementGet the rules engine version that this syntax element is available since.- Overrides:
availableSincein classSyntaxElement- Returns:
- the version this is available since.
-
split
Split a string by a delimiter.- Parameters:
value- the string to split (must not be null).delimiter- the delimiter to split by (must not be null or empty).limit- controls the split behavior: 0 = unlimited splits, 1 = no split (return original), n > 1 = split into at most n parts by performing up to n-1 split operations.- Returns:
- a non-null list of parts (never empty; returns [""] for empty input).
- Throws:
NullPointerException- if value or delimiter is null.IllegalArgumentException- if delimiter is empty, or if limit is negative.
-