cleanups (no functional changes)

this makes pmd and javac on linux happier


git-svn-id: http://google-refine.googlecode.com/svn/trunk@427 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-08 20:46:02 +00:00
parent be084ff0da
commit 7526c4e582
14 changed files with 80 additions and 113 deletions

View File

@ -110,23 +110,19 @@ public class InterProjectModel {
for (Row fromRow : fromProject.rows) { for (Row fromRow : fromProject.rows) {
Object value = fromRow.getCellValue(fromColumn.getCellIndex()); Object value = fromRow.getCellValue(fromColumn.getCellIndex());
if (ExpressionUtils.isNonBlankData(value)) { if (ExpressionUtils.isNonBlankData(value) && !join.valueToRowIndices.containsKey(value)) {
if (!join.valueToRowIndices.containsKey(value)) {
join.valueToRowIndices.put(value, new ArrayList<Integer>()); join.valueToRowIndices.put(value, new ArrayList<Integer>());
} }
} }
}
int count = toProject.rows.size(); int count = toProject.rows.size();
for (int r = 0; r < count; r++) { for (int r = 0; r < count; r++) {
Row toRow = toProject.rows.get(r); Row toRow = toProject.rows.get(r);
Object value = toRow.getCellValue(toColumn.getCellIndex()); Object value = toRow.getCellValue(toColumn.getCellIndex());
if (ExpressionUtils.isNonBlankData(value)) { if (ExpressionUtils.isNonBlankData(value) && join.valueToRowIndices.containsKey(value)) {
if (join.valueToRowIndices.containsKey(value)) {
join.valueToRowIndices.get(value).add(r); join.valueToRowIndices.get(value).add(r);
} }
} }
} }
} }
}

View File

