(DataOutputStream output, String[] pieces)
| 4813 | |
| 4814 | |
| 4815 | protected void convertRow(DataOutputStream output, String[] pieces) throws IOException { |
| 4816 | if (pieces.length > getColumnCount()) { |
| 4817 | throw new IllegalArgumentException("Row with too many columns: " + |
| 4818 | PApplet.join(pieces, ",")); |
| 4819 | } |
| 4820 | // pieces.length may be less than columns.length, so loop over pieces |
| 4821 | for (int col = 0; col < pieces.length; col++) { |
| 4822 | switch (columnTypes[col]) { |
| 4823 | case STRING: |
| 4824 | output.writeUTF(pieces[col]); |
| 4825 | break; |
| 4826 | case INT: |
| 4827 | output.writeInt(PApplet.parseInt(pieces[col], missingInt)); |
| 4828 | break; |
| 4829 | case LONG: |
| 4830 | try { |
| 4831 | output.writeLong(Long.parseLong(pieces[col])); |
| 4832 | } catch (NumberFormatException nfe) { |
| 4833 | output.writeLong(missingLong); |
| 4834 | } |
| 4835 | break; |
| 4836 | case FLOAT: |
| 4837 | output.writeFloat(PApplet.parseFloat(pieces[col], missingFloat)); |
| 4838 | break; |
| 4839 | case DOUBLE: |
| 4840 | try { |
| 4841 | output.writeDouble(Double.parseDouble(pieces[col])); |
| 4842 | } catch (NumberFormatException nfe) { |
| 4843 | output.writeDouble(missingDouble); |
| 4844 | } |
| 4845 | break; |
| 4846 | case CATEGORY: |
| 4847 | String peace = pieces[col]; |
| 4848 | if (peace.equals(missingString)) { |
| 4849 | output.writeInt(missingCategory); |
| 4850 | } else { |
| 4851 | output.writeInt(columnCategories[col].index(peace)); |
| 4852 | } |
| 4853 | break; |
| 4854 | } |
| 4855 | } |
| 4856 | for (int col = pieces.length; col < getColumnCount(); col++) { |
| 4857 | switch (columnTypes[col]) { |
| 4858 | case STRING: |
| 4859 | output.writeUTF(""); |
| 4860 | break; |
| 4861 | case INT: |
| 4862 | output.writeInt(missingInt); |
| 4863 | break; |
| 4864 | case LONG: |
| 4865 | output.writeLong(missingLong); |
| 4866 | break; |
| 4867 | case FLOAT: |
| 4868 | output.writeFloat(missingFloat); |
| 4869 | break; |
| 4870 | case DOUBLE: |
| 4871 | output.writeDouble(missingDouble); |
| 4872 | break; |
no test coverage detected