From 42eef2f0804100728451afcc085f0940cbbc44c4 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 17 Nov 2019 11:29:05 +0100 Subject: Cleanup whitespace --- .../pl/edu/mimuw/cloudatlas/interpreter/Table.java | 134 ++++++++++----------- 1 file changed, 67 insertions(+), 67 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java index 9f2e1d9..c120171 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Table.java @@ -44,80 +44,80 @@ import pl.edu.mimuw.cloudatlas.model.ValueNull; import pl.edu.mimuw.cloudatlas.model.ZMI; public class Table implements Iterable { - private final List columns = new ArrayList(); - private final Map headersMap = new HashMap(); - private final List rows = new ArrayList(); + private final List columns = new ArrayList(); + private final Map headersMap = new HashMap(); + private final List rows = new ArrayList(); - // creates whole table based on a given ZMI - public Table(ZMI zmi) { - Set allColumns = new HashSet(); - for(ZMI z : zmi.getSons()) - for(Entry e : z.getAttributes()) - allColumns.add(e.getKey().getName()); + // creates whole table based on a given ZMI + public Table(ZMI zmi) { + Set allColumns = new HashSet(); + for(ZMI z : zmi.getSons()) + for(Entry e : z.getAttributes()) + allColumns.add(e.getKey().getName()); - columns.addAll(allColumns); - int i = 0; - for(String c : columns) - headersMap.put(c, i++); - for(ZMI z : zmi.getSons()) { - Value[] row = new Value[columns.size()]; - for(int j = 0; j < row.length; ++j) - row[j] = ValueNull.getInstance(); - for(Entry e : z.getAttributes()) - row[getColumnIndex(e.getKey().getName())] = e.getValue(); - appendRow(new TableRow(row)); - } - } + columns.addAll(allColumns); + int i = 0; + for(String c : columns) + headersMap.put(c, i++); + for(ZMI z : zmi.getSons()) { + Value[] row = new Value[columns.size()]; + for(int j = 0; j < row.length; ++j) + row[j] = ValueNull.getInstance(); + for(Entry e : z.getAttributes()) + row[getColumnIndex(e.getKey().getName())] = e.getValue(); + appendRow(new TableRow(row)); + } + } - // creates an empty table with same columns as given - public Table(Table table) { - this.columns.addAll(table.columns); - this.headersMap.putAll(table.headersMap); - } + // creates an empty table with same columns as given + public Table(Table table) { + this.columns.addAll(table.columns); + this.headersMap.putAll(table.headersMap); + } - public List getColumns() { - return Collections.unmodifiableList(columns); - } + public List getColumns() { + return Collections.unmodifiableList(columns); + } - public void appendRow(TableRow row) { - if(row.getSize() != columns.size()) - throw new InternalInterpreterException("Cannot append row. Length expected: " + columns.size() + ", got: " - + row.getSize() + "."); - rows.add(row); - } + public void appendRow(TableRow row) { + if(row.getSize() != columns.size()) + throw new InternalInterpreterException("Cannot append row. Length expected: " + columns.size() + ", got: " + + row.getSize() + "."); + rows.add(row); + } - public int getColumnIndex(String column) { - try { - return headersMap.get(column).intValue(); - } catch(NullPointerException exception) { - throw new NoSuchAttributeException(column); - } - } + public int getColumnIndex(String column) { + try { + return headersMap.get(column).intValue(); + } catch(NullPointerException exception) { + throw new NoSuchAttributeException(column); + } + } - public ValueList getColumn(String column) { - if(column.startsWith("&")) { - throw new NoSuchAttributeException(column); - } - try { - int position = headersMap.get(column); - List result = new ArrayList(); - for(TableRow row : rows) { - Value v = row.getIth(position); - result.add(v); - } - Type elementType = TypeCollection.computeElementType(result); - return new ValueList(result, elementType); - } catch(NullPointerException exception) { - throw new NoSuchAttributeException(column); - } - } + public ValueList getColumn(String column) { + if(column.startsWith("&")) { + throw new NoSuchAttributeException(column); + } + try { + int position = headersMap.get(column); + List result = new ArrayList(); + for(TableRow row : rows) { + Value v = row.getIth(position); + result.add(v); + } + Type elementType = TypeCollection.computeElementType(result); + return new ValueList(result, elementType); + } catch(NullPointerException exception) { + throw new NoSuchAttributeException(column); + } + } - @Override - public Iterator iterator() { - return rows.iterator(); - } + @Override + public Iterator iterator() { + return rows.iterator(); + } - public void sort(Comparator comparator) { - Collections.sort(rows, comparator); - } + public void sort(Comparator comparator) { + Collections.sort(rows, comparator); + } } -- cgit v1.2.3