Package org.apache.commons.collections4

Examples of org.apache.commons.collections4.Predicate




    //put entries in bag to get count
    String entryBuilder;
    Bag <String> bagOfEntries = new <String>HashBag();
    for (ArrayList<String> temp : output)
    {
      entryBuilder = "";
      for (String tempWord : temp)
      {
        String scrap = tempWord + " ";
        entryBuilder += scrap;
      }
      bagOfEntries.add(entryBuilder);
    }

    //make a map with values - count and keys - string and sort by frequency
    Map<String, Integer> frequentWords = new <String, Integer>HashMap();
    for (String pattern : bagOfEntries.uniqueSet()) {
      frequentWords.put(pattern, bagOfEntries.getCount(pattern));
    }
    Map.Entry<String, Integer>[] entries = frequentWords.entrySet().toArray(new Map.Entry[0]);
    Arrays.sort(entries, new Comparator<Map.Entry<String, Integer>>() {
        public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
          return o2.getValue().compareTo(o1.getValue());
View Full Code Here


    // collections testing framework
    // ------------------------------------------------------------------------

    @Override
    public Comparator<Boolean> makeObject() {
        return new BooleanComparator();
    }
View Full Code Here

    // tests
    // ------------------------------------------------------------------------

    @Test
    public void testConstructors() {
        allTests(false,new BooleanComparator());
        allTests(false,new BooleanComparator(false));
        allTests(true,new BooleanComparator(true));
    }
View Full Code Here

        allTests(true,BooleanComparator.booleanComparator(true));
    }

    @Test
    public void testEqualsCompatibleInstance() {
        assertEquals(new BooleanComparator(),new BooleanComparator(false));
        assertEquals(new BooleanComparator(false),new BooleanComparator(false));
        assertEquals(new BooleanComparator(false),BooleanComparator.getFalseFirstComparator());
        assertSame(BooleanComparator.getFalseFirstComparator(),BooleanComparator.booleanComparator(false));

        assertEquals(new BooleanComparator(true),new BooleanComparator(true));
        assertEquals(new BooleanComparator(true),BooleanComparator.getTrueFirstComparator());
        assertSame(BooleanComparator.getTrueFirstComparator(),BooleanComparator.booleanComparator(true));

        assertTrue(!new BooleanComparator().equals(new BooleanComparator(true)));
        assertTrue(!new BooleanComparator(true).equals(new BooleanComparator(false)));
    }
View Full Code Here

                return 0;
            }
        };

        if (createIteratorWithStandardConstr) {
            return new NodeListIterator(emptyNodeList);
        } else {
            final Node parentNode = createMock(Node.class);
            expect(parentNode.getChildNodes()).andStubReturn(emptyNodeList);
            replay(parentNode);

            return new NodeListIterator(parentNode);
        }
    }
View Full Code Here

            public int getLength() {
                return nodes.length;
            }
        };

        return new NodeListIterator(nodeList);
    }
View Full Code Here

    }

    //-----------------------------------------------------------------------
    public void testNullConstructor(){
        try{
            new NodeListIterator((Node) null);
            fail("IllegalArgumentException expected!");
        }catch(final IllegalArgumentException e){
            // expected.
        }
    }
View Full Code Here

     */
    public static NodeListIterator nodeListIterator(final NodeList nodeList) {
        if (nodeList == null) {
            throw new NullPointerException("NodeList must not be null");
        }
        return new NodeListIterator(nodeList);
    }
View Full Code Here

     */
    public static NodeListIterator nodeListIterator(final Node node) {
        if (node == null) {
            throw new NullPointerException("Node must not be null");
        }
        return new NodeListIterator(node);
    }
View Full Code Here

        }
        if (obj instanceof Map) {
            return ((Map<?, ?>) obj).values().iterator();
        }
        if (obj instanceof NodeList) {
            return new NodeListIterator((NodeList) obj);
        }
        if (obj instanceof Node) {
            return new NodeListIterator((Node) obj);
        }
        if (obj instanceof Dictionary) {
            return new EnumerationIterator<Object>(((Dictionary<?, ?>) obj).elements());
        } else if (obj.getClass().isArray()) {
            return new ArrayIterator<Object>(obj);
View Full Code Here

TOP

Related Classes of org.apache.commons.collections4.Predicate

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.