(File additions)
| 331 | } |
| 332 | |
| 333 | void read(File additions) { |
| 334 | String[] lines = PApplet.loadStrings(additions); |
| 335 | if (lines == null) { |
| 336 | throw new NullPointerException("File not found:\n" + additions.getAbsolutePath()); |
| 337 | } |
| 338 | //for (String line : lines) { |
| 339 | for (int i = 0; i < lines.length; i++) { |
| 340 | String line = lines[i]; |
| 341 | if ((line.length() == 0) || |
| 342 | (line.charAt(0) == '#')) continue; |
| 343 | |
| 344 | // this won't properly handle = signs inside in the text |
| 345 | int equals = line.indexOf('='); |
| 346 | if (equals != -1) { |
| 347 | String key = line.substring(0, equals).trim(); |
| 348 | String value = line.substring(equals + 1).trim(); |
| 349 | |
| 350 | /* |
| 351 | // Support for backslashes to continue lines... Nah. |
| 352 | while (line.endsWith("\\")) { |
| 353 | // remove the backslash from the previous |
| 354 | value = value.substring(0, value.length() - 1); |
| 355 | // get the next line |
| 356 | line = lines[++i].trim(); |
| 357 | // append the new line to the value (with a space) |
| 358 | // This is imperfect since the prev may end <br> |
| 359 | value += " " + line; |
| 360 | } |
| 361 | */ |
| 362 | |
| 363 | // fix \n and \' |
| 364 | value = value.replaceAll("\\\\n", "\n"); |
| 365 | value = value.replaceAll("\\\\'", "'"); |
| 366 | |
| 367 | table.put(key, value); |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | String getString(String key) { |
| 373 | return table.get(key); |
no test coverage detected