Package java.util

Examples of java.util.SortedSet


   */
  private void addToMap(final Map map, final String key, final BundleArchive ba) {
    if (null == key)
      return;

    SortedSet bas = (SortedSet) map.get(key);
    if (null == bas) {
      bas = new TreeSet();
      map.put(key, bas);
      task.log("Found bundle '" + key + "'.", Project.MSG_DEBUG);
    }
    if (bas.add(ba)) {
      task.log("Found bundle '" + key + "' '" + ba.version + "'.",
               Project.MSG_DEBUG);
    }
  }
View Full Code Here


  private void printConfiguredLogLevels(final LogConfig configuration,
                                        final String[] selections,
                                        final Set weedOut,
                                        final PrintWriter out) {
    final SortedSet selectionSet = new TreeSet();
    for (int i = selections.length - 1; i >= 0; i--) {
      final String selection = selections[i];
      if (null!=selection && 0<selection.length()
          && !weedOut.contains(selection)) {
        selectionSet.add(selection);
      }
    }

    for (Iterator it = selectionSet.iterator(); it.hasNext(); ) {
      final String selection = (String) it.next();
      out.println("    -  "
                  + LogUtil.fromLevel(getLevel(configuration,
                                               selection, ""), 8)
                  + getFullName(selection)
View Full Code Here

            working = deAliased;
        }
        if (working.isResolved()) {
            return working;
        }
        SortedSet existingArtifacts;
        if (artifactManager != null) {
            existingArtifacts = artifactManager.getLoadedArtifacts(working);
        } else {
            existingArtifacts = new TreeSet();
        }

        // if we have exactly one artifact loaded use its' version
        if (existingArtifacts.size() == 1) {
            return (Artifact) existingArtifacts.first();
        }


        // if we have no existing loaded artifacts grab the highest version from the repository
        if (existingArtifacts.size() == 0) {
            SortedSet<Artifact> list = new TreeSet<Artifact>();
            for (ListableRepository repository : repositories) {
                list.addAll(repository.list(working));
            }

            if (list.isEmpty()) {
                if ("xbean-naming".equals(working.getArtifactId())) {
                    return new Artifact("org.apache.xbean", "xbean-naming", "2.8", "jar");
                } else {
                    return null;
                }
            }
            return list.last();
        }

        // more than one version of the artifact was loaded...

        // if one of parents already loaded the artifact, use that version
        Artifact artifact = searchParents(parentConfigurations, working);
        if (artifact != null) {
            return artifact;
        }

        // it wasn't declared by the parent so just use the highest verstion already loaded
        return (Artifact) existingArtifacts.last();
    }
View Full Code Here

        File file = null;
       
        for (Repository arepository : repositories) {
            if (arepository instanceof ListableRepository) {
                ListableRepository repository = (ListableRepository) arepository;
                SortedSet artifactSet = repository.list(artifactQuery);
                // if we have exactly one artifact found
                if (artifactSet.size() == 1) {
                    file = repository.getLocation((Artifact) artifactSet.first());
                    return file.getAbsoluteFile();
                } else if (artifactSet.size() > 1) {// if we have more than 1 artifacts found use the latest one.
                    file = repository.getLocation((Artifact) artifactSet.last());
                    return file.getAbsoluteFile();
                }
            }
        }
       
View Full Code Here

        try {
            List list = new ArrayList();
            ListableRepository[] repos = PortletManager.getCurrentServer(request).getRepositories();
            for (int i = 0; i < repos.length; i++) {
                ListableRepository repo = repos[i];
                final SortedSet artifacts = repo.list();
                for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
                    String fileName = iterator.next().toString();
                    list.add(fileName);
                }
            }
            Collections.sort(list);
View Full Code Here

        List list = new ArrayList();
        ListableRepository[] repos = PortletManager.getCurrentServer(renderRequest).getRepositories();
        for (int i = 0; i < repos.length; i++) {
            ListableRepository repo = repos[i];

            SortedSet artifacts = repo.list();
            outer:
            for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
                Artifact artifact = (Artifact) iterator.next();
                String test = artifact.toString();
                // todo should only test groupId and should check for long (org.apache.geronimo) and short form
                for (int k = 0; k < SKIP_ENTRIES_WITH.length; k++) {
                    String skip = SKIP_ENTRIES_WITH[k];
View Full Code Here

        // List the available RARs
        List list = new ArrayList();
        ListableRepository[] repos = PortletManager.getCurrentServer(renderRequest).getRepositories();
        for (int i = 0; i < repos.length; i++) {
            ListableRepository repo = repos[i];
            final SortedSet artifacts = repo.list();
            outer:
            for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
              Artifact artifact = (Artifact)iterator.next();
                String test = artifact.toString();
                if (!test.endsWith("/rar")) { //todo: may need to change this logic if configId format changes
                    continue;
                } else if (repo.getLocation(artifact).isDirectory()) {
View Full Code Here

  public void testMapper() throws IOException {
    TermVectorsReader reader = new TermVectorsReader(dir, seg, fieldInfos);
    assertTrue(reader != null);
    SortedTermVectorMapper mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
    reader.get(0, mapper);
    SortedSet set = mapper.getTermVectorEntrySet();
    assertTrue("set is null and it shouldn't be", set != null);
    //three fields, 4 terms, all terms are the same
    assertTrue("set Size: " + set.size() + " is not: " + 4, set.size() == 4);
    //Check offsets and positions
    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
      TermVectorEntry tve = (TermVectorEntry) iterator.next();
      assertTrue("tve is null and it shouldn't be", tve != null);
      assertTrue("tve.getOffsets() is null and it shouldn't be", tve.getOffsets() != null);
      assertTrue("tve.getPositions() is null and it shouldn't be", tve.getPositions() != null);

    }

    mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
    reader.get(1, mapper);
    set = mapper.getTermVectorEntrySet();
    assertTrue("set is null and it shouldn't be", set != null);
    //three fields, 4 terms, all terms are the same
    assertTrue("set Size: " + set.size() + " is not: " + 4, set.size() == 4);
    //Should have offsets and positions b/c we are munging all the fields together
    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
      TermVectorEntry tve = (TermVectorEntry) iterator.next();
      assertTrue("tve is null and it shouldn't be", tve != null);
      assertTrue("tve.getOffsets() is null and it shouldn't be", tve.getOffsets() != null);
      assertTrue("tve.getPositions() is null and it shouldn't be", tve.getPositions() != null);

    }


    FieldSortedTermVectorMapper fsMapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
    reader.get(0, fsMapper);
    Map map = fsMapper.getFieldToTerms();
    assertTrue("map Size: " + map.size() + " is not: " + testFields.length, map.size() == testFields.length);
    for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
      Map.Entry entry = (Map.Entry) iterator.next();
      SortedSet sortedSet = (SortedSet) entry.getValue();
      assertTrue("sortedSet Size: " + sortedSet.size() + " is not: " + 4, sortedSet.size() == 4);
      for (Iterator inner = sortedSet.iterator(); inner.hasNext();) {
        TermVectorEntry tve = (TermVectorEntry) inner.next();
        assertTrue("tve is null and it shouldn't be", tve != null);
        //Check offsets and positions.
        assertTrue("tve is null and it shouldn't be", tve != null);
        String field = tve.getField();
        if (field.equals(testFields[0])) {
          //should have offsets

          assertTrue("tve.getOffsets() is null and it shouldn't be", tve.getOffsets() != null);
          assertTrue("tve.getPositions() is null and it shouldn't be", tve.getPositions() != null);
        }
        else if (field.equals(testFields[1])) {
          //should not have offsets

          assertTrue("tve.getOffsets() is not null and it shouldn't be", tve.getOffsets() == null);
          assertTrue("tve.getPositions() is not null and it shouldn't be", tve.getPositions() == null);
        }
      }
    }
    //Try mapper that ignores offs and positions
    fsMapper = new FieldSortedTermVectorMapper(true, true, new TermVectorEntryFreqSortedComparator());
    reader.get(0, fsMapper);
    map = fsMapper.getFieldToTerms();
    assertTrue("map Size: " + map.size() + " is not: " + testFields.length, map.size() == testFields.length);
    for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
      Map.Entry entry = (Map.Entry) iterator.next();
      SortedSet sortedSet = (SortedSet) entry.getValue();
      assertTrue("sortedSet Size: " + sortedSet.size() + " is not: " + 4, sortedSet.size() == 4);
      for (Iterator inner = sortedSet.iterator(); inner.hasNext();) {
        TermVectorEntry tve = (TermVectorEntry) inner.next();
        assertTrue("tve is null and it shouldn't be", tve != null);
        //Check offsets and positions.
        assertTrue("tve is null and it shouldn't be", tve != null);
        String field = tve.getField();
View Full Code Here

                rarPath);
        ListableRepository[] repos = PortletManager.getCurrentServer(request).getRepositories();
        for (ListableRepository repo : repos) {
            // if the artifact is not fully resolved then try to resolve it
            if (!artifact.isResolved()) {
                SortedSet results = repo.list(artifact);
                if (!results.isEmpty()) {
                    artifact = (Artifact) results.first();
                } else {
                    continue;
                }
            }
            File url = repo.getLocation(artifact);
View Full Code Here

        // prevent further "reloads" until change
        this.needReload = false;
    }

    private void registerResourceByCategory(Object category, Resource res) {
        SortedSet resources = (SortedSet) this.resourcesByCategory.get(category);
        if (resources == null) {
            resources = new TreeSet();
            this.resourcesByCategory.put(category, resources);
        }
        resources.add(res);
    }
View Full Code Here

TOP

Related Classes of java.util.SortedSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.