contains ( )源码实例Demo

java.util.Properties#contains ( )源码实例Demo

下面列出了java.util.Properties#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jkube   文件: ResourceMojo.java
private void lateInit() {
    RuntimeMode runtimeMode = getRuntimeMode();
    jkubeServiceHub.setPlatformMode(runtimeMode);
    if (runtimeMode.equals(RuntimeMode.OPENSHIFT)) {
        Properties properties = project.getProperties();
        if (!properties.contains(DOCKER_IMAGE_USER)) {
            String namespaceToBeUsed = this.namespace != null && !this.namespace.isEmpty() ?
                    this.namespace: clusterAccess.getNamespace();
            log.info("Using docker image name of namespace: " + namespaceToBeUsed);
            properties.setProperty(DOCKER_IMAGE_USER, namespaceToBeUsed);
        }
        if (!properties.contains(RuntimeMode.JKUBE_EFFECTIVE_PLATFORM_MODE)) {
            properties.setProperty(RuntimeMode.JKUBE_EFFECTIVE_PLATFORM_MODE, runtimeMode.toString());
        }
    }
}
 
源代码2 项目: Flink-CEPplus   文件: Configuration.java
/**
 * 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;
				}
			}
		}
	}
}
 
源代码3 项目: flink   文件: Configuration.java
/**
 * 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;
				}
			}
		}
	}
}
 
源代码4 项目: hadoop   文件: Configuration.java
/**
 * 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;
        }
      }
    }
  }
}
 
源代码5 项目: gemfirexd-oss   文件: DistributedTestCase.java
public final 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;
}
 
源代码6 项目: tomee   文件: DataSourceFactory.java
private static void convert(final Properties properties, final Duration duration, final String key, final String oldKey) {
    properties.remove(key);

    // If someone is using the legacy property, use it
    if (properties.contains(oldKey)) {
        return;
    }
    properties.remove(oldKey);

    if (duration == null) {
        return;
    }
    if (duration.getUnit() == null) {
        duration.setUnit(TimeUnit.MILLISECONDS);
    }

    final long milliseconds = TimeUnit.MILLISECONDS.convert(duration.getTime(), duration.getUnit());
    properties.put(oldKey, String.valueOf(milliseconds));
}
 
源代码7 项目: spork   文件: Storage.java
/**
 * reset the store and get the Data object to access it
 * @param context
 * @return data as Data
 */
public static Data resetData(PigContext context) {
  Properties properties = context.getProperties();

  // cleaning up previous data
  try {
    if (properties.contains(PIG_CONTEXT_KEY)) {
      Integer previousId = new Integer(properties.getProperty(PIG_CONTEXT_KEY));
      idToData.remove(previousId);
    }
  } catch (RuntimeException e) {
    LOG.warn("invalid id in context properties for "+PIG_CONTEXT_KEY, e);
  }

  // setting new Store
  int id = nextId++;
  properties.setProperty(PIG_CONTEXT_KEY, String.valueOf(id));
  Data data = new Data();
  idToData.put(id, data);
  return data;
}
 
源代码8 项目: gemfirexd-oss   文件: DistributedTestCase.java
public final 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;
}
 
源代码9 项目: digdag   文件: TestUtils.java
public static void withSystemProperties(Map<String, String> props, Action a)
        throws Exception
{
    Properties systemProperties = System.getProperties();
    Map<String, Object> prev = new HashMap<>();
    for (String key : props.keySet()) {
        if (systemProperties.contains(key)) {
            prev.put(key, systemProperties.getProperty(key));
        } else {
            prev.put(key, NOT_PRESENT);
        }
    }
    try {
        systemProperties.putAll(props);
        a.run();
    }
    finally {
        for (Map.Entry<String, Object> e : prev.entrySet()) {
            if (e.getValue() == NOT_PRESENT) {
                systemProperties.remove(e.getKey());
            } else {
                systemProperties.put(e.getKey(), e.getValue());
            }
        }
    }
}
 
源代码10 项目: rice   文件: PropertiesUtils.java
/**
 * <p>
 * In addition to overriding file properties from System Properties, System properties are added to the returned
 * Properties.
 * </p><p>
 * {@see #systemPropertiesOverride}
 * </p>
 *
 *
 * @param props Properties with System Properties added and Overriding file properties
 * @param arg filter System Properties added to Properties by the Property key starting with arg
 * @return
 */
