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:com.telefonica.iot.cygnus.utils.CommonUtils.java

/**
 * Gets the Cygnus version from the pom.xml.
 * @return The Cygnus version//  w w w  .  ja  v  a2  s.  com
 */
public static String getCygnusVersion() {
    InputStream stream = CommonUtils.class.getClassLoader().getResourceAsStream("pom.properties");

    if (stream == null) {
        return "UNKNOWN";
    } // if

    Properties props = new Properties();

    try {
        props.load(stream);
        stream.close();
        return (String) props.get("version");
    } catch (IOException e) {
        return "UNKNOWN";
    } // try catch
}

From source file:atg.tools.dynunit.test.util.DBUtils.java

/**
 * @param pProps/*from  w  w  w .j  a va 2s  . c om*/
 *
 * @return
 */
public static boolean isOracle(@NotNull Properties pProps) {
    return pProps.get("driver").toString().toLowerCase().contains("oracle");
}

From source file:atg.tools.dynunit.test.util.DBUtils.java

/**
 * @param pProps/*w w  w .j  a v  a  2 s .c  om*/
 *
 * @return
 */
public static boolean isSybase(@NotNull Properties pProps) {
    return pProps.get("driver").toString().toLowerCase().contains("sybase");
}

From source file:atg.tools.dynunit.test.util.DBUtils.java

/**
 * @param pProps/*from  w ww  . ja va 2 s . c  o m*/
 *
 * @return
 */
public static boolean isMSSQLServer(@NotNull Properties pProps) {
    return pProps.get("driver").equals("com.inet.tds.TdsDriver");
}

From source file:atg.tools.dynunit.test.util.DBUtils.java

/**
 * @param pProps/*from   ww  w.j av a2  s .  co  m*/
 *
 * @return
 */
public static boolean isDB2(@NotNull Properties pProps) {
    return pProps.get("driver").toString().contains("DB2");
}

From source file:org.esgf.web.FacetFileController.java

/**
 * New helper method for extracting facet info from the facets.properties file in /esg/config
 * //from  w  w  w  .j  av  a 2  s . c  om
 * @return
 */
private static String[] getFacetInfo() {

    String[] facetTokens = null;

    Properties properties = new Properties();
    String propertiesFile = FACET_PROPERTIES_FILE;

    boolean createDefault = false;

    try {

        properties.load(new FileInputStream(propertiesFile));

        facetTokens = new String[properties.size()];

        for (Object key : properties.keySet()) {
            String value = (String) properties.get(key);

            String[] valueTokens = value.split(":");
            try {
                int index = Integer.parseInt(valueTokens[0]);

                if (index > -1) {
                    if (index < properties.size()) {

                        String facetInfo = (String) key + ":" + valueTokens[1] + ":" + valueTokens[2];
                        facetTokens[index] = facetInfo;
                    }
                }

            }
            //Note: need to fix this.  This will only work if ALL facet readings are wrong
            catch (Exception e) {
                System.out.println("COULD NOT INDEX: " + key);

                createDefault = true;

            }

        }

        List<String> fixedFacetTokens = new ArrayList<String>();

        //"fix" the array here (for any index collisions
        for (int i = 0; i < facetTokens.length; i++) {
            if (facetTokens[i] != null) {
                fixedFacetTokens.add(facetTokens[i]);
            }
        }

        facetTokens = (String[]) fixedFacetTokens.toArray(new String[fixedFacetTokens.size()]);

    } catch (FileNotFoundException f) {

        System.out.println("Using default facet list");
        facetTokens = getDefaultFacets();

    } catch (Exception e) {

        e.printStackTrace();
    }

    if (createDefault) {
        System.out.println("Using default facet list");
        facetTokens = getDefaultFacets();
    }

    return facetTokens;
}

From source file:org.ops4j.pax.web.itest.util.TestConfiguration.java

public static Option paxCdiWithWeldBundles() {

    Properties props = new Properties();
    try {//from   w ww. j  a  va  2s. c  om
        props.load(TestConfiguration.class.getResourceAsStream("/systemPackages.properties"));
    } catch (IOException exc) {
        throw new Ops4jException(exc);
    }

    return composite(
            // do not treat javax.annotation as system package
            when(isEquinox()).useOptions(frameworkProperty("org.osgi.framework.system.packages")
                    .value(props.get("org.osgi.framework.system.packages"))),

            linkBundle("org.ops4j.pax.cdi.weld"),

            // there is a classloader conflict when adding this dep to the POM
            mavenBundle("org.ops4j.pax.cdi", "pax-cdi-undertow-weld", "0.8.0"),

            mavenBundle("com.google.guava", "guava", "13.0.1"),
            mavenBundle("org.jboss.weld", "weld-osgi-bundle", "2.1.2.Final"));
}

From source file:de.pawlidi.openaletheia.utils.CipherUtils.java

/**
 * /*from   ww w  .  j  a va  2 s  .co m*/
 * @param properties
 * @return
 */
public static byte[] computeSignature(Properties properties) {
    if (properties != null && !properties.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        ArrayList keys = new ArrayList<Object>(properties.keySet());
        Collections.sort(keys);
        for (Object key : keys) {
            Object value = properties.get(key);
            if (value != null) {
                builder.append(key);
                builder.append("=");
                builder.append(value);
                builder.append("\n");
            }
        }
        String pattern = builder.toString();
        if (!pattern.isEmpty()) {
            return computeSignature(Converter.getBytesIso8859(pattern));
        }
    }
    return null;
}

From source file:com.jiangyifen.ec2.globaldata.license.LicenseManager.java

/**
 * ?License????//from   w  w w  .  ja va2s  .  c o  m
 * @return
 */
public static void loadLicenseFile(String licenseFilename) {
    try {
        //???
        Properties props = new Properties();
        InputStream inputStream = LicenseManager.class.getClassLoader().getResourceAsStream(licenseFilename);
        props.load(inputStream);
        inputStream.close();

        //??
        String license_count = (String) props.get(LicenseManager.LICENSE_COUNT);
        license_count = license_count == null ? "" : license_count;
        licenseMap.put(LicenseManager.LICENSE_COUNT, license_count);

        //?
        String license_date = (String) props.get(LicenseManager.LICENSE_DATE);
        license_date = license_date == null ? "" : license_date;
        licenseMap.put(LicenseManager.LICENSE_DATE, license_date);

        //???
        String license_localmd5 = (String) props.get(LicenseManager.LICENSE_LOCALMD5);
        license_localmd5 = license_localmd5 == null ? "" : license_localmd5;
        licenseMap.put(LicenseManager.LICENSE_LOCALMD5, license_localmd5);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.alibaba.rocketmq.common.MixAll.java

public static String properties2String(final Properties properties) {
    Set<Object> sets = properties.keySet();
    StringBuilder sb = new StringBuilder();
    for (Object key : sets) {
        Object value = properties.get(key);
        if (value != null) {
            sb.append(key.toString() + "=" + value.toString() + IOUtils.LINE_SEPARATOR);
        }//from   ww w  . j a  v  a 2  s  . c  om
    }

    return sb.toString();
}