Example usage for java.util SortedSet add

List of usage examples for java.util SortedSet add

Introduction

In this page you can find the example usage for java.util SortedSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:com.revetkn.ios.analyzer.ArtworkAnalyzer.java

protected void detectStandardApplicationImages(ApplicationArtwork applicationArtwork) {
    SortedSet<File> standardApplicationImageFiles = new TreeSet<File>();
    SortedSet<String> missingStandardApplicationImageFilenames = new TreeSet<String>();

    for (String standardImageFilename : STANDARD_APPLICATION_IMAGE_FILENAMES) {
        boolean foundStandardImage = false;

        for (File imageFile : applicationArtwork.getAllImageFiles()) {
            if (imageFile.getName().equals(standardImageFilename)) {
                standardApplicationImageFiles.add(imageFile);
                foundStandardImage = true;
            }//  ww  w  .j  a va 2  s.c  om
        }

        if (!foundStandardImage)
            missingStandardApplicationImageFilenames.add(standardImageFilename);
    }

    applicationArtwork.setStandardApplicationImageFiles(standardApplicationImageFiles);
    applicationArtwork.setMissingStandardApplicationImageFilenames(missingStandardApplicationImageFilenames);
}

From source file:de.jcup.egradle.codeassist.dsl.HTMLDescriptionBuilder.java

private void appendAppendixProperties(Type type, StringBuilder description) {
    SortedSet<String> sortedLinkReferences;
    description.append("<h5 id='appendix_properties'>Properties:</h5>");
    Set<Property> properties = type.getProperties();
    sortedLinkReferences = new TreeSet<>();

    for (Property p : properties) {
        String propertySignature = p.getName();
        StringBuilder referenceLink = new StringBuilder();
        Type declaringType = p.getParent();
        referenceLink.append("\n<a href='type://").append(declaringType.getName()).append("#")
                .append(propertySignature).append("'>");
        referenceLink.append(propertySignature);
        referenceLink.append("</a>");
        sortedLinkReferences.add(referenceLink.toString());

    }/*  ww  w . j  a  va  2 s. c  o  m*/
    appendList(description, sortedLinkReferences);
}

From source file:com.revetkn.ios.analyzer.ArtworkAnalyzer.java

protected void detectRetinaAndNonretinaImages(ApplicationArtwork applicationArtwork) {
    SortedSet<String> allImageFilenames = extractFilenames(applicationArtwork.getAllImageFiles());
    SortedSet<File> retinaImageFiles = new TreeSet<File>();
    SortedSet<File> nonretinaImageFiles = new TreeSet<File>();
    SortedSet<File> nonretinaImageFilesMissingRetinaImages = new TreeSet<File>();
    SortedSet<File> retinaImageFilesMissingNonretinaImages = new TreeSet<File>();

    for (String imageFilename : allImageFilenames) {
        int lastIndexOf2x = imageFilename.lastIndexOf("@2x");

        // Nonretina; search for a retina version
        if (lastIndexOf2x == -1) {
            nonretinaImageFiles.add(new File(imageFilename));

            if (!allImageFilenames.contains(retinaImageFilename(imageFilename)))
                nonretinaImageFilesMissingRetinaImages.add(new File(imageFilename));
        } else {//from   w  ww .jav  a 2 s .  co  m
            retinaImageFiles.add(new File(imageFilename));

            String nonretinaImageFilename = imageFilename.replace("@2x", "");

            if (!allImageFilenames.contains(nonretinaImageFilename))
                retinaImageFilesMissingNonretinaImages.add(new File(imageFilename));
        }
    }

    applicationArtwork.setRetinaImageFiles(retinaImageFiles);
    applicationArtwork.setNonretinaImageFiles(nonretinaImageFiles);
    applicationArtwork.setNonretinaImageFilesMissingRetinaImages(nonretinaImageFilesMissingRetinaImages);
    applicationArtwork.setRetinaImageFilesMissingNonretinaImages(retinaImageFilesMissingNonretinaImages);
}

From source file:com.rapidminer.gui.graphs.TransitionGraphCreator.java

