(InputStream input, String options)
| 325 | |
| 326 | |
| 327 | protected void parse(InputStream input, String options) throws IOException { |
| 328 | // boolean awfulCSV = false; |
| 329 | boolean header = false; |
| 330 | String extension = null; |
| 331 | boolean binary = false; |
| 332 | String encoding = "UTF-8"; |
| 333 | |
| 334 | String worksheet = null; |
| 335 | final String sheetParam = "worksheet="; |
| 336 | |
| 337 | String[] opts = null; |
| 338 | if (options != null) { |
| 339 | opts = PApplet.trim(PApplet.split(options, ',')); |
| 340 | for (String opt : opts) { |
| 341 | if (opt.equals("tsv")) { |
| 342 | extension = "tsv"; |
| 343 | } else if (opt.equals("csv")) { |
| 344 | extension = "csv"; |
| 345 | } else if (opt.equals("ods")) { |
| 346 | extension = "ods"; |
| 347 | } else if (opt.equals("newlines")) { |
| 348 | //awfulCSV = true; |
| 349 | //extension = "csv"; |
| 350 | throw new IllegalArgumentException("The 'newlines' option is no longer necessary."); |
| 351 | } else if (opt.equals("bin")) { |
| 352 | binary = true; |
| 353 | extension = "bin"; |
| 354 | } else if (opt.equals("header")) { |
| 355 | header = true; |
| 356 | } else if (opt.startsWith(sheetParam)) { |
| 357 | worksheet = opt.substring(sheetParam.length()); |
| 358 | } else if (opt.startsWith("dictionary=")) { |
| 359 | // ignore option, this is only handled by PApplet |
| 360 | } else if (opt.startsWith("encoding=")) { |
| 361 | encoding = opt.substring(9); |
| 362 | } else { |
| 363 | throw new IllegalArgumentException("'" + opt + "' is not a valid option for loading a Table"); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | if (extension == null) { |
| 369 | throw new IllegalArgumentException("No extension specified for this Table"); |
| 370 | } |
| 371 | |
| 372 | if (binary) { |
| 373 | loadBinary(input); |
| 374 | |
| 375 | } else if (extension.equals("ods")) { |
| 376 | odsParse(input, worksheet, header); |
| 377 | |
| 378 | } else { |
| 379 | InputStreamReader isr = new InputStreamReader(input, encoding); |
| 380 | BufferedReader reader = new BufferedReader(isr); |
| 381 | |
| 382 | // strip out the Unicode BOM, if present |
| 383 | reader.mark(1); |
| 384 | int c = reader.read(); |
no test coverage detected