public Path.Absolute resolvePath(Path path) { return qn.resolve(path); }
public Path.Absolute resolvePath(Path path) { return qn.resolve(path); }
private Properties loadBundle(ProcessingContext context, ElementHandle.Package pkg, String bundleName) { Path.Absolute absolute = pkg.getPackageName().resolve(bundleName + ".properties"); FileObject bundle = context.resolveResourceFromSourcePath(pkg, absolute); if (bundle != null) { try { InputStream in = bundle.openInputStream(); Properties properties = new Properties(); properties.load(in); return properties; } catch (IOException e) { context.log(Level.SEVERE, "Could not load resource bundle", e); } } return null; } // end::loadBundle[]
private Properties loadBundle(ProcessingContext context, ElementHandle.Package pkg, String bundleName) { Path.Absolute absolute = pkg.getPackageName().resolve(bundleName + ".properties"); FileObject bundle = context.resolveResourceFromSourcePath(pkg, absolute); if (bundle != null) { try { InputStream in = bundle.openInputStream(); Properties properties = new Properties(); properties.load(in); return properties; } catch (IOException e) { context.log(Level.SEVERE, "Could not load resource bundle", e); } } return null; } // end::loadBundle[]
public String load(String ref) { try { Path.Absolute path = pkg.resolve(ref); FileObject c = processingContext.resolveResourceFromSourcePath(context, path); if (c != null) { try { return c.getCharContent(true).toString(); } catch (IOException e) { processingContext.info("Could not get content of " + path, e); } } } catch (IllegalArgumentException e) { // Log ? } // return null; } }
public String load(String ref) { try { Path.Absolute path = pkg.resolve(ref); FileObject c = processingContext.resolveResourceFromSourcePath(context, path); if (c != null) { try { return c.getCharContent(true).toString(); } catch (IOException e) { processingContext.info("Could not get content of " + path, e); } } } catch (IllegalArgumentException e) { // Log ? } // return null; } }
Path.Absolute resolved = descriptor.getPackage().resolve(path);
Path.Absolute resolved = descriptor.getPackage().resolve(path);
@Test public void testResolveBug() { Path.Absolute path = (Path.Absolute)Path.parse("/plugin/less/ancestor/assets/folder/stylesheet.less"); Name dirs = path.getDirs(); Path.Absolute resolved = dirs.resolve("../stylesheet.less"); assertEquals(Path.parse("/plugin/less/ancestor/assets/stylesheet.less"), resolved); } }
@Test public void testResolveBug() { Path.Absolute path = (Path.Absolute)Path.parse("/plugin/less/ancestor/assets/folder/stylesheet.less"); Name dirs = path.getDirs(); Path.Absolute resolved = dirs.resolve("../stylesheet.less"); assertEquals(Path.parse("/plugin/less/ancestor/assets/stylesheet.less"), resolved); } }
Path.Absolute to = assetPkg.resolve(path.as("css")); log.info("Resource " + resource + " destination resolved to " + to);
Path.Absolute to = assetPkg.resolve(path.as("css")); log.info("Resource " + resource + " destination resolved to " + to);
@Test public void testResolveDotInRawName() throws Exception { Name name = Name.parse("foo"); Path path = Path.parse("a.b.c"); Path.Absolute file = name.resolve(path); assertEquals("foo", file.getDirs().toString()); assertEquals("a.b.c", file.getSimpleName()); assertEquals("b.c", file.ext); assertEquals("a", file.getRawName()); assertEquals("foo.a", file.getName().toString()); }
@Test public void testResolveUp() throws Exception { Name name = Name.parse("foo.bar"); Path.Absolute file = name.resolve("../juu/daa.txt"); assertEquals("foo.juu", file.getDirs().toString()); assertEquals("daa.txt", file.getSimpleName()); assertEquals("txt", file.getExt()); assertEquals("daa", file.getRawName()); assertEquals("foo.juu.daa", file.getName().toString()); }
@Test public void testResolveUp() throws Exception { Name name = Name.parse("foo.bar"); Path.Absolute file = name.resolve("../juu/daa.txt"); assertEquals("foo.juu", file.getDirs().toString()); assertEquals("daa.txt", file.getSimpleName()); assertEquals("txt", file.getExt()); assertEquals("daa", file.getRawName()); assertEquals("foo.juu.daa", file.getName().toString()); }
@Test public void testResolveDotInRawName() throws Exception { Name name = Name.parse("foo"); Path path = Path.parse("a.b.c"); Path.Absolute file = name.resolve(path); assertEquals("foo", file.getDirs().toString()); assertEquals("a.b.c", file.getSimpleName()); assertEquals("b.c", file.ext); assertEquals("a", file.getRawName()); assertEquals("foo.a", file.getName().toString()); }