Example usage for java.util Properties containsKey

List of usage examples for java.util Properties containsKey

Introduction

In this page you can find the example usage for java.util Properties containsKey.

Prototype

@Override
    public boolean containsKey(Object key) 

Source Link

Usage

From source file:eu.uqasar.util.UQasarUtil.java

/**
 * Get the data dir to be used; in case JBoss is used, use its data dir, 
 * otherwise the user temp./*w ww . ja  va  2  s  . c o m*/
 * @return
 */
public static String getDataDirPath() {
    String dataDirectory = null;
    Properties systemProp = System.getProperties();
    // In case JBoss is used
    if (systemProp.containsKey("jboss.server.data.dir")) {
        dataDirectory = systemProp.getProperty("jboss.server.data.dir");
        if (!dataDirectory.endsWith(SEPARATOR)) {
            dataDirectory += SEPARATOR;
        }
    }
    // Otherwise use a temp directory
    else {
        dataDirectory = System.getProperty("java.io.tmpdir");
        if (!dataDirectory.endsWith(SEPARATOR)) {
            dataDirectory += SEPARATOR;
        }
    }

    return dataDirectory;
}

From source file:de.qucosa.servlet.MetsDisseminatorServlet.java

private FedoraClient attemptToCreateFedoraClientFrom(Properties properties) {
    if (properties.containsKey(PROP_FEDORA_CREDENTIALS) && properties.containsKey(PROP_FEDORA_HOST_URL)) {

        final Credentials credentials = Credentials
                .fromColonSeparatedString(properties.getProperty(PROP_FEDORA_CREDENTIALS));

        try {/*from   ww  w  .j  a  va2 s . c  om*/
            return new FedoraClient(new FedoraCredentials(properties.getProperty(PROP_FEDORA_HOST_URL),
                    credentials.getUsername(), credentials.getPassword()));
        } catch (MalformedURLException ignored) {
            // noop
        }
    }
    return null;
}

From source file:org.apache.stratos.cloud.controller.validate.OpenstackNovaPartitionValidator.java

@Override
public IaasProvider validate(String partitionId, Properties properties) throws InvalidPartitionException {
    try {/*  ww w . ja  va  2 s .c o m*/
        // validate the existence of the zone and hosts properties.
        if (properties.containsKey(Scope.region.toString())) {
            String region = properties.getProperty(Scope.region.toString());

            if (iaasProvider.getImage() != null && !iaasProvider.getImage().contains(region)) {

                String msg = "Invalid Partition Detected : " + partitionId + " - Cause: Invalid Region: "
                        + region;
                log.error(msg);
                throw new InvalidPartitionException(msg);
            }

            iaas.isValidRegion(region);

            IaasProvider updatedIaasProvider = new IaasProvider(iaasProvider);
            Iaas updatedIaas = CloudControllerUtil.getIaas(updatedIaasProvider);
            updatedIaas.setIaasProvider(updatedIaasProvider);

            if (properties.containsKey(Scope.zone.toString())) {
                String zone = properties.getProperty(Scope.zone.toString());
                iaas.isValidZone(region, zone);

                updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, zone);
                updatedIaas = CloudControllerUtil.getIaas(updatedIaasProvider);
                updatedIaas.setIaasProvider(updatedIaasProvider);
            }

            return updatedIaasProvider;

        } else {

            return iaasProvider;
        }
    } catch (Exception ex) {
        String msg = "Invalid Partition Detected : " + partitionId + ". Cause: " + ex.getMessage();
        log.error(msg, ex);
        throw new InvalidPartitionException(msg, ex);
    }
}

From source file:com.facebook.LinkBench.distributions.GeometricDistribution.java

@Override
public void init(long min, long max, Properties props, String keyPrefix) {
    double parsedP = ConfigUtil.getDouble(props, keyPrefix + PROB_PARAM_KEY);

    double scaleVal = 1.0;
    ;/*www  .  j  a v a 2s  .c  o m*/
    if (props.containsKey(LinkBenchConstants.PROB_MEAN)) {
        scaleVal = (max - min) * ConfigUtil.getDouble(props, keyPrefix + LinkBenchConstants.PROB_MEAN);
    }
    init(min, max, parsedP, scaleVal);
}

From source file:com.siemens.industrialbenchmark.externaldrivers.setpointgen.SetPointGenerator.java

/**
 Constructor with given seed and properties file
 * @param seed The seed for the random number generator 
 * @param aProperties The properties file to parse 
 * @throws PropertiesException// www  . j a v a2 s. co m
 */
public SetPointGenerator(long seed, Properties aProperties) throws PropertiesException {

    mIsStationary = aProperties.containsKey("STATIONARY_SETPOINT");
    if (mIsStationary) {
        mSetPoint = PropertiesUtil.getFloat(aProperties, "STATIONARY_SETPOINT", true);
        Preconditions.checkArgument(mSetPoint >= 0.0f && mSetPoint <= 100.0f,
                "setpoint must be in range [0, 100]");
    }
    MAX_CHANGE_RATE_PER_STEP_SETPOINT = PropertiesUtil.getFloat(aProperties,
            "MAX_CHANGE_RATE_PER_STEP_SETPOINT", true);
    MAX_SEQUENCE_LENGTH = PropertiesUtil.getInt(aProperties, "MAX_SEQUENCE_LENGTH", true);
    MINSETPOINT = PropertiesUtil.getFloat(aProperties, "SetPoint_MIN", true);
    MAXSETPOINT = PropertiesUtil.getFloat(aProperties, "SetPoint_MAX", true);
    SETPOINT_STEP_SIZE = PropertiesUtil.getFloat(aProperties, "SETPOINT_STEP_SIZE", true);

    this.mRandom = new RandomDataGenerator();
    this.mRandom.reSeed(seed);
    defineNewSequence();
}

