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

37 lines
738 B
Java
Raw Normal View History

2016-03-06 08:05:32 +00:00
package com.bytezone.diskbrowser.visicalc;
2017-03-15 04:40:18 +00:00
import com.bytezone.diskbrowser.visicalc.Cell.CellType;
2017-02-18 09:54:24 +00:00
class Count extends Function
2016-03-06 08:05:32 +00:00
{
2017-03-15 00:41:45 +00:00
private final ExpressionList list;
private final boolean isRange;
2017-02-18 09:54:24 +00:00
2017-03-14 11:28:52 +00:00
public Count (Sheet parent, Cell cell, String text)
2016-03-06 08:05:32 +00:00
{
2017-03-14 11:28:52 +00:00
super (parent, cell, text);
2017-03-03 23:41:08 +00:00
2017-03-15 00:41:45 +00:00
list = new ExpressionList (parent, cell, functionText);
isRange = functionText.indexOf ("...") > 0;
2016-03-06 08:05:32 +00:00
}
2016-03-12 05:05:50 +00:00
@Override
2017-02-28 20:39:26 +00:00
public void calculate ()
2016-03-12 05:05:50 +00:00
{
2016-03-16 06:15:39 +00:00
value = 0;
2016-03-17 04:40:43 +00:00
valueType = ValueType.VALUE;
2017-03-15 00:41:45 +00:00
if (!isRange)
value = list.size ();
else
for (Value v : list)
{
v.calculate ();
2017-03-03 23:41:08 +00:00
2017-03-15 04:40:18 +00:00
if (v instanceof Cell && ((Cell) v).isCellType (CellType.EMPTY))
2017-03-15 00:41:45 +00:00
continue;
2016-03-17 04:40:43 +00:00
2017-03-15 00:41:45 +00:00
value++;
}
2016-03-06 08:05:32 +00:00
}
}