Java Code Examples for java.util.Properties.contains()

The following are Jave code examples for showing how to use contains() of the java.util.Properties class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop-oss   File: Configuration.java   Source Code and License Vote up 6 votes
/**
 * Sets all deprecated properties that are not currently set but have a
 * corresponding new property that is set. Useful for iterating the
 * properties when all deprecated properties for currently set properties
 * need to be present.
 */
public void setDeprecatedProperties() {
  DeprecationContext deprecations = deprecationContext.get();
  Properties props = getProps();
  Properties overlay = getOverlay();
  for (Map.Entry<String, DeprecatedKeyInfo> entry :
      deprecations.getDeprecatedKeyMap().entrySet()) {
    String depKey = entry.getKey();
    if (!overlay.contains(depKey)) {
      for (String newKey : entry.getValue().newKeys) {
        String val = overlay.getProperty(newKey);
        if (val != null) {
          props.setProperty(depKey, val);
          overlay.setProperty(depKey, val);
          break;
        }
      }
    }
  }
}
 
Example 2
Project: monarch   File: DistributedTestCase.java   Source Code and License Vote up 6 votes
public final static Properties getAllDistributedSystemProperties(Properties props) {
  Properties p = DUnitEnv.get().getDistributedSystemProperties();

  // our tests do not expect auto-reconnect to be on by default
  if (!p.contains(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME)) {
    p.put(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true");
  }

  for (Iterator iter = props.entrySet().iterator();
       iter.hasNext(); ) {
    Map.Entry entry = (Map.Entry) iter.next();
    String key = (String) entry.getKey();
    Object value = entry.getValue();
    p.put(key, value);
  }
  return p;
}
 
Example 3
Project: monarch   File: DistributedTestUtils.java   Source Code and License Vote up 6 votes
public final static Properties getAllDistributedSystemProperties(final Properties properties) {
  Properties dsProperties = DUnitEnv.get().getDistributedSystemProperties();

  // our tests do not expect auto-reconnect to be on by default
  if (!dsProperties.contains(DISABLE_AUTO_RECONNECT)) {
    dsProperties.put(DISABLE_AUTO_RECONNECT, "true");
  }

  for (Iterator<Map.Entry<Object, Object>> iterator = properties.entrySet().iterator(); iterator
      .hasNext();) {
    Map.Entry<Object, Object> entry = iterator.next();
    String key = (String) entry.getKey();
    Object value = entry.getValue();
    dsProperties.put(key, value);
  }
  System.out.println("distributed system properties: " + dsProperties);
  return dsProperties;
}
 
Example 4
Project: hadoop   File: Configuration.java   Source Code and License Vote up 6 votes
/**
 * Sets all deprecated properties that are not currently set but have a
 * corresponding new property that is set. Useful for iterating the
 * properties when all deprecated properties for currently set properties
 * need to be present.
 */
public void setDeprecatedProperties() {
  DeprecationContext deprecations = deprecationContext.get();
  Properties props = getProps();
  Properties overlay = getOverlay();
  for (Map.Entry<String, DeprecatedKeyInfo> entry :
      deprecations.getDeprecatedKeyMap().entrySet()) {
    String depKey = entry.getKey();
    if (!overlay.contains(depKey)) {
      for (String newKey : entry.getValue().newKeys) {
        String val = overlay.getProperty(newKey);
        if (val != null) {
          props.setProperty(depKey, val);
          overlay.setProperty(depKey, val);
          break;
        }
      }
    }
  }
}
 
Example 5
Project: lams   File: IdentifierGeneratorResolver.java   Source Code and License Vote up 5 votes
@SuppressWarnings( {"unchecked"} )
void resolve() {
	for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
		if ( entityBinding.isRoot() ) {
			Properties properties = new Properties( );
			properties.putAll(
					metadata.getServiceRegistry()
							.getService( ConfigurationService.class )
							.getSettings()
			);
			//TODO: where should these be added???
			if ( ! properties.contains( AvailableSettings.PREFER_POOLED_VALUES_LO ) ) {
				properties.put( AvailableSettings.PREFER_POOLED_VALUES_LO, "false" );
			}
			if ( ! properties.contains( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER ) ) {
				properties.put(
						PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
						new ObjectNameNormalizerImpl( metadata )
				);
			}
			entityBinding.getHierarchyDetails().getEntityIdentifier().createIdentifierGenerator(
					metadata.getIdentifierGeneratorFactory(),
					properties
			);
		}
	}
}
 
Example 6
Project: openrouteservice   File: FtpDataSource.java   Source Code and License Vote up 5 votes
@Override
public void Initialize(Properties props) {
	server = props.getProperty("server");
	user = props.getProperty("user");
	password = props.getProperty("password");
	file = props.getProperty("file");
	if (props.contains("port"))
		port = Integer.parseInt(props.getProperty("port"));
}