Package org.apache.commons.collections

Examples of org.apache.commons.collections.ExtendedProperties


     */
    public void addProperty(String key, Object value)
    {
        if (overridingProperties == null)
        {
            overridingProperties = new ExtendedProperties();
        }

        overridingProperties.addProperty(key, value);
    }
View Full Code Here


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

    public void testExtendedProperties ()
            throws Exception
    {
            assureResultsDirectoryExists(RESULTS_DIR);

            ExtendedProperties c = new ExtendedProperties(TEST_CONFIG);

            FileWriter result = new FileWriter(
                getFileName(RESULTS_DIR, "output", "res"));

            message(result, "Testing order of keys ...");
            showIterator(result, c.getKeys());

            message(result, "Testing retrieval of CSV values ...");
            showVector(result, c.getVector("resource.loader"));

            message(result, "Testing subset(prefix).getKeys() ...");
            ExtendedProperties subset = c.subset("file.resource.loader");
            showIterator(result, subset.getKeys());

            message(result, "Testing getVector(prefix) ...");
            showVector(result, subset.getVector("path"));

            message(result, "Testing getString(key) ...");
            result.write(c.getString("config.string.value"));
            result.write("\n\n");
View Full Code Here

     * generating process starts.
     */
    public void setContextProperties( String file )
    {
        String[] sources = StringUtils.split(file,",");
        contextProperties = new ExtendedProperties();

        // Always try to get the context properties resource
        // from a file first. Templates may be taken from a JAR
        // file but the context properties resource may be a
        // resource in the filesystem. If this fails than attempt
        // to get the context properties resource from the
        // classpath.
        for (int i = 0; i < sources.length; i++)
        {
            ExtendedProperties source = new ExtendedProperties();

            try
            {
                // resolve relative path from basedir and leave
                // absolute path untouched.
                File fullPath = project.resolveFile(sources[i]);
                log("Using contextProperties file: " + fullPath);
                source.load(new FileInputStream(fullPath));
            }
            catch (IOException e)
            {
                ClassLoader classLoader = this.getClass().getClassLoader();

                try
                {
                    InputStream inputStream = classLoader.getResourceAsStream(sources[i]);

                    if (inputStream == null)
                    {
                        throw new BuildException("Context properties file " + sources[i] +
                            " could not be found in the file system or on the classpath!");
                    }
                    else
                    {
                        source.load(inputStream);
                    }
                }
                catch (IOException ioe)
                {
                    source = null;
                }
            }

            if (source != null)
            {
                for (Iterator j = source.getKeys(); j.hasNext(); )
                {
                    String name = (String) j.next();
                    String value = StringUtils.nullTrim(source.getString(name));
                    contextProperties.setProperty(name,value);
                }
            }
        }
    }
View Full Code Here

        try
        {
            if ( velocityPropertiesFile.exists() )
            {
                String file = velocityPropertiesFile.getAbsolutePath();
                ExtendedProperties config = new ExtendedProperties(file);
                ve.setExtendedProperties(config);
            }

            // override the templatePath if it exists
            if (templatePath != null && templatePath.length() > 0)
View Full Code Here

        {
            /**
             * Resource loader can be loaded either via class name or be passed
             * in as an instance.
             */
            ExtendedProperties configuration =
                (ExtendedProperties) sourceInitializerList.get(i);
            String loaderClass = StringUtils.nullTrim(configuration.getString("class"));
            ResourceLoader loaderInstance =
                (ResourceLoader) configuration.get("instance");

            if ( (loaderClass == null) && (loaderInstance == null) )
            {
                log.error("Unable to find '"
                                + configuration.getString(RESOURCE_LOADER_IDENTIFIER)
                                + ".resource.loader.class' specification in configuation."
                                + " This is a critical value.  Please adjust configuration.");
                continue;
           
            }
View Full Code Here

     */
    public void setProperty(String key, Object value)
    {
        if (overridingProperties == null)
        {
            overridingProperties = new ExtendedProperties();
        }

        overridingProperties.setProperty(key, value);
    }
View Full Code Here

     */
    public void addProperty(String key, Object value)
    {
        if (overridingProperties == null)
        {
            overridingProperties = new ExtendedProperties();
        }

        overridingProperties.addProperty(key, value);
    }
View Full Code Here

     * @param configurationFile
     */
    public void init(String configurationFile)
        throws Exception
    {
        overridingProperties = new ExtendedProperties(configurationFile);
        init();
    }
View Full Code Here

             * pertaining to a particular loader.
             */
            String loaderID =
                resourceLoaderNames.get(i) + "." + RuntimeConstants.RESOURCE_LOADER;

            ExtendedProperties loaderConfiguration =
                rsvc.getConfiguration().subset(loaderID);

            /*
             *  we can't really count on ExtendedProperties to give us an empty set
             */

            if ( loaderConfiguration == null)
            {
                log.warn("ResourceManager : No configuration information for resource loader named '"
                         + resourceLoaderNames.get(i) + "'. Skipping.");
                continue;
            }

            /*
             *  add the loader name token to the initializer if we need it
             *  for reference later. We can't count on the user to fill
             *  in the 'name' field
             */

            loaderConfiguration.setProperty( RESOURCE_LOADER_IDENTIFIER, resourceLoaderNames.get(i));

            /*
             * Add resources to the list of resource loader
             * initializers.
             */
 
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.