(OutputStream os)
| 1609 | |
| 1610 | |
| 1611 | protected void saveBinary(OutputStream os) throws IOException { |
| 1612 | DataOutputStream output = new DataOutputStream(new BufferedOutputStream(os)); |
| 1613 | output.writeInt(0x9007AB1E); // version |
| 1614 | output.writeInt(getRowCount()); |
| 1615 | output.writeInt(getColumnCount()); |
| 1616 | if (columnTitles != null) { |
| 1617 | output.writeBoolean(true); |
| 1618 | for (String title : columnTitles) { |
| 1619 | output.writeUTF(title); |
| 1620 | } |
| 1621 | } else { |
| 1622 | output.writeBoolean(false); |
| 1623 | } |
| 1624 | for (int i = 0; i < getColumnCount(); i++) { |
| 1625 | //System.out.println(i + " is " + columnTypes[i]); |
| 1626 | output.writeInt(columnTypes[i]); |
| 1627 | } |
| 1628 | |
| 1629 | for (int i = 0; i < getColumnCount(); i++) { |
| 1630 | if (columnTypes[i] == CATEGORY) { |
| 1631 | columnCategories[i].write(output); |
| 1632 | } |
| 1633 | } |
| 1634 | if (missingString == null) { |
| 1635 | output.writeBoolean(false); |
| 1636 | } else { |
| 1637 | output.writeBoolean(true); |
| 1638 | output.writeUTF(missingString); |
| 1639 | } |
| 1640 | output.writeInt(missingInt); |
| 1641 | output.writeLong(missingLong); |
| 1642 | output.writeFloat(missingFloat); |
| 1643 | output.writeDouble(missingDouble); |
| 1644 | output.writeInt(missingCategory); |
| 1645 | |
| 1646 | for (TableRow row : rows()) { |
| 1647 | for (int col = 0; col < getColumnCount(); col++) { |
| 1648 | switch (columnTypes[col]) { |
| 1649 | case STRING: |
| 1650 | String str = row.getString(col); |
| 1651 | if (str == null) { |
| 1652 | output.writeBoolean(false); |
| 1653 | } else { |
| 1654 | output.writeBoolean(true); |
| 1655 | output.writeUTF(str); |
| 1656 | } |
| 1657 | break; |
| 1658 | case INT: |
| 1659 | output.writeInt(row.getInt(col)); |
| 1660 | break; |
| 1661 | case LONG: |
| 1662 | output.writeLong(row.getLong(col)); |
| 1663 | break; |
| 1664 | case FLOAT: |
| 1665 | output.writeFloat(row.getFloat(col)); |
| 1666 | break; |
| 1667 | case DOUBLE: |
| 1668 | output.writeDouble(row.getDouble(col)); |
no test coverage detected