Package org.apache.commons.collections4.keyvalue

Examples of org.apache.commons.collections4.keyvalue.MultiKey


        try {
            map.put(null, null);
            fail();
        } catch (NullPointerException ex) {
        }
        assertEquals(null, map.put(new MultiKey(null, null), null));
        try {
            map.put(null, new Object());
            fail();
        } catch (NullPointerException ex) {
        }
View Full Code Here


        MultiKeyMap multimap = (MultiKeyMap) map;
        MultiKey[] keys = getMultiKeyKeys();
        Object[] values = getSampleValues();

        for (int i = 0; i < keys.length; i++) {
            MultiKey key = keys[i];
            Object value = values[i];

            switch (key.size()) {
                case 2:
                    assertEquals(value, multimap.get(key.getKey(0), key.getKey(1)));
                    assertEquals(null, multimap.get(null, key.getKey(1)));
                    assertEquals(null, multimap.get(key.getKey(0), null));
                    assertEquals(null, multimap.get(null, null));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), null));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), null, null));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), null, null, null));
                    break;
                case 3:
                    assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2)));
                    assertEquals(null, multimap.get(null, key.getKey(1), key.getKey(2)));
                    assertEquals(null, multimap.get(key.getKey(0), null, key.getKey(2)));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), null));
                    assertEquals(null, multimap.get(null, null, null));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), null));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), null, null));
                    break;
                case 4:
                    assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
                    assertEquals(null, multimap.get(null, key.getKey(1), key.getKey(2), key.getKey(3)));
                    assertEquals(null, multimap.get(key.getKey(0), null, key.getKey(2), key.getKey(3)));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), null, key.getKey(3)));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), null));
                    assertEquals(null, multimap.get(null, null, null, null));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), null));
                    break;
                case 5:
                    assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
                    assertEquals(null, multimap.get(null, key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
                    assertEquals(null, multimap.get(key.getKey(0), null, key.getKey(2), key.getKey(3), key.getKey(4)));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), null, key.getKey(3), key.getKey(4)));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), null, key.getKey(4)));
                    assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), null));
                    assertEquals(null, multimap.get(null, null, null, null, null));
                    break;
                default:
                    fail("Invalid key size");
            }
View Full Code Here

     * @param entry the entry to compare to
     * @param keys  the keys
     * @return true if the key matches
     */
    protected boolean isEqualKey(AbstractHashedMap.HashEntry<MultiKey<K>, V> entry, K... keys) {
        MultiKey multi = (MultiKey) entry.getKey();
        if (multi.size() != keys.length) {
            return false;
        } else {
            for (int i = 0; i < keys.length; i++) {
                K key = keys[i];
                if ((key == null ? multi.getKey(i) != null : !key.equals(multi.getKey(i)))) {
                    return false;
                }
            }
        }
        return true;
View Full Code Here

     */
    public boolean removeAll(Object key1) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 1 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
View Full Code Here

     */
    public boolean removeAll(Object key1, Object key2) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 2 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
View Full Code Here

     */
    public boolean removeAll(Object key1, Object key2, Object key3) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 3 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) && (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
View Full Code Here

     */
    public boolean removeAll(Object key1, Object key2, Object key3, Object key4) {
        boolean modified = false;
        MapIterator it = mapIterator();
        while (it.hasNext()) {
            MultiKey multi = (MultiKey) it.next();
            if (multi.size() >= 4 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) && (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) && (key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)))) {
                it.remove();
                modified = true;
            }
        }
        return modified;
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

TOP

Related Classes of org.apache.commons.collections4.keyvalue.MultiKey

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.