Package org.apache.commons.collections

Examples of org.apache.commons.collections.ExtendedProperties


     * @param configurationFile
     * @throws Exception When an error occurs during initialization.
     */
    public void init(String configurationFile)
        throws Exception {
        overridingProperties = new ExtendedProperties(configurationFile);
        init();
    }
View Full Code Here


     *
     * @param input the InputStream to read from
     */
    public void read(InputStream input) throws IOException
    {
        ExtendedProperties props = new ExtendedProperties();
        props.load(input);

        // all factory settings should be prefixed with "tools"
        read(props.subset("tools"));
    }
View Full Code Here


    protected void readProperties(ExtendedProperties configProps,
                                  Configuration config)
    {
        ExtendedProperties properties = configProps.subset("property");
        for (Iterator i = properties.getKeys(); i.hasNext(); )
        {
            String name = (String)i.next();
            String value = properties.getString(name);

            ExtendedProperties propProps = properties.subset(name);
            if (propProps.isEmpty())
            {
                // then set this as a 'simple' property
                config.setProperty(name, value);
            }
            else
View Full Code Here

        {
            ToolboxConfiguration toolbox = new ToolboxConfiguration();
            toolbox.setScope(scope);
            addToolbox(toolbox);

            ExtendedProperties toolboxProps = factory.subset(scope);
            readTools(toolboxProps, toolbox);
            readProperties(toolboxProps, toolbox);
        }
    }
View Full Code Here

            tool.setKey(key);
            tool.setClassname(classname);
            toolbox.addTool(tool);

            // get tool properties prefixed by 'property'
            ExtendedProperties toolProps = tools.subset(key);
            readProperties(toolProps, tool);

            // ok, get tool properties that aren't prefixed by 'property'
            for (Iterator j = toolProps.getKeys(); j.hasNext(); )
            {
                String name = (String)j.next();
                tool.setProperty(name, toolProps.getString(name));
            }

            // get special props explicitly
            String restrictTo = toolProps.getString("restrictTo");
            tool.setRestrictTo(restrictTo);
        }
    }
View Full Code Here

            Data data = new Data();
            data.setKey(key);
            data.setValue(dataset.getString(key));

            // get/set the type/converter properties
            ExtendedProperties props = dataset.subset(key);
            setProperties(props, data);
        }
    }
View Full Code Here

        }

        // this will throw an exception if require is true and there
        // are no properties at the path.  if require is false, this
        // will return null when there's no properties at the path
        ExtendedProperties props = getProperties(path, require);
        if (props == null)
        {
            return false;
        }
View Full Code Here

        if (inputStream == null)
        {
            return null;
        }

        ExtendedProperties properties = new ExtendedProperties();
        try
        {
            properties.load(inputStream);
        }
        catch (IOException ioe)
        {
            String msg = "Failed to load properties at: "+path;
            getLog().error(msg, ioe);
View Full Code Here

*/
public class TestConfigurationConverter extends TestCase
{
    public void testExtendedPropertiesToConfiguration()
    {
        ExtendedProperties eprops = new ExtendedProperties();
        eprops.setProperty("string", "teststring");
        eprops.setProperty("int", "123");
        eprops.addProperty("list", "item 1");
        eprops.addProperty("list", "item 2");

        Configuration config = ConfigurationConverter.getConfiguration(eprops);

        assertEquals("This returns 'teststring'", "teststring", config.getString("string"));
        List item1 = config.getList("list");
View Full Code Here

        config.setProperty("string", "teststring");
        config.setProperty("int", "123");
        config.addProperty("list", "item 1");
        config.addProperty("list", "item 2");

        ExtendedProperties eprops = ConfigurationConverter.getExtendedProperties(config);

        assertEquals("This returns 'teststring'", "teststring", eprops.getString("string"));
        List list = eprops.getVector("list");
        assertEquals("This returns 'item 1'", "item 1", (String) list.get(0));
        assertEquals("This returns 123", 123, eprops.getInt("int"));
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.ExtendedProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.