Object[] args = new Object[] {key, classname}; String msg = "Could not find class of properties value: {0}={1}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); throw new PropertiesException(MessageFormat.format(msg, args));
Object[] args = new Object[] {key, objectValue}; String msg = "Properties value can not be converted to int: {0}={1}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); throw new PropertiesException(MessageFormat.format(msg, args));
/** * Searches for the property with the specified key in this property map. If the key is not found * in this property map, the parent property map, and its parents, recursively, are then checked. * <br/> * If the key maps to a string value, it will be returned as is. If the property is not found, * <code>null</code> will be returned. For all other types a PropertiesException will be thrown. * * @param key Property key. * @return String value in this property map with the specified key value. */ public final String getString(final String key) { Object objectValue = get(key); if (objectValue == null) { return null; } else if (objectValue instanceof String) { return (String) objectValue; } Object[] args = new Object[] {key, objectValue}; String msg = "Properties value is not a string: {0}={1}"; throw new PropertiesException(MessageFormat.format(msg, args)); }
/** * Searches for the property with the specified key in this property map. If the key is not found * in this property map, the parent property map, and its parents, recursively, are then checked. * <br/> * If the key maps to a string array, it will be returned as is. A simple string will be converted * into a string array by splitting it into substrings at every occurence of ',' character. If the * property is not found, <code>null</code> will be returned. For all other types a * PropertiesException will be thrown. * * @param key Property key. * @return String array in this property map with the specified key value. */ public final String[] getStringArray(final String key) { Object objectValue = get(key); if (objectValue == null) { return null; } else if (objectValue instanceof String[]) { return (String[]) objectValue; } else if (objectValue instanceof String) { return StringUtils.split((String) objectValue, ','); } Object[] args = new Object[] {key, objectValue}; String msg = "Properties value is not a String[]: {0}={1}"; throw new PropertiesException(MessageFormat.format(msg, args)); }
Object[] args = new Object[] {key, Integer.valueOf(i), classnames[i]}; String msg = "Could not find class of properties value: {0}[{1}]={2}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); throw new PropertiesException(MessageFormat.format(msg, args));
Object[] args = new Object[] {key, Integer.valueOf(i), classname}; String msg = "Could not find configured class: {0}[{1}]={2}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); } catch (IllegalAccessException ex) { Object[] args = new Object[] {key, Integer.valueOf(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); } catch (InstantiationException ex) { Object[] args = new Object[] {key, Integer.valueOf(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); } catch (ExceptionInInitializerError ex) { Object[] args = new Object[] {key, Integer.valueOf(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); } catch (SecurityException ex) { Object[] args = new Object[] {key, Integer.valueOf(i), classname}; String msg = "Could not instantiate configured class: {0}[{1}]={2}"; throw new PropertiesException(MessageFormat.format(msg, args), ex); throw new PropertiesException(MessageFormat.format(msg, args));
throw new PropertiesException(MessageFormat.format(msg, args));
/** * Load module properties from default locations. <br/> * First it loads default properties contained in Castor JAR. This gets overwritten by a * properties found on Java library directory. If no properties could be found until that point a * PropertiesException will be thrown. * * @param path Path to the default properties to load. * @param filename Name of the properties file. */ protected void loadDefaultProperties(final String path, final String filename) { Properties properties = new Properties(); // Get default properties from the Castor JAR. boolean inCastorJar = loadFromClassPath(properties, path + filename); // Get overriding properties from the Java library directory, ignore if not // found. If found merge existing properties. boolean inJavaLibDir = loadFromJavaHome(properties, filename); // Couldn't find properties in Castor jar nor Java library directory. if (!inCastorJar && !inJavaLibDir) { throw new PropertiesException("Failed to load properties: " + filename); } _map.putAll(properties); }