created ConditionList

This commit is contained in:
Denis Molony 2017-03-19 14:49:14 +11:00
parent 341979755d
commit 61a4bf7f94
3 changed files with 45 additions and 26 deletions

View File

@ -1,11 +1,8 @@
package com.bytezone.diskbrowser.visicalc;
import java.util.ArrayList;
import java.util.List;
class And extends Function
{
private final List<Condition> conditions = new ArrayList<Condition> ();
private final ConditionList conditions;
public And (Cell cell, String text)
{
@ -13,15 +10,7 @@ class And extends Function
assert text.startsWith ("@AND(") : text;
String remainder = functionText;
while (true)
{
String parameter = Expression.getParameter (remainder);
conditions.add (new Condition (parent, cell, parameter));
if (remainder.length () == parameter.length ())
break;
remainder = remainder.substring (parameter.length () + 1);
}
conditions = new ConditionList (cell, functionText);
}
@Override

View File

@ -0,0 +1,41 @@
package com.bytezone.diskbrowser.visicalc;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ConditionList implements Iterable<Condition>
{
protected final List<Condition> conditions = new ArrayList<Condition> ();
public ConditionList (Cell cell, String text)
{
Sheet parent = cell.getParent ();
String remainder = text;
while (true)
{
String parameter = Expression.getParameter (remainder);
conditions.add (new Condition (parent, cell, parameter));
if (remainder.length () == parameter.length ())
break;
remainder = remainder.substring (parameter.length () + 1);
}
}
public Condition get (int index)
{
return conditions.get (index);
}
public int size ()
{
return conditions.size ();
}
@Override
public Iterator<Condition> iterator ()
{
return conditions.iterator ();
}
}

View File

@ -1,11 +1,8 @@
package com.bytezone.diskbrowser.visicalc;
import java.util.ArrayList;
import java.util.List;
class Or extends Function
{
private final List<Condition> conditions = new ArrayList<Condition> ();
ConditionList conditions;
public Or (Cell cell, String text)
{
@ -13,15 +10,7 @@ class Or extends Function
assert text.startsWith ("@OR(") : text;
String remainder = functionText;
while (true)
{
String parameter = Expression.getParameter (remainder);
conditions.add (new Condition (parent, cell, parameter));
if (remainder.length () == parameter.length ())
break;
remainder = remainder.substring (parameter.length () + 1);
}
conditions = new ConditionList (cell, functionText);
}
@Override