当前位置: 首页>>代码示例>>Java>>正文


Java XMLConfiguration.getString方法代码示例

本文整理汇总了Java中org.apache.commons.configuration.XMLConfiguration.getString方法的典型用法代码示例。如果您正苦于以下问题:Java XMLConfiguration.getString方法的具体用法?Java XMLConfiguration.getString怎么用?Java XMLConfiguration.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration.XMLConfiguration的用法示例。


在下文中一共展示了XMLConfiguration.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
@Override
public boolean validate(XMLConfiguration conf) {
    value = conf.getString(paramName);
    if (value == null) {
        if (isNullOk) return true;
        return false;
    }
    try {
        DateFormat format = new SimpleDateFormat(DATE_STRING_FORMAT);
        format.parse(value);
        return true;
    } catch (ParseException e) {
        log.debug("", e);
        validateFalse();
    }
    return false;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:18,代码来源:ConfigUtil.java

示例2: reloadConfigurationInner

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
@Override
protected synchronized void reloadConfigurationInner() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        String __isSystemUserUpdateEnabled = config.getString(KEY_ENABLE_SYSTEM_USER_UPDATE);
        boolean _isSystemUserUpdateEnabled = (__isSystemUserUpdateEnabled == null ? false :
                Boolean.parseBoolean(__isSystemUserUpdateEnabled));

        this.isSystemUserUpdateEnabled = _isSystemUserUpdateEnabled;

        log().info("isSystemUserUpdateEnabled=" + this.isSystemUserUpdateEnabled);
        log().info("reload finished.");
    } catch (ConfigurationException e) {
        log().error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + FILE_NAME);
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:21,代码来源:BuilderConfiguration.java

示例3: main

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static void main(String[] args) throws ConfigurationException {
		
//		// create new configuration file
//		XMLConfiguration config = new XMLConfiguration();
//		config.setProperty("key", "value");
//		config.save("./config.xml");
		
		XMLConfiguration config = new XMLConfiguration("./config.xml");
		
		int numberOfWirings = config.getList("wirings.wiring.input").size();
		System.out.println("Found " + numberOfWirings + " wiring(s)");
		
		for (int index = 0; index < numberOfWirings; index++) {
			String path = "wirings.wiring(" + index + ")";
			String input = config.getString(path + ".input");
			String output = config.getString(path + ".output");
			config.getString(path + ".test"); // returns null because element not available
			
			System.out.println("Wiring: input=" + input + " output=" + output);
		}
		
	}
 
开发者ID:openmucextensions,项目名称:gateway,代码行数:23,代码来源:TestConfiguration.java

示例4: newCar

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static Car newCar() {
	Car car = null;
	String name = null;
	try {
		XMLConfiguration config = new XMLConfiguration("car.xml");
		name = config.getString("factory2.class");
	} catch (ConfigurationException ex) {
		LOG.error("Parsing xml configuration file failed", ex);
	}
	
	try {
		car = (Car)Class.forName(name).newInstance();
		LOG.info("Created car class name is {}", name);
	} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
		LOG.error("Instantiate car {} failed", name);
	}
	return car;
}
 
开发者ID:habren,项目名称:JavaDesignPattern,代码行数:19,代码来源:CarFactory2.java

示例5: main

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static void main(String[] args) throws ConfigurationException {
	XMLConfiguration config = new XMLConfiguration("car.xml");
	String name = config.getString("driver2.name");
	Car car;

	switch (name) {
	case "Land Rover":
		car = new LandRoverCar();
		break;
	case "BMW":
		car = new BMWCar();
		break;
	case "Benz":
		car = new BenzCar();
		break;
	default:
		car = null;
		break;
	}
	LOG.info("Created car name is {}", name);
	car.drive();
}
 
开发者ID:habren,项目名称:JavaDesignPattern,代码行数:23,代码来源:Driver2.java

示例6: gatherAliasAttributes

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
protected void gatherAliasAttributes(XMLConfiguration config, Topic topic) {
	int nbrAliases = 0;
	Object temp = config.getList("Topics.Topic.Alias[@name]");
	if (temp instanceof Collection) {
		nbrAliases = ((Collection)temp).size();
	}
	
	String name, column;
	for (int i = 0; i < nbrAliases; i++) {
		name=config.getString("Topics.Topic.Alias(" + i + ")[@name]");
		column=config.getString("Topics.Topic.Alias(" + i + ")[@column]");
		if (StringUtils.isEmpty(name) || StringUtils.isEmpty(column)) {
			throw new MonetaException("Topic Alias fields must have both name and column specified")
				.addContextValue("topic", topic.getTopicName())
				.addContextValue("name", name)
				.addContextValue("column", column);
		}
		topic.getAliasMap().put(column, name);
	}
}
 
开发者ID:Derek-Ashmore,项目名称:moneta,代码行数:21,代码来源:MonetaConfiguration.java

