/** * Get a string associated with the given configuration key. * * @param key The configuration key. * @return The associated string. * @throws ClassCastException is thrown if the key maps to an * object that is not a String. */ public String getString(String key) { return getString(key, null); }
/** * <p>Reads an properties file from an {@link InputStream} * and uses it to configure this {@link FactoryConfiguration}.</p> * * @param url the URL to read from */ protected void readImpl(URL url) throws IOException { ExtProperties props = new ExtProperties(); props.load(url.openStream()); // all factory settings should be prefixed with "tools" read(props.subset("tools")); }
/** * Combines an existing Hashtable with this Hashtable. * <p> * Warning: It will overwrite previous entries without warning. * * @param props the properties to combine */ public void combine(ExtProperties props) { for (Iterator it = props.getKeys(); it.hasNext();) { String key = (String) it.next(); setProperty(key, props.get(key)); } }
/** * Set a property, this will replace any previously * set values. Set values is implicitly a call * to clearProperty(key), addProperty(key,value). * * @param key the key to set * @param value the value to set */ public void setProperty(String key, Object value) { clearProperty(key); addProperty(key, value); }
/** * Allows an external system to set a property in * the Velocity Runtime. * * @param key property key * @param value property value */ public void setProperty(String key, Object value) { if (overridingProperties == null) { overridingProperties = new ExtProperties(); } overridingProperties.setProperty(key, value); }
/** * Add a property to the configuration. If it already * exists then the value stated here will be added * to the configuration entry. For example, if * * resource.loader = file * * is already present in the configuration and you * * addProperty("resource.loader", "classpath") * * Then you will end up with a Vector like the * following: * * ["file", "classpath"] * * @param key * @param value */ public void addProperty(String key, Object value) { if (overridingProperties == null) { overridingProperties = new ExtProperties(); } overridingProperties.addProperty(key, value); }
protected void readData(ExtProperties dataset) { if (dataset != null) { for (Iterator i = dataset.getKeys(); i.hasNext(); ) { String key = (String)i.next(); // if it contains a period, it can't be a context key; // it must be a data property. ignore it for now. if (key.indexOf('.') >= 0) { continue; } Data data = new Data(); data.setKey(key); data.setValue(dataset.getString(key)); // get/set the type/converter properties ExtProperties props = dataset.subset(key); setProperties(props, data); addData(data); } } }
protected void readProperties(ExtProperties configProps, Configuration config) { ExtProperties properties = configProps.subset("property"); if (properties != null) { for (Iterator i = properties.getKeys(); i.hasNext(); ) { String name = (String)i.next(); String value = properties.getString(name); ExtProperties propProps = properties.subset(name); if (propProps.size() == 1) { // then set this as a 'simple' property config.setProperty(name, value); } else { // add it as a convertable property Property property = new Property(); property.setName(name); property.setValue(value); // set the type/converter properties setProperties(propProps, property); } } } }
ExtProperties c = new ExtProperties(); Iterator keys = getKeys(); boolean validSubset = false; c.addPropertyDirect(newKey, get(key));
Object value = get(key); return interpolate((String) value); return interpolate(defaults.getString(key, defaultValue)); return interpolate(defaultValue); return interpolate((String) ((List) value).get(0));
String loaderName = configuration.getString(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER); log = rsvc.getLog("loader." + (loaderName == null ? this.getClass().getSimpleName() : loaderName)); isCachingOn = configuration.getBoolean("cache", false); String msg = "Exception parsing cache setting: " + configuration.getString("cache"); log.error(msg, e); throw new VelocityException(msg, e); modificationCheckInterval = configuration.getLong("modificationCheckInterval", 0); String msg = "Exception parsing modificationCheckInterval setting: " + configuration.getString("modificationCheckInterval"); log.error(msg, e); throw new VelocityException(msg, e); try className = configuration.getString("class", className);
Object value = getProperty(variable); if (value != null) result.append(interpolateHelper(value.toString(), priorVariables)); else if (defaults != null && defaults.getString(variable, null) != null) result.append(defaults.getString(variable));
private void execute0() throws IOException, MojoExecutionException { velocity = new RuntimeInstance(); final ExtProperties p = new ExtProperties(); velocity.setConfiguration(p);
/** * Add all properties contained in the file fileName to the RuntimeInstance properties */ public void setProperties(String fileName) { ExtProperties props = null; try { props = new ExtProperties(fileName); } catch (IOException e) { throw new VelocityException("Error reading properties from '" + fileName + "'", e); } Enumeration en = props.keys(); while (en.hasMoreElements()) { String key = en.nextElement().toString(); setProperty(key, props.get(key)); } }
this.load(in); defaults = new ExtProperties(defaultFile);
String repoClass = configuration.getString(REPOSITORY_CLASS, REPOSITORY_CLASS_DEFAULT); String repoName = configuration.getString(REPOSITORY_NAME, REPOSITORY_NAME_DEFAULT); boolean isStatic = configuration.getBoolean(REPOSITORY_STATIC, REPOSITORY_STATIC_DEFAULT); String encoding = configuration.getString(REPOSITORY_ENCODING);
String loaderClass = StringUtils.trim(configuration.getString("class")); ResourceLoader loaderInstance = (ResourceLoader) configuration.get("instance"); configuration.getString(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER) + ".resource.loader.class' specification in configuration." + " This is a critical value. Please adjust configuration.";
Vector resourceLoaderNames = rsvc.getConfiguration().getVector(RuntimeConstants.RESOURCE_LOADER); rsvc.getConfiguration().subset(loaderID.toString()); loaderConfiguration.setProperty(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER, loaderName);
if (getInclude() != null && key.equalsIgnoreCase(getInclude())) load(new FileInputStream(file)); addProperty(key, value);
protected void readToolboxes(ExtProperties factory) { String[] scopes = factory.getStringArray("toolbox"); for (String scope : scopes) { ToolboxConfiguration toolbox = new ToolboxConfiguration(); toolbox.setScope(scope); addToolbox(toolbox); ExtProperties toolboxProps = factory.subset(scope); readTools(toolboxProps, toolbox); readProperties(toolboxProps, toolbox); } }