Package org.apache.commons.collections4

Examples of org.apache.commons.collections4.SortedBag


    public Bag makeBag() {
        return new TreeBag();
    }

    public SortedBag setupBag() {
        SortedBag bag = (SortedBag) makeBag();
        bag.add("C");
        bag.add("A");
        bag.add("B");
        bag.add("D");
        return bag;
    }
View Full Code Here


    }
   
    //--------------------------------------------------------------------------
   
    public void testDecorate() {
        SortedBag bag = decorateBag(new TreeBag(), stringClass);
        try {
            SortedBag bag3 = decorateBag(new TreeBag(), null);
            fail("Expecting IllegalArgumentException for null predicate");
        } catch (IllegalArgumentException e) {
        }
        try {
            SortedBag bag4 = decorateBag(nullBag, stringClass);
            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

        } catch (IllegalArgumentException e) {
        }
    }

    public void testSortOrder() {
        SortedBag bag = decorateBag(new TreeBag(), stringClass);
        String one = "one";
        String two = "two";
        String three = "three";
        bag.add(one);
        bag.add(two);
        bag.add(three);
        assertEquals("first element", bag.first(), one);
        assertEquals("last element", bag.last(), two);
        Comparator c = bag.comparator();
        assertTrue("natural order, so comparator should be null", c == null);
    }
View Full Code Here

    }
   
    //--------------------------------------------------------------------------
   
    public void testDecorate() {
        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
        SortedBag bag2 = ((PredicatedSortedBag) bag).getSortedBag();
        try {
            SortedBag bag3 = decorateBag(new TreeBag(), null);
            fail("Expecting IllegalArgumentException for null predicate");
        } catch (IllegalArgumentException e) {
        }
        try {
            SortedBag bag4 = decorateBag(nullBag, stringPredicate());
            fail("Expecting IllegalArgumentException for null bag");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

        } catch (IllegalArgumentException e) {
        }
    }

    public void testSortOrder() {
        SortedBag bag = decorateBag(new TreeBag(), stringPredicate());
        String one = "one";
        String two = "two";
        String three = "three";
        bag.add(one);
        bag.add(two);
        bag.add(three);
        assertEquals("first element", bag.first(), one);
        assertEquals("last element", bag.last(), two);
        Comparator c = bag.comparator();
        assertTrue("natural order, so comparator should be null", c == null);
    }
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

TOP

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

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.