Started to add filters

master
Heiko Mueller 2016-06-25 07:49:40 -04:00
parent d04b767df4
commit e48e14db1c
27 changed files with 898 additions and 37 deletions

View File

@ -24,11 +24,35 @@ import org.vizierdb.database.value.Value;
*/
public class CellSet implements Iterable<Cell> {
private final HashMap<Integer, Cell> _cells = new HashMap<>();
private final HashMap<String, Cell> _cellIndex = new HashMap<>();
private final HashMap<Integer, Cell> _valueIndex = new HashMap<>();
public void add(Cell cell) {
_cells.put(cell.getValue().getIdentifier(), cell);
_cellIndex.put(cell.getKey(), cell);
_valueIndex.put(cell.getValue().getIdentifier(), cell);
}
/**
* Cell with the given key.
*
* @param key
* @return
*/
public Cell getCell(String key) {
return _cellIndex.get(key);
}
/**
* Cell at given coordinate position.
*
* @param coordinates
* @return
*/
public Cell getCell(CellCoordinates coordinates) {
return this.getCell(coordinates.getKey());
}
/**
@ -39,7 +63,7 @@ public class CellSet implements Iterable<Cell> {
*/
public Cell getCellForValue(int valueId) {
return _cells.get(valueId);
return _valueIndex.get(valueId);
}
/**
@ -50,7 +74,7 @@ public class CellSet implements Iterable<Cell> {
*/
public Value getValue(int valueId) {
Cell cell = _cells.get(valueId);
Cell cell = _valueIndex.get(valueId);
if (cell != null) {
return cell.getValue();
} else {
@ -61,6 +85,6 @@ public class CellSet implements Iterable<Cell> {
@Override
public Iterator<Cell> iterator() {
return _cells.values().iterator();
return _valueIndex.values().iterator();
}
}

View File

@ -17,7 +17,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.vizierdb.database.value.ConstantValue;
import org.vizierdb.database.value.DependencyGraph;
import org.vizierdb.database.value.ErrorValue;
import org.vizierdb.database.value.Value;
@ -34,7 +33,6 @@ import org.vizierdb.database.value.formula.Formula;
public class CellSetFactory {
private final CellSet _cells = new CellSet();
private final HashMap<String, Cell> _cellIndex = new HashMap<>();
private final DependencyGraph _graph = new DependencyGraph();
/**
@ -45,7 +43,6 @@ public class CellSetFactory {
public void add(Cell cell) {
_cells.add(cell);
_cellIndex.put(cell.getKey(), cell);
if (cell.getValue().isDerived()) {
int valueId = cell.getValue().getIdentifier();
for (int sourceValueId : cell.getValue().getDependencies()) {
@ -115,7 +112,7 @@ public class CellSetFactory {
*/
public Cell get(String key) {
return _cellIndex.get(key);
return _cells.getCell(key);
}
/**

View File

@ -0,0 +1,51 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database;
import org.vizierdb.database.value.Value;
/**
* Row in a spreadsheet. Primarily used to group cells for evaluation in filter
* conditions.
*
* @author Heiko Mueller
*/
public class Row {
private final CellSet _cells;
private final int _rowId;
public Row(int rowId, CellSet cells) {
_rowId = rowId;
_cells = cells;
}
/**
* Value for column with given identifier. The result is null if the row
* does not have a value for the given column.
*
* @param columnId
* @return
*/
public Value getColumnValue(int columnId) {
Cell cell = _cells.getCell(new CellCoordinates(columnId, _rowId));
if (cell != null) {
return cell.getValue();
} else {
return null;
}
}
}

View File

@ -0,0 +1,39 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.ColumnList;
import org.vizierdb.database.Row;
/**
*
* @author heiko
*/
public class ANDOp extends LogicOp {
public ANDOp(Condition left, Condition right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
if (this.left().eval(row)) {
return this.right().eval(row);
} else {
return false;
}
}
}

View File

@ -0,0 +1,60 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.ColumnList;
/**
*
* @author heiko
*/
public abstract class BinaryOp implements Condition {
private final Term _left;
private final Term _right;
public BinaryOp(Term left, Term right) {
_left = left;
_right = right;
}
@Override
public boolean isApplicable(ColumnList columns) {
Integer col = _left.getReferencedColumn();
if (col != null) {
if (!columns.contains(col)) {
return false;
}
}
col = _right.getReferencedColumn();
if (col != null) {
if (!columns.contains(col)) {
return false;
}
}
return true;
}
public Term left() {
return _left;
}
public Term rigth() {
return _right;
}
}

View File

@ -0,0 +1,44 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
* Term that returns value of column with specific identifier.
*
* @author Heiko Mueller
*/
public class ColumnTerm implements Term {
private final int _columnId;
public ColumnTerm(int columnId) {
_columnId = columnId;
}
@Override
public Value getValue(Row row) {
return row.getColumnValue(_columnId);
}
@Override
public Integer getReferencedColumn() {
return _columnId;
}
}

View File

@ -0,0 +1,42 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.ColumnList;
import org.vizierdb.database.Row;
/**
* Condition in a VizUAL filter. Conditions are evaluated over rows in a
* spreadsheet.
*
* @author Heiko Mueller
*/
public interface Condition {
/**
* Evaluate the condition on a spreadsheet row.
*
* @param row
* @return
*/
public boolean eval(Row row);
/**
* Test if all column terms can be evaluated over given list of columns.
*
* @param columns
* @return
*/
public boolean isApplicable(ColumnList columns);
}

View File

@ -0,0 +1,45 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
* Constant value term.
*
* @author heiko
*/
public class ConstantTerm implements Term{
private final Value _value;
public ConstantTerm(Value value) {
_value = value;
}
@Override
public Value getValue(Row row) {
return _value;
}
@Override
public Integer getReferencedColumn() {
return null;
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class EQOp extends BinaryOp {
public EQOp(Term left, Term right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
Value leftVal = this.left().getValue(row);
Value rightVal = this.rigth().getValue(row);
if ((leftVal != null) && (rightVal != null)) {
try {
return (leftVal.getAsBigDecimal().compareTo(rightVal.getAsBigDecimal()) == 0);
} catch (Exception exception) {
return leftVal.getAsString().equals(rightVal.getAsString());
}
} else {
return ((leftVal == null) && (rightVal == null));
}
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class GEQOp extends BinaryOp {
public GEQOp(Term left, Term right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
Value leftVal = this.left().getValue(row);
Value rightVal = this.rigth().getValue(row);
if ((leftVal != null) && (rightVal != null)) {
try {
return (leftVal.getAsBigDecimal().compareTo(rightVal.getAsBigDecimal()) >= 0);
} catch (Exception exception) {
return (leftVal.getAsString().compareTo(rightVal.getAsString()) >= 0);
}
} else {
return ((leftVal == null) && (rightVal == null));
}
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class GTOp extends BinaryOp {
public GTOp(Term left, Term right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
Value leftVal = this.left().getValue(row);
Value rightVal = this.rigth().getValue(row);
if ((leftVal != null) && (rightVal != null)) {
try {
return (leftVal.getAsBigDecimal().compareTo(rightVal.getAsBigDecimal()) > 0);
} catch (Exception exception) {
return (leftVal.getAsString().compareTo(rightVal.getAsString()) > 0);
}
} else {
return false;
}
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class LEQOp extends BinaryOp {
public LEQOp(Term left, Term right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
Value leftVal = this.left().getValue(row);
Value rightVal = this.rigth().getValue(row);
if ((leftVal != null) && (rightVal != null)) {
try {
return (leftVal.getAsBigDecimal().compareTo(rightVal.getAsBigDecimal()) <= 0);
} catch (Exception exception) {
return (leftVal.getAsString().compareTo(rightVal.getAsString()) <= 0);
}
} else {
return ((leftVal == null) && (rightVal == null));
}
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class LTOp extends BinaryOp {
public LTOp(Term left, Term right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
Value leftVal = this.left().getValue(row);
Value rightVal = this.rigth().getValue(row);
if ((leftVal != null) && (rightVal != null)) {
try {
return (leftVal.getAsBigDecimal().compareTo(rightVal.getAsBigDecimal()) < 0);
} catch (Exception exception) {
return (leftVal.getAsString().compareTo(rightVal.getAsString()) < 0);
}
} else {
return false;
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.ColumnList;
/**
*
* @author heiko
*/
public abstract class LogicOp implements Condition {
private final Condition _left;
private final Condition _right;
public LogicOp(Condition left, Condition right) {
_left = left;
_right = right;
}
@Override
public boolean isApplicable(ColumnList columns) {
if (_left.isApplicable(columns)) {
return _right.isApplicable(columns);
} else {
return false;
}
}
public Condition left() {
return _left;
}
public Condition right() {
return _right;
}
}

View File

@ -0,0 +1,61 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import java.util.regex.Pattern;
import org.vizierdb.database.ColumnList;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class MatchesOp implements Condition {
private final Pattern _pattern;
private final Term _term;
public MatchesOp(Term term, Pattern pattern) {
_term = term;
_pattern = pattern;
}
@Override
public boolean eval(Row row) {
Value val = _term.getValue(row);
if (val != null) {
try {
return _pattern.matcher(val.getAsString()).matches();
} catch (Exception exception) {
return false;
}
} else {
return false;
}
}
@Override
public boolean isApplicable(ColumnList columns) {
Integer col = _term.getReferencedColumn();
if (col != null) {
return (columns.contains(col));
}
return false;
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
*
* @author heiko
*/
public class NEQOp extends BinaryOp {
public NEQOp(Term left, Term right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
Value leftVal = this.left().getValue(row);
Value rightVal = this.rigth().getValue(row);
if ((leftVal != null) && (rightVal != null)) {
try {
return (leftVal.getAsBigDecimal().compareTo(rightVal.getAsBigDecimal()) != 0);
} catch (Exception exception) {
return !leftVal.getAsString().equals(rightVal.getAsString());
}
} else {
return !((leftVal == null) && (rightVal == null));
}
}
}

View File

@ -0,0 +1,38 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
/**
*
* @author heiko
*/
public class OROp extends LogicOp {
public OROp(Condition left, Condition right) {
super(left, right);
}
@Override
public boolean eval(Row row) {
if (this.left().eval(row)) {
return true;
} else {
return this.right().eval(row);
}
}
}

View File

@ -0,0 +1,41 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.filter;
import org.vizierdb.database.Row;
import org.vizierdb.database.value.Value;
/**
* Value expression in a filter condition operator. Returns a value. Could
* either be a constant value or the value of a cell in a spreadsheet row.
*
* @author Heiko Mueller
*/
public interface Term {
/**
* The value that the term evaluates to for the given row.
*
* @param row
* @return
*/
public Value getValue(Row row);
/**
* The identifier of the column from which the value is extracted. The
* result is null if the term represents a constant value.
* @return
*/
public Integer getReferencedColumn();
}

View File

@ -62,6 +62,7 @@ public enum OperationType {
DeleteColumn,
DeleteRow,
Filter,
InsertColumn,
InsertRow,
LoadFile,

View File

@ -0,0 +1,85 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vizierdb.database.script.op;
import java.util.ArrayList;
import org.vizierdb.database.Cell;
import org.vizierdb.database.CellSetFactory;
import org.vizierdb.database.Notebook;
import org.vizierdb.database.Row;
import org.vizierdb.database.RowList;
import org.vizierdb.database.Snapshot;
import org.vizierdb.database.filter.Condition;
import org.vizierdb.database.script.Operation;
import org.vizierdb.database.script.OperationType;
import org.vizierdb.database.script.VizUALStatement;
/**
*
* @author heiko
*/
public class RowFilter extends Operation {
private final Condition _filter;
public RowFilter(Condition filter) {
super(OperationType.Filter);
_filter = filter;
}
@Override
public Snapshot exec(Notebook notebook, Snapshot snapshot, int resultIdentifier) {
RowList rows = new RowList();
for (int rowId : snapshot.getRows()) {
Row row = new Row(rowId, snapshot.getCells());
if (_filter.eval(row)) {
rows.add(rowId);
}
}
CellSetFactory cells = new CellSetFactory();
ArrayList<Integer> deletedValues = new ArrayList<>();
for (Cell cell : snapshot.getCells()) {
if (rows.contains(cell.getRowId())) {
cells.add(cell);
} else {
deletedValues.add(cell.getValue().getIdentifier());
}
}
/*
* Create new snapshot and update values that depend on values in
* the deleted row.
*/
Snapshot nextSnapshot = new Snapshot(resultIdentifier, snapshot.getColumns(), rows, cells.getSet());
if (!deletedValues.isEmpty()) {
cells.evalForDeletedValues(nextSnapshot, deletedValues);
}
return nextSnapshot;
}
@Override
public VizUALStatement getStatement(Snapshot snapshot) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean isApplicable(Snapshot snapshot) {
return _filter.isApplicable(snapshot.getColumns());
}
}

View File

@ -48,6 +48,12 @@ public class ConstantValue extends Value {
return new BigDecimal(_value);
}
@Override
public String getAsString() {
return _value;
}
@Override
public List<Integer> getDependencies() {
@ -57,13 +63,7 @@ public class ConstantValue extends Value {
@Override
public String getFormula(Snapshot snapshot) {
return this.getText();
}
@Override
public String getText() {
return _value;
return this.getAsString();
}
@Override

View File

@ -47,6 +47,12 @@ public class ErrorValue extends Value {
throw new java.lang.NumberFormatException();
}
@Override
public String getAsString() {
return _message;
}
@Override
public List<Integer> getDependencies() {
@ -60,12 +66,6 @@ public class ErrorValue extends Value {
return _formula;
}
@Override
public String getText() {
return _message;
}
@Override
public boolean isDerived() {

View File

@ -65,6 +65,12 @@ public class FormulaValue extends Value {
return _value;
}
}
@Override
public String getAsString() {
return _text;
}
@Override
public List<Integer> getDependencies() {
@ -78,12 +84,6 @@ public class FormulaValue extends Value {
return "=" + _formula.toExternalForm(snapshot);
}
@Override
public String getText() {
return _text;
}
@Override
public boolean isDerived() {

View File

@ -56,6 +56,13 @@ public abstract class Value {
*/
public abstract BigDecimal getAsBigDecimal();
/**
* Text representation of the value.
*
* @return
*/
public abstract String getAsString();
/**
* Text representation of the values formula. The value is the same as the
* text for constant values.
@ -75,13 +82,6 @@ public abstract class Value {
return _identifier;
}
/**
* Text representation of the value.
*
* @return
*/
public abstract String getText();
/**
* Flag indicating whether the value is constant (false) or derived using
* a formula (true).

View File

@ -222,7 +222,7 @@ public class ResourceStreamWriter implements AutoCloseable {
_out.name("row").value(rowMapping.get(cell.getRowId()));
_out.name("value").beginObject();
Value value = cell.getValue();
_out.name("text").value(value.getText());
_out.name("text").value(value.getAsString());
if (value.isDerived()) {
_out.name("formula").value(value.getFormula(snapshot));
}

View File

@ -25,7 +25,7 @@
<script src="./js/ie-emulation-modes-warning.js"></script>
<!-- D3.js -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="./js/d3.v3.min.js" charset="utf-8"></script>
<script src="./js/dagre-d3.min.js"></script>
<!-- Bootstrap core JavaScript

5
src/main/webapp/js/d3.v3.min.js vendored Normal file

File diff suppressed because one or more lines are too long