Example usage for java.util Properties getProperty

List of usage examples for java.util Properties getProperty

Introduction

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

Prototype

public String getProperty(String key) 

Source Link

Document

Searches for the property with the specified key in this property list.

Usage

From source file:com.roche.iceboar.settings.GlobalSettingsFactory.java

private static boolean getHideFrameBorder(Properties properties) {
    String hideFrameBorder = properties.getProperty(JNLP_SPLASH_HIDE_FRAME_BORDER);
    return (isNotBlank(hideFrameBorder) && hideFrameBorder.equals("true"));
}

From source file:de.fhg.igd.mapviewer.server.file.PropertiesConverterFactory.java

/**
 * Creates a {@link PixelConverter} for the given {@link TileProvider} from
 * the given properties//from ww  w .j  a  va2 s . c  om
 * 
 * @param properties the properties that specify the {@link PixelConverter}
 * @param tileProvider the {@link TileProvider} for to be associated with
 *            the {@link PixelConverter}
 * 
 * @return a {@link PixelConverter} or null if the properties didn't specify
 *         a valid converter
 */
@SuppressWarnings("unchecked")
public static PixelConverter createConverter(Properties properties, TileProvider tileProvider) {
    String className = properties.getProperty(PROP_CONVERTER_CLASS);

    if (className == null) {
        log.error("Didn't find " + PROP_CONVERTER_CLASS + " property"); //$NON-NLS-1$ //$NON-NLS-2$
        return null;
    } else {
        Class<?> converterClass;
        try {
            converterClass = Class.forName(className);

            Constructor<? extends PixelConverter> constructor;

            // try Properties/TileProvider constructor
            try {
                constructor = (Constructor<? extends PixelConverter>) converterClass
                        .getConstructor(Properties.class, TileProvider.class);
                log.info("Found converter constructor with Properties and TileProvider arguments"); //$NON-NLS-1$
                return constructor.newInstance(properties, tileProvider);
            } catch (Throwable e) {
                // ignoring
            }

            // try TileProvider/Properties constructor
            try {
                constructor = (Constructor<? extends PixelConverter>) converterClass
                        .getConstructor(TileProvider.class, Properties.class);
                log.info("Found converter constructor with TileProvider and Properties arguments"); //$NON-NLS-1$
                return constructor.newInstance(tileProvider, properties);
            } catch (Throwable e) {
                // ignoring
            }

            // try Properties constructor
            try {
                constructor = (Constructor<? extends PixelConverter>) converterClass
                        .getConstructor(Properties.class);
                log.info("Found converter constructor with Properties argument"); //$NON-NLS-1$
                return constructor.newInstance(properties);
            } catch (Throwable e) {
                // ignoring
            }

            // try TileProvider constructor
            try {
                constructor = (Constructor<? extends PixelConverter>) converterClass
                        .getConstructor(TileProvider.class);
                log.info("Found converter constructor with TileProvider argument"); //$NON-NLS-1$
                return constructor.newInstance(tileProvider);
            } catch (Throwable e) {
                // ignoring
            }

            // try Default constructor
            try {
                constructor = (Constructor<? extends PixelConverter>) converterClass.getConstructor();
                log.info("Found converter default constructor"); //$NON-NLS-1$
                return constructor.newInstance();
            } catch (Throwable e) {
                // ignoring
            }

            log.warn("Found no supported constructor: " + className); //$NON-NLS-1$
        } catch (ClassNotFoundException e) {
            log.error("Converter class not found", e); //$NON-NLS-1$
        }
    }

    return null;
}

From source file:com.betfair.tornjak.monitor.overlay.AuthFileReader.java

public static RolePerms load(Resource resource) throws IOException {
    Properties properties = PropertiesLoaderUtils.loadProperties(resource);

    // find all the roles we'll be using.
    String roles = properties.getProperty("jmx.roles");
    RolePerms rolePerms = new RolePerms();
    if (roles != null) {
        // now build up the list of perms
        for (String roleName : roles.split(",")) {
            roleName = StringUtils.trim(roleName);
            AccessRules accessRules = new AccessRules();
            // find all the entries for each role
            for (int i = 0; i < MAX_MATCHERS_PER_ROLE; i++) {
                String allowPrefix = String.format("role.%s.readAllow.%d.", roleName, i);
                String denyPrefix = String.format("role.%s.readDeny.%d.", roleName, i);

                accessRules.addMatcherAllowed(createMatcher(allowPrefix, properties));
                accessRules.addMatcherDisallowed(createMatcher(denyPrefix, properties));
            }//from w w  w.j av a  2s  .c o  m
            rolePerms.addAccessRules(roleName, accessRules);
        }
    }
    return rolePerms;
}

