Java Code Examples for java.util.Set#iterator()
The following examples show how to use
java.util.Set#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteCaches.java From khan-session with GNU Lesser General Public License v2.1 | 6 votes |
public void testRemoteCache() { RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.58:11422;192.168.0.58:11322", true); RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_REMOTE"); Set<Object> keySet = cache.keySet(); Iterator<Object> i = keySet.iterator(); System.out.println("============= KHAN_SESSION_REMOTE"); while (i.hasNext()) { Object key = i.next(); System.out.println("> key=" + key); Object value = cache.get(key); System.out.println("> value=" + value); System.out.println(""); } System.out.println("============="); }
Example 2
Source File: MapperFactory.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public static Mapper getMapper(String... mappingFiles) { Set<String> mappingSet = new TreeSet(); mappingSet.addAll(Arrays.asList(mappingFiles)); MessageDigest complete = DigestUtils.getMd5Digest(); Iterator i$ = mappingSet.iterator(); while(i$.hasNext()) { String mapping = (String)i$.next(); complete.update(mapping.getBytes()); } String key = new String(Base64.encode(complete.digest())); if (!cache.containsKey(key)) { Map<String, Object> options = new HashMap(); options.put("org.taktik.connector.technical.mapper.configfiles", mappingFiles); try { cache.put(key, helper.getImplementation(options)); } catch (TechnicalConnectorException var6) { throw new IllegalArgumentException(var6); } } return (Mapper)cache.get(key); }
Example 3
Source File: MacAddressCompleter.java From onos with Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); OpenstackNetworkService osNetService = get(OpenstackNetworkService.class); Set<MacAddress> set = osNetService.externalPeerRouters().stream() .map(ExternalPeerRouter::macAddress) .collect(Collectors.toSet()); SortedSet<String> strings = delegate.getStrings(); Iterator<MacAddress> it = set.iterator(); while (it.hasNext()) { strings.add(it.next().toString()); } return delegate.complete(session, commandLine, candidates); }
Example 4
Source File: WaferMapRenderer.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Builds the paintindex by assigning colors based on the number * of unique values: totalvalues/totalcolors. * * @param uniqueValues the set of unique values. */ private void makePositionIndex(Set uniqueValues) { int valuesPerColor = (int) Math.ceil( (double) uniqueValues.size() / this.paintLimit ); int count = 0; // assign a color for each unique value int paint = 0; for (Iterator i = uniqueValues.iterator(); i.hasNext();) { this.paintIndex.put(i.next(), new Integer(paint)); if (++count % valuesPerColor == 0) { paint++; } if (paint > this.paintLimit) { paint = this.paintLimit; } } }
Example 5
Source File: WanSecurity.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Checking for the security wan sites whether they have received keys not * valid to them */ public static void checkKeys(String regionName, String validKeyPrefix) { Region region = RegionHelper.getRegion(regionName); Set keys = region.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { String key = (String)(iterator.next()); if (!key.startsWith(validKeyPrefix)) { throw new TestException("Invalid key found in the cache " + key); } else { Log.getLogWriter().info("Found valid key " + key); } } }
Example 6
Source File: BinanceTradeService.java From zheshiyigeniubidexiangmu with MIT License | 6 votes |
@Override public String placeStopOrder(StopOrder so) throws IOException { TimeInForce tif = TimeInForce.GTC; Set<IOrderFlags> orderFlags = so.getOrderFlags(); Iterator<IOrderFlags> orderFlagsIterator = orderFlags.iterator(); while (orderFlagsIterator.hasNext()) { IOrderFlags orderFlag = orderFlagsIterator.next(); if (orderFlag instanceof TimeInForce) { tif = (TimeInForce) orderFlag; } } OrderType orderType; if (so.getType().equals(Order.OrderType.BID)) { orderType = so.getLimitPrice() == null ? OrderType.TAKE_PROFIT : OrderType.TAKE_PROFIT_LIMIT; } else { orderType = so.getLimitPrice() == null ? OrderType.STOP_LOSS : OrderType.STOP_LOSS_LIMIT; } return placeOrder(orderType, so, so.getLimitPrice(), so.getStopPrice(), tif); }
Example 7
Source File: AssessmentFacadeQueries.java From sakai with Educational Community License v2.0 | 6 votes |
public Set prepareAnswerSet(ItemText newItemText, Set answerSet) { log.debug("new answer size = " + answerSet.size()); HashSet h = new HashSet(); Iterator l = answerSet.iterator(); while (l.hasNext()) { Answer answer = (Answer) l.next(); Answer newAnswer = new Answer(newItemText, answer.getText(), answer .getSequence(), answer.getLabel(), answer.getIsCorrect(), answer.getGrade(), answer.getScore(), answer.getPartialCredit(), answer.getDiscount(), //answer.getCorrectOptionLabels(), null); Set newAnswerFeedbackSet = prepareAnswerFeedbackSet(newAnswer, answer.getAnswerFeedbackSet()); newAnswer.setAnswerFeedbackSet(newAnswerFeedbackSet); h.add(newAnswer); } return h; }
Example 8
Source File: WriteResponse.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
protected void writeErrorMessage(Set<String> channelList, String CHANNEL_PREFIX_STRING) { try { // Allocate a output writer to write the response message into the network socket writerHandle.println("<!DOCTYPE html>"); writerHandle.println("<html>"); writerHandle.println("<head><title>REDIS PUBSUB Channel Data Output Service</title></head>"); writerHandle.println("<body>"); writerHandle.println("<h1>Invalid/No CrisisCode Provided! </h1>"); writerHandle.println("<h2>Can not initiate REDIS channel subscription!</h2>"); writerHandle.println("<p><big>Available active channels: </big></p>"); writerHandle.println("<ul>"); if (channelList != null) { Iterator<String> itr = channelList.iterator(); while (itr.hasNext()) { writerHandle.println("<li>" + itr.next().substring(CHANNEL_PREFIX_STRING.length()) + "</li>"); } } writerHandle.println("</body></html>"); } finally { writerHandle.flush(); writerHandle.close(); // Always close the output writer } }
Example 9
Source File: DataCollectorBase.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private String findMatchingPropertyName( Set names, String suffix ) { Iterator iter = names.iterator() ; while (iter.hasNext()) { String name = (String)(iter.next()) ; if (name.endsWith( suffix )) return name ; } return null ; }
Example 10
Source File: Fault.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public Iterator getAllFaults() { Set allFaults = getAllFaultsSet(); if (allFaults.isEmpty()) { return null; } return allFaults.iterator(); }
Example 11
Source File: TestDeadlockingWorkflows.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void testDeadlockingSpecification() throws YSchemaBuildingException, YSyntaxException, JDOMException, IOException, YStateException, YPersistenceException, YEngineStateException, YQueryException, YDataStateException { URL fileURL = getClass().getResource("DeadlockingSpecification.xml"); File yawlXMLFile = new File(fileURL.getFile()); YSpecification specification = YMarshal. unmarshalSpecifications(StringUtil.fileToString(yawlXMLFile.getAbsolutePath())).get(0); YEngine engine = YEngine.getInstance(); EngineClearer.clear(engine); engine.loadSpecification(specification); _idForTopNet = engine.startCase(specification.getSpecificationID(), null, null, null, null, null, false); YNetRunnerRepository repository = engine.getNetRunnerRepository(); YNetRunner runner = repository.get(_idForTopNet); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } Set items = engine.getAllWorkItems(); assertTrue(items.size() == 1); for (Iterator iterator = items.iterator(); iterator.hasNext();) { YWorkItem item = (YWorkItem) iterator.next(); assertTrue(item.getStatus() == YWorkItemStatus.statusDeadlocked); //System.out.println("TestDeadlockingWorkflows::..." + item.toXML()); } assertTrue(runner.isCompleted()); assertFalse(runner.isAlive()); }
Example 12
Source File: EditStudentSectionsBean.java From sakai with Educational Community License v2.0 | 5 votes |
protected boolean isEnrolledInOtherSection(Set enrolledSections, CourseSection section) { String category = section.getCategory(); for(Iterator iter = enrolledSections.iterator(); iter.hasNext();) { EnrollmentRecord enr = (EnrollmentRecord)iter.next(); if(((CourseSection)enr.getLearningContext()).getCategory().equals(category)) { return true; } } return false; }
Example 13
Source File: Util.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void dumpAddresses(SctpChannel channel, PrintStream printStream) throws IOException { Set<SocketAddress> addrs = channel.getAllLocalAddresses(); printStream.println("Local Addresses: "); for (Iterator<SocketAddress> it = addrs.iterator(); it.hasNext(); ) { InetSocketAddress addr = (InetSocketAddress)it.next(); printStream.println("\t" + addr); } }
Example 14
Source File: QueryBuilder.java From ontopia with Apache License 2.0 | 5 votes |
public void registerJDOSelectDependent(JDOQuery jdoquery, Set varnames) { // NOTE: query result being passed on to basic clauses // FIXME: no need to select those that are not needed elsewhere! Iterator iter = varnames.iterator(); while (iter.hasNext()) { JDOVariable jdovar = new JDOVariable((String)iter.next()); // select variable jdoquery.addSelect(jdovar); } }
Example 15
Source File: CorefSaxParser.java From EventCoreference with Apache License 2.0 | 5 votes |
public void serializeCrossCorpus (String outputFilePath) { try { FileOutputStream fos = new FileOutputStream(outputFilePath); String str =""; str ="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; str += "<co-ref-sets corpus=\""+corpusName+"\""; if (!method.isEmpty()) str += " method=\""+method+"\""; if (!threshold.isEmpty()) str += " threshold=\""+threshold+"\""; str += ">\n"; fos.write(str.getBytes()); Set keySet = corefMap.keySet(); Iterator keys = keySet.iterator(); while (keys.hasNext()) { String key = (String) keys.next(); ArrayList<CoRefSetAgata> coRefSetAgatas = corefMap.get(key); for (int i = 0; i < coRefSetAgatas.size(); i++) { CoRefSetAgata coRefSetAgata = coRefSetAgatas.get(i); str = coRefSetAgata.toString(); fos.write(str.getBytes()); } } str = "</co-ref-sets>\n"; fos.write(str.getBytes()); fos.close(); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
Example 16
Source File: ErrataSetupAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ @Override public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { RequestContext requestContext = new RequestContext(request); User user = requestContext.getCurrentUser(); Long sid = requestContext.getRequiredParam("sid"); RhnSet set = getSetDecl(sid).get(user); ListRhnSetHelper help = new ListRhnSetHelper(this, request, getSetDecl(sid)); help.setListName(LIST_NAME); String parentURL = request.getRequestURI() + "?sid=" + sid; help.setParentUrl(parentURL); help.setWillClearSet(false); help.execute(); if (help.isDispatched()) { if (requestContext.wasDispatched("errata.jsp.apply")) { return applyErrata(mapping, formIn, request, response); } } String showButton = "true"; // Show the "Apply Errata" button only when unapplied errata exist: if (!SystemManager.hasUnscheduledErrata(user, sid)) { showButton = "false"; } Map params = new HashMap(); Set keys = request.getParameterMap().keySet(); for (Iterator i = keys.iterator(); i.hasNext();) { String key = (String) i.next(); params.put(key, request.getParameter(key)); } Server server = SystemManager.lookupByIdAndUser(sid, user); SdcHelper.ssmCheck(request, server.getId(), user); request.setAttribute("showApplyErrata", showButton); request.setAttribute("set", set); request.setAttribute("system", server); request.setAttribute("combo", getComboList(request)); request.setAttribute(SELECTOR, request.getParameter(SELECTOR)); return getStrutsDelegate().forwardParams( mapping.findForward(RhnHelper.DEFAULT_FORWARD), params); }
Example 17
Source File: I18N.java From jease with GNU General Public License v3.0 | 4 votes |
ResourceBundleEnumeration(Set<String> set, Enumeration<String> enumeration) { this.set = set; this.iterator = set.iterator(); this.enumeration = enumeration; }
Example 18
Source File: Captor.java From aion-germany with GNU General Public License v3.0 | 4 votes |
public void openDevice(NetworkInterface ni) { try { if (_packetCaptor != null) { setCaptor(false); _packetCaptor.close(); } _packetCaptor = JpcapCaptor.openDevice(ni,SNAPSHOT_LENGHT,false,10); setCaptor(true); _networkAddress = ni.addresses; PacketSamurai.getUserInterface().log("System [Network] - Successfully opened device ("+ni.description+")."); Set<Integer> ports = Captor.getActiveProtocols().keySet(); Iterator<Integer> i = ports.iterator(); String filter = PacketSamurai.getConfigProperty("filter", "").trim(); if (filter.length() > 0) { PacketSamurai.getUserInterface().log("System [Network] - Sniffing with filter: "+filter); _packetCaptor.setFilter(filter, false); } else if (i.hasNext()) { StringBuilder sb = new StringBuilder("(tcp port"); StringBuilder portsSB = new StringBuilder(); for(; i.hasNext();) { Integer port = i.next(); sb.append(" ").append(port).append(")"); portsSB.append(port); if(i.hasNext()) { portsSB.append(' '); sb.append(" or (tcp port"); } } PacketSamurai.getUserInterface().log("System [Network] - Sniffing with filter: "+sb.toString()); _packetCaptor.setFilter(sb.toString(),false); PacketSamurai.getUserInterface().log("System [Network] - Sniffing on port(s): "+portsSB); } } catch (IOException ioe) { PacketSamurai.getUserInterface().log("System [Network] - ERROR: Failed to open device ("+ni.description+") for capture "+ioe); } }
Example 19
Source File: ExtCodeGen.java From manifold with Apache License 2.0 | 4 votes |
private String addExtensions( SrcClass extendedClass, DiagnosticListener<JavaFileObject> errorHandler ) { boolean methodExtensions = false; boolean interfaceExtensions = false; boolean annotationExtensions = false; Set<String> allExtensions = findAllExtensions(); _model.pushProcessing( _fqn ); try { for( Iterator<String> iterator = allExtensions.iterator(); iterator.hasNext(); ) { String extensionFqn = iterator.next(); //## todo: if fqn (the extension class) is source file, delegate the call to makeSrcClassStub() to the host somehow //## todo: so that IJ can use it's virtual file, otherwise this uses the file on disk, which does not have local changes SrcClass srcExtension = ClassSymbols.instance( getModule() ).makeSrcClassStub( extensionFqn ); // _location ); if( srcExtension != null ) { for( AbstractSrcMethod method: srcExtension.getMethods() ) { addExtensionMethod( method, extendedClass, errorHandler ); methodExtensions = true; } for( SrcType iface: srcExtension.getInterfaces() ) { addExtensionInteface( iface, extendedClass ); interfaceExtensions = true; } for( SrcAnnotationExpression anno: srcExtension.getAnnotations() ) { addExtensionAnnotation( anno, extendedClass ); annotationExtensions = true; } } else { iterator.remove(); } } if( !_existingSource.isEmpty() ) { if( allExtensions.isEmpty() ) { return _existingSource; } return addExtensionsToExistingClass( extendedClass, methodExtensions, interfaceExtensions, annotationExtensions ); } return extendedClass.render( new StringBuilder(), 0 ).toString(); } finally { _model.popProcessing( _fqn ); } }
Example 20
Source File: SimplePrintUtil.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public static int printEntries(Map map, int rowCount, List keyList, String keyColumnName, String valueColumnName, boolean displaySummary, boolean showValues) throws Exception { if (map == null) { System.out.println("Error: Region is null"); return 0; } if (map.size() == 0) { return 0; } // Print keys and values int row = 1; Object key = null; Object value = null; int count = 0; HashSet keyNameSet = new HashSet(); HashSet valueNameSet = new HashSet(); Set nameSet = map.entrySet(); for (Iterator itr = nameSet.iterator(); count < rowCount && itr.hasNext(); count++) { Map.Entry entry = (Map.Entry) itr.next(); key = entry.getKey(); value = entry.getValue(); if (keyList != null) { keyList.add(key); } keyNameSet.add(key.getClass().getName()); if (value != null) { valueNameSet.add(value.getClass().getName()); } printObject(row, keyColumnName, key, true, 2); if (showValues) { printObject(row, valueColumnName, value, false, 2); } System.out.println(); row++; } if (displaySummary) { System.out.println(); System.out.println("Displayed (fetched): " + (row - 1)); System.out.println(" Actual Size: " + map.size()); for (Object keyName : keyNameSet) { System.out.println(" " + keyColumnName + " Class: " + keyName); } for (Object valueName : valueNameSet) { System.out.println(" " + valueColumnName + " Class: " + valueName); } } return row - 1; }