Package org.apache.commons.configuration

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


      // response.put("url", node.getDownloadUrl());
      // response.put("name", node.getName());
    } else {
      String name = node.getName();
      String mimeType = serviceRegistry.getMimetypeService().guessMimetype(name);
      HierarchicalConfiguration configuration = configService.getConfig(ConfigurationConfig.class)
          .getConfiguration();
      List<String> inlineMimeTypes = configuration.getList("inline-openable/type");
      boolean inline = inlineMimeTypes.contains(mimeType);
      String url = inline ? node.getContentUrl() : node.getDownloadUrl();
      // response.put("inline", inline);
      // response.put("url", url);
      // response.put("name", name);
View Full Code Here


  public void setConfiguration(HierarchicalConfiguration configuration) {
    this.configuration = configuration;
  }

  public ConfigElement combine(ConfigElement combinee) {
    HierarchicalConfiguration conf2 = this.configuration;
    HierarchicalConfiguration conf1 = ((ConfigurationConfig) combinee).configuration;
    NodeCombiner combiner = new UnionCombiner();
    CombinedConfiguration cc = new CombinedConfiguration(combiner);
    cc.addConfiguration(conf1);
    cc.addConfiguration(conf2);
    ConfigurationConfig combined = new ConfigurationConfig();
View Full Code Here

  private static AlgorithmStartsListener createInitialSolution(XMLConfiguration config, final VehicleRoutingProblem vrp, VehicleFleetManager vehicleFleetManager, final StateManager routeStates, Set<PrioritizedVRAListener> algorithmListeners, TypedMap definedClasses, ExecutorService executorService, int nuOfThreads, final SolutionCostCalculator solutionCostCalculator, ConstraintManager constraintManager, boolean addDefaultCostCalculators) {
    List<HierarchicalConfiguration> modConfigs = config.configurationsAt("construction.insertion");
    if(modConfigs == null) return null;
    if(modConfigs.isEmpty()) return null;
    if(modConfigs.size() != 1) throw new IllegalStateException("#construction.modules != 1. 1 expected");
    HierarchicalConfiguration modConfig = modConfigs.get(0);
    String insertionName = modConfig.getString("[@name]");
    if(insertionName == null) throw new IllegalStateException("insertion[@name] is missing.");
    String insertionId = modConfig.getString("[@id]");
    if(insertionId == null) insertionId = "noId";
    ModKey modKey = makeKey(insertionName,insertionId);
    InsertionStrategyKey insertionStrategyKey = new InsertionStrategyKey(modKey);
    InsertionStrategy insertionStrategy = definedClasses.get(insertionStrategyKey);
    if(insertionStrategy == null){
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

    /**
     * Tests combination of simple elements.
     */
    public void testSimpleValues() throws ConfigurationException
    {
        HierarchicalConfiguration config = createCombinedConfiguration();
        assertEquals("Wrong number of bgcolors", 0, config
                .getMaxIndex("gui.bgcolor"));
        assertEquals("Wrong bgcolor", "green", config.getString("gui.bgcolor"));
        assertEquals("Wrong selcolor", "yellow", config
                .getString("gui.selcolor"));
        assertEquals("Wrong fgcolor", "blue", config.getString("gui.fgcolor"));
        assertEquals("Wrong level", 1, config.getInt("gui.level"));
    }
View Full Code Here

    /**
     * Tests combination of attributes.
     */
    public void testAttributes() throws ConfigurationException
    {
        HierarchicalConfiguration config = createCombinedConfiguration();
        assertEquals("Wrong value of min attribute", 1, config
                .getInt("gui.level[@min]"));
        assertEquals("Wrong value of default attribute", 2, config
                .getInt("gui.level[@default]"));
        assertEquals("Wrong number of id attributes", 0, config
                .getMaxIndex("database.tables.table(0)[@id]"));
        assertEquals("Wrong value of table id", 1, config
                .getInt("database.tables.table(0)[@id]"));
    }
View Full Code Here

    /**
     * Tests whether property values are correctly overridden.
     */
    public void testOverrideValues() throws ConfigurationException
    {
        HierarchicalConfiguration config = createCombinedConfiguration();
        assertEquals("Wrong user", "Admin", config
                .getString("base.services.security.login.user"));
        assertEquals("Wrong user type", "default", config
                .getString("base.services.security.login.user[@type]"));
        assertNull("Wrong password", config.getString("base.services.security.login.passwd"));
        assertEquals("Wrong password type", "secret", config
                .getString("base.services.security.login.passwd[@type]"));
    }
View Full Code Here

     * Tests if a list from the first node structure overrides a list in the
     * second structure.
     */
    public void testListFromFirstStructure() throws ConfigurationException
    {
        HierarchicalConfiguration config = createCombinedConfiguration();
        assertEquals("Wrong number of services", 0, config
                .getMaxIndex("net.service.url"));
        assertEquals("Wrong service", "http://service1.org", config
                .getString("net.service.url"));
        assertFalse("Type attribute available", config
                .containsKey("net.service.url[@type]"));
    }
View Full Code Here

     * Tests if a list from the second structure is added if it is not defined
     * in the first structure.
     */
    public void testListFromSecondStructure() throws ConfigurationException
    {
        HierarchicalConfiguration config = createCombinedConfiguration();
        assertEquals("Wrong number of servers", 3, config
                .getMaxIndex("net.server.url"));
        assertEquals("Wrong server", "http://testsvr.com", config
                .getString("net.server.url(2)"));
    }
View Full Code Here

    }

    public void testMerge() throws ConfigurationException
    {
        //combiner.setDebugStream(System.out);
        HierarchicalConfiguration config = createCombinedConfiguration();
        config.setExpressionEngine(new XPathExpressionEngine());
        assertEquals("Wrong number of Channels", 3, config.getMaxIndex("Channels/Channel"));
        assertEquals("Bad Channel 1 Name", "My Channel",
                config.getString("Channels/Channel[@id='1']/Name"));
        assertEquals("Bad Channel Type", "half",
                config.getString("Channels/Channel[@id='1']/@type"));
        assertEquals("Bad Channel 2 Name", "Channel 2",
                config.getString("Channels/Channel[@id='2']/Name"));
        assertEquals("Bad Channel Type", "full",
                config.getString("Channels/Channel[@id='2']/@type"));
        assertEquals("Bad Channel Data", "test 1 data",
                config.getString("Channels/Channel[@id='1']/ChannelData"));
        assertEquals("Bad Channel Data", "test 2 data",
                config.getString("Channels/Channel[@id='2']/ChannelData"));
        assertEquals("Bad Channel Data", "more test 2 data",
                config.getString("Channels/Channel[@id='2']/MoreChannelData"));

    }
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.