Tabs to spaces.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@874 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-05-27 21:22:27 +00:00
parent 6409f1531c
commit 2f398cfeb3
8 changed files with 101 additions and 101 deletions

View File

@ -9,26 +9,26 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Row; import com.metaweb.gridworks.model.Row;
public class ExpressionBasedRowEvaluable implements RowEvaluable { public class ExpressionBasedRowEvaluable implements RowEvaluable {
final protected String _columnName; final protected String _columnName;
final protected int _cellIndex; final protected int _cellIndex;
final protected Evaluable _eval; final protected Evaluable _eval;
public ExpressionBasedRowEvaluable( public ExpressionBasedRowEvaluable(
String columnName, int cellIndex, Evaluable eval) { String columnName, int cellIndex, Evaluable eval) {
_columnName = columnName; _columnName = columnName;
_cellIndex = cellIndex; _cellIndex = cellIndex;
_eval = eval; _eval = eval;
} }
@Override @Override
public Object eval( public Object eval(
Project project, int rowIndex, Row row, Properties bindings) { Project project, int rowIndex, Row row, Properties bindings) {
Cell cell = row.getCell(_cellIndex); Cell cell = row.getCell(_cellIndex);
ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell); ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell);
return _eval.evaluate(bindings); return _eval.evaluate(bindings);
} }
} }

View File

@ -198,14 +198,14 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
return getChoiceValueCount(value); return getChoiceValueCount(value);
} }
public Integer getChoiceValueCount(Object choiceValue) { public Integer getChoiceValueCount(Object choiceValue) {
if (ExpressionUtils.isError(choiceValue)) { if (ExpressionUtils.isError(choiceValue)) {
return errorCount; return errorCount;
} else if (ExpressionUtils.isNonBlankData(choiceValue)) { } else if (ExpressionUtils.isNonBlankData(choiceValue)) {
IndexedNominalFacetChoice choice = choices.get(choiceValue); IndexedNominalFacetChoice choice = choices.get(choiceValue);
return choice != null ? choice.count : 0; return choice != null ? choice.count : 0;
} else { } else {
return blankCount; return blankCount;
} }
} }
} }

View File

@ -6,15 +6,15 @@ import com.metaweb.gridworks.browsing.RowVisitor;
import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Project;
public class FilteredRecordsAsFilteredRows implements FilteredRows { public class FilteredRecordsAsFilteredRows implements FilteredRows {
final protected FilteredRecords _filteredRecords; final protected FilteredRecords _filteredRecords;
public FilteredRecordsAsFilteredRows(FilteredRecords filteredRecords) { public FilteredRecordsAsFilteredRows(FilteredRecords filteredRecords) {
_filteredRecords = filteredRecords; _filteredRecords = filteredRecords;
} }
@Override @Override
public void accept(Project project, RowVisitor visitor) { public void accept(Project project, RowVisitor visitor) {
_filteredRecords.accept(project, new RowVisitorAsRecordVisitor(visitor)); _filteredRecords.accept(project, new RowVisitorAsRecordVisitor(visitor));
} }
} }

View File

