List of usage examples for java.util Properties containsValue
@Override
public boolean containsValue(Object value)
From source file:cn.vlabs.duckling.vwb.service.config.impl.DomainServiceImpl.java
private Properties buildProperties(String[] domains) { boolean first = true; Properties prop = new Properties(); int i = 0;/*from w ww. j a v a2 s . c o m*/ if (domains != null) { for (String domain : domains) { if (!prop.containsValue(domain)) { if (first) { first = false; prop.put(KeyConstants.SITE_DOMAIN_KEY, domain); } else { prop.put(String.format("%s.%d", KeyConstants.SITE_DOMAIN_KEY, i), domain); } i++; } } } return prop; }
From source file:org.ala.spatial.web.services.SitesBySpeciesWSControllerTabulated.java
@RequestMapping(value = { "sxs/add", "sxs/sxs/add" }, method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView sxsAdd(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String speciesquery = req.getParameter("speciesquery");
String layers = req.getParameter("layers");
String bs = URLEncoder.encode(AlaspatialProperties.getBiocacheWsURL(), "UTF-8");
String gridsize = req.getParameter("gridsize");
String minuncertainty = req.getParameter("minuncertainty") == null ? ""
: req.getParameter("minuncertainty");
String maxuncertainty = req.getParameter("maxuncertainty") == null ? ""
: req.getParameter("maxuncertainty");
String nulluncertainty = req.getParameter("nulluncertainty") == null ? "false"
: req.getParameter("nulluncertainty");
String min = minuncertainty.length() == 0 ? "*" : minuncertainty;
String max = maxuncertainty.length() == 0 ? "*" : maxuncertainty;
if (nulluncertainty.equals("true")) {
speciesquery = "(" + speciesquery + ")%20AND%20coordinate_uncertainty:%5B" + min + "%20TO%20" + max
+ "%5D";
} else if (minuncertainty.length() + maxuncertainty.length() > 0) {
speciesquery = "(" + speciesquery
+ ")%20AND%20-(coordinate_uncertainty:*%20AND%20-coordinate_uncertainty:%5B" + min + "%20TO%20"
+ max + "%5D)";
}//from w ww.j a v a2 s . c o m
String url = req.getParameter("u");
try {
if (url == null) {
url = "q=" + speciesquery + "&gridsize=" + gridsize + "&layers=" + layers;
}
String pth = AlaspatialProperties.getAnalysisWorkingDir() + File.separator + "sxs" + File.separator;
initListProperties();
Properties p = new Properties();
p.load(new FileReader(pth + "list.properties"));
synchronized (lockProperties) {
FileWriter fw = new FileWriter(pth + "list.properties", true);
if (!p.containsValue(url)) {
for (int i = 1; i < Integer.MAX_VALUE; i++) {
if (!p.containsKey(String.valueOf(i))) {
fw.write("\n" + i + "=" + url);
new File(pth + i).delete();
break;
}
}
}
fw.flush();
fw.close();
}
for (Entry<Object, Object> entry : p.entrySet()) {
if (((String) entry.getValue()).equals(url)) {
File f = new File(pth + ((String) entry.getKey()));
if (f.exists()) {
new File(pth + ((String) entry.getKey())).delete();
}
}
}
run();
} catch (Exception e) {
e.printStackTrace();
}
return new ModelAndView("redirect:" + AlaspatialProperties.getAlaspatialUrl() + "/sxs");
}
From source file:com.streamsets.datacollector.cluster.TestShellClusterProvider.java
@Test public void testRemovingProperties() throws Exception { Properties sdcProperties = new Properties(); sdcProperties.put("stay", "Don't try to touch me!"); sdcProperties.put("remove.me", "Yes please!"); sdcProperties.put("remove.me.too", "Yes please!"); sdcProperties.put(RuntimeInfo.DATA_COLLECTOR_BASE_HTTP_URL, "Yes please!"); sdcProperties.put("http.bindHost", "Yes please!"); sdcProperties.put("cluster.slave.configs.remove", "remove.me,remove.me.too"); File etcDir = tempFolder.newFolder(); File sdcPropertiesFile = new File(etcDir, "sdc.properties"); try (OutputStream out = new FileOutputStream(sdcPropertiesFile)) { sdcProperties.store(out, null);/*from w w w . jav a 2s. c o m*/ } sparkProvider.rewriteProperties(sdcPropertiesFile, new ArrayList<>(), etcDir, Collections.emptyMap(), Collections.emptyMap(), "", Optional.empty()); try (InputStream in = new FileInputStream(sdcPropertiesFile)) { Properties updatedProperties = new Properties(); updatedProperties.load(in); Assert.assertEquals("Don't try to touch me!", updatedProperties.getProperty("stay")); Assert.assertFalse(updatedProperties.containsValue("remove.me")); Assert.assertFalse(updatedProperties.containsValue("remove.me.too")); Assert.assertFalse(updatedProperties.containsValue("http.bindHost")); Assert.assertFalse(updatedProperties.containsValue(RuntimeInfo.DATA_COLLECTOR_BASE_HTTP_URL)); } }
From source file:org.eclipse.smila.connectivity.framework.crawler.web.filter.impl.MetaTagFilter.java
/** * {@inheritDoc}/*from w w w . j a va2 s . co m*/ */ public boolean matches(final HTMLMetaTags test) { boolean result = false; Properties metaTags; if (_type.equals(HtmlMetaTagType.HTTP_EQUIV)) { metaTags = test.getHttpEquivTags(); } else { metaTags = test.getGeneralTags(); } if (StringUtils.isNotEmpty(_name)) { if (metaTags.containsKey(_name) && (metaTags.getProperty(_name).equals(_content))) { result = true; } } else { if (metaTags.containsValue(_content)) { result = true; } } return result; }