Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.HierarchicalConfiguration$Node


     */
    private ConfigurationNode checkTable(HierarchicalConfiguration config)
    {
        assertEquals("Wrong number of tables", 1, config
                .getMaxIndex("database.tables.table"));
        HierarchicalConfiguration c = config
                .configurationAt("database.tables.table(0)");
        assertEquals("Wrong table name", "documents", c.getString("name"));
        assertEquals("Wrong number of fields", 2, c
                .getMaxIndex("fields.field.name"));
        assertEquals("Wrong field", "docname", c
                .getString("fields.field(1).name"));

        List nds = config.getExpressionEngine().query(config.getRoot(),
                "database.tables.table");
        assertFalse("No node found", nds.isEmpty());
View Full Code Here


        {
            throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
        }

        // Virtualhost configuration object
        Configuration vhostConfiguration = new HierarchicalConfiguration();

        // Load from embedded configuration if possible
        if (!vhostConfig.subset("virtualhost").isEmpty())
        {
            vhostConfiguration = vhostConfig;
        }
        else
        {
        // Load from the external configuration if possible
        for (String fileName : vhostFiles)
          {
              // Open the vhosts XML file and copy values from it to our config
                _vhostsFile = new File(fileName);
                if (!_vhostsFile.exists())
                {
                    throw new ConfigurationException("Virtualhosts file does not exist");
                }
            vhostConfiguration = parseConfig(new File(fileName));

                // save the default virtualhost name
                String defaultVirtualHost = vhostConfiguration.getString("default");
                getConfig().setProperty("virtualhosts.default", defaultVirtualHost);
            }
        }

        // Now extract the virtual host names from the configuration object
        List hosts = vhostConfiguration.getList("virtualhost.name");
        for (int j = 0; j < hosts.size(); j++)
        {
            String name = (String) hosts.get(j);

            // Add the virtual hosts to the server configuration
            VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name, vhostConfiguration.subset("virtualhost." + escapeTagName(name)));
            _virtualHosts.put(virtualhost.getName(), virtualhost);
        }
    }
View Full Code Here

   * @return the configuration for the given  moduleType
   */
  @NotNull
  public HierarchicalConfiguration getModuleConfiguration( @NotNull Class<?> moduleType ) {
    String moduleTypeName = moduleType.getName().replaceAll( "\\$", "." );
    HierarchicalConfiguration modulesConfiguration = getModulesConfiguration();
    try {
      return modulesConfiguration.configurationAt( moduleTypeName );
    } catch ( IllegalArgumentException ignore ) {
      modulesConfiguration.addProperty( moduleTypeName, "" );
      return modulesConfiguration.configurationAt( moduleTypeName );
    }
  }
View Full Code Here

      throw new FitsConfigurationException("Error reading "+config+"fits.xml",e);
    }
   
    List fields = conf.configurationsAt("map");
    for(Iterator it = fields.iterator(); it.hasNext();)  {
        HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
        // sub contains now all data about a single field
        String format = sub.getString("[@format]");
        String transform = sub.getString("[@transform]");
        mappings.put(format,transform);
    }
    return mappings;
  }
View Full Code Here

    {
        PropertyListParser parser = new PropertyListParser(in);
        try
        {

            HierarchicalConfiguration config = parser.parse();
            setRoot(config.getRoot());
        }
        catch (ParseException e)
        {
            throw new ConfigurationException(e);
        }
View Full Code Here

    public void load(Reader in) throws ConfigurationException
    {
        PropertyListParser parser = new PropertyListParser(in);
        try
        {
            HierarchicalConfiguration config = parser.parse();
            setRoot(config.getRoot());
        }
        catch (ParseException e)
        {
            throw new ConfigurationException(e);
        }
View Full Code Here

     */
    public void testInitFromNullNode()
    {
        try
        {
            decl = new XMLBeanDeclaration(new HierarchicalConfiguration().configurationAt(null),
                    (ConfigurationNode) null);
            fail("Could init declaration with null node!");
        }
        catch (IllegalArgumentException iex)
        {
View Full Code Here

     */
    public void testInitFromNullConfigurationAndNode()
    {
        try
        {
            decl = new XMLBeanDeclaration(null, new HierarchicalConfiguration()
                    .getRoot());
            fail("Could init declaration with null configuration and node!");
        }
        catch (IllegalArgumentException iex)
        {
View Full Code Here

    /**
     * Tests fetching the bean's class name.
     */
    public void testGetBeanClassName()
    {
        HierarchicalConfiguration config = new HierarchicalConfiguration();
        config.addProperty(KEY + "[@config-class]", getClass().getName());
        decl = new XMLBeanDeclaration(config, KEY);
        assertEquals("Wrong class name", getClass().getName(), decl
                .getBeanClassName());
    }
View Full Code Here

    /**
     * Tests fetching the bean's class name if it is undefined.
     */
    public void testGetBeanClassNameUndefined()
    {
        decl = new XMLBeanDeclaration(new HierarchicalConfiguration());
        assertNull(decl.getBeanClassName());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.HierarchicalConfiguration$Node

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.