List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.java
/** @see org.apache.axis2.jaxws.description.DescriptionFactory#createServiceDescriptionFromDBCMap(HashMap) */ public static List<ServiceDescription> createServiceDescriptionFromDBCMap( HashMap<String, DescriptionBuilderComposite> dbcMap, ConfigurationContext configContext, boolean performVaidation) { if (log.isDebugEnabled()) { log.debug(//from ww w. j ava 2 s .c o m "createServiceDescriptionFromDBCMap(Hashmap<String,DescriptionBuilderComposite>,ConfigurationContext,boolean performVaidation "); } List<ServiceDescription> serviceDescriptionList = new ArrayList<ServiceDescription>(); for (Iterator<DescriptionBuilderComposite> nameIter = dbcMap.values().iterator(); nameIter.hasNext();) { DescriptionBuilderComposite serviceImplComposite = nameIter.next(); if (isImpl(serviceImplComposite)) { // process this impl class // the implementation class represented by this DBC represents a single wsdl:service Set<QName> sQNames = serviceImplComposite.getServiceQNames(); if (sQNames == null || sQNames.isEmpty()) { if (log.isDebugEnabled()) { log.debug("Adding ServiceDescription instances from composite"); } ServiceDescriptionImpl serviceDescription = new ServiceDescriptionImpl(dbcMap, serviceImplComposite, configContext); ServiceDescriptionValidator validator = new ServiceDescriptionValidator(serviceDescription); if (validator.validate(performVaidation)) { serviceDescriptionList.add(serviceDescription); if (log.isDebugEnabled()) { log.debug( "Service Description created from DescriptionComposite: " + serviceDescription); } } else { String msg = Messages.getMessage("createSrvcDescrDBCMapErr", validator.toString(), serviceImplComposite.toString(), serviceDescription.toString()); throw ExceptionFactory.makeWebServiceException(msg); } } // the implementation class represented by this DBC represents multiple wsdl:services else { Iterator<QName> sQNameIter = sQNames.iterator(); while (sQNameIter.hasNext()) { QName sQName = sQNameIter.next(); if (log.isDebugEnabled()) { log.debug("Adding ServiceDescription from service QName set for : " + sQName); } ServiceDescriptionImpl serviceDescription = new ServiceDescriptionImpl(dbcMap, serviceImplComposite, configContext, sQName); ServiceDescriptionValidator validator = new ServiceDescriptionValidator(serviceDescription); if (validator.validate(performVaidation)) { serviceDescriptionList.add(serviceDescription); if (log.isDebugEnabled()) { log.debug("Service Description created from DescriptionComposite: " + serviceDescription); } } else { String msg = Messages.getMessage("createSrvcDescrDBCMapErr", validator.toString(), serviceImplComposite.toString(), serviceDescription.toString()); throw ExceptionFactory.makeWebServiceException(msg); } } } } else { if (log.isDebugEnabled()) { log.debug("DBC is not a service impl: " + serviceImplComposite.toString()); } } } // TODO: Process all composites that are WebFaults...current thinking is // that // since WebFault annotations only exist on exception classes, then they // should be processed by themselves, and at this level return serviceDescriptionList; }
From source file:edu.jhuapl.openessence.web.util.ControllerUtils.java
/** * Returns a union of the Dimensions in dimension1 and dimension2 based on dimension id. *//*from www.ja v a2 s . c o m*/ public static List<Dimension> unionDimensions(List<Dimension> dimension1, List<Dimension> dimension2) { HashMap<String, Dimension> result = new LinkedHashMap<String, Dimension>( dimension1.size() + dimension2.size()); for (Dimension d : dimension1) { result.put(d.getId(), d); } for (Dimension d : dimension2) { result.put(d.getId(), d); } return new ArrayList<Dimension>(result.values()); }
From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java
/** * This function loops over all sizes of ngrams, from minN to maxN, and creates * an ngram model, and also normalizes it. * * @param minN minimum size ngram//from w ww. j a va 2 s . co m * @param maxN maximum size ngram * @param examples list of examples * @param padding whether or not this should be padded * @return a hashmap of ngrams. */ public static HashMap<String, Double> GetNgramCounts(int minN, int maxN, Iterable<String> examples, boolean padding) { HashMap<String, Double> result = new HashMap<>(); for (int i = minN; i <= maxN; i++) { HashMap<String, Integer> counts = GetNgramCounts(i, examples, padding); int total = 0; for (int v : counts.values()) { total += v; } for (String key : counts.keySet()) { int value = counts.get(key); result.put(key, ((double) value) / total); } } return result; }
From source file:org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil.java
/** * Given a list of directories, assert that any files that are named * the same thing have the same contents. For example, if a file * named "fsimage_1" shows up in more than one directory, then it must * be the same.//w w w .j a v a 2 s . c o m * @throws Exception */ public static void assertParallelFilesAreIdentical(List<File> dirs, Set<String> ignoredFileNames) throws Exception { HashMap<String, List<File>> groupedByName = new HashMap<String, List<File>>(); for (File dir : dirs) { for (File f : dir.listFiles()) { if (ignoredFileNames.contains(f.getName())) { continue; } List<File> fileList = groupedByName.get(f.getName()); if (fileList == null) { fileList = new ArrayList<File>(); groupedByName.put(f.getName(), fileList); } fileList.add(f); } } for (List<File> sameNameList : groupedByName.values()) { if (sameNameList.get(0).isDirectory()) { // recurse assertParallelFilesAreIdentical(sameNameList, ignoredFileNames); } else { if ("VERSION".equals(sameNameList.get(0).getName())) { assertPropertiesFilesSame(sameNameList.toArray(new File[0])); } else { assertFileContentsSame(sameNameList.toArray(new File[0])); } } } }
From source file:com.eternitywall.ots.OtsCli.java
private static void multistamp(List<String> argsFiles, List<String> calendarsUrl, Integer m, String signatureFile, String algorithm) { // Parse input privateUrls HashMap<String, String> privateUrls = new HashMap<>(); if (signatureFile != null && signatureFile != "") { try {//from w ww . jav a 2 s . c om privateUrls = readSignature(signatureFile); } catch (Exception e) { log.severe("No valid signature file"); return; } } // Make list of detached files HashMap<String, DetachedTimestampFile> mapFiles = new HashMap<>(); for (String argsFile : argsFiles) { try { File file = new File(argsFile); Hash hash = Hash.from(file, Hash.getOp(algorithm)._TAG()); mapFiles.put(argsFile, DetachedTimestampFile.from(hash)); } catch (IOException e) { e.printStackTrace(); log.severe("File read error"); return; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); log.severe("Crypto error"); return; } } // Stamping Timestamp stampResult; try { List<DetachedTimestampFile> detaches = new ArrayList(mapFiles.values()); stampResult = OpenTimestamps.stamp(detaches, calendarsUrl, m, privateUrls); if (stampResult == null) { throw new IOException(); } } catch (IOException e) { e.printStackTrace(); log.severe("Stamp error"); return; } // Generate ots output files for (Map.Entry<String, DetachedTimestampFile> entry : mapFiles.entrySet()) { String argsFile = entry.getKey(); DetachedTimestampFile detached = entry.getValue(); String argsOts = argsFile + ".ots"; try { Path path = Paths.get(argsOts); if (Files.exists(path)) { System.out.println("File '" + argsOts + "' already exist"); } else { Files.write(path, detached.serialize()); System.out.println("The timestamp proof '" + argsOts + "' has been created!"); } } catch (Exception e) { e.printStackTrace(); log.severe("File '" + argsOts + "' writing error"); } } }
From source file:jp.go.nict.langrid.bpel.ProcessAnalyzer.java
/** * /*w w w. j a v a2 s.c o m*/ * */ public static ProcessInfo analyze(BPELServiceInstanceReader reader) throws IOException, MalformedURLException, SAXException, ProcessAnalysisException, URISyntaxException { ProcessInfo pi = new ProcessInfo(); byte[] bpelBody = null; InputStream is = reader.getBpel(); try { bpelBody = StreamUtil.readAsBytes(reader.getBpel()); } finally { is.close(); } int n = reader.getWsdlCount(); byte[][] wsdlBodies = new byte[n][]; for (int i = 0; i < n; i++) { InputStream w = reader.getWsdl(i); try { wsdlBodies[i] = StreamUtil.readAsBytes(w); } finally { w.close(); } } BPEL bpel; try { bpel = analyzeBPEL(bpelBody); } catch (XPathExpressionException e) { throw new ProcessAnalysisException(e); } HashMap<URI, WSDL> wsdls = new HashMap<URI, WSDL>(); for (byte[] wsdlBody : wsdlBodies) { WSDL wsdl = analyzeWsdl(wsdlBody); wsdls.put(wsdl.getTargetNamespace(), wsdl); } try { resolve(bpel, wsdls); } catch (ProcessAnalysisException e) { logger.log(Level.WARNING, "BPEL Resolve error: ", e); StringBuilder b = new StringBuilder(); b.append("service contains...\n"); b.append("bpel: "); b.append(bpel.getFilename()); b.append(" "); b.append(bpel.getTargetNamespace()); b.append("\n"); for (WSDL w : wsdls.values()) { b.append("wsdl: "); b.append(w.getFilename()); b.append(" "); b.append(w.getTargetNamespace()); } logger.warning(b.toString()); throw e; } pi.setBpel(bpel); pi.setWsdls(wsdls); for (PartnerLink pl : bpel.getPartnerLinks()) { String role = pl.getPartnerRole(); if (role == null) continue; WSDL w = wsdls.get(new URI(pl.getPartnerLinkType().getNamespaceURI())); if (w == null) continue; PartnerLinkType plt = w.getPlinks().get(pl.getPartnerLinkType().getLocalPart()); if (plt == null) continue; Role r = plt.getRoles().get(role); if (r == null) continue; pi.getPartnerLinks().put(r.getPortTypeName().getNamespaceURI(), pl); } return pi; }
From source file:com.microsoft.windowsazure.core.tracing.util.JavaTracingInterceptor.java
/** * Enter a method./* w ww .j a v a2 s .co m*/ * * @param invocationId * Method invocation identifier. * @param instance * The instance with the method. * @param method * Name of the method. * @param parameters * Method parameters. */ public void enter(String invocationId, Object instance, String method, HashMap<String, Object> parameters) { ArrayList<Object> valuesList = new ArrayList<Object>(parameters.values()); logger.entering(instance.getClass().getName(), method, valuesList.toArray()); }
From source file:com.jaxio.celerio.output.FileTrackerTest.java
@Test public void deleteGeneratedFiles() throws IOException { File projectDir = new File("target"); HashMap<String, FileMetaData> generatedFiles = newHashMap(); File f1 = createFileWithContent(projectDir, "f1.txt", "my content"); File f2 = createFileWithContent(projectDir, "f2.txt", "my content2"); assertThat(f1.exists()).isTrue();/*from w w w . ja v a2s. c om*/ ; assertThat(f2.exists()).isTrue(); generatedFiles.put("f1.txt", new FileMetaData(null, null, "f1.txt", f1)); generatedFiles.put("f2.txt", new FileMetaData(null, null, "f2.txt", f2)); fileTracker.saveToProjectDir(generatedFiles, projectDir); HashMap<String, FileMetaData> loadedGeneratedFiles = fileTracker.loadFromProjectDir(projectDir); assertThat(loadedGeneratedFiles.values()).contains(new FileMetaData(null, null, "f1.txt", f1)); assertThat(loadedGeneratedFiles.values()).contains(new FileMetaData(null, null, "f2.txt", f2)); fileTracker.deleteGeneratedFileIfIdentical(projectDir, new ArrayList<String>()); HashMap<String, FileMetaData> loadedGeneratedFilesAfterDelete = fileTracker.loadFromProjectDir(projectDir); assertThat(loadedGeneratedFilesAfterDelete.values()).isEmpty(); }
From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java
/** * This is used in the generation process. * @param topK number of candidates to return * @param word1// www. j a va 2 s . c o m * @param maxSubstringLength * @param probMap a hashmap for productions, same as probs, but with no weights * @param probs * @param memoizationTable * @param pruneToSize * @return */ public static TopList<Double, String> Predict2(int topK, String word1, int maxSubstringLength, Map<String, HashSet<String>> probMap, HashMap<Production, Double> probs, HashMap<String, HashMap<String, Double>> memoizationTable, int pruneToSize) { TopList<Double, String> result = new TopList<>(topK); // calls a helper function HashMap<String, Double> rProbs = Predict2(word1, maxSubstringLength, probMap, probs, memoizationTable, pruneToSize); double probSum = 0; // gathers the total probability for normalization. for (double prob : rProbs.values()) probSum += prob; // this normalizes each value by the total prob. for (String key : rProbs.keySet()) { Double value = rProbs.get(key); result.add(new Pair<>(value / probSum, key)); } return result; }
From source file:afest.datastructures.tree.decision.erts.informationfunctions.GeneralizedNormalizedShannonEntropy.java
/** * Return the entropy of a given set of classes. * @param counts number of elements in each class. * @param size total number of elements. (denominator of the probability) * @return the entropy of a given set of classes. *//*from w w w . j a v a2 s. c o m*/ protected double getEntropy(HashMap<?, Integer> counts, int size) { double dSize = (double) size; double h = 0; for (Integer count : counts.values()) { double prob = count / dSize; h -= prob * MathUtils.log(2, prob); } return h; }