本文整理汇总了Java中org.apache.commons.configuration.Configuration.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getString方法的具体用法?Java Configuration.getString怎么用?Java Configuration.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseFromProperties
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
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;
}
示例2: getAsciiDocOptionsAndAttributes
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
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;
}
示例3: TinkerGraph
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
/**
* 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();
}
示例4: BitsyGraph
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
/**
* 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;
}
示例5: processHeader
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例6: initCombinedFrom
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
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);
}
示例7: fromPropertiesFile
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
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())
);
}
示例8: selectIdManager
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
/**
* 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));
}
}
}
示例9: clear
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@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();
}
}
示例10: loadProperties
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
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;
}
}
示例11: ServiceInfo
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
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);
}
示例12: open
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
@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();
}
示例13: loadCommandConfiguration
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
/**
* 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);
}
示例14: readExtendedPropertyClassName
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
private String readExtendedPropertyClassName(Configuration configuration, String keyName) {
String configKey = mergeStrings(getConfigOptionPrefix(), keyName);
return configuration.getString(configKey, "");
}
示例15: open
import org.apache.commons.configuration.Configuration; //导入方法依赖的package包/类
public static HDTGraph open(Configuration config) throws IOException {
String file = config.getString(CONFIG_FILENAME);
return new HDTGraph(file);
}