當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。