CPDConfiguration extends AbstractConfiguration { @Deprecated public static Renderer getRendererFromString(String name, String encoding) { String clazzname = name; if (clazzname == null || "".equals(clazzname)) { clazzname = DEFAULT_RENDERER; } @SuppressWarnings("unchecked") Class<? extends Renderer> clazz = (Class<? extends Renderer>) RENDERERS.get(clazzname.toLowerCase(Locale.ROOT)); if (clazz == null) { try { clazz = Class.forName(clazzname).asSubclass(Renderer.class); } catch (ClassNotFoundException e) { System.err.println("Can't find class '" + name + "', defaulting to SimpleRenderer."); clazz = SimpleRenderer.class; } } try { Renderer renderer = clazz.getDeclaredConstructor().newInstance(); setRendererEncoding(renderer, encoding); return renderer; } catch (Exception e) { System.err.println("Couldn't instantiate renderer, defaulting to SimpleRenderer: " + e); return new SimpleRenderer(); } }  @Parameter(names = "--encoding", description = "Character encoding to use when processing files", required = false) void setEncoding(String encoding); SourceCode sourceCodeFor(File file); SourceCode sourceCodeFor(Reader reader, String sourceCodeName); void postContruct(); @Deprecated static Renderer getRendererFromString(String name, String encoding); static CPDRenderer getCPDRendererFromString(String name, String encoding); static String[] getRenderers(); static Language getLanguageFromString(String languageString); static void setSystemProperties(CPDConfiguration configuration); Language getLanguage(); void setLanguage(Language language); int getMinimumTileSize(); void setMinimumTileSize(int minimumTileSize); boolean isSkipDuplicates(); void setSkipDuplicates(boolean skipDuplicates); String getRendererName(); void setRendererName(String rendererName); @Deprecated Renderer getRenderer(); CPDRenderer getCPDRenderer(); Tokenizer tokenizer(); FilenameFilter filenameFilter(); @Deprecated void setRenderer(Renderer renderer); void setCPDRenderer(CPDRenderer renderer); boolean isIgnoreLiterals(); void setIgnoreLiterals(boolean ignoreLiterals); boolean isIgnoreIdentifiers(); void setIgnoreIdentifiers(boolean ignoreIdentifiers); boolean isIgnoreAnnotations(); void setIgnoreAnnotations(boolean ignoreAnnotations); boolean isIgnoreUsings(); void setIgnoreUsings(boolean ignoreUsings); boolean isSkipLexicalErrors(); void setSkipLexicalErrors(boolean skipLexicalErrors); List<File> getFiles(); void setFiles(List<File> files); String getFileListPath(); void setFileListPath(String fileListPath); String getURI(); void setURI(String uri); List<File> getExcludes(); void setExcludes(List<File> excludes); boolean isNonRecursive(); void setNonRecursive(boolean nonRecursive); boolean isHelp(); void setHelp(boolean help); String getEncoding(); boolean isNoSkipBlocks(); void setNoSkipBlocks(boolean noSkipBlocks); String getSkipBlocksPattern(); void setSkipBlocksPattern(String skipBlocksPattern); boolean isFailOnViolation(); void setFailOnViolation(boolean failOnViolation); static final String DEFAULT_LANGUAGE; static final String DEFAULT_RENDERER; }
@Test public void testRenderers() { Map<String, Class<? extends CPDRenderer>> renderersToTest = new HashMap<>(); renderersToTest.put("csv", CSVRenderer.class); renderersToTest.put("xml", XMLRenderer.class); renderersToTest.put("csv_with_linecount_per_file", CSVWithLinecountPerFileRenderer.class); renderersToTest.put("vs", VSRenderer.class); renderersToTest.put("text", SimpleRenderer.class); for (Map.Entry<String, Class<? extends CPDRenderer>> entry : renderersToTest.entrySet()) { Renderer r = CPDConfiguration.getRendererFromString(entry.getKey(), "UTF-8"); Assert.assertNotNull(r); Assert.assertSame(entry.getValue(), r.getClass()); } }