@Test public void buildSourceCode() throws IOException { final CodeSnippet snippet = new CodeSnippet(); snippet.getProperties().put(CLASS_NAME_PROPERTY, "TestJava"); snippet.getProperties().put(IMPORTS_PROPERTY, "import mypackage\nmysecondpackage"); snippet.getProperties().put(WRAP_IN_MAIN_PROPERTY, "true"); snippet.setCode("System.out.println(\"Hello\");"); final String expected = IOUtils.read(JavaSnippetExecutorTest.class.getResourceAsStream("/com/twasyl/slideshowfx/snippet/executor/java/buildSourceCode_expected.txt")); assertEquals(expected, snippetExecutor.buildSourceCode(snippet)); }
protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } sourceCode.append(getStartClassDefinition(codeSnippet)).append("\n"); if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("\tpublic static void main(String ... args) {\n") .append(codeSnippet.getCode()) .append("\n\t}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n}"); return sourceCode.toString(); }
JavaSnippetExecutor extends AbstractSnippetExecutor<JavaSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } sourceCode.append(getStartClassDefinition(codeSnippet)).append("\n"); if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("\tpublic static void main(String ... args) {\n") .append(codeSnippet.getCode()) .append("\n\t}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n}"); return sourceCode.toString(); } }
JavaSnippetExecutor extends AbstractSnippetExecutor<JavaSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } sourceCode.append(getStartClassDefinition(codeSnippet)).append("\n"); if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("\tpublic static void main(String ... args) {\n") .append(codeSnippet.getCode()) .append("\n\t}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n}"); return sourceCode.toString(); } JavaSnippetExecutor(); }
JavaSnippetExecutor extends AbstractSnippetExecutor<JavaSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } sourceCode.append(getStartClassDefinition(codeSnippet)).append("\n"); if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("\tpublic static void main(String ... args) {\n") .append(codeSnippet.getCode()) .append("\n\t}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n}"); return sourceCode.toString(); } JavaSnippetExecutor(); @Override Parent getUI(final CodeSnippet codeSnippet); @Override Node getConfigurationUI(); @Override void saveNewOptions(); @Override ObservableList<String> execute(final CodeSnippet codeSnippet); }
JavaSnippetExecutor extends AbstractSnippetExecutor<JavaSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } sourceCode.append(getStartClassDefinition(codeSnippet)).append("\n"); if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("\tpublic static void main(String ... args) {\n") .append(codeSnippet.getCode()) .append("\n\t}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n}"); return sourceCode.toString(); } JavaSnippetExecutor(); @Override Parent getUI(final CodeSnippet codeSnippet); @Override Node getConfigurationUI(); @Override void saveNewOptions(); @Override ObservableList<String> execute(final CodeSnippet codeSnippet);  }