StringTruncate
See javadoc - uk.gov.gchq.koryphe.impl.function.StringTruncate
Available since Koryphe version 1.9.0
Truncates a string, with optional ellipses.
Examples
With no ellipses
Java
JSON
Full JSON
Python
final StringTruncate function = new StringTruncate(5, false);
{
"class" : "StringTruncate",
"length" : 5,
"ellipses" : false
}
{
"class" : "uk.gov.gchq.koryphe.impl.function.StringTruncate",
"length" : 5,
"ellipses" : false
}
g.StringTruncate(
length=5,
ellipses=False
)
Input type:
java.lang.String
Example inputs:
Input Type | Input | Result Type | Result |
---|---|---|---|
java.lang.String | no more than five | java.lang.String | no mo |
java.lang.String | four | java.lang.String | four |
java.lang.String | java.lang.String | ||
null | null | ||
java.lang.Long | 54 | ClassCastException: java.lang.Long cannot be cast to java.lang.String |
With ellipses
Java
JSON
Full JSON
Python
final StringTruncate function = new StringTruncate(5, true);
{
"class" : "StringTruncate",
"length" : 5,
"ellipses" : true
}
{
"class" : "uk.gov.gchq.koryphe.impl.function.StringTruncate",
"length" : 5,
"ellipses" : true
}
g.StringTruncate(
length=5,
ellipses=True
)
Input type:
java.lang.String
Example inputs:
Input Type | Input | Result Type | Result |
---|---|---|---|
java.lang.String | no more than five | java.lang.String | no mo... |
java.lang.String | four | java.lang.String | four |
java.lang.String | java.lang.String | ||
null | null | ||
java.lang.Long | 54 | ClassCastException: java.lang.Long cannot be cast to java.lang.String |