コード例 #1
0
ファイル: ElementTest.java プロジェクト: haggisandchips/jsoup
  @Test
  public void testClassNames() {
    Document doc = Jsoup.parse("<div class=\"c1 c2\">C</div>");
    Element div = doc.select("div").get(0);

    assertEquals("c1 c2", div.className());

    final Set<String> set1 = div.classNames();
    final Object[] arr1 = set1.toArray();
    assertTrue(arr1.length == 2);
    assertEquals("c1", arr1[0]);
    assertEquals("c2", arr1[1]);

    // Changes to the set should not be reflected in the Elements getters
    set1.add("c3");
    assertTrue(2 == div.classNames().size());
    assertEquals("c1 c2", div.className());

    // Update the class names to a fresh set
    final Set<String> newSet = new LinkedHashSet<String>(3);
    newSet.addAll(set1);
    newSet.add("c3");

    div.classNames(newSet);

    assertEquals("c1 c2 c3", div.className());

    final Set<String> set2 = div.classNames();
    final Object[] arr2 = set2.toArray();
    assertTrue(arr2.length == 3);
    assertEquals("c1", arr2[0]);
    assertEquals("c2", arr2[1]);
    assertEquals("c3", arr2[2]);
  }
コード例 #2
0
  private void readOldState(DataInputStream dis) throws IOException, TeamException {
    int repoSize = dis.readInt();
    boolean version1 = false;
    if (repoSize == STATE_FILE_VERSION_1) {
      version1 = true;
      repoSize = dis.readInt();
    }
    for (int i = 0; i < repoSize; i++) {
      ICVSRepositoryLocation root = KnownRepositories.getInstance().getRepository(dis.readUTF());
      RepositoryRoot repoRoot = getRepositoryRootFor(root);

      // read branch tags associated with this root
      int tagsSize = dis.readInt();
      CVSTag[] branchTags = new CVSTag[tagsSize];
      for (int j = 0; j < tagsSize; j++) {
        String tagName = dis.readUTF();
        int tagType = dis.readInt();
        branchTags[j] = new CVSTag(tagName, tagType);
      }
      // Ignore the branch tags since they are handled differently now
      // addBranchTags(root, branchTags);

      // read the number of projects for this root that have version tags
      int projSize = dis.readInt();
      if (projSize > 0) {
        for (int j = 0; j < projSize; j++) {
          String name = dis.readUTF();
          Set tagSet = new HashSet();
          int numTags = dis.readInt();
          for (int k = 0; k < numTags; k++) {
            tagSet.add(new CVSTag(dis.readUTF(), CVSTag.VERSION));
          }
          CVSTag[] tags = (CVSTag[]) tagSet.toArray(new CVSTag[tagSet.size()]);
          repoRoot.addTags(name, tags);
        }
      }
      // read the auto refresh filenames for this project
      if (version1) {
        try {
          projSize = dis.readInt();
          if (projSize > 0) {
            for (int j = 0; j < projSize; j++) {
              String name = dis.readUTF();
              Set filenames = new HashSet();
              int numFilenames = dis.readInt();
              for (int k = 0; k < numFilenames; k++) {
                filenames.add(name + "/" + dis.readUTF()); // $NON-NLS-1$
              }
              repoRoot.setAutoRefreshFiles(
                  name, (String[]) filenames.toArray(new String[filenames.size()]));
            }
          }
        } catch (EOFException e) {
          // auto refresh files are not persisted, continue and save them next time.
        }
      }
      broadcastRepositoryChange(repoRoot);
    }
  }