From source file:com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration.java

@PostConstruct
public void addPageInterceptor() {
    PageInterceptor interceptor = new PageInterceptor();
    Properties properties = pageHelperProperties.getProperties();
    Map<String, Object> subProperties = resolver.getSubProperties("");
    for (String key : subProperties.keySet()) {
        if (!properties.containsKey(key)) {
            properties.setProperty(key, resolver.getProperty(key));
        }/*www.j  a  va 2 s  . c  o m*/
    }
    interceptor.setProperties(properties);
    sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
}

From source file:gobblin.data.management.policy.CombineSelectionPolicy.java

@SuppressWarnings("unchecked")
public CombineSelectionPolicy(Properties props) throws IOException {

    Preconditions.checkArgument(props.containsKey(VERSION_SELECTION_POLICIES_PREFIX),
            "Combine operation not specified.");

    ImmutableList.Builder<VersionSelectionPolicy<FileSystemDatasetVersion>> builder = ImmutableList.builder();

    for (String property : props.stringPropertyNames()) {
        if (property.startsWith(VERSION_SELECTION_POLICIES_PREFIX)) {

            try {
                builder.add((VersionSelectionPolicy<FileSystemDatasetVersion>) ConstructorUtils
                        .invokeConstructor(Class.forName(props.getProperty(property)), props));
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
                    | InstantiationException | ClassNotFoundException e) {
                throw new IllegalArgumentException(e);
            }/*w w w  . j a va  2 s .c  o  m*/
        }
    }

    this.selectionPolicies = builder.build();
    if (this.selectionPolicies.size() == 0) {
        throw new IOException(
                "No selection policies specified for " + CombineSelectionPolicy.class.getCanonicalName());
    }

    this.combineOperation = CombineOperation
            .valueOf(props.getProperty(VERSION_SELECTION_COMBINE_OPERATION).toUpperCase());

}

From source file:org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy.java

@SuppressWarnings("unchecked")
public CombineRetentionPolicy(Properties props) throws IOException {
    Preconditions.checkArgument(props.containsKey(DELETE_SETS_COMBINE_OPERATION),
            "Combine operation not specified.");

    ImmutableList.Builder<RetentionPolicy<T>> builder = ImmutableList.builder();

    for (String property : props.stringPropertyNames()) {
        if (property.startsWith(RETENTION_POLICIES_PREFIX)) {

            try {
                builder.add((RetentionPolicy<T>) ConstructorUtils
                        .invokeConstructor(Class.forName(props.getProperty(property)), props));
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
                    | InstantiationException | ClassNotFoundException e) {
                throw new IllegalArgumentException(e);
            }//from   w w w  .  j av a  2s.c o m
        }
    }

    this.retentionPolicies = builder.build();
    if (this.retentionPolicies.size() == 0) {
        throw new IOException(
                "No retention policies specified for " + CombineRetentionPolicy.class.getCanonicalName());
    }

    this.combineOperation = DeletableCombineOperation
            .valueOf(props.getProperty(DELETE_SETS_COMBINE_OPERATION).toUpperCase());

}

From source file:gobblin.data.management.retention.policy.CombineRetentionPolicy.java

@SuppressWarnings("unchecked")
public CombineRetentionPolicy(Properties props) throws IOException {

    Preconditions.checkArgument(props.containsKey(DELETE_SETS_COMBINE_OPERATION),
            "Combine operation not specified.");

    ImmutableList.Builder<RetentionPolicy<T>> builder = ImmutableList.builder();

    for (String property : props.stringPropertyNames()) {
        if (property.startsWith(RETENTION_POLICIES_PREFIX)) {

            try {
                builder.add((RetentionPolicy<T>) ConstructorUtils
                        .invokeConstructor(Class.forName(props.getProperty(property)), props));
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
                    | InstantiationException | ClassNotFoundException e) {
                throw new IllegalArgumentException(e);
            }//from w  w w. ja v  a2 s  . c  o  m
        }
    }

    this.retentionPolicies = builder.build();
    if (this.retentionPolicies.size() == 0) {
        throw new IOException(
                "No retention policies specified for " + CombineRetentionPolicy.class.getCanonicalName());
    }

    this.combineOperation = DeletableCombineOperation
            .valueOf(props.getProperty(DELETE_SETS_COMBINE_OPERATION).toUpperCase());

}

From source file:org.apache.nifi.toolkit.cli.impl.command.AbstractCommand.java

protected ResultType getResultType(final Properties properties) {
    final ResultType resultType;
    if (properties.containsKey(CommandOption.OUTPUT_TYPE.getLongName())) {
        final String outputTypeValue = properties.getProperty(CommandOption.OUTPUT_TYPE.getLongName());
        resultType = ResultType.valueOf(outputTypeValue.toUpperCase().trim());
    } else {// www .  j av  a2 s .  co  m
        resultType = ResultType.SIMPLE;
    }
    return resultType;
}