/** * Get a property from the underlying properties. * * @param key * the property key requested * @return the property value if found, null otherwise. */ public String getProperty(String key) { return getProperty(key, null); }
/** * Get a property from the underlying properties. * * @param key * the property key requested * @return the property value if found, null otherwise. */ public String getProperty(String key) { return getProperty(key, null); }
/** * Get a property from the underlying properties. * * @param property * the property requested * @param defaultValue * the value to return if the property is not defined * @return the double property value if found and valid, defaultValue otherwise. */ public double getDouble(String property, double defaultValue) { String value = getProperty(property); if (value == null) { return defaultValue; } try { return Double.parseDouble(value); } catch (NumberFormatException e) { return defaultValue; } }
/** * Get a property from the underlying properties. * * @param property * the property requested * @param defaultValue * the value to return if the property is not defined * @return the double property value if found and valid, defaultValue otherwise. */ public double getDouble(String property, double defaultValue) { String value = getProperty(property); if (value == null) { return defaultValue; } try { return Double.parseDouble(value); } catch (NumberFormatException e) { return defaultValue; } }
/** * Get a boolean property from the underlying properties. * * @param property * the property requested * @param defaultValue * the value to return if the property is not defined * @return the boolean property value if found and valid, defaultValue otherwise. */ public boolean getBoolean(String property, boolean defaultValue) { String value = getProperty(property); if (value == null) return defaultValue; try { return Boolean.valueOf(value).booleanValue(); } catch (NumberFormatException e) { return defaultValue; } }
/** * Get a property from the underlying properties. * * @param property * the property requested * @param defaultValue * the value to return if the property is not defined * @return the integer property value if found and valid, defaultValue otherwise. */ public int getInteger(String property, int defaultValue) { String value = getProperty(property); if (value == null) { return defaultValue; } try { return Integer.decode(value).intValue(); } catch (NumberFormatException e) { return defaultValue; } }
/** * Get a boolean property from the underlying properties. * * @param property * the property requested * @param defaultValue * the value to return if the property is not defined * @return the boolean property value if found and valid, defaultValue otherwise. */ public boolean getBoolean(String property, boolean defaultValue) { String value = getProperty(property); if (value == null) return defaultValue; try { return Boolean.valueOf(value).booleanValue(); } catch (NumberFormatException e) { return defaultValue; } }
/** * Get a property from the underlying properties. * * @param property * the property requested * @param defaultValue * the value to return if the property is not defined * @return the integer property value if found and valid, defaultValue otherwise. */ public int getInteger(String property, int defaultValue) { String value = getProperty(property); if (value == null) { return defaultValue; } try { return Integer.decode(value).intValue(); } catch (NumberFormatException e) { return defaultValue; } }
/** * For the named property, attempt to get an open input stream. If the property value starts with "jar:", the remainder of the * value is interpreted as an absolute path in the classpath. Otherwise it is interpreted as a file name. * * @param propertyName * the name of a property defined in one of the mary config files. * @return an InputStream representing the given resource, or null if the property was not defined. * @throws FileNotFoundException * if the property value is a file name and the file cannot be opened * @throws MaryConfigurationException * if the property value is a classpath entry which cannot be opened */ public InputStream getStream(String propertyName) throws FileNotFoundException, MaryConfigurationException { InputStream stream; String propertyValue = getProperty(propertyName); if (propertyValue == null) { return null; } else if (propertyValue.startsWith("jar:")) { // read from classpath String classpathLocation = propertyValue.substring("jar:".length()); stream = this.getClass().getResourceAsStream(classpathLocation); if (stream == null) { throw new MaryConfigurationException("For property '" + propertyName + "', no classpath resource available at '" + classpathLocation + "'"); } } else { String fileName = propertyValue; stream = new FileInputStream(fileName); } return stream; }
/** * For the named property, attempt to get an open input stream. If the property value starts with "jar:", the remainder of the * value is interpreted as an absolute path in the classpath. Otherwise it is interpreted as a file name. * * @param propertyName * the name of a property defined in one of the mary config files. * @return an InputStream representing the given resource, or null if the property was not defined. * @throws FileNotFoundException * if the property value is a file name and the file cannot be opened * @throws MaryConfigurationException * if the property value is a classpath entry which cannot be opened */ public InputStream getStream(String propertyName) throws FileNotFoundException, MaryConfigurationException { InputStream stream; String propertyValue = getProperty(propertyName); if (propertyValue == null) { return null; } else if (propertyValue.startsWith("jar:")) { // read from classpath String classpathLocation = propertyValue.substring("jar:".length()); stream = this.getClass().getResourceAsStream(classpathLocation); if (stream == null) { throw new MaryConfigurationException("For property '" + propertyName + "', no classpath resource available at '" + classpathLocation + "'"); } } else { String fileName = propertyValue; stream = new FileInputStream(fileName); } return stream; }
if (useGV) { useContextDependentGV = p.getBoolean(prefix + ".useContextDependentGV", useContextDependentGV); if (p.getProperty(prefix + ".gvMethod") != null) { String sval = p.getProperty(prefix + ".gvMethod"); setGvMethod(sval);
if (useGV) { useContextDependentGV = p.getBoolean(prefix + ".useContextDependentGV", useContextDependentGV); if (p.getProperty(prefix + ".gvMethod") != null) { String sval = p.getProperty(prefix + ".gvMethod"); setGvMethod(sval);
if (useGV) { useContextDependentGV = p.getBoolean(prefix + ".useContextDependentGV"); /* Use context-dependent GV, (gv without sil) */ String gvMethod = p.getProperty(prefix + ".gvMethod"); /* GV method: gradient or derivative (default gradient) */
if (useGV) { useContextDependentGV = p.getBoolean(prefix + ".useContextDependentGV"); /* Use context-dependent GV, (gv without sil) */ String gvMethod = p.getProperty(prefix + ".gvMethod"); /* GV method: gradient or derivative (default gradient) */
if (useGV) { useContextDependentGV = p.getBoolean(prefix + ".useContextDependentGV", useContextDependentGV); if (p.getProperty(prefix + ".gvMethod") != null) { String sval = p.getProperty(prefix + ".gvMethod"); setGvMethod(sval);
if (useGV) { useContextDependentGV = p.getBoolean(prefix + ".useContextDependentGV"); /* Use context-dependent GV, (gv without sil) */ String gvMethod = p.getProperty(prefix + ".gvMethod"); /* GV method: gradient or derivative (default gradient) */