/** * Validate against DISALLOWED Properties. * * @param conf : configuration to check. * @throws CommandException */ public static void checkDisallowedProperties(Configuration conf, Set<String> set) throws CommandException { ParamChecker.notNull(conf, "conf"); for (String prop : set) { if (conf.get(prop) != null) { throw new CommandException(ErrorCode.E0808, prop); } } }
public static String propertiesToString(Properties props) { ParamChecker.notNull(props, "props"); try { StringWriter sw = new StringWriter(); props.store(sw, ""); sw.close(); return sw.toString(); } catch (IOException ex) { throw new RuntimeException(ex); } }
public static Properties stringToProperties(String str) { ParamChecker.notNull(str, "str"); try { StringReader sr = new StringReader(str); Properties props = new Properties(); props.load(sr); sr.close(); return props; } catch (IOException ex) { throw new RuntimeException(ex); } }
/** * Create a set from an array * * @param properties String array * @param set String set */ public static void createPropertySet(String[] properties, Set<String> set) { ParamChecker.notNull(set, "set"); for (String p : properties) { set.add(p); } }