Java Code Examples for org.apache.commons.configuration.Configuration.getString()

The following are Jave code examples for showing how to use getString() of the org.apache.commons.configuration.Configuration class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: obevo   File: DbMergeInfo.java   Source Code and License Vote up 7 votes
public static MutableCollection<DbMergeInfo> parseFromProperties(Configuration config) {
    Set<String> dbs = new HashSet<String>(config.getList("instances"));

    MutableList<DbMergeInfo> dbMergeInfos = Lists.mutable.empty();
    for (String db : dbs) {
        Configuration subset = config.subset(db);
        if (subset.containsKey("inputDir")) {
            File inputDir = new File(subset.getString("inputDir"));
            DbMergeInfo mergeInfo = new DbMergeInfo(db, inputDir);
            if (subset.containsKey("driverClassName")) {
                mergeInfo.setDriverClassName(subset.getString("driverClassName"));
                mergeInfo.setUrl(subset.getString("url"));
                mergeInfo.setUsername(subset.getString("username"));
                mergeInfo.setPassword(subset.getString("password"));
                mergeInfo.setPhysicalSchema(subset.getString("physicalSchema"));
            }

            dbMergeInfos.add(mergeInfo);
        }
    }

    return dbMergeInfos;
}
 
Example 2
Project: jbake-rtl-jalaali   File: AsciidoctorEngine.java   Source Code and License Vote up 6 votes
private Options getAsciiDocOptionsAndAttributes(ParserContext context) {
    Configuration config = context.getConfig();
    final AttributesBuilder attributes = attributes(config.getStringArray(Keys.ASCIIDOCTOR_ATTRIBUTES));
    if (config.getBoolean(Keys.ASCIIDOCTOR_ATTRIBUTES_EXPORT, false)) {
        final String prefix = config.getString(  Keys.ASCIIDOCTOR_ATTRIBUTES_EXPORT_PREFIX, "");
        for (final Iterator<String> it = config.getKeys(); it.hasNext();) {
            final String key = it.next();
            if (!key.startsWith("asciidoctor")) {
                attributes.attribute(prefix + key.replace(".", "_"), config.getProperty(key));
            }
        }
    }
    final Configuration optionsSubset = config.subset(Keys.ASCIIDOCTOR_OPTION);
    final Options options = options().attributes(attributes.get()).get();
    for (final Iterator<String> iterator = optionsSubset.getKeys(); iterator.hasNext();) {
        final String name = iterator.next();
        if (name.equals(Options.TEMPLATE_DIRS)) {
        	options.setTemplateDirs(optionsSubset.getString(name));
        } else {
        	options.setOption(name,  guessTypeByContent(optionsSubset.getString(name)));
        }
    }
    options.setBaseDir(context.getFile().getParentFile().getAbsolutePath());
    options.setSafe(UNSAFE);
    return options;
}
 
Example 3
Project: tinkergraph-gremlin   File: TinkerGraph.java   Source Code and License Vote up 6 votes
/**
 * An empty private constructor that initializes {@link TinkerGraph}.
 */
private TinkerGraph(final Configuration configuration, boolean usesSpecializedElements) {
    this.configuration = configuration;
    this.usesSpecializedElements = usesSpecializedElements;
    vertexIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, Vertex.class);
    edgeIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, Edge.class);
    vertexPropertyIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, VertexProperty.class);
    defaultVertexPropertyCardinality = VertexProperty.Cardinality.valueOf(
            configuration.getString(GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.single.name()));

    graphLocation = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null);
    graphFormat = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_FORMAT, null);

    if ((graphLocation != null && null == graphFormat) || (null == graphLocation && graphFormat != null))
        throw new IllegalStateException(String.format("The %s and %s must both be specified if either is present",
                GREMLIN_TINKERGRAPH_GRAPH_LOCATION, GREMLIN_TINKERGRAPH_GRAPH_FORMAT));

    if (graphLocation != null) loadGraph();
}
 
