Java 类org.apache.commons.configuration2.convert.DefaultListDelimiterHandler 实例源码

项目:beadledom    文件:PropertiesConfigurationSource.java   
private static FileBasedConfiguration createPropertiesConfiguration(Reader reader)
    throws ConfigurationException, IOException {
  if (reader == null) {
    throw new NullPointerException("reader: null");
  }

  FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
      new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
          .configure(new Parameters()
              .properties()
              .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));

  FileBasedConfiguration config = builder.getConfiguration();
  config.read(reader);
  return config;
}
项目:sirocco    文件:ConfigurationManager.java   
private ConfigurationManager() throws ConfigurationException{
    FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
        new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties()
            .setFileName(configFilePath)
            .setThrowExceptionOnMissing(true)
            .setListDelimiterHandler(new DefaultListDelimiterHandler(';'))
            .setIncludesAllowed(false));
    config = builder.getConfiguration();
}
项目:yajsw    文件:FilePropertiesConfiguration.java   
private void init()
{
    this.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
    FileLocationStrategy strategy = new MyFileLocationStrategy();
    String basePath = _fileName == null ? "." : new File(_fileName).getParent();
    FileLocator locator = FileLocatorUtils.fileLocator()
            .locationStrategy(strategy)
            .basePath(basePath)
            .create();
    this.initFileLocator(locator);
}
项目:swagger2markup    文件:Swagger2MarkupConfigBuilder.java   
public Swagger2MarkupConfigBuilder(Configuration configuration) {
    CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
    compositeConfiguration.addConfiguration(new SystemConfiguration());
    compositeConfiguration.addConfiguration(configuration);
    compositeConfiguration.addConfiguration(getDefaultConfiguration());

    Swagger2MarkupProperties swagger2MarkupProperties = new Swagger2MarkupProperties(compositeConfiguration);

    config.listDelimiterEnabled = swagger2MarkupProperties.getBoolean(LIST_DELIMITER_ENABLED, false);
    config.listDelimiter = swagger2MarkupProperties.getString(LIST_DELIMITER, ",").charAt(0);

    if (config.listDelimiterEnabled && configuration instanceof AbstractConfiguration) {
        ((AbstractConfiguration)configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
    }

    config.markupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage(MARKUP_LANGUAGE);
    config.swaggerMarkupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage(SWAGGER_MARKUP_LANGUAGE);
    config.generatedExamplesEnabled = swagger2MarkupProperties.getRequiredBoolean(GENERATED_EXAMPLES_ENABLED);
    config.basePathPrefixEnabled = swagger2MarkupProperties.getRequiredBoolean(BASE_PATH_PREFIX_ENABLED);
    config.separatedDefinitionsEnabled = swagger2MarkupProperties.getRequiredBoolean(SEPARATED_DEFINITIONS_ENABLED);
    config.separatedOperationsEnabled = swagger2MarkupProperties.getRequiredBoolean(SEPARATED_OPERATIONS_ENABLED);
    config.pathsGroupedBy = swagger2MarkupProperties.getGroupBy(PATHS_GROUPED_BY);
    config.outputLanguage = swagger2MarkupProperties.getLanguage(OUTPUT_LANGUAGE);
    config.inlineSchemaEnabled = swagger2MarkupProperties.getRequiredBoolean(INLINE_SCHEMA_ENABLED);
    config.interDocumentCrossReferencesEnabled = swagger2MarkupProperties.getRequiredBoolean(INTER_DOCUMENT_CROSS_REFERENCES_ENABLED);
    config.interDocumentCrossReferencesPrefix = swagger2MarkupProperties.getString(INTER_DOCUMENT_CROSS_REFERENCES_PREFIX, null);
    config.flatBodyEnabled = swagger2MarkupProperties.getRequiredBoolean(FLAT_BODY_ENABLED);
    config.pathSecuritySectionEnabled = swagger2MarkupProperties.getRequiredBoolean(PATH_SECURITY_SECTION_ENABLED);
    config.anchorPrefix = swagger2MarkupProperties.getString(ANCHOR_PREFIX, null);
    config.overviewDocument = swagger2MarkupProperties.getRequiredString(OVERVIEW_DOCUMENT);
    config.pathsDocument = swagger2MarkupProperties.getRequiredString(PATHS_DOCUMENT);
    config.definitionsDocument = swagger2MarkupProperties.getRequiredString(DEFINITIONS_DOCUMENT);
    config.securityDocument = swagger2MarkupProperties.getRequiredString(SECURITY_DOCUMENT);
    config.separatedOperationsFolder = swagger2MarkupProperties.getRequiredString(SEPARATED_OPERATIONS_FOLDER);
    config.separatedDefinitionsFolder = swagger2MarkupProperties.getRequiredString(SEPARATED_DEFINITIONS_FOLDER);
    config.tagOrderBy = swagger2MarkupProperties.getOrderBy(TAG_ORDER_BY);
    config.operationOrderBy = swagger2MarkupProperties.getOrderBy(OPERATION_ORDER_BY);
    config.definitionOrderBy = swagger2MarkupProperties.getOrderBy(DEFINITION_ORDER_BY);
    config.parameterOrderBy = swagger2MarkupProperties.getOrderBy(PARAMETER_ORDER_BY);
    config.propertyOrderBy = swagger2MarkupProperties.getOrderBy(PROPERTY_ORDER_BY);
    config.responseOrderBy = swagger2MarkupProperties.getOrderBy(RESPONSE_ORDER_BY);
    Optional<String> lineSeparator = swagger2MarkupProperties.getString(LINE_SEPARATOR);
    if (lineSeparator.isPresent() && StringUtils.isNoneBlank(lineSeparator.get())) {
        config.lineSeparator = LineSeparator.valueOf(lineSeparator.get());
    }

    config.pageBreakLocations = swagger2MarkupProperties.getPageBreakLocations(PAGE_BREAK_LOCATIONS);

    Optional<Pattern> headerPattern = swagger2MarkupProperties.getHeaderPattern(HEADER_REGEX);

    config.headerPattern = headerPattern.orElse(null);

    Configuration swagger2markupConfiguration = compositeConfiguration.subset(PROPERTIES_PREFIX);
    Configuration extensionsConfiguration = swagger2markupConfiguration.subset(EXTENSION_PREFIX);
    config.extensionsProperties = new Swagger2MarkupProperties(extensionsConfiguration);
}
项目:aptasuite    文件:Configuration.java   
/**
 * Adds the configuration stored on disk to the current set of parameters. The
 * file <code>fileName</code> must be a valid configuration file as per Javas
 * <code>Properties</code> class.
 * 
 * @param fileName
 */
public static void setConfiguration(String fileName) {

    try {
        AptaLogger.log(Level.INFO, Configuration.class, "Reading configuration from file.");

        builder = new FileBasedConfigurationBuilder<org.apache.commons.configuration2.FileBasedConfiguration>(
                PropertiesConfiguration.class)
                        .configure(new Parameters().properties().setFileName(fileName)
                                .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));


        // Create a composite configuration which allows to keep user parameters and defaults separated
        CompositeConfiguration  cc = new CompositeConfiguration(); 

        cc.addConfiguration(builder.getConfiguration(), true); // changes will be saved in the user config
        cc.addConfiguration(getDefaultParametersBuilder().getConfiguration(), false);

        parameters = cc;

    } catch (Exception e) {

        AptaLogger.log(Level.SEVERE, Configuration.class,
                "Error, could not read configuration file. Please check it for correctness");
        AptaLogger.log(Level.SEVERE, Configuration.class, e);
        e.printStackTrace();
    }


    // TODO: Sanity checks!
}
项目:aptasuite    文件:Configuration.java   
/**
 * Creates an empty configuration and configures the class 
 * @param filename location at which the config should be stored in the future
 */
public static void createConfiguration(Path filePath) {

    try {

        builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties()
                //.setFile(filePath.toFile())
                .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));

        org.apache.commons.configuration2.Configuration userParameters = builder.getConfiguration();


        //We need to explicitly save the file before setting it in the builder, for whatever reason...
        builder.getFileHandler().save(filePath.toFile());
        builder.getFileHandler().setFile(filePath.toFile());

        // Create a composite configuration which allows to keep user parameters and defaults separated
        CompositeConfiguration  cc = new CompositeConfiguration();

        cc.addConfiguration(builder.getConfiguration(), true); // changes will be saved in the user config
        cc.addConfiguration(getDefaultParametersBuilder().getConfiguration(), false);

        parameters = cc;

    } catch (Exception e) {

        AptaLogger.log(Level.SEVERE, Configuration.class,
                "Error, could not create configuration file.");
        AptaLogger.log(Level.SEVERE, Configuration.class, e);
        e.printStackTrace();
    }

}