public TransitionGraphCreator(TransitionGraph transitionGraph, ExampleSet exampleSet) {
    this.sourceAttribute = exampleSet.getAttributes().get(transitionGraph.getSourceAttribute());
    this.targetAttribute = exampleSet.getAttributes().get(transitionGraph.getTargetAttribute());
    if (transitionGraph.getStrengthAttribute() != null) {
        this.strengthAttribute = exampleSet.getAttributes().get(transitionGraph.getStrengthAttribute());
    }//from  w  w  w.ja va2 s .  co m
    if (transitionGraph.getTypeAttribute() != null) {
        this.typeAttribute = exampleSet.getAttributes().get(transitionGraph.getTypeAttribute());
    }
    this.exampleSet = exampleSet;
    this.nodeDescription = transitionGraph.getNodeDescription();

    SortedSet<SourceId> sourceNames = new TreeSet<SourceId>();
    // Attribute idAttribute = exampleSet.getAttributes().getId();
    for (Example example : exampleSet) {
        Object id = example.getValue(sourceAttribute);
        if (sourceAttribute.isNominal()) {
            id = example.getValueAsString(sourceAttribute);
        }
        String description = getNodeDescription(id);
        if (description == null) {
            sourceNames.add(new SourceId(id.toString(), id.toString()));
        } else {
            sourceNames.add(new SourceId(id.toString(), description));
        }

    }

    sourceFilter = new ExtendedJComboBox(200);
    sourceFilter.addItem(new SourceId("None", "None"));
    for (SourceId sourceId : sourceNames) {
        sourceFilter.addItem(sourceId);
    }

    objectViewer = new DefaultObjectViewer(exampleSet);
}

From source file:ch.silviowangler.dox.DocumentServiceImpl.java

private SortedSet<ch.silviowangler.dox.api.Attribute> toAttributeApi(List<Attribute> attributes) {
    SortedSet<ch.silviowangler.dox.api.Attribute> result = new TreeSet<>();

    for (Attribute attribute : attributes) {
        ch.silviowangler.dox.api.Attribute attr = toAttributeApi(attribute);
        result.add(attr);
    }/*from  w w w .  j a  v  a 2s .  c  o m*/
    return result;
}

From source file:org.gvnix.addon.datatables.addon.DatatablesMetadataProvider.java

/**
 * @see DynamicFinderServicesImpl#tokenize
 *//*from  w  w w.j  a  v a2  s.  com*/
private List<Token> tokenize(final MemberDetails memberDetails, final JavaSymbolName finderName,
        final String plural) {
    final String simpleTypeName = getConcreteJavaType(memberDetails).getSimpleTypeName();
    String finder = finderName.getSymbolName();

    // Just in case it starts with findBy we can remove it here
    final String findBy = "find" + plural + "By";
    if (finder.startsWith(findBy)) {
        finder = finder.substring(findBy.length());
    }

    // If finder still contains the findBy sequence it is most likely a
    // wrong finder (ie someone pasted the finder string accidentally twice
    if (finder.contains(findBy)) {
        throw new InvalidFinderException("Dynamic finder definition for '" + finderName.getSymbolName()
                + "' in " + simpleTypeName + ".java is invalid");
    }

    final SortedSet<FieldToken> fieldTokens = new TreeSet<FieldToken>();
    for (final MethodMetadata method : getLocatedMutators(memberDetails)) {
        final FieldMetadata field = BeanInfoUtils.getFieldForPropertyName(memberDetails,
                method.getParameterNames().get(0));

        // If we did find a field matching the first parameter name of the
        // mutator method we can add it to the finder ITD
        if (field != null) {
            fieldTokens.add(new FieldToken(field));
        }
    }

    final List<Token> tokens = new ArrayList<Token>();

    while (finder.length() > 0) {
        final Token token = getFirstToken(fieldTokens, finder, finderName.getSymbolName(), simpleTypeName);
        if (token != null) {
            if (token instanceof FieldToken || token instanceof ReservedToken) {
                tokens.add(token);
            }
            finder = finder.substring(token.getValue().length());
        }
    }

    return tokens;
}

From source file:com.atlassian.jira.upgrade.UpgradeManagerImpl.java

/**
 * Gets a set of upgrade build numbers for a specified Map of upgradeTasks.
 *
 * @param numbers This set may be already populated with numbers. Any additional numbers from the Map of
 * upgradeTasks will be added to this set
 * @param upgradeMap This is the map of upgradeTasks that the build numbers will be retrieved from
 *//* ww w.  java 2s  . c  om*/
private void addUpgradeNumbersFromMap(final SortedSet<String> numbers,
        final Map<String, UpgradeTask> upgradeMap) {
    for (final String buildNumber : upgradeMap.keySet()) {
        numbers.add(buildNumber);
    }
}