示例7: gatherKeyFields

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
protected void gatherKeyFields(XMLConfiguration config, Topic topic) {
	int nbrKeyFields = 0;
	Object temp = config.getList("Topics.Topic.PrimaryKey.Field[@name]");
	if (temp instanceof Collection) {
		nbrKeyFields = ((Collection)temp).size();
	}
	
	String name, typeStr;
	TopicKeyField.DataType dataType;
	TopicKeyField keyField;
	for (int i = 0; i < nbrKeyFields; i++) {
		name=config.getString("Topics.Topic.PrimaryKey.Field(" + i + ")[@name]");
		typeStr=config.getString("Topics.Topic.PrimaryKey.Field(" + i + ")[@type]");
		if (StringUtils.isEmpty(name) || StringUtils.isEmpty(typeStr)) {
			throw new MonetaException("Topic Primary Key Fields fields must have both name and type specified")
				.addContextValue("topic", topic.getTopicName())
				.addContextValue("name", name)
				.addContextValue("type", typeStr);
		}
		try {dataType = TopicKeyField.DataType.valueOf(typeStr.toUpperCase());}
		catch (Exception e) {
			throw new MonetaException("Datatype not supported", e)
				.addContextValue("topic", topic.getTopicName())
				.addContextValue("key field", name)
				.addContextValue("dataType", typeStr);
		}
		
		keyField = new TopicKeyField();
		topic.getKeyFieldList().add(keyField);
		keyField.setColumnName(name);
		keyField.setDataType(dataType);
	}
}
 
开发者ID:Derek-Ashmore,项目名称:moneta,代码行数:34,代码来源:MonetaConfiguration.java

示例8: gatherTopicAttributes

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
protected void gatherTopicAttributes(XMLConfiguration config, Topic topic,
		int i) {
	String readOnlyStr;
	topic.setTopicName(config.getString("Topics.Topic(" + i + ")[@name]"));
	topic.setPluralName(config.getString("Topics.Topic(" + i + ")[@pluralName]"));
	topic.setDataSourceName(config.getString("Topics.Topic(" + i + ")[@dataSource]"));
	topic.setSchemaName(config.getString("Topics.Topic(" + i + ")[@schema]"));
	topic.setCatalogName(config.getString("Topics.Topic(" + i + ")[@catalog]"));
	topic.setTableName(config.getString("Topics.Topic(" + i + ")[@table]"));
	
	readOnlyStr = config.getString("Topics.Topic(" + i + ")[@readOnly]");
	Boolean bValue = BooleanUtils.toBooleanObject(readOnlyStr);
	if (bValue != null)  {
		topic.setReadOnly(bValue);
	}
}
 
开发者ID:Derek-Ashmore,项目名称:moneta,代码行数:17,代码来源:MonetaConfiguration.java

示例9: initialize

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private static boolean initialize(String configFile) {
   // read parameters from configuration file
   try {
      config = new XMLConfiguration();
      type2key = new HashMap<String, String>();
      Exception ex = new Exception();
      StackTraceElement[] sTrace = ex.getStackTrace();
      String className = sTrace[0].getClassName();
      Class c = Class.forName(className);
      URL fileurl = ResourceLocator.getURL(configFile, defaultConfigFile, c);
      config.load(fileurl);
      // create index to map idType to key
      int types = config.getMaxIndex("type") + 1;
      String typekey, idType;
      for (int i = 0; i < types; i++) {
         typekey = "type(" + i + ").";
         idType = config.getString(typekey + "idType");
         type2key.put(idType.toLowerCase(), typekey);
      }
   } catch (ConfigurationException ce) {
      return false;
   } catch (ClassNotFoundException cnfe) {
      return false;
   }
   return true;
}
 
开发者ID:Fosstrak,项目名称:fosstrak-hal,代码行数:27,代码来源:IDType.java

