Examples of HashBag


Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testPredicatedBag() {
        Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate);
        assertTrue("Returned object should be a PredicatedBag.",
            bag instanceof PredicatedBag);
        try {
            bag = BagUtils.predicatedBag(null,truePredicate);
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.predicatedBag(new HashBag(), null);
            fail("Expecting IllegalArgumentException for null predicate.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testTypedBag() {
        Bag bag = BagUtils.typedBag(new HashBag(), stringClass);     
        assertTrue("Returned object should be a TypedBag.",
            bag instanceof PredicatedBag);
        try {
            bag = BagUtils.typedBag(null, stringClass);
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.typedBag(new HashBag(), null);
            fail("Expecting IllegalArgumentException for null type.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
     public void testTransformedBag() {
        Bag bag = BagUtils.transformedBag(new HashBag(), nopTransformer);     
        assertTrue("Returned object should be an TransformedBag.",
            bag instanceof TransformedBag);
        try {
            bag = BagUtils.transformedBag(null, nopTransformer);     
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.transformedBag(new HashBag(), null)
            fail("Expecting IllegalArgumentException for null transformer.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

        assertEquals(0, CollectionUtils.cardinality("B", set));
        assertEquals(1, CollectionUtils.cardinality("C", set));
        assertEquals(0, CollectionUtils.cardinality("D", set));
        assertEquals(1, CollectionUtils.cardinality("E", set));

        Bag bag = new HashBag();
        bag.add("A", 3);
        bag.add("C");
        bag.add("E");
        bag.add("E");
        assertEquals(3, CollectionUtils.cardinality("A", bag));
        assertEquals(0, CollectionUtils.cardinality("B", bag));
        assertEquals(1, CollectionUtils.cardinality("C", bag));
        assertEquals(0, CollectionUtils.cardinality("D", bag));
        assertEquals(2, CollectionUtils.cardinality("E", bag));
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

        // Enumeration, non-existent entry -- "dead" enumerator returned
        test = CollectionUtils.index(en,3);
        assertTrue(test.equals(en) && !en.hasMoreElements());
       
        // Collection, entry exists
        Bag bag = new HashBag();
        bag.add("element", 1);
        test = CollectionUtils.index(bag, 0);
        assertTrue(test.equals("element"));
       
        // Collection, non-existent entry -- "dead" iterator returned
        test = CollectionUtils.index(bag, 2);
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            assertTrue(!en.hasMoreElements());
        }
       
        {
            // Collection, entry exists
            Bag bag = new HashBag();
            bag.add("element", 1);
            assertEquals("element",CollectionUtils.get(bag, 0));
       
            // Collection, non-existent entry
            try {
                CollectionUtils.get(bag, 1);
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

{
    public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
    {
        List entries = jarAnalyzer.getEntries();
        SimpleDateFormat tsformat = new SimpleDateFormat( "yyyyMMdd", Locale.US ); //$NON-NLS-1$
        Bag timestamps = new HashBag();
        Iterator it = entries.iterator();
        while ( it.hasNext() )
        {
            JarEntry entry = (JarEntry) it.next();
            long time = entry.getTime();
            String timestamp = tsformat.format( new Date( time ) );
            timestamps.add( timestamp );
        }

        it = timestamps.iterator();
        String ts = "";
        int tsmax = 0;
        while ( it.hasNext() )
        {
            String timestamp = (String) it.next();
            int count = timestamps.getCount( timestamp );
            if ( count > tsmax )
            {
                ts = timestamp;
                tsmax = count;
            }
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

    protected Transformer nopTransformer = TransformerUtils.nopTransformer();
   
    //----------------------------------------------------------------------
   
    public void testSynchronizedBag() {
        Bag bag = BagUtils.synchronizedBag(new HashBag());
        assertTrue("Returned object should be a SynchronizedBag.",
            bag instanceof SynchronizedBag);
        try {
            bag = BagUtils.synchronizedBag(null);
            fail("Expecting IllegalArgumentException for null bag.");
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testUnmodifiableBag() {
        Bag bag = BagUtils.unmodifiableBag(new HashBag());
        assertTrue("Returned object should be an UnmodifiableBag.",
            bag instanceof UnmodifiableBag);
        try {
            bag = BagUtils.unmodifiableBag(null);
            fail("Expecting IllegalArgumentException for null bag.");
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testPredicatedBag() {
        Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate);
        assertTrue("Returned object should be a PredicatedBag.",
            bag instanceof PredicatedBag);
        try {
            bag = BagUtils.predicatedBag(null,truePredicate);
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.predicatedBag(new HashBag(), null);
            fail("Expecting IllegalArgumentException for null predicate.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.