int solutionMemory = config.getInt("strategy.memory"); List<HierarchicalConfiguration> strategyConfigs = config.configurationsAt("strategy.searchStrategies.searchStrategy"); for (HierarchicalConfiguration strategyConfig : strategyConfigs) {
@Override protected void loadStringTaggerFromXML(XMLConfiguration xml) throws IOException { setFromField(xml.getString("[@fromField]", getFromField())); setToField(xml.getString("[@toField]", getToField())); setOverwrite(xml.getBoolean("[@overwrite]", isOverwrite())); Integer fbMaxLength = xml.getInteger("[@fallbackMaxLength]", null); if (fbMaxLength != null) { LOG.warn("Attribute \"fallbackMaxLength\" is no longer supported " + "and will be ignored. Use \"titleMaxLength\" instead."); } setTitleMaxLength(xml.getInt( "[@titleMaxLength]", getTitleMaxLength())); setDetectHeading(xml.getBoolean("[@detectHeading]", isDetectHeading())); setDetectHeadingMinLength(xml.getInt( "[@detectHeadingMinLength]", getDetectHeadingMinLength())); setDetectHeadingMaxLength(xml.getInt( "[@detectHeadingMaxLength]", getDetectHeadingMaxLength())); }
XMLConfiguration xmlConfig = ... // Get as String the text content of the element name String name = xmlConfig.getString("name"); // Get as int the text content of the element value of the first element length int length = xmlConfig.getInt("length(0).value");
/** * Returns a configuration property <b>int</b> value based off the {@link ConfigProperty} * * @param configProperty * String Property Name * @return The configuration property <b>int</b> value */ public static int getIntConfigProperty(String configProperty) { checkArgument(configProperty != null, "Config property cannot be null"); return getConfig().getInt(configProperty); }
/** * gets a property value as integer * * @param key of the property * @return property as integer value */ public int getProperty(String key) { String error; if(!propsConfig.containsKey(key)) { error = "Value '" + key + "' not found in properties !"; } else { try { return propsConfig.getInt(key); } catch (Exception e) { error = "Value '" + key + "' is not an integer !"; } } throw new NumberFormatException(error); }
/** * gets a property value as integer * * @param key of the property * @return property as integer value */ public int getProperty(String key) { String error; if(!propsConfig.containsKey(key)) { error = "Value '" + key + "' not found in properties !"; } else { try { return propsConfig.getInt(key); } catch (Exception e) { error = "Value '" + key + "' is not an integer !"; } } throw new NumberFormatException(error); }
@Override protected final void loadCharStreamTaggerFromXML(XMLConfiguration xml) throws IOException { setMaxReadSize(xml.getInt("[@maxReadSize]", getMaxReadSize())); loadStringTaggerFromXML(xml); } /**
@Override protected final void loadCharStreamFilterFromXML(XMLConfiguration xml) throws IOException { setMaxReadSize(xml.getInt("[@maxReadSize]", getMaxReadSize())); loadStringFilterFromXML(xml); } /**
@Override protected final void loadCharStreamTransformerFromXML(XMLConfiguration xml) throws IOException { setMaxReadSize(xml.getInt("[@maxReadSize]", getMaxReadSize())); loadStringTransformerFromXML(xml); } /**
parameterValue = config.getByte(key); } else if("Int".equalsIgnoreCase(parameterType)){ parameterValue = config.getInt(key); } else if("Long".equalsIgnoreCase(parameterType)){ parameterValue = config.getLong(key);
@Override protected void loadHandlerFromXML(XMLConfiguration xml) throws IOException { fromField = xml.getString("[@fromField]", fromField); appendHash = xml.getBoolean("[@appendHash]", appendHash); suffix = xml.getString("[@suffix]", suffix); toField = xml.getString("[@toField]", toField); overwrite = xml.getBoolean("[@overwrite]", overwrite); maxLength = xml.getInt("[@maxLength]", maxLength); } @Override
try { XMLConfiguration config = new XMLConfiguration("tables.xml"); // do something with config } catch(ConfigurationException cex) { // something went wrong, e.g. the file was not found } String backColor = config.getString("colors.background"); String textColor = config.getString("colors.text"); String linkNormal = config.getString("colors.link[@normal]"); String defColor = config.getString("colors.default"); int rowsPerPage = config.getInt("rowsPerPage"); List buttons = config.getList("buttons.name");
iterations = props.getInt("iterations"); } catch (NumberFormatException e) { throw new SimulatorServerException("Property 'iterations' must be a number");
@Override protected void loadHandlerFromXML(XMLConfiguration xml) { setSeparatorCharacter(loadCharacter( xml, "[@separatorCharacter]", separatorCharacter)); setQuoteCharacter(loadCharacter( xml, "[@quoteCharacter]", quoteCharacter)); setEscapeCharacter(loadCharacter( xml, "[@escapeCharacter]", escapeCharacter)); setUseFirstRowAsFields( xml.getBoolean("[@useFirstRowAsFields]", useFirstRowAsFields)); setLinesToSkip(xml.getInt("[@linesToSkip]", linesToSkip)); setReferenceColumn( xml.getString("[@referenceColumn]", referenceColumn)); String contentCols = xml.getString("[@contentColumns]", null); if (StringUtils.isNotBlank(contentCols)) { setContentColumns(contentCols.split(",")); } }
@Override public void loadFromXML(Reader in) { XMLConfiguration xml = XMLConfigurationUtil.newXMLConfiguration(in); setSourceReferenceField( xml.getString("sourceReferenceField", sourceReferenceField)); setKeepSourceReferenceField(xml.getBoolean( "sourceReferenceField[@keep]", keepSourceReferenceField)); setTargetReferenceField(xml.getString( "targetReferenceField", targetReferenceField)); setSourceContentField( xml.getString("sourceContentField", sourceContentField)); setKeepSourceContentField(xml.getBoolean("sourceContentField[@keep]", keepSourceContentField)); setTargetContentField( xml.getString("targetContentField", targetContentField)); setQueueDir(xml.getString("queueDir", DEFAULT_QUEUE_DIR)); setQueueSize(xml.getInt("queueSize", AbstractBatchCommitter.DEFAULT_QUEUE_SIZE)); setCommitBatchSize(xml.getInt("commitBatchSize", AbstractBatchCommitter.DEFAULT_COMMIT_BATCH_SIZE)); setMaxRetries(xml.getInt("maxRetries", 0)); setMaxRetryWait(XMLConfigurationUtil.getDuration( xml, "maxRetryWait", 0)); loadFromXml(xml); }
@Override public void loadFromXML(Reader in) { XMLConfiguration xml = XMLConfigurationUtil.newXMLConfiguration(in); setDirectory(xml.getString("directory", directory)); setPretty(xml.getBoolean("pretty", pretty)); setDocsPerFile(xml.getInt("docsPerFile", docsPerFile)); setCompress(xml.getBoolean("compress", compress)); setSplitAddDelete(xml.getBoolean("splitAddDelete", splitAddDelete)); setFileNamePrefix(xml.getString("fileNamePrefix", fileNamePrefix)); setFileNameSuffix(xml.getString("fileNameSuffix", fileNameSuffix)); } @Override
@Override public void loadFromXML(Reader in) { XMLConfiguration xml = XMLConfigurationUtil.newXMLConfiguration(in); setDirectory(xml.getString("directory", directory)); setPretty(xml.getBoolean("pretty", pretty)); setDocsPerFile(xml.getInt("docsPerFile", docsPerFile)); setCompress(xml.getBoolean("compress", compress)); setSplitAddDelete(xml.getBoolean("splitAddDelete", splitAddDelete)); setFileNamePrefix(xml.getString("fileNamePrefix", fileNamePrefix)); setFileNameSuffix(xml.getString("fileNameSuffix", fileNameSuffix)); } @Override
@Override public void loadFromXML(Reader in) throws IOException { XMLConfiguration xml = XMLConfigurationUtil.newXMLConfiguration(in); connDetails.setPort(xml.getInt("port", connDetails.getPort())); connDetails.setHost(xml.getString("host", connDetails.getHost())); connDetails.setDatabaseName( xml.getString("dbname", connDetails.getDatabaseName())); connDetails.setUsername( xml.getString("username", connDetails.getUsername())); connDetails.setPassword( xml.getString("password", connDetails.getPassword())); connDetails.setMechanism( xml.getString("mechanism", connDetails.getMechanism())); setCachedCollectionName(xml.getString( "cachedCollectionName", getCachedCollectionName())); setReferencesCollectionName(xml.getString( "referencesCollectionName", getReferencesCollectionName())); // encrypted password: String xmlKey = xml.getString("passwordKey", null); String xmlSource = xml.getString("passwordKeySource", null); if (StringUtils.isNotBlank(xmlKey)) { EncryptionKey.Source source = null; if (StringUtils.isNotBlank(xmlSource)) { source = EncryptionKey.Source.valueOf(xmlSource.toUpperCase()); } connDetails.setPasswordKey(new EncryptionKey(xmlKey, source)); } }
this.hostName = config.getString("base.hostName", AndesClientConstants.CARBON_VIRTUAL_HOST_NAME); this.port = config.getInt("base.port", AndesClientConstants.DEFAULT_PORT); this.queryStringForConnection = config.getString("base.queryStringForConnection", ""); this.createConnectionString();