List of usage examples for java.util Map values
Collection<V> values();
From source file:com.splicemachine.derby.impl.sql.actions.index.CsvUtil.java
public static Collection<String> makeUnique(String dirName, String fileName, int[] colNums) { List<String> lines = fileToLines(dirName + fileName, "--"); Map<String, String> unique = new HashMap<>(lines.size()); StringBuilder key = new StringBuilder(); for (String line : lines) { String[] cols = line.split(","); if (cols.length <= max(colNums)) { throw new RuntimeException("Index " + max(colNums) + " is greater than size - " + cols.length); }/*w w w . j av a2 s . c o m*/ key.setLength(0); for (int colNum : colNums) { key.append(cols[colNum]).append("|"); } if (unique.containsKey(key.toString())) { System.out.println("Collision on key: " + key.toString()); } unique.put(key.toString(), line); } return unique.values(); }
From source file:hudson.security.SecurityRealm.java
/** * Picks up the instance of the given type from the spring context. * If there are multiple beans of the same type or if there are none, * this method treats that as an {@link IllegalArgumentException}. * * This method is intended to be used to pick up a Acegi object from * spring once the bean definition file is parsed. *//*www. ja va2 s . c o m*/ public static <T> T findBean(Class<T> type, ApplicationContext context) { Map m = context.getBeansOfType(type); switch (m.size()) { case 0: throw new IllegalArgumentException("No beans of " + type + " are defined"); case 1: return type.cast(m.values().iterator().next()); default: throw new IllegalArgumentException("Multiple beans of " + type + " are defined: " + m); } }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
private static void infoRefs(Repository db) { Map<String, Ref> refs = db.getAllRefs(); System.out.printf("%nAll Refs (%d)%n", refs.size()); Ref head = refs.get(Constants.HEAD); if (head == null) { System.out.println(" HEAD ref is dead and/or non-existent?"); return;//from ww w .j a v a 2 s . c o m } Map<String, Ref> printRefs = new TreeMap<String, Ref>(); String current = head.getLeaf().getName(); if (current.equals(Constants.HEAD)) { printRefs.put("(no branch)", head); } for (Ref ref : RefComparator.sort(refs.values())) { String name = ref.getName(); if (name.startsWith(Constants.R_HEADS) || name.startsWith(Constants.R_REMOTES)) { printRefs.put(name, ref); } } int maxLength = 0; for (String name : printRefs.keySet()) { maxLength = Math.max(maxLength, name.length()); } System.out.printf("Refs (Heads/Remotes) (%d)%n", printRefs.size()); for (Entry<String, Ref> e : printRefs.entrySet()) { Ref ref = e.getValue(); ObjectId objectId = ref.getObjectId(); System.out.printf("%c %-" + maxLength + "s %s%n", (current.equals(ref.getName()) ? '*' : ' '), e.getKey(), objectId.abbreviate(ABBREV_LEN).name()); } }
From source file:com.microsoft.tfs.core.clients.framework.location.internal.LocationCacheManager.java
/** * Convert the specified AccessMapping HashMap to an array of * AccessMappings.//from ww w . ja v a 2 s . c om * * @param accessMappingsMap * The HashMap containing the AccessMappings. * * @return An array containing each AccessMapping value from the map. */ private static AccessMapping[] accessMappingMapToArray(final Map<String, AccessMapping> accessMappingsMap) { final Collection<AccessMapping> values = accessMappingsMap.values(); return values.toArray(new AccessMapping[values.size()]); }
From source file:com.impetus.kundera.persistence.EntityResolver.java
/** * Resolve all reachable entities from entity. * /* ww w .jav a 2s. c o m*/ * @param entity * the entity * @param cascadeType * the cascade type * @param persistenceUnits * the persistence units * @return the all reachable entities */ public static List<EnhancedEntity> resolve(Object entity, CascadeType cascadeType) { Map<String, EnhancedEntity> map = new LinkedHashMap<String, EnhancedEntity>(); try { LOG.debug("Resolving reachable entities for cascade " + cascadeType); recursivelyResolveEntities(entity, cascadeType, map); } catch (PropertyAccessException e) { throw new ReaderResolverException(e); } if (LOG.isDebugEnabled()) { for (Map.Entry<String, EnhancedEntity> entry : map.entrySet()) { LOG.debug( "Entity => " + entry.getKey() + ", ForeignKeys => " + entry.getValue().getForeignKeysMap()); } } return new ArrayList<EnhancedEntity>(map.values()); }
From source file:gov.gtas.svc.util.TargetingResultUtils.java
public static void updateRuleExecutionContext(RuleExecutionContext ctx, RuleServiceResult res) { logger.info("Entering updateRuleExecutionContext()."); ctx.setRuleExecutionStatistics(res.getExecutionStatistics()); final Map<String, TargetSummaryVo> hitSummaryMap = new HashMap<>(); for (RuleHitDetail rhd : res.getResultList()) { String key = rhd.getFlightId() + "/" + rhd.getPassengerId(); TargetSummaryVo hitSummmary = hitSummaryMap.get(key); if (hitSummmary == null) { hitSummmary = new TargetSummaryVo(rhd.getHitType(), rhd.getFlightId(), rhd.getPassengerType(), rhd.getPassengerId(), rhd.getPassengerName()); hitSummaryMap.put(key, hitSummmary); }//ww w . jav a 2 s. c o m hitSummmary.addHitDetail(new TargetDetailVo(rhd.getUdrRuleId(), rhd.getRuleId(), rhd.getHitType(), rhd.getTitle(), rhd.getHitReasons())); } ctx.setTargetingResult(hitSummaryMap.values()); logger.info("Exiting updateRuleExecutionContext()."); }
From source file:gridool.processors.job.GridJobWorker.java
private static void showRemainingTasks(final GridJob<?, ?> job, final Map<String, Pair<GridTask, List<Future<?>>>> taskMap) { final StringBuilder buf = new StringBuilder(256); String jobClassName = ClassUtils.getSimpleClassName(job); buf.append("Start a job inspection... "); buf.append(jobClassName);/*w w w .j a v a2 s . co m*/ buf.append(" ["); buf.append(job.getJobId()); buf.append("] Pending tasks: \n"); final Iterator<Pair<GridTask, List<Future<?>>>> itor = taskMap.values().iterator(); boolean first = true; while (itor.hasNext()) { if (first) { first = false; } else { buf.append(",\n"); } Pair<GridTask, List<Future<?>>> e = itor.next(); GridTask task = e.getFirst(); String taskClassName = ClassUtils.getSimpleClassName(task); buf.append(taskClassName); buf.append('['); String taskId = task.getTaskId(); buf.append(taskId); buf.append(']'); buf.append(" on "); GridNode node = task.getAssignedNode(); String nodeinfo = GridUtils.toHostNameAddrPort(node); buf.append(nodeinfo); } LOG.info(buf.toString()); }
From source file:com.xpn.xwiki.internal.store.hibernate.query.HqlQueryUtils.java
private static boolean isSelectExpressionAllowed(Expression expression, Map<String, String> tables) { if (expression instanceof Column) { Column column = (Column) expression; if (isColumnAllowed(column, tables)) { return true; }/* ww w . ja va 2 s .c om*/ } else if (expression instanceof Function) { Function function = (Function) expression; if (function.isAllColumns()) { // Validate that allowed table is passed to the method // TODO: add support for more that "count" maybe return function.getName().equals("count") && tables.size() == 1 && isTableAllowed(tables.values().iterator().next()); } else { // Validate that allowed columns are used as parameters for (Expression parameter : function.getParameters().getExpressions()) { if (!isSelectExpressionAllowed(parameter, tables)) { return false; } } return true; } } return false; }
From source file:edu.byu.nlp.data.app.AnnotationStream2Annotators.java
public static double[][][] aggregateAnnotatorParameterClusters(double[][][] annotatorParameters, int[] clusterAssignments) { // group clustered parameters Map<Integer, Set<double[][]>> clusterMap = Maps.newHashMap(); for (int i = 0; i < clusterAssignments.length; i++) { int clusterAssignment = clusterAssignments[i]; if (!clusterMap.containsKey(clusterAssignment)) { clusterMap.put(clusterAssignment, Sets.<double[][]>newIdentityHashSet()); }/*from ww w . j av a2 s . c om*/ clusterMap.get(clusterAssignment).add(annotatorParameters[i]); } // aggregate clustered parameters List<double[][]> clusteredAnnotatorParameters = Lists.newArrayList(); for (Set<double[][]> cluster : clusterMap.values()) { double[][][] clusterTensor = cluster.toArray(new double[][][] {}); double[][] averagedConfusions = Matrices.sumOverFirst(clusterTensor); Matrices.divideToSelf(averagedConfusions, cluster.size()); clusteredAnnotatorParameters.add(averagedConfusions); } // re-assign confusions return clusteredAnnotatorParameters.toArray(new double[][][] {}); }
From source file:com.btisystems.pronx.ems.App.java
/** * Load mibs from list of source files./* w w w . j av a2s. co m*/ * * @param group DeviceGroup * @param loader Mib Loader * @param source Mib Source * @param interfaceMap Supported Interfaces * @return */ private static Collection<String> compileMibs(final DeviceGroup group, final MibLoader loader, final MibSource source, final Map<String, JDefinedClass> interfaceMap) { // Get complete package name using group + source. final String packageName = buildPackageName(group.getPackageName(), source.getPackageName()); final List<MibValueSymbol> rootSymbols = locateRootSymbols(loader, source.getRootObjects()); final Map<String, List<MibValueSymbol>> symbolMap = locateChildSymbols(rootSymbols, source.getExcludedRootObjects()); final MibEntityCompiler compiler = new MibEntityCompiler(symbolMap, packageName, interfaceMap, codeModel); compiler.importDependencies(); for (List<MibValueSymbol> symbolList : symbolMap.values()) { final Iterator<MibValueSymbol> iterator = symbolList.iterator(); while (iterator.hasNext()) { final MibValueSymbol symbol = iterator.next(); if (MibEntityCompiler.IMPORTED_SYMBOLS.contains(getOidFromSymbol(symbol))) { LOG.debug("removing common symbol:{}", getOidFromSymbol(symbol)); iterator.remove(); } } } compiler.compile(codeModel); compileNotifications(loader, packageName, source.isGenerateNotificationObjects()); final Map<String, JDefinedClass> classes = compiler.getEntityClasses(); return compiler.generateRootEntity(classes); }