Java Code Examples for org.apache.commons.configuration2.HierarchicalConfiguration#setProperty()

The following examples show how to use org.apache.commons.configuration2.HierarchicalConfiguration#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectConfig.java    From spoofax with Apache License 2.0 6 votes vote down vote up
protected ProjectConfig(HierarchicalConfiguration<ImmutableNode> config, @Nullable String metaborgVersion,
        @Nullable Collection<IExportConfig> sources, @Nullable Collection<LanguageIdentifier> compileDeps,
        @Nullable Collection<LanguageIdentifier> sourceDeps, @Nullable Collection<LanguageIdentifier> javaDeps) {
    this(config);

    if(metaborgVersion != null) {
        config.setProperty(PROP_METABORG_VERSION, metaborgVersion);
    }
    if(sources != null) {
        config.setProperty(PROP_SOURCES, sources);
    }
    if(compileDeps != null) {
        config.setProperty(PROP_COMPILE_DEPENDENCIES, compileDeps);
    }
    if(sourceDeps != null) {
        config.setProperty(PROP_SOURCE_DEPENDENCIES, sourceDeps);
    }
    if(javaDeps != null) {
        config.setProperty(PROP_JAVA_DEPENDENCIES, javaDeps);
    }
}
 
Example 2
Source File: LanguageSpecConfig.java    From spoofax with Apache License 2.0 6 votes vote down vote up
protected LanguageSpecConfig(HierarchicalConfiguration<ImmutableNode> config, ProjectConfig projectConfig,
    @Nullable LanguageIdentifier id, @Nullable String name, @Nullable Boolean sdfEnabled,
    @Nullable Sdf2tableVersion sdf2tableVersion, @Nullable Boolean checkOverlap, @Nullable Boolean checkPriorities,
    @Nullable Boolean dataDependent, @Nullable String parseTable, @Nullable String completionsParseTable,
    @Nullable JSGLRVersion jsglrVersion, @Nullable JSGLR2Logging jsglr2Logging,
    @Nullable Collection<LanguageContributionIdentifier> langContribs,
    @Nullable Collection<IGenerateConfig> generates, @Nullable Collection<IExportConfig> exports,
    @Nullable Collection<String> pardonedLanguages, @Nullable Boolean useBuildSystemSpec) {
    super(config, projectConfig, id, name, sdfEnabled, parseTable, completionsParseTable, sdf2tableVersion,
        checkOverlap, checkPriorities, dataDependent, jsglrVersion, jsglr2Logging, langContribs, generates,
        exports);

    if(pardonedLanguages != null) {
        config.setProperty(PROP_PARDONED_LANGUAGES, pardonedLanguages);
    }
    if(useBuildSystemSpec != null) {
        config.setProperty(PROP_USE_BUILD_SYSTEM_SPEC, useBuildSystemSpec);
    }
}
 
Example 3
Source File: ReadOnlyUsersLDAPRepositoryEmptyListTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setUp() throws Exception {
    domainList = mock(DomainList.class);
    HierarchicalConfiguration<ImmutableNode> config = ldapRepositoryConfiguration(ldapContainer);
    config.setProperty("[@userBase]", "ou=empty,dc=james,dc=org");
    ldapRepository = startUsersRepository(config);
}
 
Example 4
Source File: ReadOnlyUsersLDAPRepositoryEmptyListTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setUp() throws Exception {
    domainList = mock(DomainList.class);
    HierarchicalConfiguration<ImmutableNode> config = ldapRepositoryConfigurationWithVirtualHosting(ldapContainer);
    config.setProperty("[@userBase]", "ou=empty,dc=james,dc=org");
    ldapRepository = startUsersRepository(config);
}
 
Example 5
Source File: TestConfigurationDeclaration.java    From commons-configuration with Apache License 2.0 5 votes vote down vote up
/**
 * Tests access to certain reserved attributes of a
 * ConfigurationDeclaration.
 */
@Test
public void testConfigurationDeclarationGetAttributes()
{
    final HierarchicalConfiguration<?> config = new BaseHierarchicalConfiguration();
    config.addProperty("xml.fileName", "test.xml");
    ConfigurationDeclaration decl =
            createDeclaration(config.configurationAt("xml"));
    assertNull("Found an at attribute", decl.getAt());
    assertFalse("Found an optional attribute", decl.isOptional());
    config.addProperty("xml[@config-at]", "test1");
    decl = createDeclaration(config.configurationAt("xml"));
    assertEquals("Wrong value of at attribute", "test1", decl.getAt());
    config.addProperty("xml[@at]", "test2");
    decl = createDeclaration(config.configurationAt("xml"));
    assertEquals("Wrong value of config-at attribute", "test1",
            decl.getAt());
    config.clearProperty("xml[@config-at]");
    decl = createDeclaration(config.configurationAt("xml"));
    assertEquals("Old at attribute not detected", "test2", decl.getAt());
    config.addProperty("xml[@config-optional]", "true");
    decl = createDeclaration(config.configurationAt("xml"));
    assertTrue("Wrong value of optional attribute", decl.isOptional());
    config.addProperty("xml[@optional]", "false");
    decl = createDeclaration(config.configurationAt("xml"));
    assertTrue("Wrong value of config-optional attribute",
            decl.isOptional());
    config.clearProperty("xml[@config-optional]");
    config.setProperty("xml[@optional]", Boolean.TRUE);
    decl = createDeclaration(config.configurationAt("xml"));
    assertTrue("Old optional attribute not detected", decl.isOptional());
}
 
