public static Path parse(String path) throws NullPointerException, IllegalArgumentException { boolean absolute = path.length() > 0 && path.charAt(0) == '/'; String[] atoms = Lexers.parsePath(Lexers.PARSE_CANONICAL, EMPTY_STRING_ARRAY, 0, path, 0); if (absolute) { return new Absolute(new Name(atoms, atoms.length - 1), atoms[atoms.length - 1]); } else { return new Relative(new Name(atoms, atoms.length - 1), atoms[atoms.length - 1]); } }
public TemplatesDescriptor( ApplicationDescriptor application, ClassLoader loader, JSON config) throws Exception { ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>(); List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>(); // String packageName = config.getString("package"); Name pkg = Name.parse(packageName); // Load templates for (String fqn : config.getList("templates", String.class)) { Class<?> clazz = loader.loadClass(fqn); Field f = clazz.getField("DESCRIPTOR"); TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null); templates.add(descriptor); juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath()); Path qualifier; if (pkg.isPrefix(path.getName())) { juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt()); qualifier = new PathLiteral(relativePath.getCanonical()); } else { qualifier = new PathLiteral(path.getCanonical()); } beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType())); } // this.templates = templates; this.pkg = pkg; this.beans = beans; }
public TemplatesDescriptor( ApplicationDescriptor application, ClassLoader loader, JSON config) throws Exception { ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>(); List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>(); // String packageName = config.getString("package"); Name pkg = Name.parse(packageName); // Load templates for (String fqn : config.getList("templates", String.class)) { Class<?> clazz = loader.loadClass(fqn); Field f = clazz.getField("DESCRIPTOR"); TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null); templates.add(descriptor); juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath()); Path qualifier; if (pkg.isPrefix(path.getName())) { juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt()); qualifier = new PathLiteral(relativePath.getCanonical()); } else { qualifier = new PathLiteral(path.getCanonical()); } beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType())); } // this.templates = templates; this.pkg = pkg; this.beans = beans; }
public static Relative relative(Name qn, String rawName, String ext) { return new Relative(qn, rawName, ext); }
public static Relative relative(Name name, String ext) { return new Relative(name, ext); }
@Override protected Relative create(Name name, String ext) { return new Relative(name, ext); }
@Override protected Relative create(Name name, String ext) { return new Relative(name, ext); }
public static Relative relative(Name qn, String rawName, String ext) { return new Relative(qn, rawName, ext); }
public static Relative relative(Name name, String ext) { return new Relative(name, ext); }
public static Path parse(String path) throws NullPointerException, IllegalArgumentException { boolean absolute = path.length() > 0 && path.charAt(0) == '/'; String[] atoms = Lexers.parsePath(Lexers.PARSE_CANONICAL, EMPTY_STRING_ARRAY, 0, path, 0); if (absolute) { return new Absolute(new Name(atoms, atoms.length - 1), atoms[atoms.length - 1]); } else { return new Relative(new Name(atoms, atoms.length - 1), atoms[atoms.length - 1]); } }