/**
   * 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();
  }
示例#2
1
 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;
 }
  @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;
  }
示例#4
0
 @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 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());
  }
  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);
        }
      }
    }
  }
示例#7
0
  /** 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;
    }
  }
示例#8
0
  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 XMLComparePreferencePage() {
    super();

    fIdMaps = new HashMap();
    XMLPlugin plugin = XMLPlugin.getDefault();
    HashMap PluginIdMaps = plugin.getIdMaps();
    Set keySet = PluginIdMaps.keySet();
    for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      fIdMaps.put(key, ((HashMap) PluginIdMaps.get(key)).clone());
    }
    fIdMapsInternal = plugin.getIdMapsInternal();

    fIdExtensionToName = new HashMap();
    HashMap PluginIdExtensionToName = plugin.getIdExtensionToName();
    keySet = PluginIdExtensionToName.keySet();
    for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      fIdExtensionToName.put(key, PluginIdExtensionToName.get(key));
    }

    fOrderedElements = new HashMap();
    HashMap PluginOrderedElements = plugin.getOrderedElements();
    keySet = PluginOrderedElements.keySet();
    for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      fOrderedElements.put(key, ((ArrayList) PluginOrderedElements.get(key)).clone());
    }

    fOrderedElementsInternal = plugin.getOrderedElementsInternal();
  }
示例#10
0
  /**
   * Indicates whether this ThrowableSet includes some exception that might be caught by a handler
   * argument of the type <code>catcher</code>.
   *
   * @param catcher type of the handler parameter to be tested.
   * @return <code>true</code> if this set contains an exception type that might be caught by <code>
   *     catcher</code>, false if it does not.
   */
  public boolean catchableAs(RefType catcher) {
    if (INSTRUMENTING) {
      Manager.v().catchableAsQueries++;
    }

    FastHierarchy h = Scene.v().getOrMakeFastHierarchy();

    if (exceptionsExcluded.size() > 0) {
      if (INSTRUMENTING) {
        Manager.v().catchableAsFromSearch++;
      }
      for (Iterator i = exceptionsExcluded.iterator(); i.hasNext(); ) {
        AnySubType exclusion = (AnySubType) i.next();
        if (h.canStoreType(catcher, exclusion.getBase())) {
          return false;
        }
      }
    }

    if (exceptionsIncluded.contains(catcher)) {
      if (INSTRUMENTING) {
        if (exceptionsExcluded.size() == 0) {
          Manager.v().catchableAsFromMap++;
        } else {
          Manager.v().catchableAsFromSearch++;
        }
      }
      return true;
    } else {
      if (INSTRUMENTING) {
        if (exceptionsExcluded.size() == 0) {
          Manager.v().catchableAsFromSearch++;
        }
      }
      for (Iterator i = exceptionsIncluded.iterator(); i.hasNext(); ) {
        RefLikeType thrownType = (RefLikeType) i.next();
        if (thrownType instanceof RefType) {
          if (thrownType == catcher) {
            // assertion failure.
            throw new IllegalStateException(
                "ThrowableSet.catchableAs(RefType): exceptions.contains() failed to match contained RefType "
                    + catcher);
          } else if (h.canStoreType(thrownType, catcher)) {
            return true;
          }
        } else {
          RefType thrownBase = ((AnySubType) thrownType).getBase();
          // At runtime, thrownType might be instantiated by any
          // of thrownBase's subtypes, so:
          if (h.canStoreType(thrownBase, catcher) || h.canStoreType(catcher, thrownBase)) {
            return true;
          }
        }
      }
      return false;
    }
  }
