Returns the contents of a property resource. @param name name of the property resource @return property map
(final String name)
| 330 | * @return property map |
| 331 | */ |
| 332 | public static TokenObjectMap<byte[]> properties(final String name) { |
| 333 | final InputStream is = Util.class.getResourceAsStream('/' + name); |
| 334 | if(is == null) throw notExpected("%: Property resource missing.", name); |
| 335 | |
| 336 | final TokenObjectMap<byte[]> map = new TokenObjectMap<>(); |
| 337 | try(NewlineInput nli = new NewlineInput(is)) { |
| 338 | for(String line; (line = nli.readLine()) != null;) { |
| 339 | final int s = line.indexOf('='); |
| 340 | if(s == -1 || Strings.startsWith(line, '#')) continue; |
| 341 | final byte[] key = token(line.substring(0, s).trim()); |
| 342 | if(map.contains(key)) throw notExpected("%: '%' is declared twice.", name, key); |
| 343 | map.put(key, token(line.substring(s + 1).trim().replace("\\t", "\t").replace("\\n", "\n"))); |
| 344 | } |
| 345 | } catch(final IOException ex) { |
| 346 | throw notExpected("%: %", name, ex); |
| 347 | } |
| 348 | return map; |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * Checks if long values are small enough to be multiplied without overflow. |
no test coverage detected