public String getString(String key, String defaultValue) { String value = getString(key); if (value != null) { return value; } else { return defaultValue; } }
public AquariusProperties(String path, String stringEncoding, String readerEncoding) throws IOException { this(new AquariusContent(path, stringEncoding).getContent(), readerEncoding); }
public void mergeProperties(AquariusProperties properties) { map.putAll(properties.getMap()); }
public AquariusProperties(String path, String stringEncoding, String readerEncoding) throws IOException { this(new AquariusContent(path, stringEncoding).getContent(), readerEncoding); }
public String getString(String key, String defaultValue) { String value = getString(key); if (value != null) { return value; } else { return defaultValue; } }
public void mergeProperties(AquariusProperties properties) { map.putAll(properties.getMap()); }
public static Config createJsonFileConfig(String jsonConfigPath) throws IOException { LOG.info("Start to read {}...", jsonConfigPath); AquariusContent content = new AquariusContent(jsonConfigPath, AquariusConstant.ENCODING_UTF_8); return createJsonConfig(content.getContent()); }
public float getFloat(String key, float defaultValue) { String value = getString(key); if (value != null) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to float", e); } } else { return defaultValue; } }
public static Config createJsonFileConfig(String jsonConfigPath) throws IOException { LOG.info("Start to read {}...", jsonConfigPath); AquariusContent content = new AquariusContent(jsonConfigPath, AquariusConstant.ENCODING_UTF_8); return createJsonConfig(content.getContent()); }
public float getFloat(String key, float defaultValue) { String value = getString(key); if (value != null) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to float", e); } } else { return defaultValue; } }
public int getInteger(String key, int defaultValue) { String value = getString(key); if (value != null) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to int", e); } } else { return defaultValue; } }
public long getLong(String key, long defaultValue) { String value = getString(key); if (value != null) { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to long", e); } } else { return defaultValue; } }
public Short getShort(String key, Short defaultValue) { String value = getString(key); if (value != null) { try { return Short.parseShort(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to short", e); } } else { return defaultValue; } }
public byte getByte(String key, byte defaultValue) { String value = getString(key); if (value != null) { try { return Byte.parseByte(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to byte", e); } } else { return defaultValue; } }
public float getFloat(String key) { String value = getString(key); if (value != null) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to float", e); } } else { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] is null"); } }
public boolean getBoolean(String key) { String value = getString(key); if (value != null) { try { return Boolean.parseBoolean(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to boolean", e); } } else { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] is null"); } }
public long getLong(String key) { String value = getString(key); if (value != null) { try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to long", e); } } else { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] is null"); } }
public short getShort(String key, short defaultValue) { String value = getString(key); if (value != null) { try { return Short.parseShort(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to short", e); } } else { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] is null"); } }
public short getShort(String key, short defaultValue) { String value = getString(key); if (value != null) { try { return Short.parseShort(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to short", e); } } else { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] is null"); } }
public int getInteger(String key) { String value = getString(key); if (value != null) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] can't be parsed to int", e); } } else { throw new IllegalArgumentException("Value [" + value + "] for key [" + key + "] is null"); } }