示例#11
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.fetchEffect("Thief_Hide") != null) {
      mob.tell("You are already hiding.");
      return false;
    }

    if (mob.isInCombat()) {
      mob.tell("Not while in combat!");
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    Set<MOB> H = mob.getGroupMembers(new HashSet<MOB>());
    if (!H.contains(mob)) H.add(mob);
    int numBesidesMe = 0;
    for (Iterator e = H.iterator(); e.hasNext(); ) {
      MOB M = (MOB) e.next();
      if ((M != mob) && (mob.location().isInhabitant(M))) numBesidesMe++;
    }
    if (numBesidesMe == 0) {
      mob.tell("You need a group to set up an ambush!");
      return false;
    }
    for (int i = 0; i < mob.location().numInhabitants(); i++) {
      MOB M = mob.location().fetchInhabitant(i);
      if ((M != null) && (M != mob) && (!H.contains(M)) && (CMLib.flags().canSee(M))) {
        mob.tell(M, null, null, "<S-NAME> is watching you too closely.");
        return false;
      }
    }
    boolean success = proficiencyCheck(mob, 0, auto);

    if (!success)
      beneficialVisualFizzle(mob, null, "<S-NAME> attempt(s) to set up an ambush, but fail(s).");
    else {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_HANDS_ACT | CMMsg.MASK_MOVE),
              "<S-NAME> set(s) up an ambush, directing everyone to hiding places.");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        Ability hide = CMClass.getAbility("Thief_Hide");
        for (Iterator e = H.iterator(); e.hasNext(); ) {
          MOB M = (MOB) e.next();
          hide.invoke(M, M, true, adjustedLevel(mob, asLevel));
        }
      } else success = false;
    }
    return success;
  }
示例#12
0
  public static <T extends Body> void connectGraph(Graph g, Iterable<T> bodies) {

    Iterable<String> names = new Mapped<T, String>(bodies, new MethodCallable<T, String>("name"));
    ArrayList<Set<String>> ccs = connectedComponents(g, names);

    for (int i = 0; i < ccs.size() - 1; i++) {
      Set<String> cc1 = ccs.get(i), cc2 = ccs.get(i + 1);
      String n1 = cc1.iterator().next(), n2 = cc2.iterator().next();
      g.addEdge(n1, n2);
    }
  }
	public void testMbeans() throws MalformedObjectNameException, BundleException, InstanceNotFoundException, ReflectionException, MBeanException, AttributeNotFoundException {
		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
		ObjectName digraphName = new ObjectName(REGION_DOMAIN_PROP + ":type=RegionDigraph,*");
		ObjectName regionNameAllQuery = new ObjectName(REGION_DOMAIN_PROP + ":type=Region,name=*,*");
		Set<ObjectInstance> digraphs = server.queryMBeans(null, digraphName);
		assertEquals("Expected only one instance of digraph", 1, digraphs.size());
		Set<ObjectInstance> regions = server.queryMBeans(null, regionNameAllQuery);
		assertEquals("Expected only one instance of region", 1, regions.size());

		Region pp1Region = digraph.createRegion(PP1);
		Bundle pp1Bundle = bundleInstaller.installBundle(PP1, pp1Region);
		Region sp1Region = digraph.createRegion(SP1);
		Bundle sp1Bundle = bundleInstaller.installBundle(SP1, sp1Region);

		regions = server.queryMBeans(null, regionNameAllQuery);
		assertEquals("Wrong number of regions", 3, regions.size());

		Set<ObjectInstance> pp1Query = server.queryMBeans(null, new ObjectName(REGION_DOMAIN_PROP + ":type=Region,name=" + PP1 + ",*"));
		assertEquals("Expected only one instance of: " + PP1, 1, pp1Query.size());
		Set<ObjectInstance> sp1Query = server.queryMBeans(null, new ObjectName(REGION_DOMAIN_PROP + ":type=Region,name=" + SP1 + ",*"));
		assertEquals("Expected only one instance of: " + SP1, 1, sp1Query.size());
		ObjectName pp1Name = (ObjectName) server.invoke(digraphs.iterator().next().getObjectName(), "getRegion", new Object[] {PP1}, new String[] {String.class.getName()});
		assertEquals(PP1 + " regions not equal.", pp1Query.iterator().next().getObjectName(), pp1Name);
		ObjectName sp1Name = (ObjectName) server.invoke(digraphs.iterator().next().getObjectName(), "getRegion", new Object[] {SP1}, new String[] {String.class.getName()});
		assertEquals(SP1 + " regions not equal.", sp1Query.iterator().next().getObjectName(), sp1Name);

		// test non existing region
		ObjectName shouldNotExistName = (ObjectName) server.invoke(digraphs.iterator().next().getObjectName(), "getRegion", new Object[] {"ShouldNotExist"}, new String[] {String.class.getName()});
		assertNull("Should not exist", shouldNotExistName);

		long[] bundleIds = (long[]) server.getAttribute(pp1Name, "BundleIds");
		assertEquals("Wrong number of bundles", 1, bundleIds.length);
		assertEquals("Wrong bundle", pp1Bundle.getBundleId(), bundleIds[0]);
		String name = (String) server.getAttribute(pp1Name, "Name");
		assertEquals("Wrong name", PP1, name);

		bundleIds = (long[]) server.getAttribute(sp1Name, "BundleIds");
		assertEquals("Wrong number of bundles", 1, bundleIds.length);
		assertEquals("Wrong bundle", sp1Bundle.getBundleId(), bundleIds[0]);
		name = (String) server.getAttribute(sp1Name, "Name");
		assertEquals("Wrong name", SP1, name);

		regionBundle.stop();

		// Now make sure we have no mbeans
		digraphs = server.queryMBeans(digraphName, null);
		assertEquals("Wrong number of digraphs", 0, digraphs.size());
		regions = server.queryMBeans(null, regionNameAllQuery);
		assertEquals("Wrong number of regions", 0, regions.size());
	}
