Package org.apache.commons.collections4

Examples of org.apache.commons.collections4.OrderedMapIterator


            return;
        }

        super.testEmptyMapIterator();

        OrderedMapIterator it = makeEmptyOrderedMapIterator();
        Map map = getMap();
        assertEquals(false, it.hasPrevious());
        try {
            it.previous();
            fail();
        } catch (NoSuchElementException ex) {
        }
    }
View Full Code Here


            return;
        }

        super.testFullMapIterator();

        OrderedMapIterator it = makeFullOrderedMapIterator();
        Map map = getMap();

        assertEquals(true, it.hasNext());
        assertEquals(false, it.hasPrevious());
        Set set = new HashSet();
        while (it.hasNext()) {
            // getKey
            Object key = it.next();
            assertSame("it.next() should equals getKey()", key, it.getKey());
            assertTrue("Key must be in map", map.containsKey(key));
            assertTrue("Key must be unique", set.add(key));
           
            // getValue
            Object value = it.getValue();
            if (isGetStructuralModify() == false) {
                assertSame("Value must be mapped to key", map.get(key), value);
            }
            assertTrue("Value must be in map", map.containsValue(value));

            assertEquals(true, it.hasPrevious());

            verify();
        }
        while (it.hasPrevious()) {
            // getKey
            Object key = it.previous();
            assertSame("it.previous() should equals getKey()", key, it.getKey());
            assertTrue("Key must be in map", map.containsKey(key));
            assertTrue("Key must be unique", set.remove(key));
           
            // getValue
            Object value = it.getValue();
            if (isGetStructuralModify() == false) {
                assertSame("Value must be mapped to key", map.get(key), value);
            }
            assertTrue("Value must be in map", map.containsValue(value));

            assertEquals(true, it.hasNext());

            verify();
        }
    }
View Full Code Here

    public void testMapIteratorOrder() {
        if (supportsFullIterator() == false) {
            return;
        }

        OrderedMapIterator it = makeFullOrderedMapIterator();
        Map map = getMap();

        assertEquals("keySet() not consistent", new ArrayList(map.keySet()), new ArrayList(map.keySet()));

        Iterator it2 = map.keySet().iterator();
        assertEquals(true, it.hasNext());
        assertEquals(true, it2.hasNext());
        List list = new ArrayList();
        while (it.hasNext()) {
            Object key = it.next();
            assertEquals(it2.next(), key);
            list.add(key);
        }
        assertEquals(map.size(), list.size());
        while (it.hasPrevious()) {
            Object key = it.previous();
            assertEquals(list.get(list.size() - 1), key);
            list.remove(list.size() - 1);
        }
        assertEquals(0, list.size());
    }
View Full Code Here

    public void testOrderedMapIterator() {
        assertTrue(makeEmptyOrderedMapIterator() instanceof Unmodifiable);
    }

    public void testDecorateFactory() {
        OrderedMapIterator it = makeFullOrderedMapIterator();
        assertSame(it, UnmodifiableOrderedMapIterator.decorate(it));

        it = ((OrderedMap) getMap()).orderedMapIterator();
        assertTrue(it != UnmodifiableOrderedMapIterator.decorate(it));
View Full Code Here

  }

  //loads the files and removes words which occur less than 5 tims
  public void loadProgram() throws FileNotFoundException
  {
    Bag wordBag = new HashBag();

    //Load all the medical files in the directory
    File[] fileList = new File(recordsDir).listFiles();
    for (int i = 0; i<fileList.length; i++) {
      loadFile(fileList[i].toString(), wordBag);
    }

    //dump bag into frequent who appear in 5 or more medical records
    for (Object obj : wordBag.uniqueSet()) {
      if (wordBag.getCount(obj) > 4){
        frequent.add((String)obj);
      }
    }

  }
View Full Code Here

     * @param object  the input object
     * @return never
     * @throws FunctorException always
     */
    public boolean evaluate(final T object) {
        throw new FunctorException("ExceptionPredicate invoked");
    }
View Full Code Here

     *
     * @return never
     * @throws FunctorException always
     */
    public T create() {
        throw new FunctorException("ExceptionFactory invoked");
    }
View Full Code Here

        public T create() {
            try {
                return clazz.newInstance();
            } catch (final Exception ex) {
                throw new FunctorException("Cannot instantiate class: " + clazz, ex);
            }
        }
View Full Code Here

        try {
            final Class<?> cls = input.getClass();
            final Method method = cls.getMethod(iMethodName, iParamTypes);
            return (O) method.invoke(input, iArgs);
        } catch (final NoSuchMethodException ex) {
            throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
                                       input.getClass() + "' does not exist");
        } catch (final IllegalAccessException ex) {
            throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
                                       input.getClass() + "' cannot be accessed");
        } catch (final InvocationTargetException ex) {
            throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
                                       input.getClass() + "' threw an exception", ex);
        }
    }
View Full Code Here

     * @param input  the input object to transform
     * @return never
     * @throws FunctorException always
     */
    public O transform(final I input) {
        throw new FunctorException("ExceptionTransformer invoked");
    }
View Full Code Here

TOP

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

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.