Logo Search packages:      
Sourcecode: velocity version File versions  Download package

synchronized void org::apache::velocity::runtime::configuration::Configuration::load ( InputStream  input  )  throws IOException [inline]

Load the properties from the given input stream.

Parameters:
input An InputStream.
Exceptions:
IOException. 

Definition at line 436 of file Configuration.java.

References addProperty(), basePath, file, fileSeparator, getInclude(), and org::apache::velocity::runtime::configuration::Configuration::PropertiesReader::readProperty().

Referenced by Configuration().

    {
        PropertiesReader reader =
            new PropertiesReader(new InputStreamReader(input));

        try
        {
            while (true)
            {
                String line = reader.readProperty();
                int equalSign = line.indexOf('=');

                if (equalSign > 0)
                {
                    String key = line.substring(0, equalSign).trim();
                    String value = line.substring(equalSign + 1).trim();

                    /*
                     * Configure produces lines like this ... just
                     * ignore them.
                     */
                    if ("".equals(value))
                        continue;

                    if (getInclude() != null && 
                        key.equalsIgnoreCase(getInclude()))
                    {
                        /*
                         * Recursively load properties files.
                         */
                        File file = null;
                        
                        if (value.startsWith(fileSeparator))
                        {
                            /*
                             * We have an absolute path so we'll
                             * use this.
                             */
                            file = new File(value);
                        }
                        else
                        {   
                            /* 
                             * We have a relative path, and we have
                             * two possible forms here. If we have the
                             * "./" form then just strip that off first
                             * before continuing.
                             */
                            if (value.startsWith("." + fileSeparator))
                            {
                                value = value.substring(2);
                            }
                            
                            file = new File(basePath + value);
                        }
                        
                        if (file != null && file.exists() && file.canRead())
                        {
                            load ( new FileInputStream(file));
                        }
                    }
                    else
                    {
                        addProperty(key,value);
                        //setProperty(key,value);
                    }                       
                }
            }
        }
        catch (NullPointerException e)
        {
            /*
             * Should happen only when EOF is reached.
             */
            return;
        }
    }


Generated by  Doxygen 1.6.0   Back to index