2017-03-19 03:49:14 +00:00
|
|
|
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
2017-03-23 13:30:41 +00:00
|
|
|
public class ConditionList implements Iterable<Value>
|
2017-03-19 03:49:14 +00:00
|
|
|
{
|
2020-02-02 10:17:49 +00:00
|
|
|
private final List<Value> conditions = new ArrayList<> ();
|
2017-03-19 03:49:14 +00:00
|
|
|
|
|
|
|
public ConditionList (Cell cell, String text)
|
|
|
|
{
|
|
|
|
String remainder = text;
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
String parameter = Expression.getParameter (remainder);
|
2017-03-23 13:30:41 +00:00
|
|
|
if (Range.isRange (parameter))
|
|
|
|
for (Address address : new Range (cell, parameter))
|
|
|
|
{
|
|
|
|
Cell target = cell.getCell (address);
|
|
|
|
conditions.add (target);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
conditions.add (new Condition (cell, parameter));
|
|
|
|
|
2017-03-19 03:49:14 +00:00
|
|
|
if (remainder.length () == parameter.length ())
|
|
|
|
break;
|
|
|
|
remainder = remainder.substring (parameter.length () + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 13:30:41 +00:00
|
|
|
public Value get (int index)
|
2017-03-19 03:49:14 +00:00
|
|
|
{
|
|
|
|
return conditions.get (index);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int size ()
|
|
|
|
{
|
|
|
|
return conditions.size ();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-03-23 13:30:41 +00:00
|
|
|
public Iterator<Value> iterator ()
|
2017-03-19 03:49:14 +00:00
|
|
|
{
|
|
|
|
return conditions.iterator ();
|
|
|
|
}
|
|
|
|
}
|