public static FileKey newName(String packageName, String name) { int pos = name.indexOf('.'); String rawName; String ext; if (pos == -1) { rawName = name; ext = ""; } else { rawName = name.substring(0, pos); ext = name.substring(pos + 1); } return newName(packageName, rawName, ext); }
public static FileKey newName(String packageName, String name) { int pos = name.indexOf('.'); String rawName; String ext; if (pos == -1) { rawName = name; ext = ""; } else { rawName = name.substring(0, pos); ext = name.substring(pos + 1); } return newName(packageName, rawName, ext); }
public static FileKey newResourceName(String packageName, String name) { FileKey key = newName(packageName, name); if (key.getKind() == JavaFileObject.Kind.OTHER) { return key; } else { throw new IllegalArgumentException(); } }
/** * Resolve a resource from the provided context and path. * * @param context the context of the application that will help to resolve the path source code * @param path the path of the resource to resolve * @return the resolved resource or null if it cannot be determined * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the context package is not valid */ public FileObject resolveResourceFromSourcePath(ElementHandle.Package context, Path.Absolute path) throws NullPointerException, IllegalArgumentException { return resolveResourceFromSourcePath(context, FileKey.newName(path)); }
/** * Resolve a resource from the provided context and path. * * @param context the context of the application that will help to resolve the path source code * @param path the path of the resource to resolve * @return the resolved resource or null if it cannot be determined * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the context package is not valid */ public FileObject resolveResourceFromClassPath(ElementHandle.Package context, Path.Absolute path) throws NullPointerException, IllegalArgumentException { return resolveResourceFromClassPath(context, FileKey.newName(path)); }
/** * Resolve a resource from the provided context and path. * * @param context the context of the application that will help to resolve the path source code * @param path the path of the resource to resolve * @return the resolved resource or null if it cannot be determined * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the context package is not valid */ public FileObject resolveResourceFromSourcePath(ElementHandle.Package context, Path.Absolute path) throws NullPointerException, IllegalArgumentException { return resolveResourceFromSourcePath(context, FileKey.newName(path)); }
public static FileKey newResourceName(String packageName, String rawName, String ext) { FileKey key = newName(packageName, rawName, ext); if (key.getKind() == JavaFileObject.Kind.OTHER) { return key; } else { throw new IllegalArgumentException(); } }
public static FileKey newResourceName(String packageName, String rawName, String ext) { FileKey key = newName(packageName, rawName, ext); if (key.getKind() == JavaFileObject.Kind.OTHER) { return key; } else { throw new IllegalArgumentException(); } }
/** * Resolve a resource from the provided context and path. * * @param context the context of the application that will help to resolve the path source code * @param path the path of the resource to resolve * @return the resolved resource or null if it cannot be determined * @throws NullPointerException if any argument is null * @throws IllegalArgumentException if the context package is not valid */ public FileObject resolveResourceFromClassPath(ElementHandle.Package context, Path.Absolute path) throws NullPointerException, IllegalArgumentException { return resolveResourceFromClassPath(context, FileKey.newName(path)); }
public static FileKey newResourceName(String packageName, String name) { FileKey key = newName(packageName, name); if (key.getKind() == JavaFileObject.Kind.OTHER) { return key; } else { throw new IllegalArgumentException(); } }
private void list( String packageName, P root, Set<JavaFileObject.Kind> kinds, boolean recurse, Collection<JavaFileObject> to) throws IOException { for (Iterator<P> i = fs.getChildren(root);i.hasNext();) { P child = i.next(); if (fs.isDir(child)) { if (recurse) { String name = fs.getName(child); list(packageName.isEmpty() ? name : packageName + "." + name, child, kinds, true, to); } } else { String name = fs.getName(child); FileKey key = FileKey.newName(packageName, name); if (kinds.contains(key.getKind())) { to.add(getReadable(key)); } } } } }
private void list( String packageName, P root, Set<JavaFileObject.Kind> kinds, boolean recurse, Collection<JavaFileObject> to) throws IOException { for (Iterator<P> i = fs.getChildren(root);i.hasNext();) { P child = i.next(); if (fs.isDir(child)) { if (recurse) { String name = fs.getName(child); list(packageName.isEmpty() ? name : packageName + "." + name, child, kinds, true, to); } } else { String name = fs.getName(child); FileKey key = FileKey.newName(packageName, name); if (kinds.contains(key.getKind())) { to.add(getReadable(key)); } } } } }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (count++ == 0) { try { ProcessingContext ctx = new ProcessingContext(processingEnv); ElementHandle.Package pkg = ElementHandle.Package.create(ctx.getPackageElement("compiler.dot.foo")); FileObject file = ctx.resolveResourceFromSourcePath(pkg, FileKey.newName("compiler.dot.foo", "a.b.txt")); InputStream in = file.openInputStream(); FileObject o = ctx.createResource(StandardLocation.CLASS_OUTPUT, FileKey.newName("compiler.dot.foo", "a.b.css")); OutputStream out = o.openOutputStream(); Tools.copy(in, out); Tools.safeClose(in); Tools.safeClose(out); } catch (Exception e) { throw failure(e); } } return true; } });
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (count++ == 0) { try { ProcessingContext ctx = new ProcessingContext(processingEnv); ElementHandle.Package pkg = ElementHandle.Package.create(ctx.getPackageElement("compiler.dot.foo")); FileObject file = ctx.resolveResourceFromSourcePath(pkg, FileKey.newName("compiler.dot.foo", "a.b.txt")); InputStream in = file.openInputStream(); FileObject o = ctx.createResource(StandardLocation.CLASS_OUTPUT, FileKey.newName("compiler.dot.foo", "a.b.css")); OutputStream out = o.openOutputStream(); Tools.copy(in, out); Tools.safeClose(in); Tools.safeClose(out); } catch (Exception e) { throw failure(e); } } return true; } });