示例10: loadAppDescription

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private ApplicationDescription loadAppDescription(XMLConfiguration cfg) {
    String name = cfg.getString(NAME);
    Version version = Version.version(cfg.getString(VERSION));
    String origin = cfg.getString(ORIGIN);

    String title = cfg.getString(TITLE);
    // FIXME: title should be set as attribute to APP, but fallback for now...
    title = title == null ? name : title;

    String category = cfg.getString(CATEGORY, UTILITY);
    String url = cfg.getString(URL);
    byte[] icon = getApplicationIcon(name);
    ApplicationRole role = getRole(cfg.getString(ROLE));
    Set<Permission> perms = getPermissions(cfg);
    String featRepo = cfg.getString(FEATURES_REPO);
    URI featuresRepo = featRepo != null ? URI.create(featRepo) : null;
    List<String> features = ImmutableList.copyOf(cfg.getString(FEATURES).split(","));

    String apps = cfg.getString(APPS, "");
    List<String> requiredApps = apps.isEmpty() ?
            ImmutableList.of() : ImmutableList.copyOf(apps.split(","));

    // put full description to readme field
    String readme = cfg.getString(DESCRIPTION);

    // put short description to description field
    String desc = compactDescription(readme);

    return new DefaultApplicationDescription(name, version, title, desc, origin,
                                             category, url, readme, icon,
                                             role, perms, featuresRepo,
                                             features, requiredApps);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:ApplicationArchive.java

示例11: newCar

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static Car newCar() {
	Car car = null;
	String name = null;
	try {
		XMLConfiguration config = new XMLConfiguration("car.xml");
		name = config.getString("factory1.name");
	} catch (ConfigurationException ex) {
		LOG.error("parse xml configuration file failed", ex);
	}

	switch (name) {
	case "Land Rover":
		car = new LandRoverCar();
		break;
	case "BMW":
		car = new BMWCar();
		break;
	case "Benz":
		car = new BenzCar();
		break;
	default:
		car = null;
		break;
	}
	LOG.info("Created car name is {}", name);
	return car;
}
 
开发者ID:habren,项目名称:JavaDesignPattern,代码行数:28,代码来源:CarFactory1.java

示例12: createLServer

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
 * @param instanceName
 * @param serverType
 * @param diskImageId
 * @param controlNetworkId
 * @param vmPool
 * @param storagePool
 * @param countCPU
 * @return the id for the created LServer
 * @throws RORException
 */
public String createLServer(String instanceName, String serverType,
        String diskImageId, String controlNetworkId, String vmPool,
        String storagePool, String countCPU) throws IaasException {
    List<String> emptyParams = new ArrayList<String>();
    if (isEmpty(lplatformId)) {
        emptyParams.add(LParameter.LPLATFORM_ID);
    }
    if (isEmpty(instanceName)) {
        emptyParams.add(LParameter.LSERVER_NAME);
    }
    // TODO other checks?
    if (!emptyParams.isEmpty()) {
        throw new MissingParameterException(LOperation.CREATE_LSERVER,
                emptyParams);
    }
    HashMap<String, String> request = this.getRequestParameters();
    request.put(LParameter.ACTION, LOperation.CREATE_LSERVER);
    request.put(LParameter.LSERVER_NAME, instanceName);
    request.put(LParameter.LSERVER_TYPE, serverType);
    request.put(LParameter.DISKIMAGE_ID, diskImageId);
    request.put(LParameter.CONTROL_NETWORK_ID, controlNetworkId);
    if (vmPool != null) {
        request.put(LParameter.POOL, vmPool);
    } else {
        request.put(LParameter.POOL, "VMHostPool");
    }
    if (storagePool != null && storagePool.trim().length() > 0) {
        request.put(LParameter.STORAGE_POOL, storagePool);
    } else {
        request.put(LParameter.STORAGE_POOL, "StoragePool");
    }
    if (countCPU != null) {
        request.put(LParameter.CPU_NUMBER, countCPU);
    }
    XMLConfiguration result = vdcClient.execute(request);
    return result.getString(LParameter.LSERVER_ID);
}
 
开发者ID:servicecatalog,项目名称:development,代码行数:49,代码来源:LPlatformClient.java

示例13: createLPlatform

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
 * @param instanceName
 * @param descriptorId
 * @return the ID of the created LPlatform
 * @throws RORException
 */
public String createLPlatform(String instanceName, String descriptorId)
		throws IaasException {
	HashMap<String, String> request = getBasicParameters();
	request.put(LParameter.ACTION, LOperation.CREATE_LPLATFORM);
	request.put(LParameter.LPLATFORM_NAME, instanceName);
	request.put(LParameter.LPLATFORM_DESCR_ID, descriptorId);
	XMLConfiguration result = execute(request);
	return result.getString("lplatformId");
}
 
开发者ID:servicecatalog,项目名称:development,代码行数:16,代码来源:RORClient.java

示例14: getConfigArguments

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
 * Reads in the configuration file properties and values and converts them
 * into a set of argument strings.
 * @param configuration the {@link XMLConfiguration}.
 * @return the set of argument strings.
 */
public static Set<String> getConfigArguments(final XMLConfiguration configuration) {
    final int size = configuration.getList("property.name").size();
    final TreeSet<String> configArgs = new TreeSet<>();
    for (int i = 0; i < size; i++) {
        final String propertyName = configuration.getString("property(" + i + ").name");
        final String propertyValue = configuration.getString("property(" + i + ").value");
        final String argument = makeArgument(propertyName, propertyValue);
        configArgs.add(argument);
    }
    return configArgs;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:ToolConfigUtils.java

示例15: loadAppDescription

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private ApplicationDescription loadAppDescription(XMLConfiguration cfg) {
    cfg.setAttributeSplittingDisabled(true);
    cfg.setDelimiterParsingDisabled(true);
    String name = cfg.getString(NAME);
    Version version = Version.version(cfg.getString(VERSION));
    String desc = cfg.getString(DESCRIPTION);
    String origin = cfg.getString(ORIGIN);
    Set<Permission> perms = ImmutableSet.of();
    String featRepo = cfg.getString(FEATURES_REPO);
    URI featuresRepo = featRepo != null ? URI.create(featRepo) : null;
    List<String> features = ImmutableList.copyOf(cfg.getStringArray(FEATURES));

    return new DefaultApplicationDescription(name, version, desc, origin,
                                             perms, featuresRepo, features);
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:16,代码来源:ApplicationArchive.java


注:本文中的org.apache.commons.configuration.XMLConfiguration.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。