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:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java

@Test
public void matchAnyResourceMatchingRuleMatchingLine() {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(5);
    final IssuePattern pattern = new IssuePattern("**/*", "pmd:AbstractClassWithoutAbstractMethod", lines);

    Assert.assertTrue("must match", IgnoreIssueFilter.match(DEFAULT_ISSUE, pattern));
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java

@Test
public void matchMatchingResourceAnyRuleMatchingLine() {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(5);
    final IssuePattern pattern = new IssuePattern("src/main/java/net/example/foo/Bar.java", "*", lines);

    Assert.assertTrue("must match", IgnoreIssueFilter.match(DEFAULT_ISSUE, pattern));
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java

@Test
public void matchMatchingResourceMatchingRuleMatchingLine() {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(5);
    final IssuePattern pattern = new IssuePattern("src/main/java/net/example/foo/Bar.java",
            "pmd:AbstractClassWithoutAbstractMethod", lines);

    Assert.assertTrue("must match", IgnoreIssueFilter.match(DEFAULT_ISSUE, pattern));
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java

@Test
public void matchMatchingResourceMatchingRuleNotMatchingLine() {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(4);
    final IssuePattern pattern = new IssuePattern("src/main/java/net/example/foo/Bar.java",
            "pmd:AbstractClassWithoutAnyMethod", lines);

    Assert.assertFalse("must not match", IgnoreIssueFilter.match(DEFAULT_ISSUE, pattern));
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java

@Test
public void matchMatchingResourceNotMatchingRuleMatchingLine() {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(5);
    final IssuePattern pattern = new IssuePattern("src/main/java/net/example/foo/Bar.java",
            "pmd:AbstractClassWithoutAnyMethod", lines);

    Assert.assertFalse("must not match", IgnoreIssueFilter.match(DEFAULT_ISSUE, pattern));
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilterTest.java

@Test
public void matchNotMatchingResourceMatchingRuleMatchingLine() {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(5);
    final IssuePattern pattern = new IssuePattern("src/main/java/net/example/foo/Foo.java",
            "pmd:AbstractClassWithoutAnyMethod", lines);

    Assert.assertFalse("must not match", IgnoreIssueFilter.match(DEFAULT_ISSUE, pattern));
}

From source file:com.recomdata.export.ExportTable.java

public void setColumns(String patientIds1, String patientIds2) {
    columns.put("Gene", new ExportColumn("Gene", "Gene", "", "t"));

    //      StringTokenizer st1 = new StringTokenizer(patientIds1, ",");
    //      while (st1.hasMoreTokens()) {
    //         String id = st1.nextToken();
    //         String label = "S1_" + id;//(ids1.size() + 1);
    //         ids1.put(id, label);
    //         columns.put(label, new ExportColumn(id, label, RATIO_PATTERN, "n"));
    //      }//from   ww w. j a v a 2s.c  om

    StringTokenizer st1 = new StringTokenizer(patientIds1, ",");
    SortedSet s1 = new TreeSet();
    while (st1.hasMoreTokens()) {
        String id = st1.nextToken();
        s1.add(id);
    }

    for (Object idO : s1.toArray()) {
        String id = idO.toString();
        System.out.println("id: " + id);
        String label = "S1_" + id;//(ids1.size() + 1);
        ids1.put(id, label);
        columns.put(label, new ExportColumn(id, label, RATIO_PATTERN, "n"));
    }

    StringTokenizer st2 = new StringTokenizer(patientIds2, ",");
    while (st2.hasMoreTokens()) {
        String id = st2.nextToken();
        String label = "S2_" + id;//(ids2.size() + 1);
        ids2.put(id, label);
        columns.put(label, new ExportColumn(id, label, RATIO_PATTERN, "n"));
    }
}

From source file:avantssar.aslanpp.testing.DiskSpecificationsProvider.java

public DiskSpecificationsProvider(String baseDirectory) {
    File base = new File(baseDirectory);
    if (!base.exists() || !base.isDirectory()) {
        throw new IllegalArgumentException(
                "Path '" + baseDirectory + "' cannot be accessed or does not point to a directory.");
    }/*  ww  w  .j  a va  2  s  .c  om*/
    IOFileFilter filter = FileFilterUtils.suffixFileFilter(".aslan++");
    IOFileFilter dirFilter = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null));
    Collection<File> specs = FileUtils.listFiles(base, filter, dirFilter);
    List<String> forSort = new ArrayList<String>();
    SortedSet<String> forASLanPath = new TreeSet<String>();
    for (File f : specs) {
        if (isSpec(f)) {
            forSort.add(f.getAbsolutePath());
            forASLanPath.add(f.getParent());
        }
    }
    Collections.sort(forSort);
    for (String s : forSort) {
        add(new DiskTestTask(new File(s)));
    }
    String temp = "";
    for (String s : forASLanPath) {
        if (temp.length() > 0) {
            temp += File.pathSeparator;
        }
        temp += s;
    }
    aslanPath = temp;
}

From source file:com.espertech.esper.filter.TestFilterSpecParamComparator.java

public void testCompareAll() {
    SortedSet<FilterOperator> sorted = new TreeSet<FilterOperator>(comparator);

    for (int i = 0; i < FilterOperator.values().length; i++) {
        FilterOperator op = FilterOperator.values()[i];
        sorted.add(op);
    }/*from   w  w w.java 2 s  .  c  o m*/

    assertEquals(FilterOperator.EQUAL, sorted.first());
    assertEquals(FilterOperator.BOOLEAN_EXPRESSION, sorted.last());
    assertEquals(
            "[EQUAL, IS, IN_LIST_OF_VALUES, RANGE_OPEN, RANGE_HALF_OPEN, RANGE_HALF_CLOSED, RANGE_CLOSED, LESS, LESS_OR_EQUAL, GREATER_OR_EQUAL, GREATER, NOT_RANGE_CLOSED, NOT_RANGE_HALF_CLOSED, NOT_RANGE_HALF_OPEN, NOT_RANGE_OPEN, NOT_IN_LIST_OF_VALUES, NOT_EQUAL, IS_NOT, BOOLEAN_EXPRESSION]",
            sorted.toString());

    log.debug(".testCompareAll " + Arrays.toString(sorted.toArray()));
}

From source file:mas.MAS.java

private static SortedSet<Integer> getAuthorIdsFromPaperAuthorFile(String file) {
    final List<String> lines = IOUtils.readFileLineByLine(file, false);
    SortedSet<Integer> author_ids = new TreeSet<>();
    boolean added = true;
    for (String l : lines) {
        String[] split = l.split("\\t");
        if (split.length > 3) {
            int id = Integer.parseInt(split[2]);
            //                if (id == 4972689) {
            //                    added = true;
            //                }
            if (added) {
                author_ids.add(id);
            }/*from w w w.j  a  va  2s . c  o  m*/
        }
    }
    return author_ids;
}