public Properties systemPropertiesAndOverride(Properties props, String arg) {
    PropertiesUtils propUtils = new PropertiesUtils();
    props = propUtils.systemPropertiesOverride(props, arg);

    Iterator iter = System.getProperties().stringPropertyNames().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        if (arg == null || arg.equals("")) {
            if (!props.contains(key)) {
                props.setProperty(key, System.getProperty(key));
            }
        } else {
            if (key.startsWith(arg) && !props.contains(key)) {
                props.setProperty(key, System.getProperty(key));
            }
        }
    }
    return props;
}
 
源代码11 项目: flink   文件: Configuration.java
/**
 * 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;
				}
			}
		}
	}
}
 
源代码12 项目: spring-cloud-formula   文件: SpacedLogbackSystem.java
protected Appender<ILoggingEvent> fileAppender(Space space) {
    RollingFileAppender<ILoggingEvent> appender = new RollingFileAppender<>();
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    String logPattern = this.patterns.getProperty("logging.pattern.file", FILE_LOG_PATTERN);
    encoder.setPattern(OptionHelper.substVars(logPattern, context));
    encoder.setCharset(DEFAULT_CHARSET);
    appender.setEncoder(encoder);
    start(encoder);

    // parse path and file
    // first consider spec.path, second, default_spec.path, third logging.path
    LogFile logFile = LogFile.get(patterns);
    Properties defaultProperties = new Properties();
    if (logFile != null) {
        logFile.applyTo(defaultProperties);
    }
    String path = space.getSpec().getPath() != null ? space.getSpec().getPath() :
            space.getDefaultSpec().getPath() != null ? space.getDefaultSpec().getPath() :
                    defaultProperties.contains(LoggingSystemProperties.LOG_PATH)
                            ? defaultProperties.getProperty(LoggingSystemProperties.LOG_PATH) :
                            DEFAULT_PATH;
    path = patterns.resolvePlaceholders(path);
    String file = space.getSpec().getFile() != null
            ? fileName(space.getSpec().getFile()) : fileName(space.getName());
    file = patterns.resolvePlaceholders(file);
    appender.setFile(path + "/" + file);
    setRollingPolicy(appender, space, path, file);

    //  threshold config
    ThresholdFilter thresholdFilter = new ThresholdFilter();
    if (space.getSpec().getThreshold() != null) {
        thresholdFilter.setLevel(space.getSpec().getThreshold());
        start(thresholdFilter);
        appender.addFilter(thresholdFilter);
    }

    appender("SPACE-" + space.getName(), appender);
    return appender;
}
 
源代码13 项目: Zebra   文件: PropsUtil.java
public static String getString(Properties props, String key, String defaultValue){
	String value = defaultValue;
	if( props.contains(key)){
		value = props.getProperty(key);
	}
	return value;
}
 
源代码14 项目: Zebra   文件: PropsUtil.java
public static int getInt(Properties props, String key, int defaultValue){
	int value = defaultValue;
	if(props.contains(key)){
		value = Integer.valueOf(props.getProperty(key));
	}
	return value;
}
 
源代码15 项目: pulsar   文件: PulsarKafkaSimpleConsumer.java
private SubscriptionType getSubscriptionType(Properties properties) {
    String subType = properties != null && properties.contains(SUBSCRIPTION_TYPE)
            ? properties.getProperty(SUBSCRIPTION_TYPE)
            : SubscriptionType.Failover.toString();
    try {
        return SubscriptionType.valueOf(subType);
    } catch (IllegalArgumentException ie) {
        return SubscriptionType.Failover;
    }
}
 
源代码16 项目: database   文件: FulltextSearchServiceFactory.java
/**
 * Resolves the endpoint type, which is either a constant or a variable to
 * be looked up in the binding set.
 * @return Class name for the endpoint type or null if none found
 */
