本文整理匯總了Java中org.apache.commons.configuration.HierarchicalConfiguration.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java HierarchicalConfiguration.getString方法的具體用法?Java HierarchicalConfiguration.getString怎麽用?Java HierarchicalConfiguration.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.configuration.HierarchicalConfiguration
的用法示例。
在下文中一共展示了HierarchicalConfiguration.getString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAllValuesSets
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
*
* @return
* @should return all values
*/
public List<Set> getAllValuesSets() {
List<HierarchicalConfiguration> types = getLocalConfigurationsAt("sets.allValuesSet");
if (types != null) {
List<Set> ret = new ArrayList<>(types.size());
for (Iterator<HierarchicalConfiguration> it = types.iterator(); it.hasNext();) {
HierarchicalConfiguration sub = it.next();
Set set = new Set(sub.getString("."), null, null);
set.setTranslate(sub.getBoolean("[@translate]", false));
ret.add(set);
// logger.debug("loaded type: " + sub.getString("[@name]") + ": " + sub.getString("[@type]"));
}
return ret;
}
return new ArrayList<>(0);
}
示例2: getCollectionBlacklist
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Returns collection names to be omitted from search results, listings etc. from config_viewer.xml
*
* @return
* @should return all key-value pairs
*/
public List<String> getCollectionBlacklist() {
List<String> ret = new ArrayList<>();
if (viewerConfig == null) {
logger.error("Viewer config not loaded, cannot read collection blacklist.");
return ret;
}
List<HierarchicalConfiguration> templates = viewerConfig.configurationsAt("collections.collection");
if (templates != null && !templates.isEmpty()) {
for (Iterator<HierarchicalConfiguration> it = templates.iterator(); it.hasNext();) {
HierarchicalConfiguration sub = it.next();
String field = sub.getString("[@field]");
List<Object> collections = sub.getList("blacklist.collection");
for (Object o : collections) {
ret.add(field + ":" + (String) o);
}
}
}
return ret;
}
示例3: getRestrictedAccessConditions
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* @return
* @should return all values
*/
public List<LicenseType> getRestrictedAccessConditions() {
List<HierarchicalConfiguration> elements = getLocalConfigurationsAt("solr.restrictions.restriction");
if (elements != null) {
List<LicenseType> ret = new ArrayList<>(elements.size());
for (Iterator<HierarchicalConfiguration> it = elements.iterator(); it.hasNext();) {
HierarchicalConfiguration sub = it.next();
Map<String, String> fieldConfig = new HashMap<>();
String value = sub.getString(".");
String field = sub.getString("[@field]", null);
String condition = sub.getString("[@conditions]", null);
ret.add(new LicenseType(field, value, condition));
}
return ret;
}
return new ArrayList<>(0);
}
示例4: loadDriver
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Loads a driver from the supplied hierarchical configuration.
*
* @param driverCfg hierarchical configuration containing the driver definition
* @param resolver driver resolver
* @return driver
*/
public DefaultDriver loadDriver(HierarchicalConfiguration driverCfg,
DriverResolver resolver) {
String name = driverCfg.getString(NAME);
String parentsString = driverCfg.getString(EXTENDS, "");
List<Driver> parents = Lists.newArrayList();
if (!parentsString.equals("")) {
List<String> parentsNames;
if (parentsString.contains(",")) {
parentsNames = Arrays.asList(parentsString.replace(" ", "").split(","));
} else {
parentsNames = Lists.newArrayList(parentsString);
}
parents = parentsNames.stream().map(parent -> (parent != null) ?
resolve(parent, resolver) : null).collect(Collectors.toList());
}
String manufacturer = driverCfg.getString(MFG, "");
String hwVersion = driverCfg.getString(HW, "");
String swVersion = driverCfg.getString(SW, "");
return new DefaultDriver(name, parents, manufacturer, hwVersion, swVersion,
parseBehaviours(driverCfg),
parseProperties(driverCfg));
}
示例5: load
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Loads and parse CME MDP Configuration.
*
* @param uri URI to CME MDP Configuration (config.xml, usually available on CME FTP)
* @throws ConfigurationException if failed to parse configuration file
* @throws MalformedURLException if URI to Configuration is malformed
*/
private void load(final URI uri) throws ConfigurationException, MalformedURLException {
// todo: if to implement the same via standard JAXB then dep to apache commons configuration will be not required
final XMLConfiguration configuration = new XMLConfiguration();
configuration.setDelimiterParsingDisabled(true);
configuration.load(uri.toURL());
for (final HierarchicalConfiguration channelCfg : configuration.configurationsAt("channel")) {
final ChannelCfg channel = new ChannelCfg(channelCfg.getString("[@id]"), channelCfg.getString("[@label]"));
for (final HierarchicalConfiguration connCfg : channelCfg.configurationsAt("connections.connection")) {
final String id = connCfg.getString("[@id]");
final FeedType type = FeedType.valueOf(connCfg.getString("type[@feed-type]"));
final TransportProtocol protocol = TransportProtocol.valueOf(connCfg.getString("protocol").substring(0, 3));
final Feed feed = Feed.valueOf(connCfg.getString("feed"));
final String ip = connCfg.getString("ip");
final int port = connCfg.getInt("port");
final List<String> hostIPs = Arrays.asList(connCfg.getStringArray("host-ip"));
final ConnectionCfg connection = new ConnectionCfg(feed, id, type, protocol, ip, hostIPs, port);
channel.addConnection(connection);
connCfgs.put(connection.getId(), connection);
}
channelCfgs.put(channel.getId(), channel);
}
}
示例6: getNetworks
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
public List<Network> getNetworks() {
List<Network> result = new LinkedList<Network>();
if (configuration != null) {
List<HierarchicalConfiguration> networks = configuration
.configurationsAt("networks.network");
for (HierarchicalConfiguration networkEntry : networks) {
int maxVm = 0;
try {
maxVm = Integer.parseInt(networkEntry
.getString("numOfMaxVm"));
} catch (NumberFormatException e) {
maxVm = Integer.MAX_VALUE;
}
Network network = new Network(networkEntry.getString("name"),
networkEntry.getString("networkCategory"),
networkEntry.getString("networkId"), maxVm);
result.add(network);
}
}
return result;
}
示例7: fillGenreMap
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static void fillGenreMap(String xmlGenreFilename) {
File xmlGenreFile = new File(xmlGenreFilename);
if (xmlGenreFile.exists() && xmlGenreFile.isFile() && xmlGenreFilename.toUpperCase().endsWith("XML")) {
try {
XMLConfiguration c = new XMLConfiguration(xmlGenreFile);
List<HierarchicalConfiguration> genres = c.configurationsAt("genre");
for (HierarchicalConfiguration genre : genres) {
String masterGenre = genre.getString(LIT_NAME);
LOG.trace("New masterGenre parsed : (" + masterGenre + ")");
List<Object> subgenres = genre.getList("subgenre");
for (Object subgenre : subgenres) {
LOG.trace("New genre added to map : (" + subgenre + "," + masterGenre + ")");
GENRES_MAP.put((String) subgenre, masterGenre);
}
}
} catch (ConfigurationException error) {
LOG.error("Failed parsing moviejukebox genre input file: {}", xmlGenreFile.getName());
LOG.error(SystemTools.getStackTrace(error));
}
} else {
LOG.error("The moviejukebox genre input file you specified is invalid: {}", xmlGenreFile.getName());
}
}
示例8: getMap
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
public static Map<String, String> getMap(String key) {
// return getMapAndCache(key);
Map<String, String> result = null;
StringBuilder sb = new StringBuilder();
sb.append(key);
sb.append(".entry");
// System.out.println(sb);
List<HierarchicalConfiguration> list = configurationsAt(sb.toString());
// System.out.println(list.size());
if (!list.isEmpty()) {
result = new LinkedHashMap<String, String>();
for (HierarchicalConfiguration node : list) {
String nodeKey = node.getString("key");
String nodeValue = node.getString("value");
// System.out.println(nodeKey+" "+nodeValue);
result.put(nodeKey, nodeValue);
}
}
return result;
}
示例9: initConfig
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected void initConfig(XMLConfiguration configuration) {
messages.clear();
if (config != null) {
String style = getStyle();
@SuppressWarnings("unchecked") List<HierarchicalConfiguration> msgConfigs = config
.configurationsAt(KEY_MESSAGE_NODE);
for (HierarchicalConfiguration msgConfig : msgConfigs) {
String event = msgConfig.getString(KEY_EVENT);
String subject = msgConfig.getString(KEY_SUBJECT);
String body = msgConfig.getString(KEY_BODY);
if (!StringUtils.isEmpty(event) && !StringUtils.isEmpty(subject) && !StringUtils.isEmpty(body)) {
messages.put(event, new MailMessage(body, subject, style));
}
}
}
}
示例10: fillCategoryMap
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static void fillCategoryMap(String xmlCategoryFilename) {
File xmlFile = new File(xmlCategoryFilename);
if (xmlFile.exists() && xmlFile.isFile() && xmlCategoryFilename.toUpperCase().endsWith("XML")) {
try {
XMLConfiguration c = new XMLConfiguration(xmlFile);
List<HierarchicalConfiguration> categories = c.configurationsAt("category");
for (HierarchicalConfiguration category : categories) {
boolean enabled = Boolean.parseBoolean(category.getString("enable", TRUE));
if (enabled) {
String origName = category.getString(LIT_NAME);
String newName = category.getString("rename", origName);
CATEGORIES_MAP.put(origName, newName);
//logger.debug("Added category '" + origName + "' with name '" + newName + "'");
}
}
} catch (ConfigurationException error) {
LOG.error("Failed parsing moviejukebox category input file: {}", xmlFile.getName());
LOG.error(SystemTools.getStackTrace(error));
}
} else {
LOG.error("The moviejukebox category input file you specified is invalid: {}", xmlFile.getName());
}
}
示例11: getFieldForMetadataFormat
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
*
* @param metadataFormat
* @return
* @should return all values
*/
public List<FieldConfiguration> getFieldForMetadataFormat(String metadataFormat) {
if (metadataFormat == null) {
throw new IllegalArgumentException("metadataFormat may not be null");
}
List<HierarchicalConfiguration> elements = getLocalConfigurationsAt(metadataFormat + ".fields.field");
if (elements != null) {
List<FieldConfiguration> ret = new ArrayList<>(elements.size());
for (Iterator<HierarchicalConfiguration> it = elements.iterator(); it.hasNext();) {
HierarchicalConfiguration sub = it.next();
Map<String, String> fieldConfig = new HashMap<>();
String name = sub.getString("[@name]", null);
String valueSource = sub.getString("[@valueSource]", null);
boolean translate = sub.getBoolean("[@translate]", false);
boolean multivalued = sub.getBoolean("[@multivalued]", false);
boolean useTopstructValueIfNoneFound = sub.getBoolean("[@useTopstructValueIfNoneFound]", false);
String defaultValue = sub.getString("[@defaultValue]", null);
String prefix = sub.getString("[@prefix]", null);
if (prefix != null) {
prefix = prefix.replace("_SPACE_", " ");
}
String suffix = sub.getString("[@suffix]", null);
if (suffix != null) {
suffix = suffix.replace("_SPACE_", " ");
}
ret.add(new FieldConfiguration(name, valueSource, translate, multivalued, useTopstructValueIfNoneFound, defaultValue, prefix,
suffix));
}
return ret;
}
return null;
}
示例12: getAdditionalSets
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
*
* @return
* @should return all values
*/
public List<Set> getAdditionalSets() {
List<HierarchicalConfiguration> types = getLocalConfigurationsAt("sets.set");
if (types != null) {
List<Set> ret = new ArrayList<>(types.size());
for (Iterator<HierarchicalConfiguration> it = types.iterator(); it.hasNext();) {
HierarchicalConfiguration sub = it.next();
Set set = new Set(sub.getString("[@setName]"), sub.getString("[@setSpec]"), sub.getString("[@setQuery]"));
ret.add(set);
// logger.debug("loaded type: " + sub.getString("[@name]") + ": " + sub.getString("[@type]"));
}
return ret;
}
return new ArrayList<>(0);
}
示例13: convertCfgToUser
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static Function<HierarchicalConfiguration, User> convertCfgToUser(final Tokenizer tokenizer) {
return new Function<HierarchicalConfiguration, User>() {
@Override
public User valueOf(HierarchicalConfiguration cfg) {
return new User(tokenizer.tokenizeString(cfg.getString("[@name]")), cfg.getString("[@password]"),
cfg.getBoolean("[@admin]", false));
}
};
}
示例14: convertCfgToPermission
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static Function<HierarchicalConfiguration, Permission> convertCfgToPermission(final Tokenizer tokenizer) {
return new Function<HierarchicalConfiguration, Permission>() {
@Override
public Permission valueOf(HierarchicalConfiguration cfg) {
return new Permission(cfg.getString("[@scheme]"),
iterConfig(cfg, "grant").collect(convertCfgToGrant(tokenizer)));
}
};
}
示例15: getProperty
import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
* Returns the desired property from the config, giving preference to the environment but defaulting to the system if it exists.
* The calls above should look to adopt this method.
*/
private String getProperty(HierarchicalConfiguration sysCfg, HierarchicalConfiguration envCfg, String property) {
String envVal = envCfg.getString(property);
if (envVal != null) {
return envVal;
}
String sysVal = sysCfg.getString(property);
if (sysVal != null) {
return sysVal;
}
return null;
}