From source file:com.espertech.esper.core.deploy.EPDeploymentAdminImpl.java

public synchronized DeploymentOrder getDeploymentOrder(Collection<Module> modules,
        DeploymentOrderOptions options) throws DeploymentOrderException {
    if (options == null) {
        options = new DeploymentOrderOptions();
    }/* w ww. j av a 2  s .c om*/
    String[] deployments = deploymentStateService.getDeployments();

    List<Module> proposedModules = new ArrayList<Module>();
    proposedModules.addAll(modules);

    Set<String> availableModuleNames = new HashSet<String>();
    for (Module proposedModule : proposedModules) {
        if (proposedModule.getName() != null) {
            availableModuleNames.add(proposedModule.getName());
        }
    }

    // Collect all uses-dependencies of existing modules
    Map<String, Set<String>> usesPerModuleName = new HashMap<String, Set<String>>();
    for (String deployment : deployments) {
        DeploymentInformation info = deploymentStateService.getDeployment(deployment);
        if (info == null) {
            continue;
        }
        if ((info.getModule().getName() == null) || (info.getModule().getUses() == null)) {
            continue;
        }
        Set<String> usesSet = usesPerModuleName.get(info.getModule().getName());
        if (usesSet == null) {
            usesSet = new HashSet<String>();
            usesPerModuleName.put(info.getModule().getName(), usesSet);
        }
        usesSet.addAll(info.getModule().getUses());
    }

    // Collect uses-dependencies of proposed modules
    for (Module proposedModule : proposedModules) {

        // check uses-dependency is available
        if (options.isCheckUses()) {
            if (proposedModule.getUses() != null) {
                for (String uses : proposedModule.getUses()) {
                    if (availableModuleNames.contains(uses)) {
                        continue;
                    }
                    if (isDeployed(uses)) {
                        continue;
                    }
                    String message = "Module-dependency not found";
                    if (proposedModule.getName() != null) {
                        message += " as declared by module '" + proposedModule.getName() + "'";
                    }
                    message += " for uses-declaration '" + uses + "'";
                    throw new DeploymentOrderException(message);
                }
            }
        }

        if ((proposedModule.getName() == null) || (proposedModule.getUses() == null)) {
            continue;
        }
        Set<String> usesSet = usesPerModuleName.get(proposedModule.getName());
        if (usesSet == null) {
            usesSet = new HashSet<String>();
            usesPerModuleName.put(proposedModule.getName(), usesSet);
        }
        usesSet.addAll(proposedModule.getUses());
    }

    Map<String, SortedSet<Integer>> proposedModuleNames = new HashMap<String, SortedSet<Integer>>();
    int count = 0;
    for (Module proposedModule : proposedModules) {
        SortedSet<Integer> moduleNumbers = proposedModuleNames.get(proposedModule.getName());
        if (moduleNumbers == null) {
            moduleNumbers = new TreeSet<Integer>();
            proposedModuleNames.put(proposedModule.getName(), moduleNumbers);
        }
        moduleNumbers.add(count);
        count++;
    }

    DependencyGraph graph = new DependencyGraph(proposedModules.size(), false);
    int fromModule = 0;
    for (Module proposedModule : proposedModules) {
        if ((proposedModule.getUses() == null) || (proposedModule.getUses().isEmpty())) {
            fromModule++;
            continue;
        }
        SortedSet<Integer> dependentModuleNumbers = new TreeSet<Integer>();
        for (String use : proposedModule.getUses()) {
            SortedSet<Integer> moduleNumbers = proposedModuleNames.get(use);
            if (moduleNumbers == null) {
                continue;
            }
            dependentModuleNumbers.addAll(moduleNumbers);
        }
        dependentModuleNumbers.remove(fromModule);
        graph.addDependency(fromModule, dependentModuleNumbers);
        fromModule++;
    }

    if (options.isCheckCircularDependency()) {
        Stack<Integer> circular = graph.getFirstCircularDependency();
        if (circular != null) {
            String message = "";
            String delimiter = "";
            for (int i : circular) {
                message += delimiter;
                message += "module '" + proposedModules.get(i).getName() + "'";
                delimiter = " uses (depends on) ";
            }
            throw new DeploymentOrderException(
                    "Circular dependency detected in module uses-relationships: " + message);
        }
    }

    List<Module> reverseDeployList = new ArrayList<Module>();
    Set<Integer> ignoreList = new HashSet<Integer>();
    while (ignoreList.size() < proposedModules.size()) {

        // seconardy sort according to the order of listing
        Set<Integer> rootNodes = new TreeSet<Integer>(new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                return -1 * o1.compareTo(o2);
            }
        });
        rootNodes.addAll(graph.getRootNodes(ignoreList));

        if (rootNodes.isEmpty()) { // circular dependency could cause this
            for (int i = 0; i < proposedModules.size(); i++) {
                if (!ignoreList.contains(i)) {
                    rootNodes.add(i);
                    break;
                }
            }
        }

        for (Integer root : rootNodes) {
            ignoreList.add(root);
            reverseDeployList.add(proposedModules.get(root));
        }
    }

    Collections.reverse(reverseDeployList);
    return new DeploymentOrder(reverseDeployList);
}