private String resolveEndpointType(IBindingSet bs) {

   String endpointTypeStr = resolveAsString(endpointType, bs);

   // try override with system default, if not set
   if (endpointTypeStr==null) {
      endpointTypeStr = defaults.getDefaultEndpointType();
   }
   
   if (endpointTypeStr != null && !endpointTypeStr.isEmpty()) {
        final String endpointName = FTS.FTS_CUSTOM_TYPE + endpointTypeStr;
        final Properties props = getStoreProps(serviceCallParams);
        try {
            if (props.contains(endpointName)) {
               return props.getProperty(endpointName);
            }
            switch(EndpointType.valueOf(endpointTypeStr)) {
                case SOLR:
                    return SolrFulltextSearchImpl.class.getName();
            }
      } catch (Exception e) {

         // illegal, ignore and proceed
         if (log.isDebugEnabled()) {
            log.warn("Illegal endpoint type: " + endpointTypeStr + 
                  " -> will be ignored, using default.");
         }

      }
   }

   return null; // fallback to default
}
 
源代码17 项目: tomee   文件: RemoteTestServer.java
@Override
    public void init(final Properties props) {
        properties = props;
        if (props.contains("java.naming.security.principal"))
            throw new IllegalArgumentException("Not allowed 'java.naming.security.principal'");
//        props.put("test.server.class","org.apache.openejb.test.RemoteTestServer");
        props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
        props.put("java.naming.provider.url", "127.0.0.1:4201");
//        props.put("java.naming.security.principal", "testuser");
//        props.put("java.naming.security.credentials", "testpassword");
    }
 
源代码18 项目: tajo   文件: CliClientParamsFactory.java
public static Properties get(@Nullable Properties connParam) {
  Properties copy = connParam == null ? new Properties() : (Properties) connParam.clone();
  for (Map.Entry<String, String> entry : DEFAULT_PARAMS.entrySet()) {
    if (!copy.contains(entry.getKey())) {
      copy.setProperty(entry.getKey(), entry.getValue());
    }
  }
  return copy;
}
 
源代码19 项目: incubator-gobblin   文件: GobblinClusterManager.java
/**
 * Create the service based application launcher and other associated services
 * @throws Exception
 */
private void initializeAppLauncherAndServices() throws Exception {
  // Done to preserve backwards compatibility with the previously hard-coded timeout of 5 minutes
  Properties properties = ConfigUtils.configToProperties(this.config);
  if (!properties.contains(ServiceBasedAppLauncher.APP_STOP_TIME_SECONDS)) {
    properties.setProperty(ServiceBasedAppLauncher.APP_STOP_TIME_SECONDS, Long.toString(300));
  }
  this.applicationLauncher = new ServiceBasedAppLauncher(properties, this.clusterName);

  // create a job catalog for keeping track of received jobs if a job config path is specified
  if (this.config.hasPath(GobblinClusterConfigurationKeys.GOBBLIN_CLUSTER_PREFIX
      + ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY)) {
    String jobCatalogClassName = ConfigUtils.getString(config, GobblinClusterConfigurationKeys.JOB_CATALOG_KEY,
        GobblinClusterConfigurationKeys.DEFAULT_JOB_CATALOG);

    this.jobCatalog =
        (MutableJobCatalog) GobblinConstructorUtils.invokeFirstConstructor(Class.forName(jobCatalogClassName),
        ImmutableList.of(config
            .getConfig(StringUtils.removeEnd(GobblinClusterConfigurationKeys.GOBBLIN_CLUSTER_PREFIX, "."))
            .withFallback(this.config)));
  } else {
    this.jobCatalog = null;
  }

  SchedulerService schedulerService = new SchedulerService(properties);
  this.applicationLauncher.addService(schedulerService);
  this.jobScheduler = buildGobblinHelixJobScheduler(config, this.appWorkDir, getMetadataTags(clusterName, applicationId),
      schedulerService);
  this.applicationLauncher.addService(this.jobScheduler);
  this.jobConfigurationManager = buildJobConfigurationManager(config);
  this.applicationLauncher.addService(this.jobConfigurationManager);

  if (ConfigUtils.getBoolean(this.config, GobblinClusterConfigurationKeys.CONTAINER_HEALTH_METRICS_SERVICE_ENABLED,
      GobblinClusterConfigurationKeys.DEFAULT_CONTAINER_HEALTH_METRICS_SERVICE_ENABLED)) {
    this.applicationLauncher.addService(new ContainerHealthMetricsService(config));
  }
}
 
源代码20 项目: wildfly-core   文件: PropertiesCallbackHandler.java
@Override
protected void verifyProperties(Properties properties) throws IOException {
    final String admin = "admin";
    if (properties.contains(admin) && admin.equals(properties.get(admin))) {
        ROOT_LOGGER.userAndPasswordWarning();
    }
}