private void dumpProps(Properties systemProperties) { for(Object k: systemProperties.keySet()) { String key = (String) k; System.out.println(key + ": " + systemProperties.getProperty(key)); } } }
public void setProperties(Properties newProps) { this.properties = new Properties(); for (Iterator iter = newProps.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); // String value = newProps.getProperty(key); this.properties.setProperty(key, newProps.getProperty(key)); } }
public void load() throws IOException { Properties properties = new Properties(); properties.load(Djb2Manager.class.getResourceAsStream("/djb2.properties")); for (Object key : properties.keySet()) { int hash = Integer.parseInt((String) key); String value = properties.getProperty((String) key); hashes.put(hash, value); } logger.info("Loaded {} djb2 hashes", hashes.size()); }
@Override public Properties toSecurityProperties() { Properties result = new Properties(); for (Object attName : security.keySet()) { if (attName instanceof String) { result.put(attName, getAttribute((String) attName)); } else { result.put(attName, security.get(attName)); } } return result; }
/** * Run RegexNER over this sentence. Note that this is an in place operation, and simply * updates the NER tags. * Therefore, every time this function is called, it re-runs the annotator! * * @param mappingFile The regexner mapping file. * @param ignorecase If true, run a caseless match on the regexner file. */ public void regexner(String mappingFile, boolean ignorecase) { Properties props = new Properties(); for (Object prop : this.defaultProps.keySet()) { props.setProperty(prop.toString(), this.defaultProps.getProperty(prop.toString())); } props.setProperty(Annotator.STANFORD_REGEXNER + ".mapping", mappingFile); props.setProperty(Annotator.STANFORD_REGEXNER + ".ignorecase", Boolean.toString(ignorecase)); this.document.runRegexner(props); }
static void addGemFireSystemProperties(final List<String> commandLine, final Properties gemfireProperties) { for (final Object property : gemfireProperties.keySet()) { final String propertyName = property.toString(); final String propertyValue = gemfireProperties.getProperty(propertyName); if (StringUtils.isNotBlank(propertyValue)) { commandLine.add( "-D" + DistributionConfig.GEMFIRE_PREFIX + "" + propertyName + "=" + propertyValue); } } }
public State(State otherState) { this.commonProperties = otherState.getCommonProperties(); this.specProperties = new Properties(); this.specProperties.putAll(otherState.getProperties()); for (Object key : this.commonProperties.keySet()) { if (this.specProperties.containsKey(key) && this.commonProperties.get(key).equals(this.specProperties.get(key))) { this.specProperties.remove(key); } } }
private String getProperty(Properties props, String[] keys) { for (int i = 0; i < keys.length; i++) { String val = props.getProperty(keys[i]); if (val != null) { return val; } } for (Iterator i = props.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); for (int j = 0; j < keys.length; j++) { if (key.endsWith(keys[j])) { return props.getProperty(key); } } } return null; }
public Properties getChangedProperties() { Properties ret = new Properties(); Properties newProp = getAllProperties(); for (Object one : newProp.keySet()) { String oneProp = (String) one; String oldValue = origProp.getProperty(oneProp); if (!StringUtils.equals(oldValue, newProp.getProperty(oneProp))) { ret.setProperty(oneProp, newProp.getProperty(oneProp)); } } return (ret); }
private void setSystemProperty(Properties properties) { for (Object key : properties.keySet()) { if (!RemoteInterpreterUtils.isEnvString((String) key)) { String value = properties.getProperty((String) key); if (!StringUtils.isBlank(value)) { System.setProperty((String) key, properties.getProperty((String) key)); } } } }
/** * Remove all properties with a certain keyPrefix * * @param prefix key prefix */ public void removePropsWithPrefix(String prefix) { this.specProperties.entrySet().removeIf(entry -> ((String) entry.getKey()).startsWith(prefix)); Properties newCommonProperties = null; for (Object key: this.commonProperties.keySet()) { if (((String)key).startsWith(prefix)) { if (newCommonProperties == null) { newCommonProperties = new Properties(); newCommonProperties.putAll(this.commonProperties); } newCommonProperties.remove(key); } } if (newCommonProperties != null) { this.commonProperties = newCommonProperties; } }
@Override public void close() { // Clear the extra stuff from System properties Properties properties = System.getProperties(); properties.remove(SECURITY_SYSTEM_PREFIX + SECURITY_PEER_AUTH_INIT); properties.remove(SECURITY_SYSTEM_PREFIX + SECURITY_PEER_AUTHENTICATOR); Iterator iter = security.keySet().iterator(); while (iter.hasNext()) { properties.remove(SECURITY_SYSTEM_PREFIX + iter.next()); } System.setProperties(properties); }
public SingletonAnnotator(String host, int port, Properties properties, String annotator) { Properties forClient = new Properties(); for (Object o : properties.keySet()) { String key = o.toString(); String value = properties.getProperty(key); forClient.setProperty(key, value); forClient.setProperty(annotator + '.' + key, value); } if (lazy) { forClient.setProperty("annotators", annotator); forClient.setProperty("enforceRequirements", "false"); } else { String annotators = "tokenize,ssplit,pos,lemma,ner,parse,mention,coref,natlog,openie,sentiment"; if (!annotators.contains(annotator)) { annotators += "," + annotator; } forClient.setProperty("annotators", annotators); } this.client = new StanfordCoreNLPClient(forClient, host, port, key, secret); }
@Override public String getFormattedContent(TableClass tableClass, Properties properties, String targetPackage, String templateContent) { Map<String, Object> params = new HashMap<String, Object>(); for (Object o : properties.keySet()) { params.put(String.valueOf(o), properties.get(o)); } params.put("props", properties); params.put("package", targetPackage); params.put("tableClass", tableClass); return process(properties.getProperty("templatePath"), templateContent, params); }
/** * (non-Javadoc) * * @see org.geoserver.security.GeoServerRoleService#personalizeRoleParams(java.lang.String, * java.util.Properties, java.lang.String, java.util.Properties) * <p>Default implementation: if a user property name equals a role property name, take the * value from to user property and use it for the role property. */ public Properties personalizeRoleParams( String roleName, Properties roleParams, String userName, Properties userProps) throws IOException { Properties props = null; // this is true if the set is modified --> common // property names exist props = new Properties(); boolean personalized = false; for (Object key : roleParams.keySet()) { if (userProps.containsKey(key)) { props.put(key, userProps.get(key)); personalized = true; } else { props.put(key, roleParams.get(key)); } } return personalized ? props : null; }
/** * @return The set of properties (newly created object) that contains the connection pooling parameters All * environment variables will be replaced here. */ @Override public Properties getConnectionPoolingProperties() { Properties properties = new Properties(); for ( Iterator<Object> iter = attributes.keySet().iterator(); iter.hasNext(); ) { String element = (String) iter.next(); if ( element.startsWith( ATTRIBUTE_POOLING_PARAMETER_PREFIX ) ) { String key = element.substring( ATTRIBUTE_POOLING_PARAMETER_PREFIX.length() ); String value = attributes.getProperty( element ); properties.put( key, value ); } } return properties; }
/** * Creates new Properties object from the original one, by copying * those properties that have specified first part of the key name. * Prefix may be optionally stripped during this process. * * @param p source properties, from which new object will be created * @param prefix key names prefix * * @return subset properties */ public static Properties subset(Properties p, String prefix, boolean stripPrefix) { if (StringUtil.isBlank(prefix)) { return p; } if (!prefix.endsWith(StringPool.DOT)) { prefix += '.'; } Properties result = new Properties(); int baseLen = prefix.length(); for (Object o : p.keySet()) { String key = (String) o; if (key.startsWith(prefix)) { result.setProperty(stripPrefix ? key.substring(baseLen) : key, p.getProperty(key)); } } return result; }
@Override public String getFormattedContent(Set<TableClass> tableClassSet, Properties properties, String targetPackage, String templateContent) { Map<String, Object> params = new HashMap<String, Object>(); for (Object o : properties.keySet()) { params.put(String.valueOf(o), properties.get(o)); } params.put("props", properties); params.put("package", targetPackage); params.put("tableClassSet", tableClassSet); return process(properties.getProperty("templatePath"), templateContent, params); } }
private Properties settingsAsProperties(XNode context) { if (context == null) { return new Properties(); } Properties props = context.getChildrenAsProperties(); // Check that all settings are known to the configuration class MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory); for (Object key : props.keySet()) { if (!metaConfig.hasSetter(String.valueOf(key))) { throw new BuilderException("The setting " + key + " is not known. Make sure you spelled it correctly (case sensitive)."); } } return props; }