示例#14
0
  public Object formResult() {
    Set brs = new HashSet();
    Set urs = new HashSet();
    // scan each rule / history pair
    int ruleCount = 0;
    for (Iterator pairI = rulePairs.keySet().iterator(); pairI.hasNext(); ) {
      if (ruleCount % 100 == 0) {
        System.err.println("Rules multiplied: " + ruleCount);
      }
      ruleCount++;
      Pair rulePair = (Pair) pairI.next();
      Rule baseRule = (Rule) rulePair.first;
      String baseLabel = (String) ruleToLabel.get(baseRule);
      List history = (List) rulePair.second;
      double totalProb = 0;
      for (int depth = 1; depth <= HISTORY_DEPTH() && depth <= history.size(); depth++) {
        List subHistory = history.subList(0, depth);
        double c_label = labelPairs.getCount(new Pair(baseLabel, subHistory));
        double c_rule = rulePairs.getCount(new Pair(baseRule, subHistory));
        // System.out.println("Multiplying out "+baseRule+" with history "+subHistory);
        // System.out.println("Count of "+baseLabel+" with "+subHistory+" is "+c_label);
        // System.out.println("Count of "+baseRule+" with "+subHistory+" is "+c_rule );

        double prob = (1.0 / HISTORY_DEPTH()) * (c_rule) / (c_label);
        totalProb += prob;
        for (int childDepth = 0; childDepth <= Math.min(HISTORY_DEPTH() - 1, depth); childDepth++) {
          Rule rule = specifyRule(baseRule, subHistory, childDepth);
          rule.score = (float) Math.log(totalProb);
          // System.out.println("Created  "+rule+" with score "+rule.score);
          if (rule instanceof UnaryRule) {
            urs.add(rule);
          } else {
            brs.add(rule);
          }
        }
      }
    }
    System.out.println("Total states: " + stateNumberer.total());
    BinaryGrammar bg = new BinaryGrammar(stateNumberer.total());
    UnaryGrammar ug = new UnaryGrammar(stateNumberer.total());
    for (Iterator brI = brs.iterator(); brI.hasNext(); ) {
      BinaryRule br = (BinaryRule) brI.next();
      bg.addRule(br);
    }
    for (Iterator urI = urs.iterator(); urI.hasNext(); ) {
      UnaryRule ur = (UnaryRule) urI.next();
      ug.addRule(ur);
    }
    return new Pair(ug, bg);
  }
