/** * Create a new FLint object, adding an instance of all formats to the format list for use by * check() * * <p>This constructor can overwrite default policy properties for each available format if the * supplied map contains a key with its name. * * @param policyMap the map to use for overriding defaults * @throws InstantiationException * @throws IllegalAccessException */ public Flint(Map<String, Set<String>> policyMap) throws InstantiationException, IllegalAccessException { formats = getAvailableFormats().values(); for (Format f : formats) { if (f instanceof PolicyAware) { ((PolicyAware) f).setPatternFilter(policyMap.get(f.getFormatName())); } } }
/** * Create a new FLint object, adding an instance of all formats to the format list for use by * check() * * <p>This constructor can overwrite default policy properties if there are property files in the * specified `policyDir` that match the formats' file type. * * @param policyDir directory containing policy files ("formatName-policy.properties") * @throws IllegalAccessException * @throws InstantiationException * @throws IOException */ public Flint(File policyDir) throws IllegalAccessException, InstantiationException, IOException { formats = getAvailableFormats().values(); for (Format f : formats) { if (f instanceof PolicyAware) { final String formatName = f.getFormatName(); File[] propsFiles = policyDir.listFiles( new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(formatName + "-policy.properties"); } }); if (propsFiles.length == 1) { ((PolicyAware) f).setPatternFilter(propsFiles[0].getAbsolutePath()); gLogger.info("found and set a custom policy for {}", f); gLogger.debug("the policy should be: {}", propsFiles[0].getAbsolutePath()); } } } }