Example usage for java.util Properties get

List of usage examples for java.util Properties get

Introduction

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

Prototype

@Override
    public Object get(Object key) 

Source Link

Usage

From source file:mitm.common.properties.PropertyUtils.java

/**
 * Returns the property as an int. If propery is not found, or the property is not something that can
 * be represented by an Integer, defaultValue will be returned.
 *///from  w  w  w .  j a va2 s .c o m
public static int getIntegerProperty(Properties properties, String name, int defaultValue) {
    int result = defaultValue;

    Object value = properties.get(name);

    if (value == null) {
        value = properties.getProperty(name);
    }

    if (value instanceof String) {
        result = NumberUtils.toInt((String) value, defaultValue);
    } else if (value instanceof Integer) {
        result = (Integer) value;
    }

    return result;
}

From source file:uk.org.openeyes.oink.it.ITSupport.java

public static IGenericClient buildHapiClientForProxy(Properties proxyProps) {
    // See if Patient exists
    String proxyUri = (String) proxyProps.get("proxy.uri");

    // Create a context and get the client factory so it can be configured
    FhirContext ctx = new FhirContext();
    IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();

    // Create an HTTP Client Builder
    HttpClientBuilder builder = HttpClientBuilder.create();

    // This interceptor adds HTTP username/password to every request
    String username = (String) proxyProps.get("proxy.username");
    String password = (String) proxyProps.get("proxy.password");
    builder.addInterceptorFirst(new HttpBasicAuthInterceptor(username, password));

    builder.addInterceptorFirst(new HttpRequestInterceptor() {

        @Override//from www  . j  ava2  s  .c o  m
        public void process(HttpRequest req, HttpContext context) throws HttpException, IOException {
            req.addHeader("Accept", "application/json+fhir; charset=UTF-8");
        }
    });

    // Use the new HTTP client builder
    clientFactory.setHttpClient(builder.build());

    IGenericClient client = clientFactory.newGenericClient("http://" + proxyUri);

    return client;
}

From source file:mitm.common.properties.PropertyUtils.java

/**
 * Returns the property as a boolean. If propery is not found, or the property is not something that can
 * be represented a boolean, defaultValue will be returned.
 *///from   w  w w.  j a va  2s  .  co  m
public static boolean getBooleanProperty(Properties properties, String name, boolean defaultValue) {
    boolean result = defaultValue;

    Object value = properties.get(name);

    if (value == null) {
        value = properties.getProperty(name);
    }

    if (value instanceof String) {
        result = BooleanUtils.toBoolean((String) value);
    } else if (value instanceof Boolean) {
        result = (Boolean) value;
    }

    return result;
}

From source file:com.wolvereness.bluebutton.Version.java

private static String getProperty(final Properties properties, final String property) {
    final Object obj = properties.get(property);
    if (obj == null)
        throw new NullPointerException(property);
    return obj.toString();
}

From source file:uk.org.openeyes.oink.it.multi.ITHl7v2ToOpenEyes.java

public static IGenericClient buildOpenEyesClient(Properties props) {
    String proxyUri = (String) props.get("openeyes.uri");

    // Create a context and get the client factory so it can be configured
    FhirContext ctx = new FhirContext();
    IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();

    // Create an HTTP Client Builder
    HttpClientBuilder builder = HttpClientBuilder.create();

    // This interceptor adds HTTP username/password to every request
    String username = (String) props.get("openeyes.username");
    String password = (String) props.get("openeyes.password");
    builder.addInterceptorFirst(new HttpBasicAuthInterceptor(username, password));

    builder.addInterceptorFirst(new HttpRequestInterceptor() {

        @Override//from  w  w  w  .ja  v a2 s  .  co m
        public void process(HttpRequest req, HttpContext context) throws HttpException, IOException {
            req.addHeader("Accept", "application/json+fhir; charset=UTF-8");
        }
    });

    // Use the new HTTP client builder
    clientFactory.setHttpClient(builder.build());

    IGenericClient client = clientFactory.newGenericClient("http://" + proxyUri);

    return client;
}

From source file:Main.java

/**
 * Copy a set of properties from one Property to another.
 * /*from  w ww.  j a  va 2 s  .c o  m*/
 *
 * @param src_prop  Source set of properties to copy from.
 * @param dest_prop Dest Properties to copy into.
 *
 **/
public static void copyProperties(Properties src_prop, Properties dest_prop) {
    for (Enumeration propertyNames = src_prop.propertyNames(); propertyNames.hasMoreElements();) {
        Object key = propertyNames.nextElement();
        dest_prop.put(key, src_prop.get(key));
    }
}

From source file:net.sf.ehcache.util.PropertyUtil.java

/**
 * @return null if their is no property for the key, or their are no properties
 *//*  w  w w .  ja v a2  s . com*/
public static String extractAndLogProperty(String name, Properties properties) {
    if (properties == null || properties.size() == 0) {
        return null;
    }
    String foundValue = (String) properties.get(name);
    if (foundValue != null) {
        foundValue = foundValue.trim();
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug(new StringBuffer().append("Value found for ").append(name).append(": ").append(foundValue)
                .toString());
    }
    return foundValue;
}

From source file:com.netpet.spools.spring.springcase.ActionFactory.java

public static Action getAction(String actionName) {
    Properties pro = new Properties();

    try {/*  ww  w.  j  av  a2  s  . co  m*/
        pro.load(new FileInputStream(System.getProperty("user.dir") + "/springTest/" + "config.properties"));
        String actionImplName = (String) pro.get(actionName);
        String actionMessage = (String) pro.get(actionName + "_msg");
        Object obj = Class.forName(actionImplName).newInstance();
        BeanUtils.setProperty(obj, "message", actionMessage);

        return (Action) obj;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.nokia.dempsy.mpcluster.zookeeper.ZookeeperTestServer.java

private static TestZookeeperServerIntern startZookeeper(Properties zkConfig) {
    logger.debug("Starting the test zookeeper server on port " + zkConfig.get("clientPort"));

    final TestZookeeperServerIntern server = new TestZookeeperServerIntern();
    try {/* w  w w .  ja  v a  2  s .c o  m*/
        QuorumPeerConfig qpConfig = new QuorumPeerConfig();
        qpConfig.parseProperties(zkConfig);
        final ServerConfig sConfig = new ServerConfig();
        sConfig.readFrom(qpConfig);

        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    server.runFromConfig(sConfig);
                } catch (IOException ioe) {
                    logger.error(MarkerFactory.getMarker("FATAL"), "", ioe);
                    fail("can't start zookeeper");
                }
            }
        });
        t.start();
        Thread.sleep(2000); // give the server time to start
    } catch (Exception e) {
        logger.error("Can't start zookeeper", e);
        fail("Can't start zookeeper");
    }
    return server;
}

From source file:com.microsoft.windowsazure.services.core.Configuration.java

public static Configuration load() throws IOException {
    Configuration config = new Configuration();

    InputStream stream = Configuration.class.getClassLoader()
            .getResourceAsStream("META-INF/com.microsoft.windowsazure.properties");
    if (stream != null) {
        Properties properties = new Properties();
        properties.load(stream);//from  www  . ja  v  a2s  .  com
        for (Object key : properties.keySet()) {
            config.setProperty(key.toString(), properties.get(key));
        }
    }

    return config;
}