/** * Return a string representation of this object. It should be nicely formated and include the * list of children and ancestor nodes. */ public String toDeepString() { StringBuffer buffer = new StringBuffer(); // write ID writeln(buffer, 0, NLS.bind(Messages.stats_pluginid, descriptor.getSymbolicName())); // write ancestors if (ancestors.size() == 0) { writeln(buffer, 1, Messages.depend_noParentPlugins); } else { writeln(buffer, 1, Messages.depend_requiredBy); for (Iterator i = ancestors.iterator(); i.hasNext(); ) { PluginDependencyGraphNode ancestor = (PluginDependencyGraphNode) i.next(); writeln(buffer, 2, ancestor.getId()); } } // write children if (children.size() == 0) { writeln(buffer, 1, Messages.depend_noChildrenPlugins); } else { writeln(buffer, 1, Messages.depend_requires); for (Iterator i = children.iterator(); i.hasNext(); ) { PluginDependencyGraphNode child = (PluginDependencyGraphNode) i.next(); writeln(buffer, 2, child.getId()); } } return buffer.toString(); }
@SuppressWarnings({"ConstantConditions"}) public Element getState() { if (myBundledDisabledDictionariesPaths.isEmpty() && myDictionaryFoldersPaths.isEmpty() && myDisabledDictionariesPaths.isEmpty()) { return null; } final Element element = new Element(SPELLCHECKER_MANAGER_SETTINGS_TAG); // bundled element.setAttribute( BUNDLED_DICTIONARIES_ATTR_NAME, String.valueOf(myBundledDisabledDictionariesPaths.size())); Iterator<String> iterator = myBundledDisabledDictionariesPaths.iterator(); int i = 0; while (iterator.hasNext()) { element.setAttribute(BUNDLED_DICTIONARY_ATTR_NAME + i, iterator.next()); i++; } // user element.setAttribute(FOLDERS_ATTR_NAME, String.valueOf(myDictionaryFoldersPaths.size())); for (int j = 0; j < myDictionaryFoldersPaths.size(); j++) { element.setAttribute(FOLDER_ATTR_NAME + j, myDictionaryFoldersPaths.get(j)); } element.setAttribute( DICTIONARIES_ATTR_NAME, String.valueOf(myDisabledDictionariesPaths.size())); iterator = myDisabledDictionariesPaths.iterator(); i = 0; while (iterator.hasNext()) { element.setAttribute(DICTIONARY_ATTR_NAME + i, iterator.next()); i++; } return element; }
@Test public void testSearch() throws LdapDAOException { Set<LdapUser> users = this.ldapManager.searchUsers("cstamas"); assertEquals(1, users.size()); LdapUser user = users.iterator().next(); assertEquals("cstamas", user.getUsername()); assertTrue(this.isPasswordsEncrypted() || ("cstamas123".equals(user.getPassword()))); users = this.ldapManager.searchUsers("br"); assertEquals(1, users.size()); user = users.iterator().next(); assertEquals("brianf", user.getUsername()); // assertEquals( "Brian Fox", user.getRealName() ); assertTrue(this.isPasswordsEncrypted() || ("brianf123".equals(user.getPassword()))); users = this.ldapManager.searchUsers("j"); assertEquals(1, users.size()); user = users.iterator().next(); assertEquals("jvanzyl", user.getUsername()); // assertEquals( "Jason Van Zyl", user.getRealName() ); assertTrue(this.isPasswordsEncrypted() || ("jvanzyl123".equals(user.getPassword()))); users = this.ldapManager.searchUsers("INVALID"); assertEquals(0, users.size()); }
@Override public void runStep() throws Throwable { AuthenticationClient client = new AuthenticationClient(serviceURL); Set<QName> profiles = client.getSupportedAuthenticationProfiles(); Iterator<QName> itr = profiles.iterator(); while (itr.hasNext()) { QName profile = itr.next(); if (!this.expectedProfiles.contains(profile)) { throw new Exception( "The profile " + profile.getNamespaceURI() + ":" + profile.getLocalPart() + " is supported by the service but is not in the list of expected profiles."); } } Iterator<QName> itr2 = expectedProfiles.iterator(); while (itr2.hasNext()) { QName profile = itr2.next(); if (!profiles.contains(profile)) { throw new Exception( "The profile " + profile.getNamespaceURI() + ":" + profile.getLocalPart() + " is in the list of expected profiles but is not supported by the service."); } } }
public Set /*<PCNode>*/ matchClass(Pattern simple_name_pattern) { Set this_class = matchSpecific(simple_name_pattern); Set this_class_names = new HashSet(); Iterator tsi = this_class.iterator(); while (tsi.hasNext()) { PCNode pc = (PCNode) tsi.next(); this_class_names.add(pc.name); } Iterator pi = parents.iterator(); while (pi.hasNext()) { PCNode parent = (PCNode) pi.next(); // System.out.println("Parent: "+parent); Set parent_class = parent.matchClass(simple_name_pattern); Iterator osi = parent_class.iterator(); while (osi.hasNext()) { PCNode pc = (PCNode) osi.next(); if (!this_class_names.contains(pc.name)) { this_class.add(pc); } } } if (abc.main.Debug.v().namePatternProcessing) System.out.println(this + ".matchClass " + simple_name_pattern.pattern() + ": " + this_class); return this_class; }
public void testAddUnidirectionalRelation() { DocumentProperties documentProperties3 = MockHelper.createDocument(testTicket, testTicket.getRepositoryId()); try { testDocument3 = repositoryService.createDocument(testTicket, documentProperties3); Relation relation = new Relation(); relation.setBidirectional(false); relation.setDestinationNode(testDocument2); documentProperties3 = testDocument3.dumpProperties(); documentProperties3.addProperty(DocumentProperties.DOCUMENT_ADD_RELATION, relation); Document updatedDocument = repositoryService.updateDocument(testTicket, documentProperties3); Set relations = updatedDocument.getRelations(); assertNotNull(relations); assertTrue(relations.size() == 1); Document relationDoc = (Document) relations.iterator().next(); assertFalse(relation.isBidirectional()); assertEquals(relationDoc.getId(), testDocument2.getId()); Document updatedDocument2 = repositoryService.findDocument(testTicket, testDocument2.getId()); relations = updatedDocument2.getRelations(); assertNotNull(relations); assertTrue(relations.size() == 1); relationDoc = (Document) relations.iterator().next(); assertEquals(relationDoc.getId(), testDocument1.getId()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
// ***** VDMTOOLS START Name=inv_BoardLine KEEP=NO public Boolean inv_BoardLine() { Boolean rexpr_2 = null; Set var2_5 = new HashSet(); var2_5 = new HashSet(); for (int count_8 = 1; count_8 <= 9; count_8++) var2_5.add(new Integer(count_8)); if ((rexpr_2 = Boolean.valueOf(UTIL.Contains(var2_5, y))).booleanValue()) { Boolean var2_11 = null; Boolean var1_12 = null; if ((var1_12 = Boolean.valueOf(new HashSet(line.keySet()).size() == 9)).booleanValue()) { Set var2_21 = new HashSet(); var2_21 = new HashSet(); for (int count_24 = 1; count_24 <= 9; count_24++) var2_21.add(new Integer(count_24)); var1_12 = Boolean.valueOf(UTIL.equals(new HashSet(line.keySet()), var2_21)); } if ((var2_11 = var1_12).booleanValue()) { Boolean var2_27 = null; boolean tmpQuant_29 = true; { Set e1_set_32 = new HashSet(line.values()); Cell c = null; Set tmpSet_40 = new HashSet(e1_set_32); for (Iterator enm_39 = tmpSet_40.iterator(); enm_39.hasNext() && tmpQuant_29; ) { Cell elem_38 = (Cell) enm_39.next(); /* c */ c = elem_38; if (!((c.y).intValue() == y.intValue())) tmpQuant_29 = false; } } if ((var2_27 = Boolean.valueOf(tmpQuant_29)).booleanValue()) { boolean tmpQuant_43 = false; { Set e1_set_46 = new HashSet(line.values()); Cell c1 = null; Cell c2 = null; Set e_set_60 = e1_set_46; Set tmpSet_63 = new HashSet(e_set_60); for (Iterator enm_62 = tmpSet_63.iterator(); enm_62.hasNext() && !tmpQuant_43; ) { Cell elem_61 = (Cell) enm_62.next(); /* c2 */ c2 = elem_61; Set tmpSet_59 = new HashSet(e1_set_46); for (Iterator enm_58 = tmpSet_59.iterator(); enm_58.hasNext() && !tmpQuant_43; ) { Cell elem_57 = (Cell) enm_58.next(); /* c1 */ c1 = elem_57; Boolean pred_47 = null; if ((pred_47 = Boolean.valueOf(!UTIL.equals(c1, c2))).booleanValue()) pred_47 = Boolean.valueOf((c1.x).intValue() == (c2.x).intValue()); if (pred_47.booleanValue()) tmpQuant_43 = true; } } } var2_27 = Boolean.valueOf(!tmpQuant_43); } var2_11 = var2_27; } rexpr_2 = var2_11; } return rexpr_2; }
/** Returns a string describing the entire map */ public String toString() { // If there is nothing to print, let the user know that. if (stateCityMap.isEmpty()) return "The map is empty."; // Otherwise, print out each state, followed // by its corresponding city data. else { String s = "\n"; Set<String> stateNames = stateCityMap.keySet(); // Keys of Map Iterator<String> stateIter = stateNames.iterator(); // Iterator to run through Keys while (stateIter.hasNext()) { String state = stateIter.next(); s += state + ":"; Set<String> cities = stateCityMap.get(state); Iterator<String> cityIter = cities.iterator(); while (cityIter.hasNext()) { String city = cityIter.next(); s += " " + city; } s += "\n"; } return s; } }
public synchronized RemoteFileDesc getBest() throws NoSuchElementException { if (!hasMore()) return null; RemoteFileDesc ret; // try a verified host if (!verifiedHosts.isEmpty()) { LOG.debug("getting a verified host"); ret = (RemoteFileDesc) verifiedHosts.first(); verifiedHosts.remove(ret); } else { LOG.debug("getting a non-verified host"); // use the legacy ranking logic to select a non-verified host Iterator dual = new DualIterator(testedLocations.iterator(), newHosts.iterator()); ret = LegacyRanker.getBest(dual); newHosts.remove(ret); testedLocations.remove(ret); if (ret.needsPush()) { for (Iterator iter = ret.getPushProxies().iterator(); iter.hasNext(); ) pingedHosts.remove(iter.next()); } else pingedHosts.remove(ret); } pingNewHosts(); if (LOG.isDebugEnabled()) LOG.debug("the best host we came up with is " + ret + " " + ret.getPushAddr()); return ret; }
@Override public Map<QName, List<String>> getClaimedAttributes( Subject subject, String appliesTo, String tokenType, Claims claims) { String name = null; Set<Principal> principals = subject.getPrincipals(); if (principals != null) { final Iterator<Principal> iterator = principals.iterator(); while (iterator.hasNext()) { String cnName = principals.iterator().next().getName(); int pos = cnName.indexOf("="); name = cnName.substring(pos + 1); break; } } Map<QName, List<String>> attributes = new HashMap<QName, List<String>>(); addAttribute(attributes, STSAttributeProvider.NAME_IDENTIFIER, name); addAttribute(attributes, "dummy_id1", "test_dummy_attribute1"); addAttribute(attributes, "userid", name); addAttribute(attributes, "dummy_id2", "test_dummy_attribute2"); String tenantId = PropertyLoader.getInstance().load(COMMON_PROPERTIES_PATH).getProperty(TENANT_ID); addAttribute(attributes, TENANT_ID, tenantId); // claims not considered here return attributes; }
/** Eliminate below less frequency n-grams and noise Latin alphabets */ public void omitLessFreq() { if (getName() == null) return; // Illegal int threshold = getNWords()[0] / LESS_FREQ_RATIO; if (threshold < MINIMUM_FREQ) threshold = MINIMUM_FREQ; Set<String> keys = getFreq().keySet(); int roman = 0; for (Iterator<String> i = keys.iterator(); i.hasNext(); ) { String key = i.next(); int count = getFreq().get(key); if (count <= threshold) { getNWords()[key.length() - 1] -= count; i.remove(); } else { if (key.matches("^[A-Za-z]$")) { roman += count; } } } // roman check if (roman < getNWords()[0] / 3) { Set<String> keys2 = getFreq().keySet(); for (Iterator<String> i = keys2.iterator(); i.hasNext(); ) { String key = i.next(); if (key.matches(".*[A-Za-z].*")) { getNWords()[key.length() - 1] -= getFreq().get(key); i.remove(); } } } }
@Override protected void initScope() { for (WeldClass<?> clazz = getWeldAnnotated(); clazz != null; clazz = clazz.getWeldSuperclass()) { Set<Annotation> scopes = new HashSet<Annotation>(); scopes.addAll(clazz.getDeclaredMetaAnnotations(Scope.class)); scopes.addAll(clazz.getDeclaredMetaAnnotations(NormalScope.class)); if (scopes.size() == 1) { if (getWeldAnnotated().isAnnotationPresent(scopes.iterator().next().annotationType())) { this.scope = scopes.iterator().next().annotationType(); log.trace(USING_SCOPE, scope, this); } break; } else if (scopes.size() > 1) { throw new DefinitionException(ONLY_ONE_SCOPE_ALLOWED, getWeldAnnotated()); } } if (this.scope == null) { initScopeFromStereotype(); } if (this.scope == null) { this.scope = Dependent.class; log.trace(USING_DEFAULT_SCOPE, this); } }
private void setConfiguration( Set<String> userNames, Set<String> groupNames, boolean loginShouldSucceed) { HashMap<String, String> configOptions = new HashMap<String, String>(); String userNamesString; { Iterator<String> iter = userNames.iterator(); userNamesString = "" + (iter.hasNext() ? iter.next() : ""); while (iter.hasNext()) { userNamesString += "," + iter.next(); } } String groupNamesString = ""; { Iterator<String> iter = groupNames.iterator(); groupNamesString = "" + (iter.hasNext() ? iter.next() : ""); while (iter.hasNext()) { groupNamesString += "," + iter.next(); } } configOptions.put(StubLoginModule.ALLOW_LOGIN_PROPERTY, loginShouldSucceed ? "true" : "false"); configOptions.put(StubLoginModule.USERS_PROPERTY, userNamesString); configOptions.put(StubLoginModule.GROUPS_PROPERTY, groupNamesString); AppConfigurationEntry configEntry = new AppConfigurationEntry( "org.apache.activemq.security.StubLoginModule", AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, configOptions); StubJaasConfiguration jaasConfig = new StubJaasConfiguration(configEntry); Configuration.setConfiguration(jaasConfig); }
public static void main(String[] args) { Map<String, String> a = new HashMap<String, String>(); a.put("cat", "猫"); a.put("desk", "桌子"); a.put("table", "桌子"); a.put("table", "表格"); System.out.println(a.get("table")); // 遍历表格 Set<String> key = a.keySet(); Iterator<String> it = key.iterator(); while (it.hasNext()) { String s = it.next(); System.out.println(s + "---->" + a.get(s)); } Set<Map.Entry<String, String>> et = a.entrySet(); Iterator<Map.Entry<String, String>> it2 = et.iterator(); while (it2.hasNext()) { Map.Entry en = it2.next(); } Set st = a.entrySet(); Iterator it3 = st.iterator(); while (it3.hasNext()) { Map.Entry en = (Map.Entry) it3.next(); System.out.println(en.getKey() + "+++" + en.getValue()); } }
public String toXML(AMEncryption encryptObj) throws SMSException, SSOException { StringBuffer buff = new StringBuffer(); buff.append(SMSSchema.XML_ENC) .append("\n") .append("<!DOCTYPE ServicesConfiguration\n") .append("PUBLIC \"=//iPlanet//Service Management Services (SMS) 1.0 DTD//EN\"\n") .append("\"jar://com/sun/identity/sm/sms.dtd\">\n\n"); buff.append("<ServicesConfiguration>\n"); Set serviceNames = getServiceNames(); for (Iterator i = serviceNames.iterator(); i.hasNext(); ) { String serviceName = (String) i.next(); Set versions = getServiceVersions(serviceName); for (Iterator j = versions.iterator(); j.hasNext(); ) { String version = (String) j.next(); ServiceSchemaManager ssm = new ServiceSchemaManager(token, serviceName, version); String xml = ssm.toXML(encryptObj); ServiceConfigManager scm = new ServiceConfigManager(serviceName, token); int idx = xml.lastIndexOf("</" + SMSUtils.SERVICE + ">"); xml = xml.substring(0, idx) + scm.toXML(encryptObj) + "</" + SMSUtils.SERVICE + ">"; buff.append(xml).append("\n"); } } buff.append("</ServicesConfiguration>\n"); return buff.toString().replaceAll("&#160;", " "); }
public void printSet(Log logger, Set set) { if (logger != null) { logger.debug("------------------ printing set ---start----------------"); if (set != null) { Iterator it = set.iterator(); while (it.hasNext()) { logger.debug(": " + it.next()); } } else { logger.debug("null"); } logger.debug("------------------ printing set ---end------------------"); } else { System.out.println("------------------ printing set ---start----------------"); if (set != null) { Iterator it = set.iterator(); while (it.hasNext()) { System.out.println(": " + it.next()); } } else { System.out.println("null"); } System.out.println("------------------ printing set ---end------------------"); } }
public void check_DialogueGame_invariant() { Player playerProponent = DialogueGame.this.getProponent(); Set setTurn = playerProponent.getTurn(); // evaluate 'forAll(getNumber()/2=1)': boolean bForAll = true; final Iterator iter = setTurn.iterator(); while (bForAll && iter.hasNext()) { final Turn iter1 = (Turn) iter.next(); int nGetNumber = iter1.getNumber(); float fDivide = nGetNumber / 2; boolean bEquals = fDivide == 1; bForAll = bEquals; } Player playerOpponent = DialogueGame.this.getOpponent(); Set setTurn0 = playerOpponent.getTurn(); // evaluate 'forAll(getNumber()/2=0)': boolean bForAll0 = true; final Iterator iter0 = setTurn0.iterator(); while (bForAll0 && iter0.hasNext()) { final Turn iter1 = (Turn) iter0.next(); int nGetNumber0 = iter1.getNumber(); float fDivide0 = nGetNumber0 / 2; boolean bEquals0 = fDivide0 == 0; bForAll0 = bEquals0; } boolean bAnd = bForAll && bForAll0; if (!bAnd) { System.err.println("invariant 'invariant' failed for object " + DialogueGame.this); } }
public void printHash(Log logger, Map hashMap) { if (logger != null) { logger.debug("------------------ printing set ---start----------------"); if (hashMap != null) { Set entrySet = hashMap.entrySet(); Iterator it = entrySet.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); logger.debug(": <" + entry.getKey() + ", " + entry.getValue() + ">"); } } else { logger.debug("null"); } logger.debug("------------------ printing set ---end------------------"); } else { System.out.println("------------------ printing set ---start----------------"); if (hashMap != null) { Set entrySet = hashMap.entrySet(); Iterator it = entrySet.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); System.out.println(": <" + entry.getKey() + ", " + entry.getValue() + ">"); } } else { System.out.println("null"); } System.out.println("------------------ printing set ---end------------------"); } }
/** * A convenience method for performing KeyValue existence/nonexistence tests. * * @param expectedKeys The expected KeyValue keys. * @param actualKeys The actual KeyValue keys. * @throws Exception */ private void assertRuleTemplateHasExpectedKeyValues( Set<String> expectedKeys, Set<String> actualKeys) throws Exception { // Check to see if all required keys are in the set. for (Iterator<String> iterator = expectedKeys.iterator(); iterator.hasNext(); ) { final String expKey = iterator.next(); assertTrue( "The key label pair with a key of '" + expKey + "' should have been true.", actualKeys.contains(expKey)); actualKeys.remove(expKey); } // If any keys are still in the list, then fail the test because we expected their equivalent // rule template options to // have a non-true value. if (!actualKeys.isEmpty()) { // Construct the error message. final String pluralStr = (actualKeys.size() != 1) ? "s" : ""; final StringBuilder errMsg = new StringBuilder(); errMsg .append("The key label pair") .append(pluralStr) .append(" with the key") .append(pluralStr) .append(" of "); for (Iterator<String> iterator = actualKeys.iterator(); iterator.hasNext(); ) { errMsg.append("'").append(iterator.next()).append(iterator.hasNext() ? "', " : "' "); } errMsg.append("should have been false."); // Fail the test. fail(errMsg.toString()); } }
public void updateTrackedEntities() { ArrayList arraylist = new ArrayList(); Iterator iterator = trackedEntitySet.iterator(); do { if (!iterator.hasNext()) { break; } EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); entitytrackerentry.updatePlayerList(field_72795_a.playerEntities); if (entitytrackerentry.playerEntitiesUpdated && (entitytrackerentry.trackedEntity instanceof EntityPlayerMP)) { arraylist.add((EntityPlayerMP) entitytrackerentry.trackedEntity); } } while (true); for (Iterator iterator1 = arraylist.iterator(); iterator1.hasNext(); ) { EntityPlayerMP entityplayermp = (EntityPlayerMP) iterator1.next(); EntityPlayerMP entityplayermp1 = entityplayermp; Iterator iterator2 = trackedEntitySet.iterator(); while (iterator2.hasNext()) { EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator2.next(); if (entitytrackerentry1.trackedEntity != entityplayermp1) { entitytrackerentry1.updatePlayerEntity(entityplayermp1); } } } }
// ***** VDMTOOLS START Name=BoardLine#2|List|Number KEEP=NO public BoardLine(final List cells, final Number yi) throws CGException { vdm_init_BoardLine(); if (!this.pre_BoardLine(cells, yi).booleanValue()) UTIL.RunTime("Precondition failure in BoardLine"); { final Number atom_1 = yi; Map res_m_8 = new HashMap(); { Set e1_set_13 = new HashSet(cells); Set e_set_14 = new HashSet(); e_set_14 = new HashSet(); for (int count_17 = 1; count_17 <= 9; count_17++) e_set_14.add(new Integer(count_17)); Number x = null; Cell cell = null; Set tmpSet_30 = new HashSet(e_set_14); for (Iterator enm_29 = tmpSet_30.iterator(); enm_29.hasNext(); ) { Number elem_28 = UTIL.NumberToInt(enm_29.next()); /* x */ x = elem_28; Set tmpSet_27 = new HashSet(e1_set_13); for (Iterator enm_26 = tmpSet_27.iterator(); enm_26.hasNext(); ) { Cell elem_25 = (Cell) enm_26.next(); /* cell */ cell = elem_25; if ((cell.x).intValue() == x.intValue()) res_m_8.put(x, cell); } } } final Map atom_2 = res_m_8; y = UTIL.NumberToInt(UTIL.clone(atom_1)); line = (Map) UTIL.clone(atom_2); } }
@Test public void shouldReturnEmptySetWhenPlayerIsPlayingAtOnlyTableAndTableIsExcluded() throws Exception { RandomTableGenerator generator = new RandomTableGenerator(); generator.setGameTypes(gameType); generator.setTemplateNames(toMap(gameType, variation)); generator.setClients(toMap(gameType, clientId)); generator.setFulls(false); generator.setShowInLobbys(true); generator.setAvailableForJoinings(true); generator.setStatii(TableStatus.open); Set<Table> generated = generator.generateTables(1); Table tableWithPlayer = generated.iterator().next(); tableWithPlayer.addPlayerToTable(new PlayerInformation(BigDecimal.TEN)); generated = generator.generateTables(1); Table excludedTable = generated.iterator().next(); excludedTable.setTableId(BigDecimal.valueOf(45)); gigaSpace.writeMultiple(new Table[] {tableWithPlayer, excludedTable}); Collection<TableSearchResult> found = tableSearchService.findTables( BigDecimal.TEN, new TableSearchCriteria( gameType, variation, clientId, Collections.<String>emptySet(), BigDecimal.valueOf(45))); assertEquals(0, found.size()); }
/** Removes all <code>children</code> nodes from the children set. */ public void removeAllChildrenDisplay() { Iterator i = childrenDisplay.iterator(); Set<Object> toRemove = new HashSet<Object>(childrenDisplay.size()); while (i.hasNext()) toRemove.add(i.next()); i = toRemove.iterator(); while (i.hasNext()) removeChildDisplay((TreeBrowserDisplay) i.next()); }
@Override public boolean chooseTargetAmount( Outcome outcome, TargetAmount target, Ability source, Game game) { Set<UUID> possibleTargets = target.possibleTargets(source == null ? null : source.getSourceId(), playerId, game); if (possibleTargets.isEmpty()) return !target.isRequired(); if (!target.isRequired()) { if (rnd.nextInt(possibleTargets.size() + 1) == 0) { return false; } } if (possibleTargets.size() == 1) { target.addTarget( possibleTargets.iterator().next(), target.getAmountRemaining(), source, game); return true; } Iterator<UUID> it = possibleTargets.iterator(); int targetNum = rnd.nextInt(possibleTargets.size()); UUID targetId = it.next(); for (int i = 0; i < targetNum; i++) { targetId = it.next(); } target.addTarget(targetId, rnd.nextInt(target.getAmountRemaining()) + 1, source, game); return true; }
@Test public void testLifecycleInEndpointWithMessageSource() throws Exception { context = new GenericXmlApplicationContext(getClass(), "lifecycle-source.xml"); messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class); assertNotNull(messageChannelsMonitor); MBeanServer server = context.getBean(MBeanServer.class); Set<ObjectName> names = server.queryNames( ObjectName.getInstance("org.springframework.integration:type=ManagedEndpoint,*"), null); assertEquals(0, names.size()); names = server.queryNames( ObjectName.getInstance("org.springframework.integration:name=explicit,*"), null); assertEquals(1, names.size()); MBeanOperationInfo[] operations = server.getMBeanInfo(names.iterator().next()).getOperations(); String startName = null; for (MBeanOperationInfo info : operations) { String name = info.getName(); if (name.startsWith("start")) { startName = name; } } // Lifecycle method name assertEquals("start", startName); assertTrue((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null)); messageChannelsMonitor.stopActiveComponents(false, 3000); assertFalse((Boolean) server.invoke(names.iterator().next(), "isRunning", null, null)); ActiveChannel activeChannel = context.getBean("activeChannel", ActiveChannel.class); assertTrue(activeChannel.isStopCalled()); OtherActiveComponent otherActiveComponent = context.getBean(OtherActiveComponent.class); assertTrue(otherActiveComponent.isBeforeCalled()); assertTrue(otherActiveComponent.isAfterCalled()); }
// Récupère le dictionnaire de données Produit/Quantité pour un Arc en sortie (numéro de sortie) public Map<String, Float> exitProductsFromArc(int exitNumber) { Map<String, Float> result = new HashMap<>(); // Verifie la Map des produits en entree est instanciee if (entranceProducts != null) { Set<String> listProducts = entranceProducts.keySet(); Iterator<String> listProductsIterator = listProducts.iterator(); // Pour chaque produit en entree de l'element while (listProductsIterator.hasNext()) { String entranceProduct = listProductsIterator.next(); float entranceQuantity = entranceProducts.get(entranceProduct); // Si Produit en entree present dans la matrice && Si Arc est une sortie de la // transformation du produit if ((matrix.containsKey(entranceProduct)) && (matrix.get(entranceProduct)).containsKey(exitNumber)) { Map<String, Float> currentArc = matrix.get(entranceProduct).get(exitNumber); Set<String> exitProducts = currentArc.keySet(); Iterator<String> exitProductIterator = exitProducts.iterator(); // Si le produit en sortie est deja dans la matrice, on ajoute la quantite produite par le // produit en entree while (exitProductIterator.hasNext()) { String exitProduct = exitProductIterator.next(); Float exitQuantity = entranceQuantity * currentArc.get(exitProduct) / 100; if (result.containsKey(exitProduct)) { exitQuantity += result.get(exitProduct); } result.put(exitProduct, exitQuantity); } } } } return result; }
public boolean contains(Signature signature) { String name = signature.getStamp(); Iterator<String> iterator; String mask; if (signatures != null) { if (signatures.contains(name)) { return true; } iterator = signatures.iterator(); while (iterator.hasNext()) { mask = (String) iterator.next(); if (name.startsWith(mask)) { return true; } } } if (signaturesRe != null) { iterator = signaturesRe.iterator(); while (iterator.hasNext()) { mask = iterator.next(); if (name.matches(mask)) { return true; } } } return false; }
@Override public Set<ValueRequirement> getRequirements( final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) { final Set<String> curves = desiredValue.getConstraints().getValues(ValuePropertyNames.CURVE); final Set<String> curveCalcConfigs = desiredValue.getConstraints().getValues(ValuePropertyNames.CURVE_CALCULATION_CONFIG); if ((curves == null) || (curves.size() != 1)) { s_logger.warn("no curve specified"); // Can't support an unbound request; an injection function must be used (or declare all as // optional and use [PLAT-1771]) return null; } if ((curveCalcConfigs == null) || (curveCalcConfigs.size() != 1)) { s_logger.warn("no curve config specified"); return null; } final String curve = curves.iterator().next(); final String curveCalcConfig = curveCalcConfigs.iterator().next(); final Set<ValueRequirement> requirements = Sets.newHashSet(); requirements.add(getCurveRequirement(target, curve, curveCalcConfig)); requirements.add(getCurveSpecRequirement(target, curve)); requirements.addAll( getSensitivityRequirements( context.getSecuritySource(), (RawSecurity) target.getSecurity())); return requirements; }
public void run(Object[] selection) { final Set elements = new HashSet(); final Set resources = new HashSet(); for (int i = 0; i < selection.length; ++i) { Object o = selection[i]; ValidatorUtils.processResourcesToElements(o, elements, resources); } for (Iterator i = elements.iterator(); i.hasNext(); ) { final ISourceModule module = (ISourceModule) i.next(); final IScriptProject sproject = module.getScriptProject(); if (sproject != null) { final IProject project = sproject.getProject(); if (project != null) { getProjectInfo(project).elements.add(module); } } } for (Iterator i = resources.iterator(); i.hasNext(); ) { final IResource resource = (IResource) i.next(); final IProject project = resource.getProject(); if (project != null) { getProjectInfo(project).resources.add(resource); } } setRule(buildSchedulingRule(elements, resources)); setUser(true); schedule(); }
public void first(Set<String> classNames) throws NotFoundException, ClassNotFoundException { // 扫描注册 ClassPool classPool = ClassPool.getDefault(); String tempClassName = null; Class register = Register.class; CtClass clazz; Object isRegister; Iterator<String> it = classNames.iterator(); while (it.hasNext()) { tempClassName = it.next(); clazz = classPool.get(tempClassName); isRegister = clazz.getAnnotation(register); AnnotationsAttribute a = (AnnotationsAttribute) clazz.getClassFile2().getAttribute(AnnotationsAttribute.visibleTag); Annotation[] as = a.getAnnotations(); for (Annotation an : as) { // System.out.println(String.format("MemberNames:%s ", an.getMemberNames())); Set anSet = an.getMemberNames(); Iterator anit = anSet.iterator(); while (anit.hasNext()) { System.out.println("type:" + anit.next().getClass()); } // AnnotationsAttribute a = (AnnotationsAttribute) // clazz.getClassFile().getAttribute(AnnotationsAttribute.visibleTag); // for() } System.err.println(a); System.err.println(a); // System.err.println(a.getName()); if (null != isRegister) System.out.println(isRegister); } }