List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:edu.uci.ics.sourcerer.tools.java.component.identifier.internal.ClusterIdentifier.java
public static ClusterCollection identifyFullyMatchingClusters(JarCollection jars) { TaskProgressLogger task = TaskProgressLogger.get(); task.start("Identifying fully matching clusters in " + jars.size() + " jar files"); Multimap<VersionedFqnNode, Cluster> clusterMap = ArrayListMultimap.create(); // Explore the tree in post-order for (VersionedFqnNode parent : jars.getRoot().getPostOrderIterable()) { // If it's a leaf, then it starts out as a trivial cluster if (!parent.hasChildren()) { clusterMap.put(parent, Cluster.create(parent)); }/*from w ww. j a v a 2 s. c om*/ // If it has children, see what children always co-occur else { // Check if the node itself should be a cluster if (parent.getJars().size() > 0) { clusterMap.put(parent, Cluster.create(parent)); } for (VersionedFqnNode child : parent.getChildren()) { // Match the clusters from the children with the current clusters for this node for (Cluster childCluster : clusterMap.get(child)) { Cluster match = null; // Which clusters have already been found for this fragment? for (Cluster parentCluster : clusterMap.get(parent)) { if (areFullyCompatible(childCluster, parentCluster)) { // We found a match! match = parentCluster; // There can be only one, so break break; } } // If we found a match, merge if (match != null) { match.mergeCore(childCluster); } // Otherwise, promote the cluster else { clusterMap.put(parent, childCluster); } } clusterMap.removeAll(child); } } } ClusterCollection clusters = ClusterCollection.create(clusterMap.get(jars.getRoot())); task.report("Identified " + clusters.size() + " fully matching clusters"); task.finish(); return clusters; }
From source file:com.ardor3d.util.TextureManager.java
private static void handleTextureDelete(final Renderer deleter, final Multimap<Object, Integer> idMap, final Map<Object, Future<Void>> futureStore) { Object currentGLRef = null;// w w w .ja v a2 s . c om // Grab the current context, if any. if (deleter != null && ContextManager.getCurrentContext() != null) { currentGLRef = ContextManager.getCurrentContext().getGlContextRep(); } // For each affected context... for (final Object glref : idMap.keySet()) { // If we have a deleter and the context is current, immediately delete if (currentGLRef != null && (!Constants.useMultipleContexts || glref.equals(currentGLRef))) { deleter.deleteTextureIds(idMap.get(glref)); } // Otherwise, add a delete request to that context's render task queue. else { final Future<Void> future = GameTaskQueueManager.getManager(ContextManager.getContextForRef(glref)) .render(new RendererCallable<Void>() { public Void call() throws Exception { getRenderer().deleteTextureIds(idMap.get(glref)); return null; } }); if (futureStore != null) { futureStore.put(glref, future); } } } }
From source file:edu.ucsb.eucalyptus.cloud.ws.SystemState.java
private static synchronized void checkNetworks() { Multimap<String, VmInstance> userVms = Multimaps.newArrayListMultimap(); for (VmInstance v : VmInstances.getInstance().listValues()) userVms.put(v.getOwnerId(), v);/*from w w w . j ava 2s . co m*/ NavigableSet<NetworkToken> revokedTokens = Sets.newTreeSet(); for (Network activeNet : Networks.getInstance().listValues()) { String user = activeNet.getUserName(); LOG.debug(String.format("checkNetworks: user=%-15s network=%-15s", user, activeNet.getNetworkName())); Multimap<String, String> clusterNetworkMap = Multimaps.newArrayListMultimap(); for (VmInstance vm : userVms.get(user)) { clusterNetworkMap.get(vm.getPlacement()).addAll(vm.getNetworkNames()); } for (NetworkToken token : activeNet.getNetworkTokens().values()) { if (!clusterNetworkMap.get(token.getCluster()).contains(token.getNetworkName())) { LOG.debug(String.format("checkNetworks: user=%-15s network=%-15s cluster=%-15s active=false", user, activeNet.getNetworkName(), token.getCluster())); revokedTokens.add(token); } else { LOG.debug(String.format("checkNetworks: user=%-15s network=%-15s cluster=%-15s active=true", user, activeNet.getNetworkName(), token.getCluster())); } } if (activeNet.getNetworkTokens().isEmpty()) Networks.getInstance().deregister(activeNet.getName()); } for (NetworkToken token : revokedTokens) SystemState.dispatchStopNetwork(token); }
From source file:org.crypto.sse.TSet.java
public static int setup(byte[] key1, byte[] key2, byte[] keyENC, String[] listOfKeyword, Multimap<String, String> lookup, Multimap<String, String> encryptedIdToRealId) throws InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, IOException { int globalCounter = 0; for (String word : listOfKeyword) { // Computation of the keyword tag byte[] tag1 = CryptoPrimitives.generateCmac(key1, word); byte[] tag2 = CryptoPrimitives.generateCmac(key2, word); // Extraction of all documents identifiers associated to the word Collection<String> documents = lookup.get(word); int counter = 0; // initialize beta to be equal to zero int beta = 1; for (String id : documents) { // Compute the hash of the tag alongside with the counter byte[] hmac = CryptoPrimitives.concat( CryptoPrimitives.generateHmac512(keyHMACSI, Integer.toString(CryptoPrimitives.getIntFromByte( CryptoPrimitives.generateCmac(tag1, Integer.toString(counter)), 128))), CryptoPrimitives//from w ww .ja v a 2 s . com .generateHmac512(keyHMACSI, Integer.toString(CryptoPrimitives.getIntFromByte( CryptoPrimitives.generateCmac(tag2, Integer.toString(counter)), 128)))); // Determine the needed number of bytes for the bucket // Divide the result of the hash in three different values int numberOfBytes = (int) Math.ceil((Math.log(bucketSize) / (Math.log(2) * 8))); byte[] bucket = new byte[numberOfBytes]; byte[] labelAndValue = new byte[securityParameter + valueSize]; System.arraycopy(hmac, 0, bucket, 0, bucket.length); System.arraycopy(hmac, bucket.length, labelAndValue, 0, labelAndValue.length); if (free.get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))) .isEmpty()) { Printer.normalln("Sub-Buckets are not big enough ==> re-do the process with a new key"); System.exit(0); } // generate the integer which is associated to free[b] byte[] randomBytes = CryptoPrimitives .randomBytes((int) Math.ceil((Math .log(free.get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))).size()) / (Math.log(2) * 8)))); int position = CryptoPrimitives .getIntFromByte(randomBytes, (int) Math.ceil(Math .log(free.get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))).size()) / Math.log(2))); while (position >= free .get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))) .size()) { position = position / 2; } int valueOfSubBucket = free .get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))) .get(position); free.get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))) .remove(position); // The last document if (counter == documents.size() - 1) { beta = 0; } byte[] label = new byte[securityParameter]; byte[] value = new byte[valueSize]; System.arraycopy(labelAndValue, 0, label, 0, label.length); System.arraycopy(labelAndValue, label.length, value, 0, value.length); secureIndex .get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))) .get(valueOfSubBucket).setLabel(label); // Computation of masked value Iterator<String> itr = encryptedIdToRealId.get(id).iterator(); byte[] identifierBytes = CryptoPrimitives.encryptAES_CTR_String(keyENC, CryptoPrimitives.randomBytes(16), itr.next(), 60); byte[] identifierBF = new byte[10]; String idBF = Integer.toString(globalCounter); while (idBF.length() < 10) { idBF = "0" + idBF; } for (int h = 0; h < 10; h++) { identifierBF[h] = (byte) idBF.charAt(h); } byte[] betaByte = { (byte) beta }; byte[] concatenation = CryptoPrimitives.concat(betaByte, identifierBytes); concatenation = CryptoPrimitives.concat(concatenation, identifierBF); int k = 0; for (byte b : value) { value[k] = (byte) (b ^ concatenation[k++]); } secureIndex .get(CryptoPrimitives.getIntFromByte(bucket, (int) (Math.log(bucketSize) / (Math.log(2))))) .get(valueOfSubBucket).setValue(value); counter++; globalCounter++; } } return 1; }
From source file:de.csenk.gwt.commons.bean.rebind.observe.ObservableBeanModel.java
/** * @param logger /* w w w. ja v a 2s .c o m*/ * @param methods * @param typeOracle * @return * @throws UnableToCompleteException */ private static Map<String, ObservableBeanPropertyModel> modelProperties(TreeLogger logger, Set<ObservableBeanMethodModel> methods, TypeOracle typeOracle) throws UnableToCompleteException { final Multimap<String, ObservableBeanMethodModel> associatedMethods = LinkedListMultimap.create(); for (ObservableBeanMethodModel methodModel : methods) { final JBeanMethod action = methodModel.getAction(); if (action != JBeanMethod.SET && action != JBeanMethod.GET) continue; final String propertyName = action.inferName(methodModel.getMethod()); associatedMethods.put(propertyName, methodModel); } final Map<String, ObservableBeanPropertyModel> properties = Maps.newHashMap(); for (String propertyName : associatedMethods.keySet()) { if (properties.containsKey(propertyName)) die(logger, "Multiple getters/setters for property %s. Check spelling and for correct camel case.", propertyName); final ObservableBeanMethodModel[] propertyAccessors = Iterables .toArray(associatedMethods.get(propertyName), ObservableBeanMethodModel.class); final JType propertyType = determinePropertyType(propertyAccessors[0], typeOracle); properties.put(propertyName, ObservableBeanPropertyModel.create(propertyName, propertyType, propertyAccessors)); } return ImmutableMap.copyOf(properties); }
From source file:org.sonar.plugins.core.notifications.reviews.ChangesInReviewAssignedToMeOrCreatedByMe.java
private void addUserToContextIfSubscribed(Context context, String user, Multimap<String, NotificationChannel> subscribedRecipients) { Collection<NotificationChannel> channels = subscribedRecipients.get(user); for (NotificationChannel channel : channels) { context.addUser(user, channel);// www . j ava 2s . c o m } }
From source file:nl.knaw.huygens.alexandria.dropwizard.cli.commands.CheckOutCommand.java
private void checkDirectoryHasNoUnCommittedChanges() throws IOException { Multimap<FileStatus, String> fileStatus = readWorkDirStatus(readContext()); Collection<String> changedFiles = fileStatus.get(FileStatus.changed); Collection<String> deletedFiles = fileStatus.get(FileStatus.deleted); if (!(changedFiles.isEmpty() && deletedFiles.isEmpty())) { showChanges(fileStatus);// w w w. jav a2 s. c om String message = "Uncommitted changes found, cannot checkout another view."; throw new AlexandriaCommandException(message); } }
From source file:uk.ac.ebi.atlas.web.controllers.rest.GeneNameTooltipController.java
String buildSynonyms(Multimap<String, String> multimap) { String synonyms = format(multimap.get("synonym"), false, NUMBER_OF_TERMS_TO_SHOW); List<String> synonymsList = Lists.newArrayList(synonyms); return Joiner.on(" ").join(synonymsList); }
From source file:org.crypto.sse.DynRH.java
public static TreeMultimap<String, byte[]> tokenUpdate(byte[] key, Multimap<String, String> lookup) throws InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, IOException { // We use a lexicographic sorted list such that the server // will not know any information of the inserted elements creation order TreeMultimap<String, byte[]> tokenUp = TreeMultimap.create(Ordering.natural(), Ordering.usingToString()); // Key generation SecureRandom random = new SecureRandom(); random.setSeed(CryptoPrimitives.randomSeed(16)); byte[] iv = new byte[16]; for (String word : lookup.keySet()) { byte[] key1 = CryptoPrimitives.generateCmac(key, 1 + new String()); byte[] key2 = CryptoPrimitives.generateCmac(key, 2 + word); for (String id : lookup.get(word)) { random.nextBytes(iv);// w ww .j a va 2 s . com int counter = 0; if (state.get(word) != null) { counter = state.get(word); } state.put(word, counter + 1); byte[] l = CryptoPrimitives.generateCmac(key2, "" + counter); byte[] value = CryptoPrimitives.encryptAES_CTR_String(key1, iv, id, sizeOfFileIdentifer); tokenUp.put(new String(l), value); } } return tokenUp; }
From source file:adwords.axis.v201506.migration.MigrateToExtensionSettings.java
/** * Gets the site links from a feed.//w ww .ja v a2 s .com * * @return a map of feed item ID to SiteLinkFromFeed */ private static Map<Long, SiteLinkFromFeed> getSiteLinksFromFeed(AdWordsServices adWordsServices, AdWordsSession session, Feed feed) throws Exception { // Retrieve the feed's attribute mapping. Multimap<Long, Integer> feedMappings = getFeedMapping(adWordsServices, session, feed, PLACEHOLDER_SITELINKS); Map<Long, SiteLinkFromFeed> feedItems = Maps.newHashMap(); for (FeedItem feedItem : getFeedItems(adWordsServices, session, feed)) { SiteLinkFromFeed siteLinkFromFeed = new SiteLinkFromFeed(); for (FeedItemAttributeValue attributeValue : feedItem.getAttributeValues()) { // Skip this attribute if it hasn't been mapped to a field. if (!feedMappings.containsKey(attributeValue.getFeedAttributeId())) { continue; } for (Integer fieldId : feedMappings.get(attributeValue.getFeedAttributeId())) { switch (fieldId) { case PLACEHOLDER_FIELD_SITELINK_LINK_TEXT: siteLinkFromFeed.text = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_SITELINK_URL: siteLinkFromFeed.url = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_FINAL_URLS: siteLinkFromFeed.finalUrls = attributeValue.getStringValues(); break; case PLACEHOLDER_FIELD_FINAL_MOBILE_URLS: siteLinkFromFeed.finalMobileUrls = attributeValue.getStringValues(); break; case PLACEHOLDER_FIELD_TRACKING_URL_TEMPLATE: siteLinkFromFeed.trackingUrlTemplate = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_LINE_2_TEXT: siteLinkFromFeed.line2 = attributeValue.getStringValue(); break; case PLACEHOLDER_FIELD_LINE_3_TEXT: siteLinkFromFeed.line3 = attributeValue.getStringValue(); break; default: // Ignore attributes that do not map to a predefined placeholder field. break; } } } siteLinkFromFeed.scheduling = feedItem.getScheduling(); feedItems.put(feedItem.getFeedItemId(), siteLinkFromFeed); } return feedItems; }