Example 4
Project: bitsy   File: BitsyGraph.java   Source Code and License Vote up 6 votes
/** 
 * Constructor with a Configuration object with String dbPath, boolean allowFullGraphScans, long txLogThreshold and double reorgFactor 
 */
public BitsyGraph(Configuration configuration) {
	this(Paths.get(configuration.getString(DB_PATH_KEY)),
		configuration.getBoolean(ALLOW_FULL_GRAPH_SCANS_KEY, Boolean.TRUE),
		configuration.getLong(TX_LOG_THRESHOLD_KEY, DEFAULT_TX_LOG_THRESHOLD),
		configuration.getDouble(REORG_FACTOR_KEY, DEFAULT_REORG_FACTOR),
		configuration.getBoolean(CREATE_DIR_IF_MISSING_KEY, false));
	String isoLevelStr = configuration.getString(DEFAULT_ISOLATION_LEVEL_KEY);
	if (isoLevelStr != null) {
		setDefaultIsolationLevel(BitsyIsolationLevel.valueOf(isoLevelStr));
	}
	String vertexIndices = configuration.getString(VERTEX_INDICES_KEY);
	if (vertexIndices != null) {
		createIndices(Vertex.class, vertexIndices);
	}
	String edgeIndices = configuration.getString(EDGE_INDICES_KEY);
	if (edgeIndices != null) {
		createIndices(Edge.class, edgeIndices);
	}
	this.origConfig = configuration;
}
 
Example 5
Project: jbake-rtl-jalaali   File: MarkupEngine.java   Source Code and License Vote up 5 votes
/**
 * Process the header of the file.
 * @param config 
 *
 * @param contents Contents of file
 * @param content
 */
