List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:io.jenkins.blueocean.config.JenkinsJSExtensions.java
private static Object mergeObjects(Object incoming) { if (incoming instanceof Map) { Map m = new HashMap(); Map in = (Map) incoming; for (Object key : in.keySet()) { Object value = mergeObjects(in.get(key)); m.put(key, value);/* ww w. ja va 2 s . com*/ } return m; } if (incoming instanceof Collection) { List l = new ArrayList(); for (Object i : (Collection) incoming) { i = mergeObjects(i); l.add(i); } return l; } if (incoming instanceof Class) { return ((Class) incoming).getName(); } if (incoming instanceof BlueExtensionClass) { BlueExtensionClass in = (BlueExtensionClass) incoming; Map m = new HashMap(); Object value = mergeObjects(in.getClasses()); m.put("_classes", value); return m; } return incoming; }
From source file:be.bittich.dynaorm.core.StringQueryBuilder.java
/** * Return the request to get a row value mapped with the parameters * * @param <T>/*from ww w . java 2s. c om*/ * @param t * @param fieldPrimary * @param dialect * @return * @throws RequestInvalidException */ public static <T> KeyValue<String, List<String>> conditionPrimaryKeysBuilder(T t, Map<Field, PrimaryKey> fieldPrimary, Dialect dialect) throws RequestInvalidException { boolean firstIteration = true; String req = ""; List<String> parameters = new LinkedList(); for (Field field : fieldPrimary.keySet()) { String label = "".equals(fieldPrimary.get(field).label()) ? field.getName() : fieldPrimary.get(field).label(); String value = AnnotationProcessor.getFieldValue(field.getName(), t); if (firstIteration) { req = dialect.where(req); firstIteration = false; } else { req = dialect.andWhere(req); } req = dialect.equalTo(req, label); parameters.add(value); } return new DefaultKeyValue(req, parameters); }
From source file:com.adguard.compiler.SettingUtils.java
public static String getScriptRulesText(Map<Integer, List<String>> filterScriptRules) { StringBuilder sb = new StringBuilder(); if (filterScriptRules != null) { for (int filterId : filterScriptRules.keySet()) { List<String> scriptRules = filterScriptRules.get(filterId); sb.append("DEFAULT_SCRIPT_RULES[").append(filterId).append("] = [];\r\n"); for (String scriptRule : scriptRules) { sb.append("DEFAULT_SCRIPT_RULES[").append(filterId).append("].push(\"") .append(StringEscapeUtils.escapeJavaScript(scriptRule)).append("\");\r\n"); }/*www.ja v a2s.c om*/ } } return sb.toString(); }
From source file:com.firewallid.util.FISQL.java
public static void updateRowInsertIfNotExist(Connection conn, String tableName, Map<String, String> updateConditions, Map<String, String> fields) throws SQLException { /* Query *///w w w .j av a 2 s . c om String query = "SELECT " + Joiner.on(", ").join(updateConditions.keySet()) + " FROM " + tableName + " WHERE " + Joiner.on(" = ? AND ").join(updateConditions.keySet()) + " = ?"; /* Execute */ PreparedStatement pst = conn.prepareStatement(query); int i = 1; for (String value : updateConditions.values()) { pst.setString(i, value); i++; } ResultSet executeQuery = pst.executeQuery(); if (executeQuery.next()) { /* Update */ query = "UPDATE " + tableName + " SET " + Joiner.on(" = ?, ").join(fields.keySet()) + " = ? WHERE " + Joiner.on(" = ? AND ").join(updateConditions.keySet()) + " = ?"; pst = conn.prepareStatement(query); i = 1; for (String value : fields.values()) { pst.setString(i, value); i++; } for (String value : updateConditions.values()) { pst.setString(i, value); i++; } pst.executeUpdate(); return; } /* Row is not exists. Insert */ query = "INSERT INTO " + tableName + " (" + Joiner.on(", ").join(fields.keySet()) + ", " + Joiner.on(", ").join(updateConditions.keySet()) + ") VALUES (" + StringUtils.repeat("?, ", fields.size() + updateConditions.size() - 1) + "?)"; pst = conn.prepareStatement(query); i = 1; for (String value : fields.values()) { pst.setString(i, value); i++; } for (String value : updateConditions.values()) { pst.setString(i, value); i++; } pst.execute(); }
From source file:com.metricsplugin.charts.BarChart.java
private static CategoryDataset createDataset(String nameY, Map<String, Number> dataSet2) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Set<String> chaves = dataSet2.keySet(); for (String chave : chaves) { dataset.addValue(dataSet2.get(chave), chave, ""); }/* w w w .ja va 2s .c om*/ return dataset; }
From source file:com.google.mr4c.sources.SourceUtils.java
public static Map<DatasetSource.SourceType, Set<String>> sortSourceNamesByType( Map<String, DatasetSource> srcMap) { Map<DatasetSource.SourceType, Set<String>> result = new HashMap<DatasetSource.SourceType, Set<String>>(); for (String name : srcMap.keySet()) { DatasetSource src = srcMap.get(name); DatasetSource.SourceType type = src.getSourceType(); Set<String> names = result.get(type); if (names == null) { names = new HashSet<String>(); result.put(type, names);//ww w . j av a 2s. co m } names.add(name); } return result; }
From source file:org.acra.util.HttpUtils.java
/** * Send an HTTP(s) request with POST parameters. * //from w ww .jav a2s .com * @param parameters * @param url * @throws ClientProtocolException * @throws IOException */ public static void doPost(Map<?, ?> parameters, URL url, String login, String password) throws ClientProtocolException, IOException { // Construct data final StringBuilder dataBfr = new StringBuilder(); for (final Object key : parameters.keySet()) { if (dataBfr.length() != 0) { dataBfr.append('&'); } Object value = parameters.get(key); if (value == null) { value = ""; } dataBfr.append(URLEncoder.encode(key.toString(), "UTF-8")).append('=') .append(URLEncoder.encode(value.toString(), "UTF-8")); } final HttpRequest req = new HttpRequest(isNull(login) ? null : login, isNull(password) ? null : password); req.sendPost(url.toString(), dataBfr.toString()); }
From source file:com.google.code.uclassify.client.examples.ClassifyExample.java
/** * Prints the result.// w w w . j ava 2 s . c o m * * @param classifications the classifications */ private static void printResult(Map<String, Classification> classifications) { System.out.println("================ Classifications =================="); for (String text : classifications.keySet()) { Classification classification = classifications.get(text); System.out.println(text); System.out.println("===================="); for (Class clazz : classification.getClazz()) { System.out.println(clazz.getClassName() + ":" + clazz.getP()); } } }
From source file:com.mirth.connect.server.util.SqlConfig.java
private static void addPluginSqlMaps(String database, DonkeyElement sqlMapConfigElement) throws Exception { ExtensionController extensionController = ControllerFactory.getFactory().createExtensionController(); Map<String, PluginMetaData> plugins = extensionController.getPluginMetaData(); if (MapUtils.isNotEmpty(plugins)) { for (String pluginName : plugins.keySet()) { PluginMetaData pmd = plugins.get(pluginName); if (extensionController.isExtensionEnabled(pluginName)) { // only add configs for plugins that have some configs defined if (pmd.getSqlMapConfigs() != null) { /* get the SQL map for the current database */ String pluginSqlMapName = pmd.getSqlMapConfigs().get(database); if (StringUtils.isBlank(pluginSqlMapName)) { /* * if we couldn't find one for the current * database, check for one that works with * all databases *///from ww w . j a v a 2s . c o m pluginSqlMapName = pmd.getSqlMapConfigs().get("all"); } if (StringUtils.isNotBlank(pluginSqlMapName)) { File sqlMapConfigFile = new File( ExtensionController.getExtensionsPath() + pmd.getPath(), pluginSqlMapName); Element sqlMapElement = sqlMapConfigElement.addChildElement("mapper"); sqlMapElement.setAttribute("url", sqlMapConfigFile.toURI().toURL().toString()); } else { throw new RuntimeException("SQL map file not found for database: " + database); } } } } } }
From source file:it.geosolutions.opensdi2.workflow.utils.TestUtils.java
public static void addSchemaToStore(DataStore store, String typeName, Map<String, Class> attributes) throws IOException { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(typeName);// w ww .ja v a2 s . co m for (String propName : attributes.keySet()) { typeBuilder.add(propName, attributes.get(propName)); } store.createSchema(typeBuilder.buildFeatureType()); }