コード例 #3
0
  protected void handleAdd() {
    ElementListSelectionDialog dialog =
        new ElementListSelectionDialog(getShell(), new StyledBundleLabelProvider(false, false));

    try {
      dialog.setElements(getValidBundles());
    } catch (CoreException e) {
      dialog.setMessage(e.getMessage());
    }

    dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
    dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
    dialog.setMultipleSelection(true);
    if (dialog.open() == Window.OK) {

      Object[] models = dialog.getResult();
      ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<NameVersionDescriptor>();
      for (int i = 0; i < models.length; i++) {
        BundleInfo desc = ((BundleInfo) models[i]);
        pluginsToAdd.add(new NameVersionDescriptor(desc.getSymbolicName(), null));
      }
      Set<NameVersionDescriptor> allDependencies = new HashSet<NameVersionDescriptor>();
      allDependencies.addAll(pluginsToAdd);
      NameVersionDescriptor[] currentBundles = getTargetDefinition().getImplicitDependencies();
      if (currentBundles != null) {
        allDependencies.addAll(Arrays.asList(currentBundles));
      }
      getTargetDefinition()
          .setImplicitDependencies(
              allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()]));
      fElementViewer.refresh();
      updateImpButtons();
    }
  }
コード例 #4
0
 private void handleFieldWildcards(TermVectorRequest request) {
   Set<String> fieldNames = new HashSet<>();
   for (String pattern : request.selectedFields()) {
     fieldNames.addAll(indexShard.mapperService().simpleMatchToIndexNames(pattern));
   }
   request.selectedFields(fieldNames.toArray(Strings.EMPTY_ARRAY));
 }
コード例 #5
0
  private static Set<Link> getLinks(ArrayList<String> linkList, Entry entry) {
    Set<Link> existingLinks = entry.getLinks();
    Set<Link> links = new HashSet<>();

    if (existingLinks == null) existingLinks = new HashSet<>();

    if (linkList == null) return existingLinks;

    for (int i = 0; i < linkList.size(); i++) {
      String currentItem = linkList.get(i);
      Link link;

      if (existingLinks.size() > i) {
        link = (Link) existingLinks.toArray()[i];
      } else {
        link = new Link();
        existingLinks.add(link);
      }
      link.setLink(currentItem);
      link.setEntry(entry);
      links.add(link);
    }

    return links;
  }
コード例 #6
0
  private static Set<SelectionMarker> getSelectionMarkers(
      ArrayList<String> markerStr, Entry entry) {
    Set<SelectionMarker> existingMarkers = entry.getSelectionMarkers();
    Set<SelectionMarker> markers = new HashSet<>();

    if (existingMarkers == null) existingMarkers = new HashSet<>();

    if (markerStr != null) {
      int itemLength = markerStr.size();

      for (int i = 0; i < itemLength; i++) {
        String currentItem = markerStr.get(i);
        SelectionMarker marker;

        if (existingMarkers.size() > i) {
          marker = (SelectionMarker) existingMarkers.toArray()[i];
        } else {
          marker = new SelectionMarker();
          existingMarkers.add(marker);
        }

        marker.setName(currentItem);
        marker.setEntry(entry);
        markers.add(marker);
      }
    } else return null;

    return markers;
  }
コード例 #7
0
  public Privilege[] getPrivileges(String s) throws RepositoryException {

    Item item = registrySession.getItem(s);
    if (item instanceof Property) {
      throw new PathNotFoundException("No privilages can be added for Properties");
    }

    Set<Privilege> privileges = new HashSet<Privilege>();

    if (accessCtrlPolicies.get(s) instanceof RegistryAccessControlList) {

      AccessControlEntry[] accessNtries =
          ((RegistryAccessControlList) accessCtrlPolicies.get(s)).getAccessControlEntries();

      for (AccessControlEntry ac : accessNtries) {
        if (ac != null) {
          privileges.addAll(Arrays.asList(ac.getPrivileges()));
        }
      }
    } else {
      // TODO check how to apply NamedAccessControlPolicy
    }

    // Read-only session must have READ privilege on test node
    if (RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(registrySession.getUserID())
        && !privileges.contains(privilegeRegistry.getPrivilegeFromName(Privilege.JCR_READ))) {
      privileges.add(privilegeRegistry.getPrivilegeFromName(Privilege.JCR_READ));
    }

    if (privileges.size() != 0) {
      return privileges.toArray(new Privilege[privileges.size()]);
    } else return new Privilege[0];
  }
  private static PsiSubstitutor obtainFinalSubstitutor(
      PsiClass superClass,
      PsiSubstitutor superSubstitutor,
      PsiSubstitutor derivedSubstitutor,
      boolean inRawContext) {
    if (inRawContext) {
      Set<PsiTypeParameter> typeParams = superSubstitutor.getSubstitutionMap().keySet();
      PsiElementFactory factory = JavaPsiFacade.getElementFactory(superClass.getProject());
      superSubstitutor =
          factory.createRawSubstitutor(
              derivedSubstitutor, typeParams.toArray(new PsiTypeParameter[typeParams.size()]));
    }
    Map<PsiTypeParameter, PsiType> map = null;
    for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(superClass)) {
      PsiType type = superSubstitutor.substitute(typeParameter);
      final PsiType t = derivedSubstitutor.substitute(type);
      if (map == null) {
        map = new THashMap<PsiTypeParameter, PsiType>();
      }
      map.put(typeParameter, t);
    }

    return map == null
        ? PsiSubstitutor.EMPTY
        : JavaPsiFacade.getInstance(superClass.getProject())
            .getElementFactory()
            .createSubstitutor(map);
  }