示例#15
0
    private void ifItWasLink(
        List<TaskDataDto> result,
        MetricPanel metricPanel,
        TaskDataTreeViewModel taskDataTreeViewModel) {

      Set<MetricNameDto> metricsToSelect = new HashSet<MetricNameDto>();
      Set<PlotNameDto> trendsToSelect = new HashSet<PlotNameDto>();

      for (TaskDataDto taskDataDto : result) {
        for (TestsMetrics testMetric : place.getSelectedTestsMetrics()) {
          if (testMetric.getTestName().equals(taskDataDto.getTaskName())) {
            // add metrics
            for (String metricName : testMetric.getMetrics()) {
              MetricNameDto meticDto = new MetricNameDto();
              meticDto.setName(metricName);
              meticDto.setTests(taskDataDto);
              metricsToSelect.add(meticDto);
            }

            // add plots
            for (String trendsName : testMetric.getTrends()) {
              PlotNameDto plotNameDto = new PlotNameDto(taskDataDto, trendsName);
              trendsToSelect.add(plotNameDto);
            }
          }
        }
      }

      MetricNameDto fireMetric = null;
      if (!metricsToSelect.isEmpty()) fireMetric = metricsToSelect.iterator().next();

      for (MetricNameDto metric : metricsToSelect) {
        metricPanel.setSelected(metric);
      }
      metricPanel.addSelectionListener(new MetricsSelectionChangedHandler());

      if (fireMetric != null) metricPanel.setSelected(fireMetric);

      PlotNameDto firePlot = null;
      if (!trendsToSelect.isEmpty()) firePlot = trendsToSelect.iterator().next();

      for (PlotNameDto plotNameDto : trendsToSelect) {
        taskDataTreeViewModel.getSelectionModel().setSelected(plotNameDto, true);
      }
      taskDataTreeViewModel
          .getSelectionModel()
          .addSelectionChangeHandler(new TaskPlotSelectionChangedHandler());

      if (firePlot != null) taskDataTreeViewModel.getSelectionModel().setSelected(firePlot, true);
    }
示例#16
0
 /** Returns a string representation of this <code>ThrowableSet</code>. */
 public String toString() {
   StringBuffer buffer = new StringBuffer(this.toBriefString());
   buffer.append(":\n  ");
   for (Iterator i = exceptionsIncluded.iterator(); i.hasNext(); ) {
     buffer.append('+');
     Object o = i.next();
     buffer.append(o == null ? "null" : o.toString());
     // buffer.append(i.next().toString());
   }
   for (Iterator i = exceptionsExcluded.iterator(); i.hasNext(); ) {
     buffer.append('-');
     buffer.append(i.next().toString());
   }
   return buffer.toString();
 }
    public String getGeneratedName(final JavaRunConfigurationModule configurationModule) {
      if (TEST_PACKAGE.equals(TEST_OBJECT) || TEST_DIRECTORY.equals(TEST_OBJECT)) {
        final String moduleName =
            TEST_SEARCH_SCOPE.getScope() == TestSearchScope.WHOLE_PROJECT
                ? ""
                : configurationModule.getModuleName();
        final String packageName = getPackageName();
        if (packageName.length() == 0) {
          if (moduleName.length() > 0) {
            return ExecutionBundle.message("default.junit.config.name.all.in.module", moduleName);
          }
          return DEFAULT_PACKAGE_NAME;
        }
        if (moduleName.length() > 0) {
          return ExecutionBundle.message(
              "default.junit.config.name.all.in.package.in.module", packageName, moduleName);
        }
        return packageName;
      }
      if (TEST_PATTERN.equals(TEST_OBJECT)) {
        final int size = myPattern.size();
        if (size == 0) return "Temp suite";
        return StringUtil.getShortName(myPattern.iterator().next())
            + (size > 1 ? " and " + (size - 1) + " more" : "");
      }
      final String className =
          JavaExecutionUtil.getPresentableClassName(getMainClassName(), configurationModule);
      if (TEST_METHOD.equals(TEST_OBJECT)) {
        return className + '.' + getMethodName();
      }

      return className;
    }
示例#18
0
	/**
	 * 获取所有服务器上一分钟状态
	 * @return
	 * @throws IOException 
	 * @throws ClassNotFoundException 
	 */
	public String getAllServer() throws Exception {
		//服务器列表
		HashMap<String, String> serverList = createServerList();
		Set<String> aSet = serverList.keySet();
		Iterator<String> aaSet = aSet.iterator();
		int i = 0;
		String dataString = "";
		while(aaSet.hasNext()) {
			String ip = aaSet.next();
//			String des = serverList.get(ip);
			String data = getOneServer(ip, "");
			String lastNum = "0";
			String lastTime = "0:0";
			if(!data.isEmpty() && !data.equals("0=0")) {
				String[] dataList = data.split(",");
				if(dataList.length > 2) {
					String[] numList = dataList[(dataList.length -2)].split("=");
					lastNum = numList[0];
					lastTime = numList[1];
				} else {
					String[] numList = dataList[(dataList.length -1)].split("=");
					lastNum = numList[0];
					lastTime = numList[1];
				}
					
				
			}
			if(i != 0) dataString += ",";
			dataString += ip.replace("192.168.0.", "")  + "-" + lastNum + "-" + lastTime;
			i++;
		}
		return dataString;
	}
