2017-02-26 10:44:10 +00:00
|
|
|
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
|
2017-03-19 02:31:20 +00:00
|
|
|
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
|
|
|
|
|
2017-03-19 23:33:23 +00:00
|
|
|
public class Choose extends ValueListFunction
|
2017-02-26 10:44:10 +00:00
|
|
|
{
|
2017-03-18 08:33:40 +00:00
|
|
|
Choose (Cell cell, String text)
|
2017-02-26 10:44:10 +00:00
|
|
|
{
|
2017-03-18 08:33:40 +00:00
|
|
|
super (cell, text);
|
2017-03-18 09:21:11 +00:00
|
|
|
assert text.startsWith ("@CHOOSE(") : text;
|
2017-02-26 10:44:10 +00:00
|
|
|
}
|
2017-03-05 10:42:27 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void calculate ()
|
2017-03-19 02:31:20 +00:00
|
|
|
{
|
|
|
|
Value source = list.get (0);
|
|
|
|
|
|
|
|
source.calculate ();
|
|
|
|
if (!source.isValueType (ValueType.VALUE))
|
|
|
|
{
|
|
|
|
valueType = source.getValueType ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = (int) source.getValue ();
|
|
|
|
if (index < 1 || index >= list.size ())
|
|
|
|
{
|
|
|
|
valueType = ValueType.NA;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Cell cell = (Cell) list.get (index);
|
|
|
|
if (cell.isCellType (CellType.EMPTY))
|
|
|
|
valueType = ValueType.NA;
|
|
|
|
else
|
|
|
|
{
|
2017-03-16 00:27:45 +00:00
|
|
|
valueType = cell.getValueType ();
|
|
|
|
value = cell.getValue ();
|
|
|
|
}
|
2017-03-05 10:42:27 +00:00
|
|
|
}
|
2017-02-26 10:44:10 +00:00
|
|
|
}
|