@ -21,12 +21,12 @@ import com.metaweb.gridworks.model.Row;
*/ */
abstract public class NumericBinIndex { abstract public class NumericBinIndex {
protected int _totalValueCount; protected int _totalValueCount;
protected int _numbericValueCount; protected int _numbericValueCount;
protected double _min; protected double _min;
protected double _max; protected double _max;
protected double _step; protected double _step;
protected int[] _bins; protected int[] _bins;
protected int _numericRowCount; protected int _numericRowCount;
protected int _nonNumericRowCount; protected int _nonNumericRowCount;
@ -130,14 +130,14 @@ abstract public class NumericBinIndex {
return _errorRowCount; return _errorRowCount;
} }
protected void processRow( protected void processRow(
Project project, Project project,
RowEvaluable rowEvaluable, RowEvaluable rowEvaluable,
List<Double> allValues, List<Double> allValues,
int rowIndex, int rowIndex,
Row row, Row row,
Properties bindings Properties bindings
) { ) {
Object value = rowEvaluable.eval(project, rowIndex, row, bindings); Object value = rowEvaluable.eval(project, rowIndex, row, bindings);
if (ExpressionUtils.isError(value)) { if (ExpressionUtils.isError(value)) {
@ -191,16 +191,16 @@ abstract public class NumericBinIndex {
} else { } else {
_hasBlank = true; _hasBlank = true;
} }
} }
protected void preprocessing() { protected void preprocessing() {
_hasBlank = false; _hasBlank = false;
_hasError = false; _hasError = false;
_hasNonNumeric = false; _hasNonNumeric = false;
_hasNumeric = false; _hasNumeric = false;
} }
protected void postprocessing() { protected void postprocessing() {
if (_hasError) { if (_hasError) {
_errorRowCount++; _errorRowCount++;
} }
@ -213,7 +213,7 @@ abstract public class NumericBinIndex {
if (_hasNonNumeric) { if (_hasNonNumeric) {
_nonNumericRowCount++; _nonNumericRowCount++;
} }
} }
protected void processValue(double v, List<Double> allValues) { protected void processValue(double v, List<Double> allValues) {
if (!Double.isInfinite(v) && !Double.isNaN(v)) { if (!Double.isInfinite(v) && !Double.isNaN(v)) {

View File

@ -9,30 +9,30 @@ import com.metaweb.gridworks.model.Record;
import com.metaweb.gridworks.model.Row; import com.metaweb.gridworks.model.Row;
public class NumericBinRecordIndex extends NumericBinIndex { public class NumericBinRecordIndex extends NumericBinIndex {
public NumericBinRecordIndex(Project project, RowEvaluable rowEvaluable) { public NumericBinRecordIndex(Project project, RowEvaluable rowEvaluable) {
super(project, rowEvaluable); super(project, rowEvaluable);
} }
@Override @Override
protected void iterate( protected void iterate(
Project project, RowEvaluable rowEvaluable, List<Double> allValues) { Project project, RowEvaluable rowEvaluable, List<Double> allValues) {
Properties bindings = ExpressionUtils.createBindings(project); Properties bindings = ExpressionUtils.createBindings(project);
int count = project.recordModel.getRecordCount(); int count = project.recordModel.getRecordCount();
for (int r = 0; r < count; r++) { for (int r = 0; r < count; r++) {
Record record = project.recordModel.getRecord(r); Record record = project.recordModel.getRecord(r);
preprocessing(); preprocessing();
for (int i = record.fromRowIndex; i < record.toRowIndex; i++) { for (int i = record.fromRowIndex; i < record.toRowIndex; i++) {
Row row = project.rows.get(i); Row row = project.rows.get(i);
processRow(project, rowEvaluable, allValues, i, row, bindings); processRow(project, rowEvaluable, allValues, i, row, bindings);
} }
postprocessing(); postprocessing();
} }
} }
} }

View File

@ -8,15 +8,15 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Row; import com.metaweb.gridworks.model.Row;
public class NumericBinRowIndex extends NumericBinIndex { public class NumericBinRowIndex extends NumericBinIndex {
public NumericBinRowIndex(Project project, RowEvaluable rowEvaluable) { public NumericBinRowIndex(Project project, RowEvaluable rowEvaluable) {
super(project, rowEvaluable); super(project, rowEvaluable);
} }
@Override @Override
protected void iterate( protected void iterate(
Project project, RowEvaluable rowEvaluable, List<Double> allValues) { Project project, RowEvaluable rowEvaluable, List<Double> allValues) {
Properties bindings = ExpressionUtils.createBindings(project); Properties bindings = ExpressionUtils.createBindings(project);
for (int i = 0; i < project.rows.size(); i++) { for (int i = 0; i < project.rows.size(); i++) {
@ -28,6 +28,6 @@ public class NumericBinRowIndex extends NumericBinIndex {
postprocessing(); postprocessing();
} }
} }
} }

View File

@ -6,5 +6,5 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Row; import com.metaweb.gridworks.model.Row;
public interface RowEvaluable { public interface RowEvaluable {
public Object eval(Project project, int rowIndex, Row row, Properties bindings); public Object eval(Project project, int rowIndex, Row row, Properties bindings);
} }

View File

@ -6,29 +6,29 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Record; import com.metaweb.gridworks.model.Record;
public class RowVisitorAsRecordVisitor implements RecordVisitor { public class RowVisitorAsRecordVisitor implements RecordVisitor {
final protected RowVisitor _rowVisitor; final protected RowVisitor _rowVisitor;
public RowVisitorAsRecordVisitor(RowVisitor rowVisitor) { public RowVisitorAsRecordVisitor(RowVisitor rowVisitor) {
_rowVisitor = rowVisitor; _rowVisitor = rowVisitor;
} }
@Override @Override
public void start(Project project) { public void start(Project project) {
_rowVisitor.start(project); _rowVisitor.start(project);
} }
@Override @Override
public void end(Project project) { public void end(Project project) {
_rowVisitor.end(project); _rowVisitor.end(project);
} }
@Override @Override
public boolean visit(Project project, Record record) { public boolean visit(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) { for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
if (_rowVisitor.visit(project, r, project.rows.get(r))) { if (_rowVisitor.visit(project, r, project.rows.get(r))) {
return true; return true;
} }
} }
return false; return false;
} }
} }