From source file:com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.java

private void updateGroups() {
    SortedSet<String> groups = new TreeSet<String>();
    if (groupByColumn >= 0) {
        synchronized (dataTable) {
            if (dataTable.isDate(groupByColumn)) {
                for (int i = 0; i < dataTable.getNumberOfRows(); i++) {
                    DataTableRow row = dataTable.getRow(i);
                    groups.add(Tools.createDateAndFormat(row.getValue(groupByColumn)));
                }//w ww. ja v a 2  s .  c  o m
            } else if (dataTable.isTime(groupByColumn)) {
                for (int i = 0; i < dataTable.getNumberOfRows(); i++) {
                    DataTableRow row = dataTable.getRow(i);
                    groups.add(Tools.createTimeAndFormat(row.getValue(groupByColumn)));
                }
            } else if (dataTable.isDateTime(groupByColumn)) {
                for (int i = 0; i < dataTable.getNumberOfRows(); i++) {
                    DataTableRow row = dataTable.getRow(i);
                    groups.add(Tools.createDateTimeAndFormat(row.getValue(groupByColumn)));
                }
            } else if (dataTable.isNominal(groupByColumn)) {
                for (int i = 0; i < dataTable.getNumberOfRows(); i++) {
                    DataTableRow row = dataTable.getRow(i);
                    groups.add(dataTable.mapIndex(groupByColumn, (int) row.getValue(groupByColumn)));
                }
            } else {
                for (int i = 0; i < dataTable.getNumberOfRows(); i++) {
                    DataTableRow row = dataTable.getRow(i);
                    groups.add(Tools.formatIntegerIfPossible(row.getValue(groupByColumn)));
                }
            }
        }
    }
    if (groups.size() > 0) {
        ExtendedListModel model = new ExtendedListModel();
        for (String group : groups) {
            model.addElement(group, "Select group '" + group + "' for explosion.");
        }
        this.explodingGroupList.setModel(model);
    } else {
        ExtendedListModel model = new ExtendedListModel();
        model.addElement("Specify 'Group By' first...");
        this.explodingGroupList.setModel(model);
    }
}

From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java

@Test
public void testDoHandleListPage04() throws IOException, ServletException {
    this.setUpSecurity();

    SortedSet<SharedBuildNumber> set = new TreeSet<SharedBuildNumber>();
    set.add(new SharedBuildNumber(12));

    expect(this.request.getParameter("action")).andReturn("list");
    expect(this.request.getMethod()).andReturn("POST");
    expect(this.request.getParameter("direction")).andReturn("desc");
    expect(this.request.getParameter("sort")).andReturn("id");
    expect(this.service.getAllSharedBuildNumbersSortedById(true)).andReturn(set);

    replay(this.service, this.request, this.response);

    ModelAndView modelAndView = this.controller.doHandle(this.request, this.response);

    assertNotNull("The model and view should not be null.", modelAndView);
    assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/list.jsp",
            modelAndView.getViewName());

    Map<String, Object> model = modelAndView.getModel();

    assertNotNull("The model should not be null.", model);
    assertEquals("sortedBy is not correct.", "id", model.get("sortedBy"));
    assertEquals("sortClass is not correct.", "sortedDesc", model.get("sortClass"));
    assertEquals("sortChange is not correct.", "asc", model.get("sortChange"));
    assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX,
            model.get("sbnParameterPrefix"));
    assertEquals("numResults is not correct.", 1, model.get("numResults"));
    assertSame("buildNumbers is not correct.", set, model.get("buildNumbers"));
}