示例#19
0
  /**
   * Adds the given POP application satisfier set as a subset of this set, with the given
   * exceptions. The exceptions set must be a subset of the given satisfier set. If the given POP
   * application was already a subset of this set, then the new exceptions set is the intersection
   * of the given exceptions set with the old one. Otherwise, the exceptions set is the given one
   * minus any individual elements of this set that satisfy the given POP application.
   */
  public void addSatisfiers(NumberVar popApp, ObjectSet satisfiers, Set newExceptions) {
    if (popAppSatisfiers.containsKey(popApp)) {
      // already in set; assume satisfiers the same
      Set curExceptions = (Set) popAppExceptions.get(popApp);
      int oldNumExceptions = curExceptions.size();
      curExceptions.retainAll(newExceptions);
      size += (oldNumExceptions - curExceptions.size());
    } else {
      popAppSatisfiers.put(popApp, satisfiers);
      Set oldIndivs = (Set) popAppIndivs.remove(popApp);
      for (Iterator iter = oldIndivs.iterator(); iter.hasNext(); ) {
        individuals.remove(iter.next());
      }

      Set curExceptions = new HashSet(newExceptions);
      curExceptions.removeAll(oldIndivs);
      popAppExceptions.put(popApp, curExceptions);

      size +=
          (satisfiers.size()
              - oldIndivs.size() // because they were already
              // here
              - curExceptions.size()); // because they weren't added
    }
  }
  private Set<String> build(String type, Set<String> inferiors, String startType) {
    Set<String> directInferiors = directInferiorsMap.get(type);
    if (directInferiors == null) return inferiors;

    if (inferiors == null) inferiors = new HashSet<String>();

    Iterator<String> iter = directInferiors.iterator();
    while (iter.hasNext()) {
      String inferiorType = iter.next();
      if (inferiorType == startType)
        throw new UnsupportedOperationException(
            "Can not sort ClientPlayerBase classes for method '"
                + methodName
                + "'. Circular superiosity found including '"
                + startType
                + "'");
      if (list.contains(inferiorType)) inferiors.add(inferiorType);

      Set<String> inferiorSet;
      try {
        inferiorSet = build(inferiorType, startType);
      } catch (UnsupportedOperationException uoe) {
        throw new UnsupportedOperationException(
            "Can not sort ClientPlayerBase classes for method '"
                + methodName
                + "'. Circular superiosity found including '"
                + inferiorType
                + "'",
            uoe);
      }

      if (inferiorSet != Empty) inferiors.addAll(inferiorSet);
    }
    return inferiors;
  }
示例#21
0
  /**
   * This function prints a parsed TCRL refinement law. Only for debug purposes
   *
   * @param r The AST object
   */
  public static void printRefFunction(TCRL_AST r) {

    System.out.println();
    System.out.println("**************************************************");
    System.out.println("RefFunction");
    System.out.println("**************************************************");
    System.out.println("Nombre: " + r.getName());
    System.out.println("Preambulo: " + r.getPreamble());
    System.out.println("Reglas: ");

    NodeRules rules = r.getRules();
    NodeRule rule;

    Set<String> keys = rules.getKeys();
    Iterator<String> iter = keys.iterator();

    while (iter.hasNext()) {
      rule = rules.getRule(iter.next());

      if (rule instanceof RuleSynonym) {
        printRuleSynonym((RuleSynonym) rule);
      } else {
        printRuleRefinement((RuleRefinement) rule);
      }
    }
  }
示例#22
0
  // ===========================SCORING METHODS===================//
  public double scoreDag(Graph graph) {
    Graph dag = new EdgeListGraphSingleConnections(graph);
    buildIndexing(graph);

    double score = 0.0;

    for (Node y : dag.getNodes()) {
      Set<Node> parents = new HashSet<Node>(dag.getParents(y));
      int nextIndex = -1;
      for (int i = 0; i < getVariables().size(); i++) {
        nextIndex = hashIndices.get(variables.get(i));
      }
      int parentIndices[] = new int[parents.size()];
      Iterator<Node> pi = parents.iterator();
      int count = 0;
      while (pi.hasNext()) {
        Node nextParent = pi.next();
        parentIndices[count++] = hashIndices.get(nextParent);
      }

      if (this.isDiscrete()) {
        score += localDiscreteScore(nextIndex, parentIndices);
      } else {
        score += localSemScore(nextIndex, parentIndices);
      }
    }
    return score;
  }
  @Test
  public void shouldReturnEmptyWhenOnlyTableIsExcluded() throws Exception {
    TableSearchCriteria searchCriteria =
        new TableSearchCriteria(
            gameType, variation, clientId, Collections.<String>emptySet(), BigDecimal.valueOf(80));

    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 first = generated.iterator().next();
    first.setTableId(BigDecimal.valueOf(80));

    Collection<TableSearchResult> found =
        tableSearchService.findTables(BigDecimal.TEN, searchCriteria);
    assertEquals(0, found.size());
  }
