MCPcopy Create free account
hub / github.com/PCGen/pcgen / load

Method load

code/src/java/pcgen/gui2/converter/LSTConverter.java:304–355  ·  view source on GitHub ↗
(URI uri, Loader loader)

Source from the content-addressed store, hash-verified

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 {

Callers 8

startItemMethod · 0.95
JFXPanelFromResourceMethod · 0.45
showAsStageMethod · 0.45
PCGenStatusBarMethod · 0.45
OKCloseButtonBarMethod · 0.45
PCGenPreloaderMethod · 0.45
getStageMethod · 0.45
AboutDialogMethod · 0.45

Calls 12

readFromURIMethod · 0.95
getFormattedStringMethod · 0.95
errorPrintMethod · 0.95
setSourceURIMethod · 0.65
setExtractURIMethod · 0.65
isEmptyMethod · 0.65
processMethod · 0.65
addToListForMethod · 0.65
getMessageMethod · 0.65
toStringMethod · 0.65
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected