List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:atg.tools.dynunit.test.util.DBUtils.java
/** * Returns connection properties for MSSQL * * @param hostName/*from www . ja va2s.c o m*/ * host name of db server * @param port * port number of db * @param user * database username * @param password * database user's password * * @return */ @NotNull public static Properties getSolidDBConnection(String hostName, @Nullable String port, String user, String password) { Properties props = new Properties(); if (port == null) { port = "1313"; } props.put("driver", "solid.jdbc.SolidDriver"); props.put("URL", "jdbc:solid://" + hostName + ":" + port); props.put("user", user); props.put("password", password); return props; }
From source file:atg.tools.dynunit.test.util.DBUtils.java
/** * Returns connection properties for MSSQL * * @param hostName//from w ww.j a v a 2 s. co m * host name of db server * @param port * port number of db * @param databaseName * database name * @param user * database username * @param password * database user's password * * @return */ @NotNull public static Properties getSybaseDBConnection(String hostName, @Nullable String port, String databaseName, String user, String password) { Properties props = new Properties(); if (port == null) { port = "5000"; } props.put("driver", "com.sybase.jdbc2.jdbc.SybDriver"); props.put("URL", " jdbc:sybase:Tds:" + hostName + ":" + port + "/" + databaseName); props.put("user", user); props.put("password", password); return props; }
From source file:de.tudarmstadt.ukp.dkpro.tc.core.util.SaveModelUtils.java
public static void writeModelParameters(TaskContext aContext, File aOutputFolder, List<String> aFeatureSet, List<Object> aFeatureParameters) throws Exception { // write meta collector data // automatically determine the required metaCollector classes from the // provided feature // extractors Set<Class<? extends MetaCollector>> metaCollectorClasses; try {/*w w w . j a v a 2 s.c om*/ metaCollectorClasses = TaskUtils.getMetaCollectorsFromFeatureExtractors(aFeatureSet); } catch (ClassNotFoundException e) { throw new ResourceInitializationException(e); } catch (InstantiationException e) { throw new ResourceInitializationException(e); } catch (IllegalAccessException e) { throw new ResourceInitializationException(e); } // collect parameter/key pairs that need to be set Map<String, String> metaParameterKeyPairs = new HashMap<String, String>(); for (Class<? extends MetaCollector> metaCollectorClass : metaCollectorClasses) { try { metaParameterKeyPairs.putAll(metaCollectorClass.newInstance().getParameterKeyPairs()); } catch (InstantiationException e) { throw new ResourceInitializationException(e); } catch (IllegalAccessException e) { throw new ResourceInitializationException(e); } } Properties parameterProperties = new Properties(); for (Entry<String, String> entry : metaParameterKeyPairs.entrySet()) { File file = new File(aContext.getStorageLocation(META_KEY, AccessMode.READWRITE), entry.getValue()); String name = file.getName(); String subFolder = aOutputFolder.getAbsoluteFile() + "/" + name; File targetFolder = new File(subFolder); copyToTargetLocation(file, targetFolder); parameterProperties.put(entry.getKey(), name); // should never be reached } for (int i = 0; i < aFeatureParameters.size(); i = i + 2) { String key = (String) aFeatureParameters.get(i).toString(); String value = aFeatureParameters.get(i + 1).toString(); if (valueExistAsFileOrFolderInTheFileSystem(value)) { String name = new File(value).getName(); String destination = aOutputFolder + "/" + name; copyToTargetLocation(new File(value), new File(destination)); parameterProperties.put(key, name); continue; } parameterProperties.put(key, value); } FileWriter writer = new FileWriter(new File(aOutputFolder, MODEL_PARAMETERS)); parameterProperties.store(writer, ""); writer.close(); }
From source file:fredboat.db.DatabaseManager.java
private static void connectSSH() { try {/*from ww w. j ava 2 s . c o m*/ //establish the tunnel log.info("Starting SSH tunnel"); java.util.Properties config = new java.util.Properties(); JSch jsch = new JSch(); JSch.setLogger(new JSchLogger()); //Parse host:port String sshHost = Config.CONFIG.getSshHost().split(":")[0]; int sshPort = Integer.parseInt(Config.CONFIG.getSshHost().split(":")[1]); Session session = jsch.getSession(Config.CONFIG.getSshUser(), sshHost, sshPort); jsch.addIdentity(Config.CONFIG.getSshPrivateKeyFile()); config.put("StrictHostKeyChecking", "no"); config.put("ConnectionAttempts", "3"); session.setConfig(config); session.connect(); log.info("SSH Connected"); //forward the port int assignedPort = session.setPortForwardingL(SSH_TUNNEL_PORT, "localhost", Config.CONFIG.getForwardToPort()); sshTunnel = session; log.info("localhost:" + assignedPort + " -> " + sshHost + ":" + Config.CONFIG.getForwardToPort()); log.info("Port Forwarded"); } catch (Exception e) { throw new RuntimeException("Failed to start SSH tunnel", e); } }
From source file:atg.tools.dynunit.test.util.DBUtils.java
/** * Returns connection properties for MSSQL * * @param hostName/* w w w . ja va 2 s .c o m*/ * host name of db server * @param port * port number of db or {@code null} to use the default port 1521 * @param databaseName * database name * @param user * database username * @param password * database user's password * * @return */ @NotNull public static Properties getOracleDBConnection(String hostName, @Nullable String port, String databaseName, String user, String password) { Properties props = new Properties(); props = new Properties(); if (port == null) { port = "1521"; } props.put("driver", "oracle.jdbc.OracleDriver"); props.put("URL", "jdbc:oracle:thin:@" + hostName + ":" + port + ":" + databaseName); props.put("user", user); props.put("password", password); return props; }
From source file:org.eclipse.gemini.blueprint.test.internal.util.PropertiesUtil.java
/** * Filter/Eliminate keys that start with the given prefix. * /* w w w . j a va2 s. c om*/ * @param properties * @param prefix * @return */ public static Properties filterKeysStartingWith(Properties properties, String prefix) { if (!StringUtils.hasText(prefix)) return EMPTY_PROPERTIES; Assert.notNull(properties); Properties excluded = (properties instanceof OrderedProperties ? new OrderedProperties() : new Properties()); // filter ignore keys out for (Enumeration enm = properties.keys(); enm.hasMoreElements();) { String key = (String) enm.nextElement(); if (key.startsWith(prefix)) { excluded.put(key, properties.get(key)); } } for (Enumeration enm = excluded.keys(); enm.hasMoreElements();) { properties.remove(enm.nextElement()); } return excluded; }
From source file:com.anjlab.sat3.Program.java
private static ObjectArrayList unifyAndCreateHSS(Properties statistics, StopWatch stopWatch, ObjectArrayList cts) {//from w ww . ja v a 2 s. c om long timeElapsed; stopWatch.start("Unify all CTS"); Helper.unify(cts); timeElapsed = stopWatch.stop(); printFormulas(cts); stopWatch.printElapsed(); statistics.put(Helper.CTS_UNIFICATION_TIME, String.valueOf(timeElapsed)); LOGGER.info("CTF: {}", cts.size()); ObjectArrayList hss = null; try { stopWatch.start("Create HSS"); hss = Helper.createHyperStructuresSystem(cts, statistics); } finally { timeElapsed = stopWatch.stop(); stopWatch.printElapsed(); if (hss != null) { statistics.put(Helper.BASIC_CTS_FINAL_CLAUSES_COUNT, String.valueOf(((IHyperStructure) hss.get(0)).getBasicCTS().getClausesCount())); } statistics.put(Helper.HSS_CREATION_TIME, String.valueOf(timeElapsed)); } return hss; }
From source file:com.google.code.pentahoflashcharts.charts.AbstractChartFactory.java
public static String buildCSSString(String fontfamily, String fontsize, String fontweight, String fontstyle) { Properties props = new Properties(); props.put("fontfamily", fontfamily != null ? fontfamily : CSS_FONT_FAMILY_DEFAULT); //$NON-NLS-1$ props.put("fontsize", fontsize != null ? fontsize : CSS_FONT_SIZE_DEFAULT); //$NON-NLS-1$ props.put("fontweight", fontweight != null ? fontweight : CSS_FONT_WEIGHT_DEFAULT); //$NON-NLS-1$ props.put("fontstyle", fontstyle != null ? fontstyle : CSS_FONT_STYLE_DEFAULT); //$NON-NLS-1$ return TemplateUtil.applyTemplate(CSS_FONT_STYLES, props, null); }
From source file:com.microsoft.tfs.core.clients.build.internal.utils.XamlHelper.java
public static Properties loadPartial(final String xaml) { final Properties properties = new Properties(); try {/*w w w . j a v a 2 s. co m*/ final Document document = DOMCreateUtils.parseString(xaml); final Element root = document.getDocumentElement(); final NodeList nodes = root.getElementsByTagName("x:String"); //$NON-NLS-1$ for (int i = 0; i < nodes.getLength(); i++) { final Element element = (Element) nodes.item(i); final String key = element.getAttribute("x:Key"); //$NON-NLS-1$ final String value = element.getFirstChild().getNodeValue(); properties.put(key, value); } } catch (final XMLException e) { log.error( MessageFormat.format(Messages.getString("XamlHelper.ExceptionParsingProcessParaemtersFormat"), //$NON-NLS-1$ xaml), e); } return properties; }
From source file:com.ibm.iotf.connector.Connector.java
public static final Properties getClientConfiguration(String broker) throws IOException { Properties props = new Properties(); InputStream propsStream;/* ww w .j a v a 2s. c om*/ String fileName = "producer.properties"; String propertiesPath = resourceDir + File.separator + fileName; try { propsStream = new FileInputStream(propertiesPath); props.load(propsStream); propsStream.close(); } catch (IOException e) { logger.log(Level.FATAL, "Could not load Message Hub producer properties from file: " + propertiesPath); throw e; } props.put("bootstrap.servers", broker); // if we're running in bluemix, we need to update the location of the Java truststore if (isBluemix) { props.put("ssl.truststore.location", userDir + "/.java-buildpack/open_jdk_jre/lib/security/cacerts"); } return props; }