dmolony-DiskBrowser/src/com/bytezone/diskbrowser/visicalc/ConditionList.java

58 lines
1.9 KiB
Java
Raw Normal View History

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;
2020-02-10 11:05:40 +00:00
// -----------------------------------------------------------------------------------//
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
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
ConditionList (Cell cell, String text)
// ---------------------------------------------------------------------------------//
2017-03-19 03:49:14 +00:00
{
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);
}
}
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2017-03-23 13:30:41 +00:00
public Value get (int index)
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2017-03-19 03:49:14 +00:00
{
return conditions.get (index);
}
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2017-03-19 03:49:14 +00:00
public int size ()
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2017-03-19 03:49:14 +00:00
{
return conditions.size ();
}
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2017-03-19 03:49:14 +00:00
@Override
2017-03-23 13:30:41 +00:00
public Iterator<Value> iterator ()
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2017-03-19 03:49:14 +00:00
{
return conditions.iterator ();
}
}