Add new split functions
This commit is contained in:
5 files changed
+52
-16
No files matched your search
@@ -347,6 +347,24 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|
||||
return new ListValue((Collection<? extends Value>) getItems().subList(from, to));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value split(Value delimiter) {
|
||||
ListValue result = new ListValue();
|
||||
int startIndex = 0;
|
||||
int index = 0;
|
||||
for (Value val : this.items)
|
||||
{
|
||||
index++;
|
||||
if (val.equals(delimiter))
|
||||
{
|
||||
result.items.add(ListValue.wrap(this.items.subList(startIndex, index-1)));
|
||||
startIndex = index;
|
||||
}
|
||||
}
|
||||
result.items.add(ListValue.wrap(this.items.subList(startIndex, length())));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double readDoubleNumber()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user