java.util.Iterator Java Examples
The following examples show how to use
java.util.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: Gui2ndChat.java From The-5zig-Mod with MIT License | 6 votes |
/** * finds and deletes a Chat line by ID */ public void deleteChatLine(int id) { Iterator<GuiChatLine> iterator = this.singleChatLines.iterator(); GuiChatLine chatLine; while (iterator.hasNext()) { chatLine = iterator.next(); if (chatLine.getChatLineID() == id) { iterator.remove(); } } iterator = this.chatLines.iterator(); while (iterator.hasNext()) { chatLine = iterator.next(); if (chatLine.getChatLineID() == id) { iterator.remove(); break; } } }
Example #2
Source File: SignatureUtil.java From jeewx-boot with Apache License 2.0 | 6 votes |
/** * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 */ private static String createSign(Map<String, String> paramMap, String key) { StringBuffer sb = new StringBuffer(); SortedMap<String,String> sort=new TreeMap<String,String>(paramMap); Set<Entry<String, String>> es = sort.entrySet(); Iterator<Entry<String, String>> it = es.iterator(); while (it.hasNext()) { @SuppressWarnings("rawtypes") Map.Entry entry = (Map.Entry) it.next(); String k = (String) entry.getKey(); String v = (String) entry.getValue(); if (null != v && !"".equals(v)&& !"null".equals(v) && !"sign".equals(k) && !"key".equals(k)) { sb.append(k + "=" + v + "&"); } } sb.append("key=" + key); LOG.info("HMAC source:{}", new Object[] { sb.toString() } ); String sign = MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase(); LOG.info("HMAC:{}", new Object[] { sign } ); return sign; }
Example #3
Source File: AttestationTopicSubscriber.java From teku with Apache License 2.0 | 6 votes |
@Override public synchronized void onSlot(final UnsignedLong slot) { boolean shouldUpdateENR = false; final Iterator<Entry<Integer, UnsignedLong>> iterator = subnetIdToUnsubscribeSlot.entrySet().iterator(); while (iterator.hasNext()) { final Entry<Integer, UnsignedLong> entry = iterator.next(); if (entry.getValue().compareTo(slot) < 0) { iterator.remove(); int subnetId = entry.getKey(); eth2Network.unsubscribeFromAttestationSubnetId(subnetId); if (persistentSubnetIdSet.contains(subnetId)) { persistentSubnetIdSet.remove(subnetId); shouldUpdateENR = true; } } } if (shouldUpdateENR) { eth2Network.setLongTermAttestationSubnetSubscriptions(persistentSubnetIdSet); } }
Example #4
Source File: ConfigValidatorImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private boolean validate() { this.unfoundProps = new Object[0]; Iterator i$ = this.expectedProps.iterator(); while(i$.hasNext()) { String prop = (String)i$.next(); boolean validProp = this.config.containsKey(prop); boolean validMatchProp = this.config.containsKey(prop + ".1"); if (validProp || validMatchProp) { validProp = true; } if (!validProp) { LOG.warn("Could not find property:" + prop); this.unfoundProps = ArrayUtils.add(this.unfoundProps, prop); } } return ArrayUtils.isEmpty(this.unfoundProps); }
Example #5
Source File: CopyOnWriteStateMapSnapshot.java From flink with Apache License 2.0 | 6 votes |
@Override Iterator<CopyOnWriteStateMap.StateMapEntry<K, N, S>> getEntryIterator( final CopyOnWriteStateMap.StateMapEntry<K, N, S> stateMapEntry) { return new Iterator<CopyOnWriteStateMap.StateMapEntry<K, N, S>>() { CopyOnWriteStateMap.StateMapEntry<K, N, S> nextEntry = stateMapEntry; @Override public boolean hasNext() { return nextEntry != null; } @Override public CopyOnWriteStateMap.StateMapEntry<K, N, S> next() { if (nextEntry == null) { throw new NoSuchElementException(); } CopyOnWriteStateMap.StateMapEntry<K, N, S> entry = nextEntry; nextEntry = nextEntry.next; return entry; } }; }
Example #6
Source File: Internalizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private NodeList getWSDLDefintionNode(Node bindings, Node target) { return evaluateXPathMultiNode(bindings, target, "wsdl:definitions", new NamespaceContext() { @Override public String getNamespaceURI(String prefix) { return "http://schemas.xmlsoap.org/wsdl/"; } @Override public String getPrefix(String nsURI) { throw new UnsupportedOperationException(); } @Override public Iterator getPrefixes(String namespaceURI) { throw new UnsupportedOperationException(); } }); }
Example #7
Source File: CassandraTable.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public Number queryNumber(CassandraSessionPool.Session session, Query query) { Aggregate aggregate = query.aggregateNotNull(); Iterator<Number> results = this.query(query, statement -> { // Set request timeout to a large value int timeout = session.aggregateTimeout(); statement.setReadTimeoutMillis(timeout * 1000); return session.query(statement); }, (q, rs) -> { Row row = rs.one(); if (row == null) { return IteratorUtils.of(aggregate.defaultValue()); } return IteratorUtils.of(row.getLong(0)); }); return aggregate.reduce(results); }
Example #8
Source File: RtPlugins.java From docker-java-api with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Iterator<PluginPrivilege> privileges(final String remote) throws IOException, UnexpectedResponseException { final UncheckedUriBuilder uri = new UncheckedUriBuilder( this.baseUri.toString().concat("/privileges") ).addParameter("remote", remote); return new ResourcesIterator<>( this.client, new HttpGet( uri.build() ), PluginPrivilege::new ); }
Example #9
Source File: SamRecordSortingIteratorFactory.java From Drop-seq with MIT License | 6 votes |
/** * @param progressLogger pass null if not interested in progress. * @return An iterator with all the records from underlyingIterator, in order defined by comparator. */ public static CloseableIterator<SAMRecord> create(final SAMFileHeader header, final Iterator<SAMRecord> underlyingIterator, final Comparator<SAMRecord> comparator, final ProgressLogger progressLogger) { final SortingIteratorFactory.ProgressCallback<SAMRecord> progressCallback; if (progressLogger != null) progressCallback = new SortingIteratorFactory.ProgressCallback<SAMRecord>() { @Override public void logProgress(final SAMRecord record) { progressLogger.record(record); } }; else progressCallback = null; return SortingIteratorFactory.create(SAMRecord.class, underlyingIterator, comparator, new BAMRecordCodec(header), SAMFileWriterImpl.getDefaultMaxRecordsInRam(), progressCallback); }
Example #10
Source File: CodecUtils.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 树状恢复 * @param prefix 前缀 * @param sourceMap 原始map * @param dstMap 目标map * @param remove 命中遍历后是否删除 */ public static void treeCopyTo(String prefix, Map<String, String> sourceMap, Map<String, String> dstMap, boolean remove) { Iterator<Map.Entry<String, String>> it = sourceMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); if (entry.getKey().startsWith(prefix)) { dstMap.put(entry.getKey().substring(prefix.length()), entry.getValue()); if (remove) { it.remove(); } } } }
Example #11
Source File: UtilAll.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public static String jstack(Map<Thread, StackTraceElement[]> map) { StringBuilder result = new StringBuilder(); try { Iterator<Map.Entry<Thread, StackTraceElement[]>> ite = map.entrySet().iterator(); while (ite.hasNext()) { Map.Entry<Thread, StackTraceElement[]> entry = ite.next(); StackTraceElement[] elements = entry.getValue(); Thread thread = entry.getKey(); if (elements != null && elements.length > 0) { String threadName = entry.getKey().getName(); result.append(String.format("%-40sTID: %d STATE: %s%n", threadName, thread.getId(), thread.getState())); for (StackTraceElement el : elements) { result.append(String.format("%-40s%s%n", threadName, el.toString())); } result.append("\n"); } } } catch (Throwable e) { result.append(RemotingHelper.exceptionSimpleDesc(e)); } return result.toString(); }
Example #12
Source File: SoftwareHandlerTest.java From uyuni with GNU General Public License v2.0 | 6 votes |
public void testSetSoftwareList() throws Exception { KickstartData ksProfile = KickstartDataTest.createKickstartWithProfile(admin); List<String> packages = new ArrayList<String>(); packages.add("gcc"); int result = handler.setSoftwareList(admin, ksProfile.getLabel(), packages); boolean pkgFound = false; for (Iterator<KickstartPackage> itr = ksProfile.getKsPackages().iterator(); itr.hasNext();) { KickstartPackage pkg = itr.next(); if (pkg.getPackageName().getName().equals("gcc")) { pkgFound = true; } } assertEquals(1, result); assertEquals(ksProfile.getKsPackages().size(), 1); assertEquals(pkgFound, true); }
Example #13
Source File: DefaultMQAdminExtImpl.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Override public Set<String> getTopicClusterList( final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException { Set<String> clusterSet = new HashSet<String>(); ClusterInfo clusterInfo = examineBrokerClusterInfo(); TopicRouteData topicRouteData = examineTopicRouteInfo(topic); BrokerData brokerData = topicRouteData.getBrokerDatas().get(0); String brokerName = brokerData.getBrokerName(); Iterator<Map.Entry<String, Set<String>>> it = clusterInfo.getClusterAddrTable().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Set<String>> next = it.next(); if (next.getValue().contains(brokerName)) { clusterSet.add(next.getKey()); } } return clusterSet; }
Example #14
Source File: FormData.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
/** * @param name the name of the field to check * @return true if the name exists */ @JsxFunction({CHROME, FF}) public boolean has(final String name) { if (StringUtils.isEmpty(name)) { return false; } final Iterator<NameValuePair> iter = requestParameters_.iterator(); while (iter.hasNext()) { final NameValuePair pair = iter.next(); if (name.equals(pair.getName())) { return true; } } return false; }
Example #15
Source File: AccountSSOSql.java From jivejdon with Apache License 2.0 | 6 votes |
public String getRoleNameFByusername(String username) { logger.debug("enter getAccountByName for username=" + username); String SQL = "SELECT RL.name, 'Roles' FROM role as RL, user as U , users_roles as RU WHERE U.userid = RU.userid and RU.roleid = RL.roleid and U.name = ?"; //String SQL = "SELECT name FROM role where roleid=(SELECT roleid FROM users_roles WHERE userid = ( SELECT userId FROM user WHERE name=? ) )"; List queryParams = new ArrayList(); queryParams.add(username); String roleName = null; try { List list = jdbcTempSSOSource.getJdbcTemp().queryMultiObject(queryParams, SQL); Iterator iter = list.iterator(); if (iter.hasNext()) { logger.debug("found the role"); Map map = (Map) iter.next(); roleName = ((String) map.get("name")).trim(); } } catch (Exception se) { logger.error(username + " error:" + se); } return roleName; }
Example #16
Source File: Parser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void markEval(final LexicalContext lc) { final Iterator<FunctionNode> iter = lc.getFunctions(); boolean flaggedCurrentFn = false; while (iter.hasNext()) { final FunctionNode fn = iter.next(); if (!flaggedCurrentFn) { lc.setFlag(fn, FunctionNode.HAS_EVAL); flaggedCurrentFn = true; } else { lc.setFlag(fn, FunctionNode.HAS_NESTED_EVAL); } // NOTE: it is crucial to mark the body of the outer function as needing scope even when we skip // parsing a nested function. functionBody() contains code to compensate for the lack of invoking // this method when the parser skips a nested function. lc.setBlockNeedsScope(lc.getFunctionBody(fn)); } }
Example #17
Source File: StorageCli.java From waltz with Apache License 2.0 | 6 votes |
private Map<Integer, PartitionInfoSnapshot> getPartitionInfo(String metricsJson) throws IOException { JsonNode metricsNode = mapper.readTree(metricsJson).path("gauges"); Map<Integer, PartitionInfoSnapshot> partitionInfo = new HashMap<>(); if (metricsNode.path(STORAGE_PARTITION_METRIC_KEY) != null) { JsonNode partitionIds = metricsNode.path(STORAGE_PARTITION_METRIC_KEY).path("value"); Iterator<JsonNode> element = partitionIds.elements(); while (element.hasNext()) { Integer id = element.next().asInt(); PartitionInfoSnapshot partitionInfoSnapshot = new PartitionInfoSnapshot( id, metricsNode.path("waltz-storage.partition-" + id + ".session-id").path("value").asInt(), metricsNode.path("waltz-storage.partition-" + id + ".low-water-mark").path("value").asInt(), metricsNode.path("waltz-storage.partition-" + id + ".local-low-water-mark").path("value").asInt(), metricsNode.path("waltz-storage.partition-" + id + ".flags").path("value").asInt() ); partitionInfo.put(id, partitionInfoSnapshot); } } return partitionInfo; }
Example #18
Source File: DataCollectorBase.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private void findPropertiesByPrefix( Set prefixes, Iterator propertyNames, PropertyCallback getProperty ) { while (propertyNames.hasNext()) { String name = (String)(propertyNames.next()) ; Iterator iter = prefixes.iterator() ; while (iter.hasNext()) { String prefix = (String)(iter.next()) ; if (name.startsWith( prefix )) { String value = getProperty.get( name ) ; // Note: do a put even if value is null since just // the presence of the property may be significant. setProperty( name, value ) ; } } } }
Example #19
Source File: BaseNotificationParser.java From NewsPushMonitor with Apache License 2.0 | 5 votes |
private void intentToString(StringBuilder b, Intent intent) { boolean first = true; b.append("Intent detials { "); String data = intent.getDataString(); if (data != null) { b.append("dat=").append(data); first = false; } try { Bundle extras = intent.getExtras(); LogWriter.i(TAG, "Intent extras=" + extras); if (extras != null) { RefUtil.callDeclaredMethod(extras, "unparcel", new Class[]{}); if (!first) { b.append(' '); } b.append("extras=").append(extras.toString()); } if (extras != null) { Iterator<String> keyIter = extras.keySet().iterator(); while (keyIter.hasNext()) { String key = keyIter.next(); Object value = extras.get(key); if (value instanceof Intent) { intentToString(b, (Intent) value); } } } } catch (Exception e) { LogWriter.e(TAG, e); } finally { b.append(" }"); } }
Example #20
Source File: HcPartyUtil.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static void addEncryptionReplyToEtkBase64(HcpartyType hcParty, String projectName) throws TechnicalConnectorException { if (projectName != null) { String finalProjectName = determineProjectNameToUse(projectName); String configPrefix = "kmehr." + finalProjectName + "."; String hcPartylist = ConfigFactory.getConfigValidator().getProperty(configPrefix + "hcpartylist"); if (hcPartylist == null) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_CONFIG, new Object[]{configPrefix + "hcpartylist property not found"}); } List<String> elements = Arrays.asList(hcPartylist.split(",")); Iterator i$ = elements.iterator(); while(i$.hasNext()) { String element = (String)i$.next(); String hcpartyPropertyPrefix = configPrefix + element; if (ConfigFactory.getConfigValidator().getBooleanProperty(hcpartyPropertyPrefix + ".id.idencryptionkey", false)) { Id idApplicationBuilder = (new Id()).s(IDHCPARTYschemes.ID_ENCRYPTION_KEY).sv(ConfigFactory.getConfigValidator().getProperty(hcpartyPropertyPrefix + ".id.idencryptionkey.sv")); try { idApplicationBuilder.value(new String(KeyDepotManagerFactory.getKeyDepotManager().getETK(KeyDepotManager.EncryptionTokenType.HOLDER_OF_KEY).getBase64Encoded(), Charset.UTF_8.getName())); } catch (UnsupportedEncodingException var11) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_TECHNICAL, var11, new Object[]{var11.getMessage()}); } hcParty.getIds().add(idApplicationBuilder.build()); } } } }
Example #21
Source File: XmlSignatureBuilder.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static Transforms transforms(List<String> tranformerList, Document doc) throws TransformationException { Transforms baseDocTransform = new Transforms(doc); Iterator i$ = tranformerList.iterator(); while(i$.hasNext()) { String transform = (String)i$.next(); baseDocTransform.addTransform(transform); } return baseDocTransform; }
Example #22
Source File: StAXEventFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Create a new EndElement * @param namespaceUri the uri of the QName of the new StartElement * @param localName the local name of the QName of the new StartElement * @param prefix the prefix of the QName of the new StartElement * @param namespaces an unordered set of objects that implement * Namespace that have gone out of scope, may be null * @return an instance of the requested EndElement */ public EndElement createEndElement(String prefix, String namespaceUri, String localName, Iterator namespaces) { EndElementEvent event = new EndElementEvent(prefix, namespaceUri, localName); if(namespaces!=null){ while(namespaces.hasNext()) event.addNamespace((Namespace)namespaces.next()); } if(location != null)event.setLocation(location); return event; }
Example #23
Source File: ConcurrentSkipListMap.java From JDKSourceCode1.8 with MIT License | 5 votes |
@SuppressWarnings("unchecked") public Iterator<Map.Entry<K1,V1>> iterator() { if (m instanceof ConcurrentSkipListMap) return ((ConcurrentSkipListMap<K1,V1>)m).entryIterator(); else return ((SubMap<K1,V1>)m).entryIterator(); }
Example #24
Source File: TransactionRecover.java From joyqueue with Apache License 2.0 | 5 votes |
protected void doRecover(TransactionStore transactionStore, int storeId) { try { boolean isExpired = false; Iterator<ByteBuffer> readIterator = transactionStore.readIterator(storeId); if (readIterator == null || !readIterator.hasNext()) { isExpired = true; } else { ByteBuffer byteBuffer = readIterator.next(); BrokerPrepare brokerPrepare = Serializer.readBrokerPrepare(byteBuffer); TransactionId transactionId = new TransactionId(brokerPrepare.getTopic(), brokerPrepare.getApp(), brokerPrepare.getTxId(), brokerPrepare.getQueryId(), storeId, brokerPrepare.getSource(), brokerPrepare.getTimeout(), brokerPrepare.getStartTime()); if (transactionId.isExpired(config.getTransactionExpireTime())) { isExpired = true; logger.info("recover transaction is expired, topic: {}, app: {}, txId: {}", brokerPrepare.getTopic(), brokerPrepare.getApp(), brokerPrepare.getTxId()); } else { unCompletedTransactionManager.putTransaction(transactionId); logger.info("recover transaction, topic: {}, app: {}, txId: {}", brokerPrepare.getTopic(), brokerPrepare.getApp(), brokerPrepare.getTxId()); } } if (isExpired) { transactionStore.remove(storeId); } } catch (Exception e) { logger.error("recover transaction exception, store: {}, storeId: {}", transactionStore, storeId, e); } }
Example #25
Source File: UdpProxyServer.java From NetBare with MIT License | 5 votes |
@Override protected void process() throws IOException { int select = mSelector.select(); if (select == 0) { // Wait a short time to let the selector register or interest. SystemClock.sleep(SELECTOR_WAIT_TIME); return; } Set<SelectionKey> selectedKeys = mSelector.selectedKeys(); if (selectedKeys == null) { return; } Iterator<SelectionKey> iterator = selectedKeys.iterator(); while (iterator.hasNext()) { SelectionKey key = iterator.next(); if (key.isValid()) { Object attachment = key.attachment(); if (attachment instanceof NioCallback) { NioCallback callback = (NioCallback) attachment; try { if (key.isReadable()) { callback.onRead(); } else if (key.isWritable()) { callback.onWrite(); } else if (key.isConnectable()) { callback.onConnected(); } } catch (IOException e) { callback.onClosed(); removeTunnel(callback.getTunnel()); } } } iterator.remove(); } }
Example #26
Source File: AbstractReplicatedMap.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public int size() { //todo, implement a counter variable instead //only count active members in this node int counter = 0; Iterator<Map.Entry<K,MapEntry<K,V>>> it = innerMap.entrySet().iterator(); while (it!=null && it.hasNext() ) { Map.Entry<?,?> e = it.next(); if ( e != null ) { MapEntry<K,V> entry = innerMap.get(e.getKey()); if (entry!=null && entry.isActive() && entry.getValue() != null) counter++; } } return counter; }
Example #27
Source File: SortedRangeListTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testIntersectPos() { list.addRange(5,15); list.addRange(38, 52); list.addRange(1234500, 1234999); SortedRangeList other = new SortedRangeList(); other.addRange(8,41); other.addRange(1234567, Integer.MAX_VALUE); SortedRangeList intersection = list.intersect(other); Iterator<Range> it = intersection.getRanges(); assertEquals(new Range(8, 15), it.next()); assertEquals(new Range(38, 41), it.next()); assertEquals(new Range(1234567, 1234999), it.next()); }
Example #28
Source File: Project.java From onedev with MIT License | 5 votes |
public List<RefInfo> getBranchRefInfos() { List<RefInfo> refInfos = getRefInfos(Constants.R_HEADS); for (Iterator<RefInfo> it = refInfos.iterator(); it.hasNext();) { RefInfo refInfo = it.next(); if (refInfo.getRef().getName().equals(GitUtils.branch2ref(getDefaultBranch()))) { it.remove(); refInfos.add(0, refInfo); break; } } return refInfos; }
Example #29
Source File: CommonBuilderImpl.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private void addSsinToCareReceiver(CareReceiverIdType careReceiver, List<IDPATIENT> patientIds) { Iterator i$ = patientIds.iterator(); while(i$.hasNext()) { IDPATIENT idpatient = (IDPATIENT)i$.next(); if (this.itsAFilledPatientId(idpatient)) { careReceiver.setSsin(idpatient.getValue()); } } }
Example #30
Source File: ContextImplHook.java From ZjDroid with Apache License 2.0 | 5 votes |
public String descIntentFilter(IntentFilter intentFilter){ StringBuilder sb = new StringBuilder(); Iterator<String> actions =intentFilter.actionsIterator(); String action = null; while(actions.hasNext()){ action = actions.next(); sb.append(action+","); } return sb.toString(); }