From source file:com.bmwcarit.barefoot.roadmap.Loader.java

public static PostGISReader reader(Properties properties) {
    String host = properties.getProperty("database.host");
    int port = Integer.parseInt(properties.getProperty("database.port", "0"));
    String database = properties.getProperty("database.name");
    String table = properties.getProperty("database.table");
    String user = properties.getProperty("database.user");
    String password = properties.getProperty("database.password");
    String path = properties.getProperty("database.road-types");

    if (host == null || port == 0 || database == null || table == null || user == null || password == null
            || path == null) {// w w  w.j av  a2s .  c om
        throw new SourceException("could not read database properties");
    }

    logger.info("open road reader for database {} at {}:{}", database, host, port);

    logger.info("database.host={}", host);
    logger.info("database.port={}", port);
    logger.info("database.name={}", database);
    logger.info("database.table={}", table);
    logger.info("database.user={}", user);
    logger.info("database.road-types={}", path);

    Map<Short, Tuple<Double, Integer>> config = null;
    try {
        config = read(path);
    } catch (JSONException | IOException e) {
        throw new SourceException("could not read road types from file " + path);
    }

    return new PostGISReader(host, port, database, table, user, password, config);
}

From source file:com.roche.iceboar.settings.GlobalSettingsFactory.java

private static boolean getShowDebug(Properties properties) {
    String showDebugProperty = properties.getProperty(JNLP_SHOW_DEBUG);
    System.out.println("showDebug: " + showDebugProperty);
    return isNotBlank(showDebugProperty) && showDebugProperty.equals("true");
}

From source file:Main.java

public static String extractComment(String tag, Properties properties) {
    if (properties == null || "span".equals(tag))
        return null;

    String[] attributes = new String[] { "id", "name", "class" };
    for (String a : attributes) {
        String comment = properties.getProperty(a);
        if (comment != null) {
            return " <!-- " + comment.replaceAll("[-]{2,}", "-") + " -->";
        }/*  ww w .jav a 2 s  . co  m*/
    }

    return null;
}

From source file:io.warp10.worf.WorfTemplate.java

public static boolean isTemplate(Properties warp10Config) {
    return "true".equals(warp10Config.getProperty("worf.template"));
}

From source file:com.lambdasoup.panda.PandaHttp.java

static Map<String, String> signedParams(String method, String url, Map<String, String> params,
        Properties properties) {
    params.put("cloud_id", properties.getProperty("cloud-id"));
    params.put("access_key", properties.getProperty("access-key"));
    params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz").format(new Date()));
    //      params.put("api_host", properties.getProperty("api-host"));
    params.put("signature", generateSignature(method, url, properties.getProperty("api-host"),
            properties.getProperty("secret-key"), params));
    return params;
}

From source file:com.controlj.experiment.bulktrend.trendclient.Main.java

private static String getProperty(Properties props, String propName) {
    String propVal = props.getProperty(propName);
    if (propVal == null) {
        System.out.println("Property '" + propName + "' missing from trendclient.properties.");
        System.out.println();/*from   w ww  . j a v  a  2 s.c  om*/
        printConfigHelp();
        System.exit(-1);
    }
    return propVal;
}

From source file:com.sap.prd.mobile.ios.mios.XCodeTest.java

private static String getMavenXcodePluginVersion() throws IOException {
    Properties properties = new Properties();
    properties.load(XCodeManagerTest.class.getResourceAsStream("/misc/project.properties"));
    final String xcodePluginVersion = properties.getProperty("xcode-plugin-version");

    if (xcodePluginVersion.equals("${project.version}"))
        throw new IllegalStateException(
                "Variable ${project.version} was not replaced. May be running \"mvn clean install\" beforehand might solve this issue.");
    return xcodePluginVersion;
}