mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-15 19:29:45 +00:00
58 lines
1.9 KiB
Java
58 lines
1.9 KiB
Java
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
// -----------------------------------------------------------------------------------//
|
|
class ConditionList implements Iterable<Value>
|
|
// -----------------------------------------------------------------------------------//
|
|
{
|
|
private final List<Value> conditions = new ArrayList<> ();
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
ConditionList (Cell cell, String text)
|
|
// ---------------------------------------------------------------------------------//
|
|
{
|
|
String remainder = text;
|
|
|
|
while (true)
|
|
{
|
|
String parameter = Expression.getParameter (remainder);
|
|
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));
|
|
|
|
if (remainder.length () == parameter.length ())
|
|
break;
|
|
remainder = remainder.substring (parameter.length () + 1);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
public Value get (int index)
|
|
// ---------------------------------------------------------------------------------//
|
|
{
|
|
return conditions.get (index);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
public int size ()
|
|
// ---------------------------------------------------------------------------------//
|
|
{
|
|
return conditions.size ();
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
@Override
|
|
public Iterator<Value> iterator ()
|
|
// ---------------------------------------------------------------------------------//
|
|
{
|
|
return conditions.iterator ();
|
|
}
|
|
} |