@ -49,10 +49,10 @@ public class ConjunctiveFilteredRows implements FilteredRows {
// and this row is a dependent row since it's not a record row // and this row is a dependent row since it's not a record row
row.recordIndex < 0 && row.recordIndex < 0 &&
row.contextRows != null && row.contextRows != null &&
row.contextRows.size() > 0 row.contextRows.size() > 0 &&
) {
if (row.contextRows.get(0) == lastRecordRowAcceptedRowIndex) { row.contextRows.get(0) == lastRecordRowAcceptedRowIndex
) {
// this row depends on the last previously matched record row, // this row depends on the last previously matched record row,
// so we visit it as well as a dependent row // so we visit it as well as a dependent row
@ -61,7 +61,6 @@ public class ConjunctiveFilteredRows implements FilteredRows {
} }
} }
} }
}
protected void visitRow(Project project, RowVisitor visitor, int rowIndex, Row row, int lastVisitedRow) { protected void visitRow(Project project, RowVisitor visitor, int rowIndex, Row row, int lastVisitedRow) {
if (_includeContextual && // we need to include any context row and if (_includeContextual && // we need to include any context row and

View File

@ -5,8 +5,6 @@ import java.io.OutputStream;
import java.io.Writer; import java.io.Writer;
import java.util.Properties; import java.util.Properties;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.metaweb.gridworks.ProjectManager; import com.metaweb.gridworks.ProjectManager;
import com.metaweb.gridworks.browsing.Engine; import com.metaweb.gridworks.browsing.Engine;
import com.metaweb.gridworks.browsing.FilteredRows; import com.metaweb.gridworks.browsing.FilteredRows;
@ -27,7 +25,7 @@ public class HtmlTableExporter implements Exporter {
public void export(Project project, Properties options, Engine engine, public void export(Project project, Properties options, Engine engine,
OutputStream outputStream) throws IOException { OutputStream outputStream) throws IOException {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException { public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException {

View File

@ -5,8 +5,6 @@ import java.io.OutputStream;
import java.io.Writer; import java.io.Writer;
import java.util.Properties; import java.util.Properties;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.metaweb.gridworks.browsing.Engine; import com.metaweb.gridworks.browsing.Engine;
import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.protograph.Protograph; import com.metaweb.gridworks.protograph.Protograph;
@ -24,7 +22,7 @@ public class TripleloaderExporter implements Exporter {
public void export(Project project, Properties options, Engine engine, public void export(Project project, Properties options, Engine engine,
OutputStream outputStream) throws IOException { OutputStream outputStream) throws IOException {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
public void export(Project project, Properties options, Engine engine, public void export(Project project, Properties options, Engine engine,

View File

@ -5,8 +5,6 @@ import java.io.OutputStream;
import java.io.Writer; import java.io.Writer;
import java.util.Properties; import java.util.Properties;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.metaweb.gridworks.browsing.Engine; import com.metaweb.gridworks.browsing.Engine;
import com.metaweb.gridworks.browsing.FilteredRows; import com.metaweb.gridworks.browsing.FilteredRows;
import com.metaweb.gridworks.browsing.RowVisitor; import com.metaweb.gridworks.browsing.RowVisitor;
@ -26,7 +24,7 @@ public class TsvExporter implements Exporter {
public void export(Project project, Properties options, Engine engine, public void export(Project project, Properties options, Engine engine,
OutputStream outputStream) throws IOException { OutputStream outputStream) throws IOException {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException { public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException {

View File

@ -12,8 +12,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.metaweb.gridworks.ProjectManager; import com.metaweb.gridworks.ProjectManager;
import com.metaweb.gridworks.browsing.Engine; import com.metaweb.gridworks.browsing.Engine;
import com.metaweb.gridworks.browsing.FilteredRows; import com.metaweb.gridworks.browsing.FilteredRows;
@ -33,7 +31,7 @@ public class XlsExporter implements Exporter {
} }
public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException { public void export(Project project, Properties options, Engine engine, Writer writer) throws IOException {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
public void export(Project project, Properties options, Engine engine, public void export(Project project, Properties options, Engine engine,

View File

@ -20,8 +20,7 @@ public class Diff implements Function {
if (o1 != null && o2 != null) { if (o1 != null && o2 != null) {
if (o1 instanceof String && o2 instanceof String) { if (o1 instanceof String && o2 instanceof String) {
return StringUtils.difference((String) o1,(String) o2); return StringUtils.difference((String) o1,(String) o2);
} else if (o1 instanceof Calendar) { } else if (o1 instanceof Calendar && args.length == 3) {
if (args.length == 3) {
Object o3 = args[3]; Object o3 = args[3];
if (o3 != null && o3 instanceof String) { if (o3 != null && o3 instanceof String) {
try { try {
@ -46,7 +45,6 @@ public class Diff implements Function {
} }
} }
} }
}
return null; return null;
} }

View File

@ -36,15 +36,13 @@ public class ColumnGroup implements Jsonizable {
writer.key("columnSpan"); writer.value(columnSpan); writer.key("columnSpan"); writer.value(columnSpan);
writer.key("keyColumnIndex"); writer.value(keyColumnIndex); writer.key("keyColumnIndex"); writer.value(keyColumnIndex);
if (!"save".equals(options.get("mode"))) { if (!"save".equals(options.get("mode")) && (subgroups != null) && (subgroups.size() > 0)) {
if (subgroups != null && subgroups.size() > 0) {
writer.key("subgroups"); writer.array(); writer.key("subgroups"); writer.array();
for (ColumnGroup g : subgroups) { for (ColumnGroup g : subgroups) {
g.write(writer, options); g.write(writer, options);
} }
writer.endArray(); writer.endArray();
} }
}
writer.endObject(); writer.endObject();
} }

View File

@ -69,16 +69,12 @@ public class CellChange implements Change {
row = Integer.parseInt(value); row = Integer.parseInt(value);
} else if ("cell".equals(field)) { } else if ("cell".equals(field)) {
cellIndex = Integer.parseInt(value); cellIndex = Integer.parseInt(value);
} else if ("new".equals(field)) { } else if ("new".equals(field) && value.length() > 0) {
if (value.length() > 0) {
newCell = Cell.load(value); newCell = Cell.load(value);
} } else if ("old".equals(field) && value.length() > 0) {
} else if ("old".equals(field)) {
if (value.length() > 0) {
oldCell = Cell.load(value); oldCell = Cell.load(value);
} }
} }
}
return new CellChange(row, cellIndex, oldCell, newCell); return new CellChange(row, cellIndex, oldCell, newCell);
} }

View File

@ -7,8 +7,6 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONWriter; import org.json.JSONWriter;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import com.metaweb.gridworks.model.Cell; import com.metaweb.gridworks.model.Cell;
import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Recon; import com.metaweb.gridworks.model.Recon;
@ -36,13 +34,12 @@ public class DataExtensionReconConfig extends StrictReconConfig {
@Override @Override
public ReconJob createJob(Project project, int rowIndex, Row row, public ReconJob createJob(Project project, int rowIndex, Row row,
String columnName, Cell cell) { String columnName, Cell cell) {
throw new RuntimeException("Not implemented");
throw new NotImplementedException();
} }
@Override @Override
public int getBatchSize() { public int getBatchSize() {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
public void write(JSONWriter writer, Properties options) public void write(JSONWriter writer, Properties options)
@ -56,12 +53,12 @@ public class DataExtensionReconConfig extends StrictReconConfig {
@Override @Override
public List<Recon> batchRecon(List<ReconJob> jobs) { public List<Recon> batchRecon(List<ReconJob> jobs) {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
@Override @Override
public String getBriefDescription(Project project, String columnName) { public String getBriefDescription(Project project, String columnName) {
throw new NotImplementedException(); throw new RuntimeException("Not implemented");
} }
} }

View File

@ -25,9 +25,7 @@ public class SaveProtographOperation extends AbstractOperation {
); );
} }
public SaveProtographOperation( public SaveProtographOperation(Protograph protograph) {
Protograph protograph
) {
_protograph = protograph; _protograph = protograph;
} }
@ -91,18 +89,13 @@ public class SaveProtographOperation extends AbstractOperation {
CharSequence field = line.subSequence(0, equal); CharSequence field = line.subSequence(0, equal);
String value = line.substring(equal + 1); String value = line.substring(equal + 1);
if ("oldProtograph".equals(field)) { if ("oldProtograph".equals(field) && value.length() > 0) {
if (value.length() > 0) {
oldProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value)); oldProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
} } else if ("newProtograph".equals(field) && value.length() > 0) {
} else if ("newProtograph".equals(field)) {
if (value.length() > 0) {
newProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value)); newProtograph = Protograph.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
} }
} }
}
ProtographChange change = new ProtographChange(newProtograph); ProtographChange change = new ProtographChange(newProtograph);
change._oldProtograph = oldProtograph; change._oldProtograph = oldProtograph;

View File

@ -81,8 +81,7 @@ public class Protograph implements Jsonizable {
node = new AnonymousNode(reconstructType(o.getJSONObject("type"))); node = new AnonymousNode(reconstructType(o.getJSONObject("type")));
} }
if (node != null) { if (node != null && node instanceof NodeWithLinks && o.has("links")) {
if (node instanceof NodeWithLinks && o.has("links")) {
NodeWithLinks node2 = (NodeWithLinks) node; NodeWithLinks node2 = (NodeWithLinks) node;
JSONArray links = o.getJSONArray("links"); JSONArray links = o.getJSONArray("links");
@ -97,7 +96,6 @@ public class Protograph implements Jsonizable {
)); ));
} }
} }
}
return node; return node;
} }
@ -123,9 +121,7 @@ public class Protograph implements Jsonizable {
); );
} }
public void write(JSONWriter writer, Properties options) public void write(JSONWriter writer, Properties options) throws JSONException {
throws JSONException {
writer.object(); writer.object();
writer.key("rootNodes"); writer.array(); writer.key("rootNodes"); writer.array();

View File

@ -55,12 +55,11 @@ public class Transposer {
Column column = project.columnModel.getColumnByName(node2.columnName); Column column = project.columnModel.getColumnByName(node2.columnName);
Cell cell = row.getCell(column.getCellIndex()); Cell cell = row.getCell(column.getCellIndex());
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) { if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
if (node2 instanceof CellTopicNode) { if (node2 instanceof CellTopicNode &&
if (!((CellTopicNode) node2).createForNoReconMatch && !((CellTopicNode) node2).createForNoReconMatch &&
(cell.recon == null || cell.recon.judgment == Judgment.None)) { (cell.recon == null || cell.recon.judgment == Judgment.None)) {
return; return;
} }
}
context.count++; context.count++;
if (context.limit > 0 && context.count > context.limit) { if (context.limit > 0 && context.count > context.limit) {

View File

@ -37,7 +37,10 @@ import com.metaweb.util.threads.ThreadPoolExecutorAdapter;
public class Gridworks { public class Gridworks {
static private final String version = "1.0a"; static private final String VERSION = "1.0a";
static private final String DEFAULT_HOST = "127.0.0.1";
static private final int DEFAULT_PORT = 3333;
static private File tempDir; static private File tempDir;
private static Logger root = Logger.getRootLogger(); private static Logger root = Logger.getRootLogger();
@ -64,7 +67,7 @@ public class Gridworks {
} }
public static String getVersion() { public static String getVersion() {
return version; return VERSION;
} }
public static File getTempFile(String name) { public static File getTempFile(String name) {
@ -99,8 +102,8 @@ public class Gridworks {
public void init(String[] args) throws Exception { public void init(String[] args) throws Exception {
int port = Configurations.getInteger("gridworks.port",3333); int port = Configurations.getInteger("gridworks.port",DEFAULT_PORT);
String host = Configurations.get("gridworks.host","127.0.0.1"); String host = Configurations.get("gridworks.host",DEFAULT_HOST);
GridworksServer server = new GridworksServer(); GridworksServer server = new GridworksServer();
server.init(host,port); server.init(host,port);