コード例 #9
0
  /** Tests getting the list of titles for all guides. */
  public void testGetGuidesTitles() {
    Set titles;

    // Empty set of titles -- not guides
    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 0, titles.size());

    // There's one guide in the set
    StandardGuide guide = new StandardGuide();
    guide.setTitle("A");
    set.add(guide);

    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 1, titles.size());
    assertEquals("Wrong title", "A", titles.toArray()[0]);

    // There's another guide with the same title
    StandardGuide guide2 = new StandardGuide();
    guide2.setTitle("A");
    set.add(guide2);

    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 1, titles.size());
    assertTrue("Wrong title", titles.contains("A"));

    // There's third guide with different title
    StandardGuide guide3 = new StandardGuide();
    guide3.setTitle("B");
    set.add(guide3);

    titles = set.getGuidesTitles();
    assertEquals("Should be not titles.", 2, titles.size());
    assertTrue("Wrong title", titles.contains("A"));
    assertTrue("Wrong title", titles.contains("B"));
  }
コード例 #10
0
ファイル: MonitorJob.java プロジェクト: josecerejo/flamingo
  private void mail(JobExecutionContext jec, Set emails, String subject, String mail) {
    try {
      log.info("Sending mail to service admins: " + Arrays.toString(emails.toArray()));

      for (String email : (Set<String>) emails) {
        if (isInterrupted()) {
          log.info("Interrupted, ending monitoring job");
          return;
        }

        try {
          Mailer.sendMail(
              (String) jec.getJobDetail().getJobDataMap().get("from.name"),
              (String) jec.getJobDetail().getJobDataMap().get("from.email"),
              email,
              subject,
              mail);
        } catch (Exception e) {
          log.error("Error sending mail to service admin " + email, e);
        }
      }
    } catch (Exception e) {
      log.error("Error sending mail to service admins", e);
    }
  }
コード例 #11
0
  public static Set<PsiType> flatten(PsiType[] conjuncts, Set<PsiType> types) {
    for (PsiType conjunct : conjuncts) {
      if (conjunct instanceof PsiIntersectionType) {
        PsiIntersectionType type = (PsiIntersectionType) conjunct;
        flatten(type.getConjuncts(), types);
      } else {
        types.add(conjunct);
      }
    }
    if (types.size() > 1) {
      PsiType[] array = types.toArray(createArray(types.size()));
      for (Iterator<PsiType> iterator = types.iterator(); iterator.hasNext(); ) {
        PsiType type = iterator.next();

        for (PsiType existing : array) {
          if (type != existing) {
            final boolean allowUncheckedConversion =
                type instanceof PsiClassType && ((PsiClassType) type).isRaw();
            if (TypeConversionUtil.isAssignable(type, existing, allowUncheckedConversion)) {
              iterator.remove();
              break;
            }
          }
        }
      }
      if (types.isEmpty()) {
        types.add(array[0]);
      }
    }
    return types;
  }
