Package java.util

Examples of java.util.Collection.clear()


    // optional operation
    public void testCollectionClear() {
        Collection c = makeCollection();
        boolean cleared = false;
        try {
            c.clear();
            cleared = true;
        } catch(UnsupportedOperationException e) {
            // ignored, must not be supported
        } catch(Throwable t) {
            t.printStackTrace();
View Full Code Here


        if(added) {
            assertTrue("After element is added, Collection.isEmpty() should be false.",!c.isEmpty());
            boolean cleared2 = false;
            try {
                c.clear();
                cleared2 = true;
            } catch(UnsupportedOperationException e) {
                // ignored, must not be supported
            } catch(Throwable t) {
                t.printStackTrace();
View Full Code Here

        em = emf.createEntityManager();
        pc = em.find(ManagedIface.class, oid);
        set = pc.getSetPC();
        assertEquals(4, set.size());
        seen.clear();
        for (Iterator it = set.iterator(); it.hasNext();) {
            rel = (SimpleEntity) it.next();
            seen.add(rel.getName());
        }
        assertEquals(4, seen.size());
View Full Code Here

     */
    if (supportsMultiple)
    {
      Collection modelCollection = (Collection)object;
      modelChanging();
      modelCollection.clear();
      if (converted != null)
      {
        modelCollection.addAll((Collection)converted);
      }
      modelChanged();
View Full Code Here

        conf.addProperty("testAddNodes.property(-1)[@name]", "prop2");
        conf.addProperty("testAddNodes.property(1).value", "value2");
        Collection nodes = new ArrayList();
        nodes.add(new HierarchicalConfiguration.Node("property"));
        conf.addNodes("testAddNodes", nodes);
        nodes.clear();
        ConfigurationNode nd = new HierarchicalConfiguration.Node("name",
                "prop3");
        nd.setAttribute(true);
        nodes.add(nd);
        conf.addNodes("testAddNodes.property(2)", nodes);
View Full Code Here

        ValueMetaData vmd = fmd.getElement();
        if (!vmd.isDeclaredTypePC())
            return coll;

        // unfortunately we have to clear the original and re-add
        coll.clear();
        Object elem;
        for (Iterator itr = orig.iterator(); itr.hasNext();) {
            if (vmd.getCascadeAttach() == ValueMetaData.CASCADE_NONE)
                elem = getReference(manager, itr.next(), sm, vmd);
            else
View Full Code Here

        Collection value = asCollection(propValue, descriptor.getPropertyType());
        Collection collection = (Collection)get(targetBean);

        // Now add our our object to the collection
        collection.clear();
        if (propValue != null) {
            collection.addAll(value);
        }
    }
View Full Code Here

        // all JDK-Collections are cloneable ...
        // and if the collection is not clonable, then we should throw
        // a CloneNotSupportedException anyway ...
        final Collection result
            = (Collection) ObjectUtilities.clone(collection);
        result.clear();
        final Iterator iterator = collection.iterator();
        while (iterator.hasNext()) {
            final Object item = iterator.next();
            if (item != null) {
                result.add(clone(item));
View Full Code Here

      findUnlinkedDirs(rootDir, installer.getOptions(), result);
    }
    catch (ScanFailedException e) {
      System.out.println("Abort scan for unlinked installations because exception occurred");
      e.printStackTrace();
      result.clear();
    }
    StringBuffer buf = new StringBuffer(result.size() * 40);
    for (Iterator iter = result.iterator(); iter.hasNext();) {
      File installDir = (File) iter.next();
      if (buf.length() > 0)
View Full Code Here

    public final void testValues() {
        p.put("MessageDigest.SHA-256", "aaa.bbb.ccc.ddd");
       
        Collection c = p.values();
        try {
            c.clear();
        } catch (UnsupportedOperationException e) {
        }
        Collection c1 = p.values();
        if ((c == c1) || c1.isEmpty() ) {
            fail("Must return unmodifiable set");
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.