List of usage examples for org.apache.commons.lang StringUtils StringUtils
public StringUtils()
StringUtils
instances should NOT be constructed in standard programming.
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate a java source file for the specified interface * description./* w ww .j av a 2 s.com*/ * * @param id interface description, must not be null */ public static void generateSource(final InterfaceDescription id) { if (id == null) { throw new IllegalArgumentException("id must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter(id.getUpper() + ".java"); VelocityContext context = new VelocityContext(); context.put("id", id); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/Interface.wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate an abstract unit test java source file for the specified interface * description./*from ww w.j a va 2 s. co m*/ * * @param id interface description, must not be null */ public static void generateAbstractUnitTest(final InterfaceDescription id) { if (id == null) { throw new IllegalArgumentException("id must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter("Abstract" + id.getUpper() + "Test.java"); VelocityContext context = new VelocityContext(); context.put("id", id); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/AbstractInterfaceTest.wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate a java source file for the specified class * description and style./* w ww . ja va2 s .c o m*/ * * @param cd class description, must not be null * @param style style, must not be null */ public static void generateSource(final ClassDescription cd, final Style style) { if (cd == null) { throw new IllegalArgumentException("cd must not be null"); } if (style == null) { throw new IllegalArgumentException("style must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter(cd.getUpper() + ".java"); VelocityContext context = new VelocityContext(); context.put("cd", cd); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/" + style + ".wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate a java source file for a fluent builder API for the specified class * description and style./*from w w w .j a va 2 s . com*/ * * @param cd class description, must not be null * @param style style, must not be null */ public static void generateBuilderSource(final ClassDescription cd, final Style style) { // TODO: perhaps style doesn't matter here, if all the templates are the same if (cd == null) { throw new IllegalArgumentException("cd must not be null"); } if (style == null) { throw new IllegalArgumentException("style must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter(cd.getUpper() + "Builder.java"); VelocityContext context = new VelocityContext(); context.put("cd", cd); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/" + style + "Builder.wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate a unit test source file for the specified class * description and style.//w w w.j a v a2s . c om * * @param cd class description, must not be null * @param style style, must not be null */ public static void generateUnitTest(final ClassDescription cd, final Style style) { if (cd == null) { throw new IllegalArgumentException("cd must not be null"); } if (style == null) { throw new IllegalArgumentException("style must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter(cd.getUpper() + "Test.java"); VelocityContext context = new VelocityContext(); context.put("cd", cd); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/" + style + "Test.wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate an enum source file for the specified class description. * * @param cd class description, must not be null *///from w w w .j a va2 s. com public static void generateEnum(final ClassDescription cd) { if (cd == null) { throw new IllegalArgumentException("cd must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter(cd.getUpper() + ".java"); VelocityContext context = new VelocityContext(); context.put("cd", cd); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/Enum.wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }
From source file:org.dishevelled.codegen.Codegen.java
/** * Generate an enum with lookup source file for the specified class description. * * @param cd class description, must not be null *//*from ww w. jav a 2 s . co m*/ public static void generateEnumWithLookup(final ClassDescription cd) { if (cd == null) { throw new IllegalArgumentException("cd must not be null"); } FileWriter fw = null; try { Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(p); fw = new FileWriter(cd.getUpper() + ".java"); VelocityContext context = new VelocityContext(); context.put("cd", cd); context.put("CodegenUtils", new CodegenUtils()); context.put("StringUtils", new StringUtils()); Template template = Velocity.getTemplate("org/dishevelled/codegen/EnumWithLookup.wm"); template.merge(context, fw); } catch (Exception e) { e.printStackTrace(); System.exit(1); } finally { try { fw.close(); } catch (Exception e) { // empty } } }