コード例 #12
0
  private static OrderEntry[] calcOrderEntries(
      @NotNull RootInfo info,
      @NotNull MultiMap<VirtualFile, OrderEntry> depEntries,
      @NotNull MultiMap<VirtualFile, OrderEntry> libClassRootEntries,
      @NotNull MultiMap<VirtualFile, OrderEntry> libSourceRootEntries,
      @NotNull List<VirtualFile> hierarchy) {
    @Nullable VirtualFile libraryClassRoot = info.findLibraryRootInfo(hierarchy, false);
    @Nullable VirtualFile librarySourceRoot = info.findLibraryRootInfo(hierarchy, true);
    Set<OrderEntry> orderEntries = ContainerUtil.newLinkedHashSet();
    orderEntries.addAll(
        info.getLibraryOrderEntries(
            hierarchy,
            libraryClassRoot,
            librarySourceRoot,
            libClassRootEntries,
            libSourceRootEntries));
    for (VirtualFile root : hierarchy) {
      orderEntries.addAll(depEntries.get(root));
    }
    VirtualFile moduleContentRoot = info.findModuleRootInfo(hierarchy);
    if (moduleContentRoot != null) {
      ContainerUtil.addIfNotNull(
          orderEntries,
          info.getModuleSourceEntry(hierarchy, moduleContentRoot, libClassRootEntries));
    }
    if (orderEntries.isEmpty()) {
      return null;
    }

    OrderEntry[] array = orderEntries.toArray(new OrderEntry[orderEntries.size()]);
    Arrays.sort(array, BY_OWNER_MODULE);
    return array;
  }
コード例 #13
0
 public static Machine[] getMachinesHostingContainers(GridServiceContainer[] containers) {
   Set<Machine> machines = new HashSet<Machine>();
   for (GridServiceContainer container : containers) {
     machines.add(container.getMachine());
   }
   return machines.toArray(new Machine[machines.size()]);
 }
コード例 #14
0
  /**
   * @param instance
   * @return list of containers that are used by the relocated processing unit instance to
   *     synchronize all data.
   */
  public static GridServiceContainer[] getReplicationSourceContainers(
      ProcessingUnitInstance instance) {
    Set<GridServiceContainer> repContainers = new HashSet<GridServiceContainer>();

    GridServiceContainer[] containers =
        instance.getAdmin().getGridServiceContainers().getContainers();

    int numberOfBackups = instance.getProcessingUnit().getNumberOfBackups();
    if (numberOfBackups == 0) {
      return new GridServiceContainer[] {};
    }

    if (!isProcessingUnitPartitionIntact(
        instance.getProcessingUnit(), instance.getInstanceId(), containers)) {
      throw new IllegalStateException(
          "Cannot relocate pu instance "
              + puInstanceToString(instance)
              + " since partition is not intact.");
    }

    for (int backupId = 0; backupId <= numberOfBackups; backupId++) {
      if (backupId != instance.getBackupId()) {
        repContainers.add(
            findProcessingUnitInstance(
                    instance.getProcessingUnit(), instance.getInstanceId(), backupId, containers)
                .getGridServiceContainer());
      }
    }

    return repContainers.toArray(new GridServiceContainer[repContainers.size()]);
  }
コード例 #15
0
ファイル: ThrowsTaglet.java プロジェクト: karianna/jdk8_tl
 /** Inherit throws documentation for exceptions that were declared but not documented. */
 private TagletOutput inheritThrowsDocumentation(
     Doc holder,
     Type[] declaredExceptionTypes,
     Set<String> alreadyDocumented,
     TagletWriter writer) {
   TagletOutput result = writer.getOutputInstance();
   if (holder instanceof MethodDoc) {
     Set<Tag> declaredExceptionTags = new LinkedHashSet<Tag>();
     for (int j = 0; j < declaredExceptionTypes.length; j++) {
       DocFinder.Output inheritedDoc =
           DocFinder.search(
               new DocFinder.Input(
                   (MethodDoc) holder, this, declaredExceptionTypes[j].typeName()));
       if (inheritedDoc.tagList.size() == 0) {
         inheritedDoc =
             DocFinder.search(
                 new DocFinder.Input(
                     (MethodDoc) holder, this, declaredExceptionTypes[j].qualifiedTypeName()));
       }
       declaredExceptionTags.addAll(inheritedDoc.tagList);
     }
     result.appendOutput(
         throwsTagsOutput(
             declaredExceptionTags.toArray(new ThrowsTag[] {}), writer, alreadyDocumented, false));
   }
   return result;
 }
