From af2015753218af77d331fa5398711d308f09b95a Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Sun, 28 Nov 2010 17:46:57 +0000 Subject: [PATCH] Fix indentation so indent levels match logical block levels. No code changes. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1940 7d457c2a-affb-35e4-300a-418c747d4874 --- .../refine/importers/TreeImportUtilities.java | 198 +++++++++--------- 1 file changed, 97 insertions(+), 101 deletions(-) diff --git a/main/src/com/google/refine/importers/TreeImportUtilities.java b/main/src/com/google/refine/importers/TreeImportUtilities.java index a2a721a97..0c149711b 100644 --- a/main/src/com/google/refine/importers/TreeImportUtilities.java +++ b/main/src/com/google/refine/importers/TreeImportUtilities.java @@ -61,11 +61,7 @@ public abstract class TreeImportUtilities { int count; } - /** - * - * - * - */ + static protected abstract class ImportVertical { public String name = ""; public int nonBlankCount; @@ -134,142 +130,142 @@ public abstract class TreeImportUtilities { static public void createColumnsFromImport( Project project, ImportColumnGroup columnGroup - ) { - int startColumnIndex = project.columnModel.columns.size(); + ) { + int startColumnIndex = project.columnModel.columns.size(); - List columns = new ArrayList(columnGroup.columns.values()); - Collections.sort(columns, new Comparator() { - public int compare(ImportColumn o1, ImportColumn o2) { - if (o1.blankOnFirstRow != o2.blankOnFirstRow) { - return o1.blankOnFirstRow ? 1 : -1; - } - - int c = o2.nonBlankCount - o1.nonBlankCount; - return c != 0 ? c : (o1.name.length() - o2.name.length()); + List columns = new ArrayList(columnGroup.columns.values()); + Collections.sort(columns, new Comparator() { + public int compare(ImportColumn o1, ImportColumn o2) { + if (o1.blankOnFirstRow != o2.blankOnFirstRow) { + return o1.blankOnFirstRow ? 1 : -1; } - }); - for (int i = 0; i < columns.size(); i++) { - ImportColumn c = columns.get(i); - - Column column = new com.google.refine.model.Column(c.cellIndex, c.name); - project.columnModel.columns.add(column); + int c = o2.nonBlankCount - o1.nonBlankCount; + return c != 0 ? c : (o1.name.length() - o2.name.length()); } + }); - List subgroups = new ArrayList(columnGroup.subgroups.values()); - Collections.sort(subgroups, new Comparator() { - public int compare(ImportColumnGroup o1, ImportColumnGroup o2) { - int c = o2.nonBlankCount - o1.nonBlankCount; - return c != 0 ? c : (o1.name.length() - o2.name.length()); - } - }); + for (int i = 0; i < columns.size(); i++) { + ImportColumn c = columns.get(i); - for (ImportColumnGroup g : subgroups) { - createColumnsFromImport(project, g); - } - - int endColumnIndex = project.columnModel.columns.size(); - int span = endColumnIndex - startColumnIndex; - if (span > 1 && span < project.columnModel.columns.size()) { - project.columnModel.addColumnGroup(startColumnIndex, span, startColumnIndex); - } + Column column = new com.google.refine.model.Column(c.cellIndex, c.name); + project.columnModel.columns.add(column); } + List subgroups = new ArrayList(columnGroup.subgroups.values()); + Collections.sort(subgroups, new Comparator() { + public int compare(ImportColumnGroup o1, ImportColumnGroup o2) { + int c = o2.nonBlankCount - o1.nonBlankCount; + return c != 0 ? c : (o1.name.length() - o2.name.length()); + } + }); + + for (ImportColumnGroup g : subgroups) { + createColumnsFromImport(project, g); + } + + int endColumnIndex = project.columnModel.columns.size(); + int span = endColumnIndex - startColumnIndex; + if (span > 1 && span < project.columnModel.columns.size()) { + project.columnModel.addColumnGroup(startColumnIndex, span, startColumnIndex); + } + } + static protected void addCell( Project project, ImportColumnGroup columnGroup, ImportRecord record, String columnLocalName, String text - ) { - if (text == null || ((String) text).isEmpty()) { - return; - } - - Serializable value = ImporterUtilities.parseCellValue(text); - - ImportColumn column = getColumn(project, columnGroup, columnLocalName); - int cellIndex = column.cellIndex; - - int rowIndex = Math.max(columnGroup.nextRowIndex, column.nextRowIndex); - while (rowIndex >= record.rows.size()) { - record.rows.add(new ArrayList()); - } - - List row = record.rows.get(rowIndex); - while (cellIndex >= row.size()) { - row.add(null); - } - - row.set(cellIndex, new Cell(value, null)); - - column.nextRowIndex = rowIndex + 1; - column.nonBlankCount++; + ) { + if (text == null || ((String) text).isEmpty()) { + return; } + Serializable value = ImporterUtilities.parseCellValue(text); + + ImportColumn column = getColumn(project, columnGroup, columnLocalName); + int cellIndex = column.cellIndex; + + int rowIndex = Math.max(columnGroup.nextRowIndex, column.nextRowIndex); + while (rowIndex >= record.rows.size()) { + record.rows.add(new ArrayList()); + } + + List row = record.rows.get(rowIndex); + while (cellIndex >= row.size()) { + row.add(null); + } + + row.set(cellIndex, new Cell(value, null)); + + column.nextRowIndex = rowIndex + 1; + column.nonBlankCount++; + } + static protected ImportColumn getColumn( Project project, ImportColumnGroup columnGroup, String localName - ) { - if (columnGroup.columns.containsKey(localName)) { - return columnGroup.columns.get(localName); - } - - ImportColumn column = createColumn(project, columnGroup, localName); - columnGroup.columns.put(localName, column); - - return column; + ) { + if (columnGroup.columns.containsKey(localName)) { + return columnGroup.columns.get(localName); } - static protected ImportColumn createColumn( + ImportColumn column = createColumn(project, columnGroup, localName); + columnGroup.columns.put(localName, column); + + return column; + } + + static protected ImportColumn createColumn( Project project, ImportColumnGroup columnGroup, String localName - ) { - ImportColumn newColumn = new ImportColumn(); + ) { + ImportColumn newColumn = new ImportColumn(); - newColumn.name = - columnGroup.name.length() == 0 ? + newColumn.name = columnGroup.name.length() == 0 ? (localName == null ? "Text" : localName) : - (localName == null ? columnGroup.name : (columnGroup.name + " - " + localName)); + (localName == null ? columnGroup.name : (columnGroup.name + " - " + localName)); - newColumn.cellIndex = project.columnModel.allocateNewCellIndex(); - newColumn.nextRowIndex = columnGroup.nextRowIndex; + newColumn.cellIndex = project.columnModel.allocateNewCellIndex(); + newColumn.nextRowIndex = columnGroup.nextRowIndex; - return newColumn; - } + return newColumn; + } - static protected ImportColumnGroup getColumnGroup( + static protected ImportColumnGroup getColumnGroup( Project project, ImportColumnGroup columnGroup, String localName - ) { - if (columnGroup.subgroups.containsKey(localName)) { - return columnGroup.subgroups.get(localName); - } - - ImportColumnGroup subgroup = createColumnGroup(project, columnGroup, localName); - columnGroup.subgroups.put(localName, subgroup); - - return subgroup; + ) { + if (columnGroup.subgroups.containsKey(localName)) { + return columnGroup.subgroups.get(localName); } - static protected ImportColumnGroup createColumnGroup( + ImportColumnGroup subgroup = createColumnGroup(project, columnGroup, localName); + columnGroup.subgroups.put(localName, subgroup); + + return subgroup; + } + + static protected ImportColumnGroup createColumnGroup( Project project, ImportColumnGroup columnGroup, String localName - ) { - ImportColumnGroup newGroup = new ImportColumnGroup(); + ) { + ImportColumnGroup newGroup = new ImportColumnGroup(); - newGroup.name = - columnGroup.name.length() == 0 ? - (localName == null ? "Text" : localName) : - (localName == null ? columnGroup.name : (columnGroup.name + " - " + localName)); + newGroup.name = + columnGroup.name.length() == 0 ? + (localName == null ? "Text" : localName) : + (localName == null ? columnGroup.name : (columnGroup.name + " - " + localName)); - newGroup.nextRowIndex = columnGroup.nextRowIndex; + newGroup.nextRowIndex = columnGroup.nextRowIndex; - return newGroup; - } + return newGroup; + } + }