(URI uri, Loader loader)
| 302 | } |
| 303 | |
| 304 | private Optional<String> load(URI uri, Loader loader) throws PersistenceLayerException |
| 305 | { |
| 306 | context.setSourceURI(uri); |
| 307 | context.setExtractURI(uri); |
| 308 | try |
| 309 | { |
| 310 | return LstFileLoader.readFromURI(uri) |
| 311 | .map((String dataBuffer) -> { |
| 312 | StringBuilder resultBuffer = new StringBuilder(dataBuffer.length()); |
| 313 | |
| 314 | String[] fileLines = dataBuffer.split(LstFileLoader.LINE_SEPARATOR_REGEXP); |
| 315 | for (int line = 0; line < fileLines.length; line++) |
| 316 | { |
| 317 | String lineString = fileLines[line]; |
| 318 | if ((lineString.isEmpty()) || (lineString.charAt(0) == LstFileLoader.LINE_COMMENT_CHAR) |
| 319 | || lineString.startsWith("SOURCE")) |
| 320 | { |
| 321 | resultBuffer.append(lineString); |
| 322 | } |
| 323 | else |
| 324 | { |
| 325 | try |
| 326 | { |
| 327 | List<CDOMObject> newObj = loader.process(resultBuffer, line, lineString, decider); |
| 328 | if (newObj != null) |
| 329 | { |
| 330 | for (CDOMObject cdo : newObj) |
| 331 | { |
| 332 | injected.addToListFor(loader, uri, cdo); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | catch (PersistenceLayerException | InterruptedException e) |
| 337 | { |
| 338 | String message = LanguageBundle.getFormattedString("Errors.LstFileLoader.LoadError", //$NON-NLS-1$ |
| 339 | uri, e.getMessage()); |
| 340 | Logging.errorPrint(message, e); |
| 341 | return null; |
| 342 | } |
| 343 | } |
| 344 | resultBuffer.append("\n"); |
| 345 | } |
| 346 | return resultBuffer.toString(); |
| 347 | }); |
| 348 | } |
| 349 | catch (PersistenceLayerException ple) |
| 350 | { |
| 351 | Logging.errorPrint(LanguageBundle.getFormattedString("Errors.LstFileLoader.LoadError", //$NON-NLS-1$ |
| 352 | uri, ple.getMessage())); |
| 353 | return Optional.empty(); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | public Collection<Loader> getInjectedLoaders() |
| 358 | { |
no test coverage detected