コード例 #16
0
 public Object getMinValue() {
   if (intervals.isEmpty()) return null;
   Interval interval = (Interval) intervals.toArray()[0];
   if (interval instanceof NumericInterval) return ((NumericInterval) interval).getMinValue();
   if (interval instanceof DateInterval) return ((DateInterval) interval).getMinDate();
   return null;
 }
コード例 #17
0
 @Override
 @NotNull
 public Project[] getOpenProjects() {
   synchronized (myOpenProjects) {
     if (myOpenProjectsArrayCache.length != myOpenProjects.size()) {
       LOG.error(
           "Open projects: "
               + myOpenProjects
               + "; cache: "
               + Arrays.asList(myOpenProjectsArrayCache));
     }
     if (myOpenProjectsArrayCache.length > 0
         && myOpenProjectsArrayCache[0] != myOpenProjects.get(0)) {
       LOG.error(
           "Open projects cache corrupted. Open projects: "
               + myOpenProjects
               + "; cache: "
               + Arrays.asList(myOpenProjectsArrayCache));
     }
     if (ApplicationManager.getApplication().isUnitTestMode()) {
       Project[] testProjects = myTestProjects.toArray(new Project[myTestProjects.size()]);
       for (Project testProject : testProjects) {
         assert !testProject.isDisposed() : testProject;
       }
       return ArrayUtil.mergeArrays(myOpenProjectsArrayCache, testProjects);
     }
     return myOpenProjectsArrayCache;
   }
 }
コード例 #18
0
 @Test
 public void testToArrayWithParam() {
   addStringsToCollection(bag);
   Set<String> expected = new HashSet<>();
   addStringsToCollection(expected);
   Assert.assertEquals(expected.toArray(), bag.toArray(new Object[bag.uniqueSize()]));
 }
コード例 #19
0
ファイル: LocalSdk.java プロジェクト: glowingyilia/ddmlib
 @NonNull
 public IAndroidTarget[] getMissingTargets() {
   synchronized (mLocalPackages) {
     if (mCachedMissingTargets == null) {
       Map<MissingTarget, MissingTarget> result = Maps.newHashMap();
       Set<ISystemImage> seen = Sets.newHashSet();
       for (IAndroidTarget target : getTargets()) {
         Collections.addAll(seen, target.getSystemImages());
       }
       for (LocalPkgInfo local : getPkgsInfos(PkgType.PKG_ADDON_SYS_IMAGE)) {
         LocalAddonSysImgPkgInfo info = (LocalAddonSysImgPkgInfo) local;
         ISystemImage image = info.getSystemImage();
         if (!seen.contains(image)) {
           addOrphanedSystemImage(image, info.getDesc(), result);
         }
       }
       for (LocalPkgInfo local : getPkgsInfos(PkgType.PKG_SYS_IMAGE)) {
         LocalSysImgPkgInfo info = (LocalSysImgPkgInfo) local;
         ISystemImage image = info.getSystemImage();
         if (!seen.contains(image)) {
           addOrphanedSystemImage(image, info.getDesc(), result);
         }
       }
       mCachedMissingTargets = result.keySet();
     }
     return mCachedMissingTargets.toArray(new IAndroidTarget[mCachedMissingTargets.size()]);
   }
 }
