(InputStream is)
| 1685 | |
| 1686 | |
| 1687 | protected void loadBinary(InputStream is) throws IOException { |
| 1688 | DataInputStream input = new DataInputStream(new BufferedInputStream(is)); |
| 1689 | |
| 1690 | int magic = input.readInt(); |
| 1691 | if (magic != 0x9007AB1E) { |
| 1692 | throw new IOException("Not a compatible binary table (magic was " + PApplet.hex(magic) + ")"); |
| 1693 | } |
| 1694 | int rowCount = input.readInt(); |
| 1695 | setRowCount(rowCount); |
| 1696 | int columnCount = input.readInt(); |
| 1697 | setColumnCount(columnCount); |
| 1698 | |
| 1699 | boolean hasTitles = input.readBoolean(); |
| 1700 | if (hasTitles) { |
| 1701 | columnTitles = new String[getColumnCount()]; |
| 1702 | for (int i = 0; i < columnCount; i++) { |
| 1703 | //columnTitles[i] = input.readUTF(); |
| 1704 | setColumnTitle(i, input.readUTF()); |
| 1705 | } |
| 1706 | } |
| 1707 | for (int column = 0; column < columnCount; column++) { |
| 1708 | int newType = input.readInt(); |
| 1709 | columnTypes[column] = newType; |
| 1710 | switch (newType) { |
| 1711 | case INT: |
| 1712 | columns[column] = new int[rowCount]; |
| 1713 | break; |
| 1714 | case LONG: |
| 1715 | columns[column] = new long[rowCount];; |
| 1716 | break; |
| 1717 | case FLOAT: |
| 1718 | columns[column] = new float[rowCount];; |
| 1719 | break; |
| 1720 | case DOUBLE: |
| 1721 | columns[column] = new double[rowCount];; |
| 1722 | break; |
| 1723 | case STRING: |
| 1724 | columns[column] = new String[rowCount];; |
| 1725 | break; |
| 1726 | case CATEGORY: |
| 1727 | columns[column] = new int[rowCount];; |
| 1728 | break; |
| 1729 | default: |
| 1730 | throw new IllegalArgumentException(newType + " is not a valid column type."); |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | for (int i = 0; i < columnCount; i++) { |
| 1735 | if (columnTypes[i] == CATEGORY) { |
| 1736 | columnCategories[i] = new HashMapBlows(input); |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | if (input.readBoolean()) { |
| 1741 | missingString = input.readUTF(); |
| 1742 | } else { |
| 1743 | missingString = null; |
| 1744 | } |
no test coverage detected