示例#24
0
  /**
   * Finds the vertex set for the subgraph of all cycles.
   *
   * @return set of all vertices which participate in at least one cycle in this graph
   */
  public Set<V> findCycles() {
    // ProbeIterator can't be used to handle this case,
    // so use StrongConnectivityInspector instead.
    StrongConnectivityInspector<V, E> inspector = new StrongConnectivityInspector<V, E>(graph);
    List<Set<V>> components = inspector.stronglyConnectedSets();

    // A vertex participates in a cycle if either of the following is
    // true:  (a) it is in a component whose size is greater than 1
    // or (b) it is a self-loop

    Set<V> set = new HashSet<V>();
    for (Set<V> component : components) {
      if (component.size() > 1) {
        // cycle
        set.addAll(component);
      } else {
        V v = component.iterator().next();
        if (graph.containsEdge(v, v)) {
          // self-loop
          set.add(v);
        }
      }
    }

    return set;
  }
  private Set<TypeElement> getTypeFromProperties(Set<TypeElement> parents) {
    Set<TypeElement> elements = new HashSet<TypeElement>();
    for (Element element : parents) {
      if (element instanceof TypeElement) {
        processFromProperties((TypeElement) element, elements);
      }
    }

    Iterator<TypeElement> iterator = elements.iterator();
    while (iterator.hasNext()) {
      TypeElement element = iterator.next();
      String name = element.getQualifiedName().toString();
      if (name.startsWith("java.") || name.startsWith("org.joda.time.")) {
        iterator.remove();
      } else {
        boolean annotated = false;
        for (Class<? extends Annotation> annotation : conf.getEntityAnnotations()) {
          annotated |= element.getAnnotation(annotation) != null;
        }
        if (annotated) {
          iterator.remove();
        }
      }
    }

    return elements;
  }
 public String[] getjavaVMs() {
   // get the internal VM name
   // App Clients never run on the internal VM
   Set res = new HashSet();
   if (!(this instanceof AppClientModuleMdl)) {
     // res.addAll(findNames("j2eeType=JVM,name=" + MOAgentFactory.getAgent().getJVMId()));
   }
   // get the external VM names
   Iterator vmNames = externalVMs.iterator();
   while (vmNames.hasNext()) {
     String vmName = (String) vmNames.next();
     Set x = findNames("j2eeType=JVM,name=" + vmName);
     if (x.size() > 0) {
       res.addAll(x);
     } else {
       // no longer an active VM
       externalVMs.remove(vmName);
       vmNames = externalVMs.iterator();
     }
   }
   Iterator it = res.iterator();
   String[] vms = new String[res.size()];
   int i = 0;
   while (it.hasNext()) {
     vms[i++] = ((ObjectName) it.next()).toString();
   }
   return vms;
 }
  private void build(Port port) {
    if (wsdlModeler.isProvider(port)) return;
    Binding binding = port.resolveBinding(wsdlDocument);

    SOAPBinding soapBinding = (SOAPBinding) getExtensionOfType(binding, SOAPBinding.class);
    // lets try and see if its SOAP 1.2. dont worry about extension flag, its
    // handled much earlier
    if (soapBinding == null) {
      soapBinding = (SOAPBinding) getExtensionOfType(binding, SOAP12Binding.class);
    }
    if (soapBinding == null) return;
    PortType portType = binding.resolvePortType(wsdlDocument);

    QName bindingName = WSDLModelerBase.getQNameOf(binding);

    // we dont want to process the port bound to the binding processed earlier
    if (bindingNameToPortMap.containsKey(bindingName)) return;

    bindingNameToPortMap.put(bindingName, port);

    for (Iterator itr = binding.operations(); itr.hasNext(); ) {
      BindingOperation bindingOperation = (BindingOperation) itr.next();

      // get only the bounded operations
      Set boundedOps = portType.getOperationsNamed(bindingOperation.getName());
      if (boundedOps.size() != 1) continue;
      Operation operation = (Operation) boundedOps.iterator().next();

      // No pseudo schema required for doc/lit
      if (wsdlModeler.isAsync(portType, operation)) {
        buildAsync(portType, operation, bindingOperation);
      }
    }
  }