コード例 #20
0
  @NotNull
  public Change[] getSelectedChanges() {
    Set<Change> changes = new LinkedHashSet<Change>();

    final TreePath[] paths = getSelectionPaths();
    if (paths == null) {
      return new Change[0];
    }

    for (TreePath path : paths) {
      ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent();
      changes.addAll(node.getAllChangesUnder());
    }

    if (changes.isEmpty()) {
      final List<VirtualFile> selectedModifiedWithoutEditing = getSelectedModifiedWithoutEditing();
      if (selectedModifiedWithoutEditing != null && !selectedModifiedWithoutEditing.isEmpty()) {
        for (VirtualFile file : selectedModifiedWithoutEditing) {
          AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file);
          if (vcs == null) continue;
          final VcsCurrentRevisionProxy before =
              VcsCurrentRevisionProxy.create(file, myProject, vcs.getKeyInstanceMethod());
          if (before != null) {
            ContentRevision afterRevision = new CurrentContentRevision(new FilePathImpl(file));
            changes.add(new Change(before, afterRevision, FileStatus.HIJACKED));
          }
        }
      }
    }

    return changes.toArray(new Change[changes.size()]);
  }
コード例 #21
0
 @Test
 public void testToArray() {
   addStringsToCollection(bag);
   Set<String> expected = new HashSet<>();
   addStringsToCollection(expected);
   Assert.assertEquals(expected.toArray(), bag.toArray());
 }
  @Test
  public void shouldReturnAllMatchingTablesWhenManyTablesExist() throws Exception {
    RandomTableGenerator generator = new RandomTableGenerator();
    generator.setGameTypes("BLACKJACK", "HISSTERIA", "ROULETTE");
    Set<Table> nonMatching = generator.generateTables(100);

    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);
    generator.setTags("tag1", "tag2", "tag3");

    Set<Table> matching = generator.generateTables(12);

    Set<Table> all = new HashSet<Table>(nonMatching);
    all.addAll(matching);
    assertEquals(112, all.size());

    gigaSpace.writeMultiple(all.toArray(new Table[all.size()]));

    Collection<TableSearchResult> found =
        tableSearchService.findTables(
            BigDecimal.TEN,
            new TableSearchCriteria(gameType, variation, clientId, Collections.<String>emptySet()));
    assertEquals(12, found.size());
  }
コード例 #23
0
 @Override
 public void visit(
     final int version,
     final int access,
     final String name,
     final String signature,
     final String superName,
     final String[] interfaces) {
   Set<String> interfacesSet = new LinkedHashSet<String>();
   if (interfaces != null) Collections.addAll(interfacesSet, interfaces);
   for (Class extraInterface : classList) {
     if (extraInterface.isInterface())
       interfacesSet.add(BytecodeHelper.getClassInternalName(extraInterface));
   }
   final boolean addGroovyObjectSupport = !GroovyObject.class.isAssignableFrom(superClass);
   if (addGroovyObjectSupport) interfacesSet.add("groovy/lang/GroovyObject");
   super.visit(
       V1_5,
       ACC_PUBLIC,
       proxyName,
       signature,
       BytecodeHelper.getClassInternalName(superClass),
       interfacesSet.toArray(new String[interfacesSet.size()]));
   addDelegateFields();
   if (addGroovyObjectSupport) {
     createGroovyObjectSupport();
   }
   for (Class clazz : classList) {
     visitClass(clazz);
   }
 }
  @Test
  public void shouldReturnMatchingTablesWhenTagsAreSpecified() throws Exception {
    RandomTableGenerator generator = new RandomTableGenerator();
    generator.setGameTypes("BLACKJACK", "HISSTERIA", "ROULETTE");
    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);
    generator.setTags("tag1", "tag2", "tag3");

    Set<Table> generated = generator.generateTables(12);
    Table firstTable = generated.iterator().next();
    firstTable.setTags(newHashSet("tag4"));
    gigaSpace.writeMultiple(generated.toArray(new Table[generated.size()]));

    Collection<TableSearchResult> found =
        tableSearchService.findTables(
            BigDecimal.TEN,
            new TableSearchCriteria(gameType, variation, clientId, newHashSet("tag4")));
    assertThat(found.size(), is(equalTo(1)));
    assertThat(found.iterator().next().getTableId(), is(equalTo(firstTable.getTableId())));
  }
  @Test
  public void shouldReturnEmptySetWhenPlayerIsPlayingAtOnlyTable() 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 table = generated.iterator().next();
    table.addPlayerToTable(new PlayerInformation(BigDecimal.TEN));

    gigaSpace.writeMultiple(generated.toArray(new Table[generated.size()]));

    Collection<TableSearchResult> found =
        tableSearchService.findTables(
            BigDecimal.TEN,
            new TableSearchCriteria(gameType, variation, clientId, Collections.<String>emptySet()));

    assertEquals(0, found.size());
  }
