List of usage examples for java.util Properties get
@Override
public Object get(Object key)
From source file:net.jetrix.config.ServerConfig.java
/** * Write the configuration of the specified filter. *//*from w w w . j a va 2 s . c om*/ private void saveFilter(FilterConfig filter, PrintWriter out, String indent) { Properties props = filter.getProperties(); if (props == null || props.isEmpty()) { if (filter.getName() != null) { out.println(indent + "<filter name=\"" + filter.getName() + "\"/>"); } else { out.println(indent + "<filter class=\"" + filter.getClassname() + "\"/>"); } } else { if (filter.getName() != null) { out.println(indent + "<filter name=\"" + filter.getName() + "\">"); } else { out.println(indent + "<filter class=\"" + filter.getClassname() + "\">"); } for (Object name : props.keySet()) { out.println(indent + " <param name=\"" + name + "\" value=\"" + props.get(name) + "\"/>"); } out.println(indent + "</filter>"); } }
From source file:org.jahia.services.usermanager.ldap.LDAPUserGroupProvider.java
@Override public List<String> searchGroups(Properties searchCriteria, long offset, long limit) { if (searchCriteria.containsKey("groupname") && searchCriteria.size() == 1 && !searchCriteria.getProperty("groupname").contains("*")) { try {//w ww .j a va 2 s .c om JahiaGroup group = getGroup((String) searchCriteria.get("groupname")); return Arrays.asList(group.getGroupname()); } catch (GroupNotFoundException e) { return Collections.emptyList(); } } List<String> groups = new LinkedList<String>(searchGroups(searchCriteria, false)); // handle dynamics if (groupConfig.isDynamicEnabled()) { groups.addAll(searchGroups(searchCriteria, true)); } return groups.subList(Math.min((int) offset, groups.size()), limit < 0 ? groups.size() : Math.min((int) (offset + limit), groups.size())); }
From source file:org.jahia.services.usermanager.ldap.LDAPUserGroupProvider.java
@Override public List<String> searchUsers(final Properties searchCriteria, long offset, long limit) { if (searchCriteria.containsKey("username") && searchCriteria.size() == 1 && !searchCriteria.getProperty("username").contains("*")) { try {/*from w w w . j a v a 2 s . c o m*/ JahiaUser user = getUser((String) searchCriteria.get("username")); return Arrays.asList(user.getUsername()); } catch (UserNotFoundException e) { return Collections.emptyList(); } } final ContainerCriteria query = buildUserQuery(searchCriteria); if (query == null) { return Collections.emptyList(); } final UsersNameClassPairCallbackHandler searchNameClassPairCallbackHandler = new UsersNameClassPairCallbackHandler(); long currentTimeMillis = System.currentTimeMillis(); ldapTemplateWrapper.execute(new BaseLdapActionCallback<Object>(externalUserGroupService, key) { @Override public Object doInLdap(LdapTemplate ldapTemplate) { ldapTemplate.search(query, searchNameClassPairCallbackHandler); return null; } }); logger.debug("Search users for {} in {} ms", searchCriteria, System.currentTimeMillis() - currentTimeMillis); ArrayList<String> l = new ArrayList<String>(searchNameClassPairCallbackHandler.getNames()); return l.subList(Math.min((int) offset, l.size()), limit < 0 ? l.size() : Math.min((int) (offset + limit), l.size())); }
From source file:com.aliyun.odps.conf.Configuration.java
/** * ?? {@link OutputStream}/*from w w w . j av a 2 s . co m*/ * * @param out * {@link OutputStream} */ @SuppressWarnings("rawtypes") public void writeXml(OutputStream out) throws IOException { Properties properties = getProps(); try { Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element conf = doc.createElement("configuration"); doc.appendChild(conf); conf.appendChild(doc.createTextNode("\n")); for (Enumeration e = properties.keys(); e.hasMoreElements();) { String name = (String) e.nextElement(); Object object = properties.get(name); String value = null; if (object instanceof String) { value = (String) object; } else { continue; } Element propNode = doc.createElement("property"); conf.appendChild(propNode); Element nameNode = doc.createElement("name"); nameNode.appendChild(doc.createTextNode(name)); propNode.appendChild(nameNode); Element valueNode = doc.createElement("value"); valueNode.appendChild(doc.createTextNode(value)); propNode.appendChild(valueNode); conf.appendChild(doc.createTextNode("\n")); } DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(out); TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.transform(source, result); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:edu.dfci.cccb.mev.controllers.HeatmapController.java
@Override public void afterPropertiesSet() throws Exception { new Thread() { public void run() { Properties definitions = new Properties() { private static final long serialVersionUID = 1L; {// ww w .j a v a 2s.c o m try { load(Heatmaps.class.getResourceAsStream("/configuration/heatmap.globals.properties")); } catch (IOException e) { log.warn("Unable to load global heatmaps", e); } } }; Properties annotations = new Properties() { private static final long serialVersionUID = 1L; { try { load(Heatmaps.class .getResourceAsStream("/configuration/heatmap.globals.annotation.properties")); } catch (NullPointerException | IOException e) { log.warn("Unable to load global heatmap annotations"); } } }; for (String key : definitions.stringPropertyNames()) { File data = new File(definitions.get(key).toString()); log.debug("Loading " + data + " as " + key); if (!data.exists()) { log.debug("File " + data + " not found"); continue; } else try { log.debug(data + " found"); Heatmap heatmap; global.put(key, heatmap = heatmapBuilder.build(new FileInputStream(data), data.length(), key)); log.debug("Loaded " + data); String location; try { if ((location = annotations.getProperty(key + ".column")) != null && new File(location).exists()) heatmap.setColumnAnnotations(new FileInputStream(location)); log.debug("Loaded column annotations for " + key + " from " + location); } catch (IOException e) { log.warn("Unable to load column annotations for " + key, e); } try { if ((location = annotations.getProperty(key + ".row")) != null && new File(location).exists()) heatmap.setRowAnnotations(new FileInputStream(location)); log.debug("Loaded row annotations for " + key + " from " + location); } catch (IOException e) { log.warn("Unable to load row annotations for " + key, e); } } catch (IOException e) { log.warn("Unable to load global heatmap " + key + " data at " + data, e); } } log.info("Finished loading global heatmaps"); } }.start(); }
From source file:com.powers.wsexplorer.gui.WSExplorer.java
public Options getOptions() { Options o = new Options(); Properties options = GUIUtil.readPropertiesFile(OptionsDialog.OPTIONS_FILE); if (options != null) { o.ignoreHostCertificates = Boolean.valueOf((String) options.get(Options.IGNORE_HOST_CERTIFICATS_KEY)); // add any more options... }// w w w .jav a2 s . com return o; }
From source file:com.enioka.jqm.api.HibernateClient.java
HibernateClient(Properties p) { this.p = p;//from ww w. j ava2s. com if (p.containsKey("emf")) { jqmlogger.trace("emf present in properties"); emf = (EntityManagerFactory) p.get("emf"); } }
From source file:br.edu.ufcg.lsd.commune.context.PropertiesFileParser.java
public Map<Object, Object> parseContext() { Properties properties = new Properties(); /** Get an abstraction for the properties file */ File propertiesFile = new File(fileName); if (!propertiesFile.exists()) { return getDefaultProperties(propertiesFile); }/*from w w w . j a v a 2 s . c o m*/ /* load the properties file, if it exists */ FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(propertiesFile); } catch (FileNotFoundException e) { throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName + " does not exist. Please check this file. Exception: " + e.getMessage()); } try { properties.load(fileInputStream); } catch (IOException e) { throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName + " is corrupted. Please check this file. Exception: " + e.getMessage()); } catch (IllegalArgumentException iae) { throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName + " isn't a properties file. Please use correct file format."); } finally { try { fileInputStream.close(); } catch (IOException e) { throw new CommuneRuntimeException("Context couldn't be loaded. " + fileName + " is corrupeed. Please check this file. Exception: " + e.getMessage()); } } Map<Object, Object> responseMap = new LinkedHashMap<Object, Object>(); for (Object key : properties.keySet()) { if (!properties.get(key).toString().trim().equals("")) { responseMap.put(key, properties.get(key)); } } return responseMap; }
From source file:com.liferay.ide.project.core.tests.ProjectCoreBase.java
private void persistAppServerProperties() throws FileNotFoundException, IOException, ConfigurationException { Properties initProps = new Properties(); initProps.put("app.server.type", "tomcat"); initProps.put("app.server.tomcat.dir", getLiferayRuntimeDir().toPortableString()); initProps.put("app.server.tomcat.deploy.dir", getLiferayRuntimeDir().append("webapps").toPortableString()); initProps.put("app.server.tomcat.lib.global.dir", getLiferayRuntimeDir().append("lib/ext").toPortableString()); initProps.put("app.server.parent.dir", getLiferayRuntimeDir().removeLastSegments(1).toPortableString()); initProps.put("app.server.tomcat.portal.dir", getLiferayRuntimeDir().append("webapps/ROOT").toPortableString()); IPath loc = getLiferayPluginsSdkDir(); String userName = System.getProperty("user.name"); //$NON-NLS-1$ File userBuildFile = loc.append("build." + userName + ".properties").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ try (FileOutputStream fileOutput = new FileOutputStream(userBuildFile)) { if (userBuildFile.exists()) { PropertiesConfiguration propsConfig = new PropertiesConfiguration(userBuildFile); for (Object key : initProps.keySet()) { propsConfig.setProperty((String) key, initProps.get(key)); }/*from ww w. ja va 2 s. co m*/ propsConfig.setHeader(""); propsConfig.save(fileOutput); } else { Properties props = new Properties(); props.putAll(initProps); props.store(fileOutput, StringPool.EMPTY); } } }
From source file:com.quinsoft.zeidon.jmx.JmxObjectEngineMonitor.java
@Override public Properties getRuntimeProperties() { Properties properties = new Properties(); // Add activate information. for (String key : eventInfo.keySet()) { EventInfo info = eventInfo.get(key); synchronized (info) // To keep other threads from changing times and counts. {/* w w w.j ava2 s . c o m*/ if (info.activates > 0) { properties.put(String.format("%s activates", key), info.activates); double average = info.totalActivateTime / 1000.0 / info.activates; properties.put(String.format("%s activate average", key), String.format("%1.4f", average)); if (info.activateErrors > 0) properties.put(String.format("%s activate errors", key), info.activateErrors); } if (info.commits > 0) { properties.put(String.format("%s commits\n", key), info.commits); double average = info.totalCommitTime / 1000.0 / info.commits; properties.put(String.format("%s commit average", key), String.format("%1.4f", average)); if (info.commitErrors > 0) properties.put(String.format("%s commit errors", key), info.commitErrors); } } } ZeidonLogger logger = oe.getSystemTask().log(); for (Object key : properties.keySet()) { Object value = properties.get(key); logger.info("%s %s", key, value); } return properties; }