private Path(Name pkg, String rawName, String ext) { this.canonical = null; this.name = pkg.append(rawName); this.ext = ext; }
private Path(Name pkg, String rawName, String ext) { this.canonical = null; this.name = pkg.append(rawName); this.ext = ext; }
/** * Create and return a new name using the suffix argument appended to this name. * * @param suffix the suffix * @return the new name * @throws NullPointerException if the suffix is null */ public Name append(Name suffix) throws NullPointerException { if (suffix == null) { throw new NullPointerException("No null suffix allowed"); } return append(suffix.identifiers, suffix.size); }
/** * Create and return a new name using the suffix argument appended to this name. * * @param suffix the suffix * @return the new name * @throws NullPointerException if the suffix is null */ public Name append(Name suffix) throws NullPointerException { if (suffix == null) { throw new NullPointerException("No null suffix allowed"); } return append(suffix.identifiers, suffix.size); }
/** * Create and return a new name using the suffix argument appended to this name. * * @param identifiers the identifiers suffix * @return the new name * @throws NullPointerException if the suffix is null * @throws IllegalArgumentException if the suffix is not valid */ public Name append(String... identifiers) throws NullPointerException, IllegalArgumentException { if (identifiers == null) { throw new NullPointerException("No null suffix allowed"); } return append(identifiers, identifiers.length); }
/** * Create and return a new name using the suffix argument appended to this name. * * @param identifiers the identifiers suffix * @return the new name * @throws NullPointerException if the suffix is null * @throws IllegalArgumentException if the suffix is not valid */ public Name append(String... identifiers) throws NullPointerException, IllegalArgumentException { if (identifiers == null) { throw new NullPointerException("No null suffix allowed"); } return append(identifiers, identifiers.length); }
@Override protected void postAttach(MetaModelObject parent) { if (parent instanceof ApplicationMetaModel) { this.application = (ApplicationMetaModel)parent; this.qn = application.getName().append(name); this.emitter = createEmitter(); } } }
private void emitPortlet( ProcessingContext env, PackageElement pkgElt, String[] names) throws ProcessingException { Writer writer = null; Name fqn = Name.parse(pkgElt.getQualifiedName()).append(names[0]); try { JavaFileObject file = env.createSourceFile(fqn, pkgElt); writer = file.openWriter(); // writer.append("package ").append(pkgElt.getQualifiedName()).append(";\n"); writer.append("import ").append(Generated.class.getCanonicalName()).append(";\n"); writer.append("@Generated(value={})\n"); writer.append("public class ").append(names[0]).append(" extends juzu.bridge.portlet.JuzuPortlet {\n"); writer.append("@Override\n"); writer.append("protected String getApplicationName(javax.portlet.PortletConfig config) {\n"); writer.append("return \"").append(names[1]).append("\";\n"); writer.append("}\n"); writer.append("}\n"); } catch (IOException e) { throw CANNOT_WRITE_PORTLET_CLASS.failure(e, pkgElt, fqn); } finally { Tools.safeClose(writer); } }
@Override protected void postAttach(MetaModelObject parent) { if (parent instanceof ApplicationMetaModel) { this.application = (ApplicationMetaModel)parent; this.qn = application.getName().append(name); this.emitter = createEmitter(); } } }
private void emitPortlet( ProcessingContext env, PackageElement pkgElt, String[] names) throws ProcessingException { Writer writer = null; Name fqn = Name.parse(pkgElt.getQualifiedName()).append(names[0]); try { JavaFileObject file = env.createSourceFile(fqn, pkgElt); writer = file.openWriter(); // writer.append("package ").append(pkgElt.getQualifiedName()).append(";\n"); writer.append("import ").append(Generated.class.getCanonicalName()).append(";\n"); writer.append("@Generated(value={})\n"); writer.append("public class ").append(names[0]).append(" extends juzu.bridge.portlet.JuzuPortlet {\n"); writer.append("@Override\n"); writer.append("protected String getApplicationName(javax.portlet.PortletConfig config) {\n"); writer.append("return \"").append(names[1]).append("\";\n"); writer.append("}\n"); writer.append("}\n"); } catch (IOException e) { throw CANNOT_WRITE_PORTLET_CLASS.failure(e, pkgElt, fqn); } finally { Tools.safeClose(writer); } }
public GroovyTemplateEmitter(Name name) { if (name != null) { pkg = name.getParent(); String id = "C" + name.getIdentifier(); constants = pkg.append(id); } else { pkg = null; constants = Name.parse("Constants"); } }
/** * Resolve a path with respect to this name and return an absolute path. * * @param path the path * @return the corresponding absolute path */ public Path.Absolute resolve(Path path) { if (path instanceof Path.Absolute) { return (Path.Absolute)path; } else { return Path.absolute(append(path.getName()), path.getExt()); } }
public GroovyTemplateEmitter(Name name) { if (name != null) { pkg = name.getParent(); String id = "C" + name.getIdentifier(); constants = pkg.append(id); } else { pkg = null; constants = Name.parse("Constants"); } }
void emitApplication(ProcessingContext env, ApplicationMetaModel application) throws ProcessingException { PackageElement elt = env.get(application.getHandle()); Name fqn = application.getName().append("Application");
/** * Resolve a path with respect to this name and return an absolute path. * * @param path the path * @return the corresponding absolute path */ public Path.Absolute resolve(Path path) { if (path instanceof Path.Absolute) { return (Path.Absolute)path; } else { return Path.absolute(append(path.getName()), path.getExt()); } }
simpleName = metaModel.getBaseName() + "Servlet"; Name clazz = pkg.getPackageName().append(simpleName); Writer writer = null; try {
@Test public void testAppend() { assertAppend("a.b", "a", "b"); assertAppend("a.b.c", "a.b", "c"); try { Name.parse("a").append(""); fail(); } catch (IllegalArgumentException e) { } try { Name.parse("a").append("a.b"); fail(); } catch (IllegalArgumentException e) { } try { Name.parse("a").append((String)null); fail(); } catch (IllegalArgumentException e) { } try { Name.parse("a").append((String[])null); fail(); } catch (NullPointerException e) { } }
@Test public void testAppend() { assertAppend("a.b", "a", "b"); assertAppend("a.b.c", "a.b", "c"); try { Name.parse("a").append(""); fail(); } catch (IllegalArgumentException e) { } try { Name.parse("a").append("a.b"); fail(); } catch (IllegalArgumentException e) { } try { Name.parse("a").append((String)null); fail(); } catch (IllegalArgumentException e) { } try { Name.parse("a").append((String[])null); fail(); } catch (NullPointerException e) { } }
private void assertAppend(String expected, String qn, String simpleName) { Name parsed = Name.parse(qn); Name appended = parsed.append(simpleName); assertEquals(expected, appended.toString()); assertEquals(appended.size(), parsed.size() + 1); }
private void assertAppend(String expected, String qn, String simpleName) { Name parsed = Name.parse(qn); Name appended = parsed.append(simpleName); assertEquals(expected, appended.toString()); assertEquals(appended.size(), parsed.size() + 1); }