コード例 #26
0
ファイル: MDM.java プロジェクト: vohoangan123456/mirlastfm
 public void run() {
   if (som == null || ((som.getLabels() == null || som.voronoiSet == null) && artterms == null))
     return;
   // check if termvector information is available -> if not: crawl
   if (artterms == null) {
     //			System.out.println("do the crawl...");
     // artists are contained in labels (-> collect)
     Set<String> artistset = new HashSet<String>();
     for (int i = 0; i < som.getNumberOfColumns(); i++) { // for each column in codebook
       for (int j = 0; j < som.getNumberOfRows(); j++) { // for each row in codebook
         Vector temp = (Vector) som.voronoiSet.elementAt(i * som.getNumberOfRows() + j);
         // read all labels in Voronoi-Set of current map unit
         for (int k = 0; k < temp.size(); k++) {
           Integer labelIndex = (Integer) temp.elementAt(k);
           artistset.add(som.getLabel(labelIndex.intValue()));
         }
       }
     }
     String[] artists = artistset.toArray(new String[artistset.size()]);
     wtet = new WebTermExtractionThread(artists, queryconstraint);
     wtet.addThreadListener(this);
     wtet.start(); // -> threadEnded
   } else {
     System.out.println("data already present.");
     this.threadEnded();
   }
 }
コード例 #27
0
  public void summarizePlayer(int playerID) {
    Player p = players.get(playerID);
    Map<Integer, Playing> playersGames = p.games;
    Set<Integer> gamesKeys = playersGames.keySet();
    Integer[] gameIDs = gamesKeys.toArray(new Integer[gamesKeys.size()]);

    System.out.println("Player: " + p);
    System.out.println("Total Gamerscore: " + p.getGamerScore());
    System.out.printf(
        "%4s %-20s %-16s %-16s %-16s \n", " ", "Game", "Achievements", "Gamerscore", "IGN");
    System.out.println(
        "--------------------------------------------------------------------------------");
    for (int i = 0; i < gameIDs.length; i++) {
      Game g = games.get(gameIDs[i]);
      Playing playerInfo = p.games.get(gameIDs[i]);
      int nPlayerAchieve = playerInfo.achievements.size();
      int nTotalAchieve = g.achievements.size();
      System.out.printf(
          "%4s %-20s %-16s %-16s %-16s \n",
          (i + 1 + "."),
          g,
          (nPlayerAchieve + "/" + nTotalAchieve),
          (playerInfo.getPoints() + " pts"),
          playerInfo.ign);
    }

    System.out.printf("\n%4s %-16s %-16s \n", " ", "Friend", "Gamerscore");
    System.out.println(
        "--------------------------------------------------------------------------------");
    printSortedPlayers(p.friends);
  }
コード例 #28
0
ファイル: Utils.java プロジェクト: JSansalone/NetBeansIDE
 public static File[] toFileArray(Collection fileObjects) {
   Set files = new HashSet(fileObjects.size() * 4 / 3 + 1);
   for (Iterator i = fileObjects.iterator(); i.hasNext(); ) {
     files.add(FileUtil.toFile((FileObject) i.next()));
   }
   files.remove(null);
   return (File[]) files.toArray(new File[files.size()]);
 }
コード例 #29
0
 @Override
 @NotNull
 public Document[] getUncommittedDocuments() {
   ApplicationManager.getApplication().assertIsDispatchThread();
   Document[] documents =
       myUncommittedDocuments.toArray(new Document[myUncommittedDocuments.size()]);
   return ArrayUtil.stripTrailingNulls(documents);
 }
コード例 #30
0
 private ClassDoc[] getArray(Map<String, Set<ClassDoc>> m, String key) {
   Set<ClassDoc> s = m.get(key);
   if (s == null) {
     return new ClassDoc[] {};
   } else {
     return s.toArray(new ClassDoc[] {});
   }
 }