-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into proper-in-tests
- Loading branch information
Showing
5 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/executing/ToCharsEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.opencds.cqf.cql.engine.elm.executing; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.opencds.cqf.cql.engine.exception.InvalidOperatorArgument; | ||
|
||
/* | ||
ToChars(argument String) List<String> | ||
The ToChars operator takes a string and returns a list with one string for each character in the input, in the order in which they appear in the string. | ||
If the argument is null, the result is null. | ||
*/ | ||
|
||
public class ToCharsEvaluator { | ||
|
||
public static List<String> toChars(Object operand) { | ||
if (operand == null) { | ||
return null; | ||
} | ||
|
||
if (operand instanceof String) { | ||
List<String> result = new ArrayList<>(); | ||
for (char c : ((String) operand).toCharArray()) { | ||
result.add(String.valueOf(c)); | ||
} | ||
return result; | ||
} | ||
|
||
throw new InvalidOperatorArgument( | ||
"ToChars(String)", | ||
String.format("ToInteger(%s)", operand.getClass().getName())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters