List of usage examples for java.util Properties stringPropertyNames
public Set<String> stringPropertyNames()
From source file:org.mule.transport.siebel.PollingSiebelMessageReceiver.java
/** * Creates and configures Siebel polling message receiver * @param connector Siebel connector/*w ww . j ava2 s.c o m*/ * @param flowConstruct Flow Construct * @param endpoint Siebel Endpoint expected in format siebel://service_name/method_name?parameters * @param frequency polling frequency in milliseconds * @throws CreateException in case of initialisation error */ public PollingSiebelMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint, long frequency) throws CreateException { super(connector, flowConstruct, endpoint); logger.debug("Initializing"); setFrequency(frequency); logger.debug("Polling frequency set to " + frequency); //grab call parameters from endpoint params = new SiebelPropertySet(); Properties endPointParams = getEndpoint().getEndpointURI().getParams(); for (String paramName : endPointParams.stringPropertyNames()) { logger.debug("Setting property [" + paramName + "] to [" + endPointParams.getProperty(paramName) + "]"); params.setProperty(paramName, endPointParams.getProperty(paramName)); } }
From source file:guru.nidi.languager.PropertiesFinder.java
public SortedMap<String, Message> findProperties() throws IOException { SortedMap<String, Message> messages = new TreeMap<>(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); for (String propertyLocation : propertyLocations) { Resource[] resources = resolver.getResources(propertyLocation + "*" + PROPERTIES); for (Resource resource : resources) { String lang = resource.getFilename(); lang = lang.substring(Math.max(0, lang.length() - 20), lang.length() - PROPERTIES.length()); int pos = lang.indexOf('_'); if (pos < 0) { lang = ""; } else { lang = lang.substring(pos + 1); }//from w ww . j a v a 2 s . co m Properties props = new Properties(); props.load(resource.getInputStream()); for (String name : props.stringPropertyNames()) { Message message = messages.get(name); if (message == null) { message = new Message(name, FOUND, null); messages.put(name, message); } message.addValue(lang, props.getProperty(name)); } } } return messages; }
From source file:net.librec.tool.driver.DataDriver.java
/** * Execute the command with the given arguments. * * @param args command specific arguments. * @return exit code.//w w w . j a va2 s. c om * @throws Exception if error occurs */ public int run(String[] args) throws Exception { // init options Options options = new Options(); options.addOption("build", false, "build model"); options.addOption("load", false, "load model"); options.addOption("save", false, "save model"); options.addOption("conf", true, "the path of configuration file"); options.addOption("jobconf", true, "a specified key-value pair for configuration"); options.addOption("D", true, "a specified key-value pair for configuration"); // parse options CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args, false); // init configuration Configuration conf = new Configuration(); if (cmd.hasOption("conf")) { String confFilePath = cmd.getOptionValue("conf"); Properties prop = new Properties(); prop.load(new FileInputStream(confFilePath)); for (String name : prop.stringPropertyNames()) { conf.set(name, prop.getProperty(name)); } } if (cmd.hasOption("jobconf")) { String[] optionValues = cmd.getOptionValues("jobconf"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("="); conf.set(keyValuePair[0], keyValuePair[1]); } } if (cmd.hasOption("D")) { String[] optionValues = cmd.getOptionValues("D"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("="); conf.set(keyValuePair[0], keyValuePair[1]); } } TextDataModel dataModel = new TextDataModel(conf); dataModel.buildDataModel(); System.out.println("well done!!!"); return 0; }
From source file:de.tudarmstadt.ukp.dkpro.core.api.resources.RuntimeProvider.java
public void install() throws IOException { if (installed) { return;/* www . j a v a 2 s .c o m*/ } Properties manifest = getManifest(); for (String filename : manifest.stringPropertyNames()) { URL source = resolveLocation(baseLocation + platform + "/" + filename, this, null); File target = new File(getWorkspace(), filename); InputStream is = null; OutputStream os = null; try { is = source.openStream(); os = new FileOutputStream(target); IOUtils.copyLarge(is, os); } finally { closeQuietly(is); closeQuietly(os); } if (MODE_EXECUTABLE.equals(manifest.getProperty(filename))) { target.setExecutable(true); } target.deleteOnExit(); } installed = true; }
From source file:net.librec.tool.driver.RecDriver.java
/** * Execute the command with the given arguments. * * @param args command specific arguments. * @return exit code./*from www.java 2s. c om*/ * @throws Exception if error occurs */ public int run(String[] args) throws Exception { // init options Options options = new Options(); options.addOption("build", false, "build model"); options.addOption("load", false, "load model"); options.addOption("save", false, "save model"); options.addOption("exec", false, "run job"); options.addOption("conf", true, "the path of configuration file"); options.addOption("jobconf", true, "a specified key-value pair for configuration"); options.addOption("D", true, "a specified key-value pair for configuration"); // parse options CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args, false); // init configuration Configuration conf = new Configuration(); if (cmd.hasOption("conf")) { String confFilePath = cmd.getOptionValue("conf"); Properties prop = new Properties(); prop.load(new FileInputStream(confFilePath)); for (String name : prop.stringPropertyNames()) { conf.set(name, prop.getProperty(name)); } } if (cmd.hasOption("jobconf")) { String[] optionValues = cmd.getOptionValues("jobconf"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("="); conf.set(keyValuePair[0], keyValuePair[1]); } } if (cmd.hasOption("D")) { String[] optionValues = cmd.getOptionValues("D"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("="); conf.set(keyValuePair[0], keyValuePair[1]); } } //run job RecommenderJob job = new RecommenderJob(conf); job.runJob(); System.out.print("Finished"); return 0; }
From source file:org.patientview.monitoring.ImportMonitor.java
/** * Returns all property names that starts with the given string * * @return empty array list if no property name is found *//*from w w w . j ava2 s . c o m*/ private static List<String> getPropertyNamesStartingWith(String queriedProperyName) { Resource resource = new ClassPathResource("/" + PROJECT_PROPERTIES_FILE); Properties props = null; Set<String> allPropertyNames; List<String> propertyNames = new ArrayList<String>(); try { props = PropertiesLoaderUtils.loadProperties(resource); allPropertyNames = props.stringPropertyNames(); for (String propertyName : allPropertyNames) { if (propertyName.startsWith(queriedProperyName)) { propertyNames.add(propertyName); } } } catch (IOException e) { LOGGER.error("Could not find properties file: {}", e); } return propertyNames; }
From source file:org.xwiki.configuration.internal.CloudConfigurationSourceTest.java
/** * Check that all System properties are correctly accessible through the configuration source. * /*from w w w . j a va2 s. c o m*/ * @throws Exception If the configuration source cannot be looked up. */ @Test public void testGetSystemProperties() throws Exception { Properties properties = System.getProperties(); for (String key : properties.stringPropertyNames()) { Assert.assertEquals(properties.get(key), source.getProperty(key)); } }
From source file:com.mgmtp.jfunk.core.scripting.ScriptExecutor.java
private void initScriptProperties(final ScriptEngine se, final Properties properties) { for (String name : properties.stringPropertyNames()) { se.put(name, properties.getProperty(name)); }//from w w w . ja va 2 s.co m }
From source file:nl.opengeogroep.filesetsync.client.plugin.SetFileXpathToHttpRequestHeaderPlugin.java
@Override public void configure(Properties props) { for (String p : props.stringPropertyNames()) { if (!p.startsWith("header.")) { log.warn("Ignoring config property: " + p); continue; }/*from w w w .ja v a 2 s.co m*/ String header = p.substring("header".length() + 1); String[] parts = header.split("\\."); if (parts.length != 2) { log.warn("Invalid config property: " + Arrays.toString(parts)); continue; } header = parts[0]; String config = parts[1]; String value = props.getProperty(p); Properties headerProps = headers.get(header); if (headerProps == null) { headerProps = new Properties(); headers.put(header, headerProps); } headerProps.put(config, value); } updateAllHeaders(); context.addFilesetInterceptor(this); }
From source file:org.apache.nifi.toolkit.cli.impl.session.PersistentSession.java
public synchronized void loadSession() throws SessionException { wrappedSession.clear();/*from w w w . j a va 2s.c om*/ try (final InputStream in = new FileInputStream(persistenceFile)) { final Properties properties = new Properties(); properties.load(in); for (final String propName : properties.stringPropertyNames()) { final String propValue = properties.getProperty(propName); wrappedSession.set(propName, propValue); } } catch (Exception e) { throw new SessionException("Error loading session: " + e.getMessage(), e); } }