private void processHeader(Configuration config, List<String> contents, final Map<String, Object> content) {
    for (String line : contents) {
        if (line.equals(HEADER_SEPARATOR)) {
            break;
        }

        if (line.isEmpty()) {
        	continue;
        }
        
        String[] parts = line.split("=",2);
        if (parts.length != 2) {
            continue;
        }

        String key = parts[0].trim();
        String value = parts[1].trim();

        if (key.equalsIgnoreCase(Crawler.Attributes.DATE)) {
            DateFormat df = new SimpleDateFormat(config.getString(Keys.DATE_FORMAT));
            Date date = null;
            try {
                date = df.parse(value);
                content.put(key, date);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        } else if (key.equalsIgnoreCase(Crawler.Attributes.TAGS)) {
            content.put(key, getTags(value));
        } else if (isJson(value)) {
            content.put(key, JSONValue.parse(value));
        } else {
            content.put(key, value);
        }
    }
}
 
Example 6
Project: incubator-servicecomb-java-chassis   File: MicroserviceDefinition.java   Source Code and License Vote up 5 votes
private void initCombinedFrom(List<ConfigModel> configModels) {
  for (ConfigModel model : configModels) {
    Configuration conf = ConfigUtil.createLocalConfig(Arrays.asList(model));
    String name =
        conf.getString(CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY, DEFAULT_MICROSERVICE_NAME);
    if (!StringUtils.isEmpty(name)) {
      checkMicroserviceName(name);
      combinedFrom.add(name);
    }
  }

  combinedFrom.remove(microserviceName);
}
 
Example 7
Project: java-market-maker   File: MarketMakerConfiguration.java   Source Code and License Vote up 5 votes
public static MarketMakerConfiguration fromPropertiesFile(final String fileName) throws ConfigurationException {
    final Configuration configuration = new PropertiesConfiguration(fileName);
    return new MarketMakerConfiguration(
        configuration.getInt(ConfigKey.TIME_SLEEP_SECONDS.getKey()),
        new BigDecimal(configuration.getString(ConfigKey.SPREAD_FRACTION.getKey())),
        configuration.getDouble(ConfigKey.FAIR_VOLATILITY.getKey()),
        configuration.getDouble(ConfigKey.VOLATILITY_SPREAD_FRACTION.getKey()),
        configuration.getInt(ConfigKey.NUM_LEVELS.getKey()),
        configuration.getInt(ConfigKey.QUANTITY_ON_LEVEL.getKey()),
        configuration.getDouble(ConfigKey.DELTA_LIMIT.getKey()),
        configuration.getDouble(ConfigKey.VEGA_LIMIT.getKey())
    );
}
 
Example 8
Project: tinkergraph-gremlin   File: TinkerGraph.java   Source Code and License Vote up 5 votes
/**
 * Construct an {@link TinkerGraph.IdManager} from the TinkerGraph {@code Configuration}.
 */
private static IdManager<?> selectIdManager(final Configuration config, final String configKey, final Class<? extends Element> clazz) {
    final String vertexIdManagerConfigValue = config.getString(configKey, DefaultIdManager.ANY.name());
    try {
        return DefaultIdManager.valueOf(vertexIdManagerConfigValue);
    } catch (IllegalArgumentException iae) {
        try {
            return (IdManager) Class.forName(vertexIdManagerConfigValue).newInstance();
        } catch (Exception ex) {
            throw new IllegalStateException(String.format("Could not configure TinkerGraph %s id manager with %s", clazz.getSimpleName(), vertexIdManagerConfigValue));
        }
    }
}
 
Example 9
Project: tinkergraph-gremlin   File: TinkerGraphProvider.java   Source Code and License Vote up 5 votes
@Override
public void clear(final Graph graph, final Configuration configuration) throws Exception {
    if (graph != null)
        graph.close();

    // in the even the graph is persisted we need to clean up
    final String graphLocation = configuration.getString(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null);
    if (graphLocation != null) {
        final File f = new File(graphLocation);
        f.delete();
    }
}
 
Example 10
Project: momo-2   File: Bot.java   Source Code and License Vote up 5 votes
public boolean loadProperties() {
	try (FileInputStream finput = new FileInputStream("resources/Bot.properties")) {
		PropertiesConfiguration config = new PropertiesConfiguration();
		config.load(finput, "UTF-8");
		config.setEncoding("UTF-8");
		botConfig.setToken(config.getString("BotToken"));
		botConfig.setAvatar(config.getString("Avatar"));
		botConfig.setBotOwnerId(config.getLong("BotOwnerId", 0));
		botConfig.setBotInviteLink(config.getString("InviteLink"));
		botConfig.setMaxSongLength(config.getInt("MaxSongLength", 15));
		botConfig.setCompanionBot(config.getBoolean("MusicCompanion", false));
		botConfig.setDefaultSSLPort(config.getInt("DefaultSSLPort", 8443));
		botConfig.setDefaultInsecurePort(config.getInt("DefaultInsecurePort", 8080));

		Configuration subset = config.subset("apikey");
		Iterator<String> iter = subset.getKeys();
		while(iter.hasNext()) {
			String key = iter.next();
			String val = subset.getString(key);
			if(val.length() > 0) {
				this.apiKeys.put(key, val);
				logger.info("Added API key for: {}", key);
			}
		}
		StatusChangeJob.setStatuses(config.getStringArray("StatusRotation"));
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
Example 11
Project: redirector   File: ServiceInfo.java   Source Code and License Vote up 5 votes
public ServiceInfo(Configuration config) {
    // read the maven properties
    projectName = getString(config, PROJECT_NAME_KEY);
    projectVersion = getString(config, "ProjectVersion");

    // read the sub-version properties
    rev = getString(config, REVISION_KEY);
    source = config.getString(SOURCE_KEY);
    if (source != null && !source.isEmpty()) {
        try {
            URI uri = new URI(source);
            source = uri.getPath();
        } catch (Exception e) {
            log.warn("An error occurs while process source URI " + source, e);
            source = NA;
        }
    } else {
        source = NA;
    }

    // read the git properties
    gitBranch = getString(config, "git.branch");
    gitBuildTime = getString(config, "git.build.time");
    gitCommitId = getString(config, "git.commit.id");
    gitCommitTime = getString(config, "git.commit.time");

    // read the serviceName and serviceVersion set in wrapper.sh
    serviceName = System.getProperty("serviceName", NA);
    serviceVersion = System.getProperty("serviceVersion", NA);
}
 
Example 12
Project: redirector   File: DataServiceInfo.java   Source Code and License Vote up 5 votes
public ServiceInfo(Configuration config) {
    // read the maven properties
    projectName = getString(config, PROJECT_NAME_KEY);
    projectVersion = getString(config, "ProjectVersion");

    // read the sub-version properties
    rev = getString(config, REVISION_KEY);
    source = config.getString(SOURCE_KEY);
    if (source != null && !source.isEmpty()) {
        try {
            URI uri = new URI(source);
            source = uri.getPath();
        } catch (Exception e) {
            log.warn("An error occurs while process source URI " + source, e);
            source = NA;
        }
    } else {
        source = NA;
    }

    // read the git properties
    gitBranch = getString(config, "git.branch");
    gitBuildTime = getString(config, "git.build.time");
    gitCommitId = getString(config, "git.commit.id");
    gitCommitTime = getString(config, "git.commit.time");

    // read the serviceName and serviceVersion set in wrapper.sh
    serviceName = System.getProperty("serviceName", NA);
    serviceVersion = System.getProperty("serviceVersion", NA);
}
 
Example 13
Project: gremzeppelin   File: GremlinInterpreter.java   Source Code and License Vote up 5 votes
@Override
public void open() {
    logger.info("init gremlin client via {}", property);
    Configuration configuration = new BaseConfiguration();
    property.keySet().forEach(key -> configuration.setProperty(key.toString(), property.get(key)));
    //transform hosts
    String hosts = configuration.getString(GREMLIN_SERVER_HOSTS, DEFAULT_GREMLIN_SERVER_HOSTS);
    configuration.clearProperty(GREMLIN_SERVER_HOSTS);
    configuration.setProperty(GREMLIN_SERVER_HOSTS, Arrays.asList(hosts.split(",")));

    cluster = Cluster.open(configuration.subset("gremlin.server"));
    client = cluster.connect();
}
 
Example 14
Project: NGB-master   File: ConfigurationLoader.java   Source Code and License Vote up 5 votes
/**
 * Loads XML configuration file with application commands. This file contains
 * information required for initializing and running commands: type of the command,
 * type of request and URL (for NGB server commands) and any supplementary data
 * @param fullCommand name of the command to load configuration for
 * @return configuration for the specifies command
 */
public CommandConfiguration loadCommandConfiguration(String fullCommand) {
    Configuration configuration = loadXmlConfiguration(COMMAND_XML_CONFIG);
    String name = configuration.getString(fullCommand + COMMAND_NAME_PROPERTY);
    String url = configuration.getString(fullCommand + COMMAND_URL_PROPERTY);
    String type = configuration.getString(fullCommand + COMMAND_TYPE_PROPERTY);
    boolean secure = false;
    if (configuration.getString(fullCommand + COMMAND_SECURE_PROPERTY) != null) {
        secure = configuration.getBoolean(fullCommand + COMMAND_SECURE_PROPERTY);
    }
    return new CommandConfiguration(name, url, type, secure);
}
 
Example 15
Project: incubator-servicecomb-java-chassis   File: AbstractPropertiesLoader.java   Source Code and License Vote up 4 votes
private String readExtendedPropertyClassName(Configuration configuration, String keyName) {
  String configKey = mergeStrings(getConfigOptionPrefix(), keyName);
  return configuration.getString(configKey, "");
}
 
Example 16
Project: hdt-gremlin   File: HDTGraph.java   Source Code and License Vote up 4 votes
public static HDTGraph open(Configuration config) throws IOException {
	String file = config.getString(CONFIG_FILENAME);
	return new HDTGraph(file);
}