示例#28
0
 public static void main(String[] args) {
   try {
     if (args.length == 1) {
       URL url = new URL(args[0]);
       System.out.println("Content-Type: " + url.openConnection().getContentType());
       // 				Vector links = extractLinks(url);
       // 				for (int n = 0; n < links.size(); n++) {
       // 					System.out.println((String) links.elementAt(n));
       // 				}
       Set links = extractLinksWithText(url).entrySet();
       Iterator it = links.iterator();
       while (it.hasNext()) {
         Map.Entry en = (Map.Entry) it.next();
         String strLink = (String) en.getKey();
         String strText = (String) en.getValue();
         System.out.println(strLink + " \"" + strText + "\" ");
       }
       return;
     } else if (args.length == 2) {
       writeURLtoFile(new URL(args[0]), args[1]);
       return;
     }
   } catch (Exception e) {
     System.err.println("An error occured: ");
     e.printStackTrace();
     // 			System.err.println(e.toString());
   }
   System.err.println("Usage: java SaveURL <url> [<file>]");
   System.err.println("Saves a URL to a file.");
   System.err.println("If no file is given, extracts hyperlinks on url to console.");
 }
  private Variance calculateArgumentProjectionKindFromSuper(
      @NotNull TypeProjection argument,
      @NotNull List<TypeProjectionAndVariance> projectionsFromSuper) {
    Set<Variance> projectionKindsInSuper = Sets.newLinkedHashSet();
    for (TypeProjectionAndVariance projectionAndVariance : projectionsFromSuper) {
      projectionKindsInSuper.add(projectionAndVariance.typeProjection.getProjectionKind());
    }

    Variance defaultProjectionKind = argument.getProjectionKind();
    if (projectionKindsInSuper.size() == 0) {
      return defaultProjectionKind;
    } else if (projectionKindsInSuper.size() == 1) {
      Variance projectionKindInSuper = projectionKindsInSuper.iterator().next();
      if (defaultProjectionKind == INVARIANT || defaultProjectionKind == projectionKindInSuper) {
        return projectionKindInSuper;
      } else {
        reportError(
            "Incompatible projection kinds in type arguments of super methods' return types: "
                + projectionsFromSuper
                + ", defined in current: "
                + argument);
        return defaultProjectionKind;
      }
    } else {
      reportError(
          "Incompatible projection kinds in type arguments of super methods' return types: "
              + projectionsFromSuper);
      return defaultProjectionKind;
    }
  }
示例#30
0
  /**
   * Gets closure of all the referenced documents from the primary document(typically the service
   * WSDL). It traverses the WSDL and schema imports and builds a closure set of documents.
   *
   * @param systemId primary wsdl or the any root document
   * @param resolver used to get SDDocumentImpl for a document
   * @param onlyTopLevelSchemas if true, the imported schemas from a schema would be ignored
   * @return all the documents
   */
  public static Map<String, SDDocument> getMetadataClosure(
      @NotNull String systemId, @NotNull SDDocumentResolver resolver, boolean onlyTopLevelSchemas) {
    Map<String, SDDocument> closureDocs = new HashMap<String, SDDocument>();
    Set<String> remaining = new HashSet<String>();
    remaining.add(systemId);

    while (!remaining.isEmpty()) {
      Iterator<String> it = remaining.iterator();
      String current = it.next();
      remaining.remove(current);

      SDDocument currentDoc = resolver.resolve(current);
      SDDocument old = closureDocs.put(currentDoc.getURL().toExternalForm(), currentDoc);
      assert old == null;

      Set<String> imports = currentDoc.getImports();
      if (!currentDoc.isSchema() || !onlyTopLevelSchemas) {
        for (String importedDoc : imports) {
          if (closureDocs.get(importedDoc) == null) {
            remaining.add(importedDoc);
          }
        }
      }
    }

    return closureDocs;
  }