List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:eu.edisonproject.training.execute.Main.java
private static void termExtraction(String docs, String out) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, InterruptedException { if (!new File(docs).exists()) { throw new IOException(new File(docs).getAbsolutePath() + " don't exist"); }//from w w w . j a v a2s . c o m // String[] extractors = prop.getProperty("term.extractors", "eu.edisonproject.training.term.extraction.LuceneExtractor," + "eu.edisonproject.training.term.extraction.JtopiaExtractor," + "eu.edisonproject.training.term.extraction.AprioriExtraction") .split(","); // String[] extractors = prop.getProperty("term.extractors", // "eu.edisonproject.training.term.extraction.JtopiaExtractor," // + "eu.edisonproject.training.term.extraction.AprioriExtraction").split(","); // String[] extractors = "eu.edisonproject.training.term.extraction.JtopiaExtractor".split(","); Map<String, Double> termDictionaray = new HashMap(); for (String className : extractors) { Class c = Class.forName(className); Object obj = c.newInstance(); TermExtractor termExtractor = (TermExtractor) obj; termExtractor.configure(prop); termDictionaray.putAll(termExtractor.termXtraction(docs)); } writeDictionary2File(termDictionaray, out); calculateTermTFIDF(docs, out, out); }
From source file:playground.johannes.socialnets.GraphStatistics.java
public static Histogram1D createAPLHistogram(Graph g, double min, double max) { ClusterSet clusters = new WeakComponentClusterer().extract(g); Map<Vertex, Double> distances = new HashMap<Vertex, Double>(); for (int i = 0; i < clusters.size(); i++) { Graph subGraph = clusters.getClusterAsNewSubGraph(i); if (subGraph.numVertices() > 1) distances.putAll(edu.uci.ics.jung.statistics.GraphStatistics.averageDistances(subGraph)); }//from w ww . jav a 2 s .c o m DoubleArrayList values = new DoubleArrayList(distances.size()); for (Vertex v : distances.keySet()) { if (v.getUserDatum(UserDataKeys.ANONYMOUS_KEY) == null) values.add(distances.get(v)); } if (min < 0 && max < 0) { values.sort(); min = values.get(0); max = values.get(values.size() - 1); } return createHistogram(values, min, max, "average path length distribution"); }
From source file:org.pentaho.di.core.util.StringUtil.java
/** * Substitutes variables in <code>aString</code> with the environment values in the system properties * * @param aString// ww w . j a v a2 s . c o m * the string on which to apply the substitution. * @param systemProperties * the system properties to use * @return the string with the substitution applied. */ public static final synchronized String environmentSubstitute(String aString, Map<String, String> systemProperties) { Map<String, String> sysMap = new HashMap<String, String>(); synchronized (sysMap) { sysMap.putAll(Collections.synchronizedMap(systemProperties)); aString = substituteWindows(aString, sysMap); aString = substituteUnix(aString, sysMap); aString = substituteHex(aString); return aString; } }
From source file:de.adesso.referencer.search.helper.MyHelpMethods.java
public static Map<String, Long> mergeMapOfWords(Map<String, Long> map1, Map<String, Long> map2) { if (map1 == null && map2 == null) { return null; }/*from w ww . j a v a 2 s .c o m*/ Map<String, Long> result = new HashMap<>(); if (map1 != null && map1.size() > 0) { result.putAll(map1); if (map2 != null && map2.size() > 0) { for (String s : map2.keySet()) { if (result.containsKey(s)) { if (result.get(s) != null && map2.get(s) != null) { result.put(s, result.get(s) + map2.get(s)); } else if (result.get(s) == null && map2.get(s) != null) { result.put(s, map2.get(s)); } else if (result.get(s) != null && map2.get(s) == null) { result.put(s, map1.get(s)); } else { result.put(s, map1.get(s)); } } else { result.put(s, map2.get(s)); } } } } else if (map2 != null && map2.size() > 0) { result.putAll(map2); } return result; }
From source file:com.adobe.acs.commons.email.process.impl.SendTemplatedEmailUtils.java
/*** * Tests whether the payload is a DAM asset or a cq:Page for DAM asset * returns all properties at the metadata node for DAM assets for cq:Page * returns all properties at the jcr:content node The Map<String, String> * that is returned contains string representations of each of the * respective properties//from w w w .ja v a 2 s .c o m * * @param payloadRes * the payload as a resource * @param sdf * used by the method to transform Date properties into Strings * @return Map<String, String> String representation of jcr properties */ protected static final Map<String, String> getPayloadProperties(Resource payloadRes, SimpleDateFormat sdf) { Map<String, String> emailParams = new HashMap<String, String>(); if (payloadRes == null) { return emailParams; } // Check if the payload is an asset if (DamUtil.isAsset(payloadRes)) { // get metadata resource Resource mdRes = payloadRes.getChild(JcrConstants.JCR_CONTENT + "/" + DamConstants.METADATA_FOLDER); Map<String, String> assetMetadata = getJcrKeyValuePairs(mdRes, sdf); emailParams.putAll(assetMetadata); } else { // check if the payload is a page Page payloadPage = payloadRes.adaptTo(Page.class); if (payloadPage != null) { Map<String, String> pageContent = getJcrKeyValuePairs(payloadPage.getContentResource(), sdf); emailParams.putAll(pageContent); } } return emailParams; }
From source file:io.fabric8.spring.cloud.kubernetes.config.ConfigMapPropertySource.java
private static Map<String, String> getData(KubernetesClient client, String name, String namespace) { Map<String, String> result = new HashMap<>(); try {// w ww. j a va 2 s . c o m ConfigMap map = namespace == null || namespace.isEmpty() ? client.configMaps().withName(name).get() : client.configMaps().inNamespace(namespace).withName(name).get(); if (map != null) { for (Map.Entry<String, String> entry : map.getData().entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key.equals(APPLICATION_YAML) || key.equals(APPLICATION_YML)) { result.putAll(YAML_TO_PROPETIES.andThen(PROPERTIES_TO_MAP).apply(value)); } else if (key.equals(APPLICATION_PROPERTIES)) { result.putAll(KEY_VALUE_TO_PROPERTIES.andThen(PROPERTIES_TO_MAP).apply(value)); } else { result.put(key, value); } } } } catch (Exception e) { LOGGER.warn( "Can't read configMap with name: [" + name + "] in namespace:[" + namespace + "]. Ignoring"); } return result; }
From source file:de.xwic.appkit.core.util.CollectionUtil.java
/** * @param where map to clear and add to// ww w . ja v a2s. c o m * @param fromWhere what to add * @throws NullPointerException if <code>where</code> is empty */ public static <K, V> void clearAndPutAll(final Map<? super K, ? super V> where, final Map<? extends K, ? extends V> fromWhere) throws NullPointerException { if (where == fromWhere) { return; } where.clear(); if (!isEmpty(fromWhere)) { where.putAll(fromWhere); } }
From source file:edu.uci.ics.asterix.metadata.feeds.FeedUtil.java
public static Triple<IFeedAdapterFactory, ARecordType, AdapterType> getPrimaryFeedFactoryAndOutput( PrimaryFeed feed, FeedPolicyAccessor policyAccessor, MetadataTransactionContext mdTxnCtx) throws AlgebricksException { String adapterName = null;//w w w. jav a2s. c o m DatasourceAdapter adapterEntity = null; String adapterFactoryClassname = null; IFeedAdapterFactory adapterFactory = null; ARecordType adapterOutputType = null; Triple<IFeedAdapterFactory, ARecordType, AdapterType> feedProps = null; AdapterType adapterType = null; try { adapterName = feed.getAdaptorName(); adapterEntity = MetadataManager.INSTANCE.getAdapter(mdTxnCtx, MetadataConstants.METADATA_DATAVERSE_NAME, adapterName); if (adapterEntity == null) { adapterEntity = MetadataManager.INSTANCE.getAdapter(mdTxnCtx, feed.getDataverseName(), adapterName); } if (adapterEntity != null) { adapterType = adapterEntity.getType(); adapterFactoryClassname = adapterEntity.getClassname(); switch (adapterType) { case INTERNAL: adapterFactory = (IFeedAdapterFactory) Class.forName(adapterFactoryClassname).newInstance(); break; case EXTERNAL: String[] anameComponents = adapterName.split("#"); String libraryName = anameComponents[0]; ClassLoader cl = ExternalLibraryManager.getLibraryClassLoader(feed.getDataverseName(), libraryName); adapterFactory = (IFeedAdapterFactory) cl.loadClass(adapterFactoryClassname).newInstance(); break; } } else { adapterFactoryClassname = AqlMetadataProvider.adapterFactoryMapping.get(adapterName); if (adapterFactoryClassname == null) { adapterFactoryClassname = adapterName; } adapterFactory = (IFeedAdapterFactory) Class.forName(adapterFactoryClassname).newInstance(); adapterType = AdapterType.INTERNAL; } Map<String, String> configuration = feed.getAdaptorConfiguration(); configuration.putAll(policyAccessor.getFeedPolicy()); adapterOutputType = getOutputType(feed, configuration); adapterFactory.configure(configuration, adapterOutputType); feedProps = new Triple<IFeedAdapterFactory, ARecordType, AdapterType>(adapterFactory, adapterOutputType, adapterType); } catch (Exception e) { e.printStackTrace(); throw new AlgebricksException("unable to create adapter " + e); } return feedProps; }
From source file:com.kylinolap.metadata.MetadataManager.java
@SuppressWarnings("unchecked") /**//from w w w .ja v a2 s . c o m * return table name */ public static String loadSourceTableExd(ResourceStore store, String path, Map<String, String> attrContainer) throws IOException { logger.debug("Loading SourceTable exd " + path); InputStream is = store.getResource(path); if (is != null) { attrContainer.putAll(JsonUtil.readValue(is, HashMap.class)); String file = path; if (file.indexOf("/") > -1) { file = file.substring(file.lastIndexOf("/") + 1); } return file.substring(0, file.length() - MetadataConstances.FILE_SURFIX.length()); } else { logger.debug("Failed to get table exd info from " + path); return null; } }
From source file:com.baidu.rigel.biplatform.tesseract.util.QueryRequestUtil.java
/** * collectAllMem/*from www. j av a2s . co m*/ * @param queryContext * @return */ private static Map<String, String> collectAllMem(QueryContext queryContext) { Map<String, String> allDimVal = new HashMap<String, String>(); if (CollectionUtils.isNotEmpty(queryContext.getColumnMemberTrees())) { queryContext.getColumnMemberTrees().forEach(tree -> { allDimVal.putAll(coolectAllMem(tree)); }); } if (CollectionUtils.isNotEmpty(queryContext.getRowMemberTrees())) { queryContext.getRowMemberTrees().forEach(tree -> { allDimVal.putAll(coolectAllMem(tree)); }); } return allDimVal; }