/** * Returns a boolean property. * * @param key * the property key. * * @return the {@link Boolean} from the property or {@code null} if no * property with the key was found. */ public Boolean getBooleanProperty(String key) { String property = getProperty(key); return property == null ? null : parseBoolean(property); }
/** * Returns a File property. * * @param key * the property key. * * @return the {@link File} from the property or {@code null} if no property * with the key was found. */ public File getFileProperty(String key) { String property = getProperty(key); return property == null ? null : new File(property); }
/** * Returns a number property. * * @param key * the property key. * * @return the {@link Number} from the property or {@code null} if no * property with the key was found. */ public Number getNumberProperty(String key) { String property = getProperty(key); return property == null ? null : parseDouble(property); }
/** * Returns a URL property. * * @param key * the property key. * * @return the {@link URL} from the property or {@code null} if no property * with the key was found. * * @throws MalformedURLException * if the property value is not a valid URL. */ public URL getURLProperty(String key) throws MalformedURLException { String property = getProperty(key); return property == null ? null : new URL(property); }
/** * Returns a character property. * * @param key * the property key. * * @return the {@link Character} from the property or {@code null} if no * property with the key was found. * * @throws IndexOutOfBoundsException * if the property is an empty string. */ public Character getCharProperty(String key) { String property = getProperty(key); return property == null ? null : property.charAt(0); }
/** * Returns a URI property. * * @param key * the property key. * * @return the {@link URI} from the property or {@code null} if no property * with the key was found. * * @throws URISyntaxException * if the property value is not a valid URI. */ public URI getURIProperty(String key) throws URISyntaxException { String property = getProperty(key); return property == null ? null : new URI(property); }
/** * Returns a File property. * * @param key * the property key. * * @param defaultValue * the default {@link File}. * * @return the {@link File} from the property or the default value if no * property with the key was found. */ public File getFileProperty(String key, File defaultValue) { String property = getProperty(key); return property == null ? defaultValue : new File(property); }
/** * Returns a character set property. * * @param key * the property key. * * @return the {@link Charset} from the property or {@code null} if no * property with the key was found. * * @throws UnsupportedCharsetException * If no support for the named character set is available in * this instance of the Java virtual machine. */ public Charset getCharsetProperty(String key) { String property = getProperty(key); return property == null ? null : Charset.forName(property); }
/** * Returns a URL property. * * @param key * the property key. * * @param defaultValue * the default {@link URL}. * * @return the {@link URL} from the property or the default value if no * property with the key was found. * * @throws MalformedURLException * if the property value is not a valid URL. */ public URL getURLProperty(String key, URL defaultValue) throws MalformedURLException { String property = getProperty(key); return property == null ? defaultValue : new URL(property); }
/** * Returns a character property. * * @param key * the property key. * * @param defaultValue * the default {@link Character}. * * @return the {@link Character} from the property or the default value if * no property with the key was found. * * @throws IndexOutOfBoundsException * if the property is an empty string. */ public Character getCharProperty(String key, Character defaultValue) { String property = getProperty(key); return property == null ? defaultValue : property.charAt(0); }
/** * Returns a boolean property. * * @param key * the property key. * * @param defaultValue * the default {@link Boolean}. * * @return the {@link Boolean} from the property or the default value if no * property with the key was found. */ public Boolean getBooleanProperty(String key, Boolean defaultValue) { String property = getProperty(key, String.valueOf(defaultValue)); return parseBoolean(property); }
/** * Returns a number property. * * @param key * the property key. * * @param defaultValue * the default {@link Number}. * * @return the {@link Number} from the property or the default value if no * property with the key was found. * * @throws NumberFormatException * if the string does not contain a parseble {@code double}. */ public Number getNumberProperty(String key, Number defaultValue) { String property = getProperty(key, String.valueOf(defaultValue)); return parseDouble(property); }
/** * Returns a character set property. * * @param key * the property key. * * @param defaultValue * the default {@link Charset}. * * @return the {@link Charset} from the property or the default value if no * property with the key was found. * * @throws UnsupportedCharsetException * If no support for the named character set is available in * this instance of the Java virtual machine. */ public Charset getCharsetProperty(String key, Charset defaultValue) { String property = getProperty(key, String.valueOf(defaultValue)); return Charset.forName(property); }
/** * Returns a URI property. * * @param key * the property key. * * @param defaultValue * the default {@link URI}. * * @return the {@link URI} from the property or the default value if no * property with the key was found. * * @throws URISyntaxException * if the property value is not a valid URI. */ public URI getURIProperty(String key, URI defaultValue) throws URISyntaxException { String property = getProperty(key, String.valueOf(defaultValue)); return new URI(property); }
/** * Returns a list property. * * @param key * the property key. * * @param separatorChars * the characters used as the delimiters, {@code null} splits on * whitespace. * * @return the {@link List} from the property or an empty list if no * property with the key was found. */ public List<String> getListProperty(String key, String separatorChars) { String property = getProperty(key); return property == null ? new ArrayList<String>() : asList(split( property, separatorChars)); }
/** * Returns a list property. * * @param key * the property key. * * @param defaultValue * the default {@link List}. * * @param separatorChars * the characters used as the delimiters, {@code null} splits on * whitespace. * * @return the {@link List} from the property or the default value if no * property with the key was found. */ public List<String> getListProperty(String key, List<String> defaultValue, String separatorChars) { String property = getProperty(key, join(defaultValue, ",")); return Arrays.asList(split(property, separatorChars)); }
/** * Returns a property of the specified type. * * @param key * the property key. * * @param defaultValue * the default value. * * @param format * the {@link Format} to parse the type. * * @return the the property or the default value if no property with the key * was found. * * @throws ParseException * if the property cannot be parsed to the type. */ @SuppressWarnings("unchecked") public <T> T getTypedProperty(String key, Format format, T defaultValue) throws ParseException { String property = getProperty(key, String.valueOf(defaultValue)); return property == null ? null : (T) format.parseObject(property); }
List<T> defaultValue, String separatorChars) throws ParseException { List<T> list = new ArrayList<T>(); String property = getProperty(key, join(defaultValue, ",")); for (String value : split(property, listSepChars)) { addParsedObject(list, format, value);
String separatorChars) throws ParseException { List<T> list = new ArrayList<T>(); String property = getProperty(key); if (property == null) { return list;
String separatorChars) throws ParseException { List<T> list = new ArrayList<T>(); String property = getProperty(key, join(defaultValue, ",")); for (String value : split(property, listSepChars)) { list.add(stringToType.stringToType(value));