Example 6
Source File: TestConfigurationDeclaration.java    From commons-configuration with Apache License 2.0 5 votes vote down vote up
/**
 * Tests whether an invalid value of an optional attribute is detected.
 */
@Test(expected = ConfigurationRuntimeException.class)
public void testConfigurationDeclarationOptionalAttributeInvalid()
{
    final HierarchicalConfiguration<?> factory = new BaseHierarchicalConfiguration();
    factory.addProperty("xml.fileName", "test.xml");
    factory.setProperty("xml[@optional]", "invalid value");
    final ConfigurationDeclaration decl =
            createDeclaration(factory.configurationAt("xml"));
    decl.isOptional();
}
 
Example 7
Source File: ProjectConfig.java    From spoofax with Apache License 2.0 5 votes vote down vote up
public ProjectConfig(HierarchicalConfiguration<ImmutableNode> config) {
    super(config);

    // Set metaborgVersion to default if it was not set in the config.
    if(!config.containsKey(PROP_METABORG_VERSION)) {
        config.setProperty(PROP_METABORG_VERSION, MetaborgConstants.METABORG_VERSION);
    }
}
 
Example 8
Source File: NaBL2ConfigReaderWriter.java    From spoofax with Apache License 2.0 5 votes vote down vote up
public static void write(NaBL2Config nabl2Config, HierarchicalConfiguration<ImmutableNode> config) {
    if(nabl2Config.incremental()) {
        config.setProperty(PROP_INCREMENTAL, nabl2Config.incremental());
    }
    if(!nabl2Config.debug().flags().isEmpty()) {
        config.setProperty(PROP_DEBUG, nabl2Config.debug().flags());
    }
}
 
Example 9
Source File: LanguageComponentConfig.java    From spoofax with Apache License 2.0 4 votes vote down vote up
protected LanguageComponentConfig(HierarchicalConfiguration<ImmutableNode> config, ProjectConfig projectConfig,
    @Nullable LanguageIdentifier identifier, @Nullable String name, @Nullable Boolean sdfEnabled,
    @Nullable String parseTable, @Nullable String completionParseTable, @Nullable Sdf2tableVersion sdf2tableVersion, 
    @Nullable Boolean checkOverlap, @Nullable Boolean checkPriorities,
    @Nullable Boolean dataDependent, @Nullable JSGLRVersion jsglrVersion, @Nullable JSGLR2Logging jsglr2Logging,
    @Nullable Collection<LanguageContributionIdentifier> langContribs,
    @Nullable Collection<IGenerateConfig> generates, @Nullable Collection<IExportConfig> exports) {
    super(config);
    this.projectConfig = projectConfig;

    if(sdfEnabled != null) {
        config.setProperty(PROP_SDF_ENABLED, sdfEnabled);
    }
    if(sdf2tableVersion != null) {
        config.setProperty(PROP_SDF2TABLE_VERSION, sdf2tableVersion);
    }
    if(parseTable != null) {
        config.setProperty(PROP_SDF_PARSE_TABLE, parseTable);
    }
    if(checkOverlap != null) {
        config.setProperty(PROP_SDF2TABLE_CHECKOVERLAP, checkOverlap);
    }
    if(checkPriorities != null) {
        config.setProperty(PROP_SDF2TABLE_CHECKPRIORITIES, checkPriorities);
    }
    if(completionParseTable != null) {
        config.setProperty(PROP_SDF_COMPLETION_PARSE_TABLE, completionParseTable);
    }
    if(jsglrVersion != null) {
        config.setProperty(PROP_SDF_JSGLR_VERSION, jsglrVersion);
    }
    if(jsglr2Logging != null) {
        config.setProperty(PROP_SDF_JSGLR2_LOGGING, jsglr2Logging);
    }
    if(name != null) {
        config.setProperty(PROP_NAME, name);
    }
    if(identifier != null) {
        config.setProperty(PROP_IDENTIFIER, identifier);
    }
    if(langContribs != null) {
        config.setProperty(PROP_LANGUAGE_CONTRIBUTIONS, langContribs);
    }
    if(generates != null) {
        config.setProperty(PROP_GENERATES, generates);
    }
    if(exports != null) {
        config.setProperty(PROP_EXPORTS, exports);
    }
}