MCPcopy Create free account
hub / github.com/jOOQ/jOOQ / load

Method load

jOOQ/src/main/java/org/jooq/FilePattern.java:255–314  ·  view source on GitHub ↗

Load a set of Source items from this pattern. @throws IOException if something goes wrong while loading file contents.

(Consumer<Source> loader)

Source from the content-addressed store, hash-verified

253 * @throws IOException if something goes wrong while loading file contents.
254 */
255 public final void load(Consumer<Source> loader) {
256 boolean loaded = false;
257 URL url = null;
258
259 try {
260 url = FilePattern.class.getResource(pattern);
261 }
262
263 // [#10143] Starting with Java 7, and especially when running on the module path,
264 // there could be an InvalidPathException here.
265 catch (Exception ignore) {}
266
267 File file = null;
268
269 try {
270 if (url != null) {
271 log.info("Reading from classpath: " + pattern);
272
273 // [#11637] Avoid working with File to support classpath resources
274 // inside of nested jar files.
275 try (InputStream is = FilePattern.class.getResourceAsStream(pattern)) {
276
277 // Cannot accept a Source based on an InputStream if using FilePattern::collect
278 loader.accept(Source.of(Source.of(is).readString()));
279 loaded = true;
280 }
281 }
282 else {
283 file = new File(pattern);
284
285 if (file.exists()) {
286 load(file, comparator, null, loader);
287 loaded = true;
288 }
289 else if (!pattern.contains("*") && !pattern.contains("?")) {
290 load(new File(basedir, pattern), comparator, null, loader);
291 loaded = true;
292 }
293 else {
294
295 // [#9726] The wildcard could be in the middle of a path segment, which
296 // has to be ignored, e.g. the prefix of a/b*/c is a/
297 String prefix = pattern.replaceAll("[^\\/]*?[*?].*", "");
298 file = new File(prefix);
299
300 if (!file.isAbsolute())
301 file = new File(basedir, prefix).getAbsoluteFile();
302
303 load(file, comparator, regexForLoad, loader);
304 loaded = true;
305 }
306 }
307 }
308 catch (java.io.IOException e) {
309 throw new IOException("Error while loading pattern", e);
310 }
311
312 if (!loaded)

Callers 1

collectMethod · 0.95

Calls 15

ofMethod · 0.95
load0Method · 0.95
readStringMethod · 0.80
matcherMethod · 0.80
infoMethod · 0.65
acceptMethod · 0.65
existsMethod · 0.65
containsMethod · 0.65
errorMethod · 0.65
replaceMethod · 0.65
isDebugEnabledMethod · 0.65
debugMethod · 0.65

Tested by

no test coverage detected