Search in sources :

Example 31 with Enumeration

use of java.util.Enumeration in project j2objc by google.

the class HashtableTest method test_entrySet.

// BEGIN android-removed
// implementation dependent
//    /**
//     * java.util.Hashtable#elements()
//     */
//    public void test_elements_subtest0() {
//        // this is the reference implementation behavior
//        final Hashtable ht = new Hashtable(7);
//        ht.put("1", "a");
//        // these three elements hash to the same bucket in a 7 element Hashtable
//        ht.put("2", "b");
//        ht.put("9", "c");
//        ht.put("12", "d");
//        // Hashtable looks like:
//        // 0: "1"
//        // 1: "12" -> "9" -> "2"
//        Enumeration en = ht.elements();
//        // cache the first entry
//        en.hasMoreElements();
//        ht.remove("12");
//        ht.remove("9");
//        boolean exception = false;
//        try {
//            // cached "12"
//            Object result = en.nextElement();
//            assertNull("unexpected: " + result, result);
//            // next is removed "9"
//            result = en.nextElement();
//            assertNull("unexpected: " + result, result);
//            result = en.nextElement();
//            assertTrue("unexpected: " + result, "b".equals(result));
//        } catch (NoSuchElementException e) {
//            exception = true;
//        }
//        assertTrue("unexpected NoSuchElementException", !exception);
//    }
// END android-removed
/**
     * java.util.Hashtable#entrySet()
     */
public void test_entrySet() {
    // Test for method java.util.Set java.util.Hashtable.entrySet()
    Set s = ht10.entrySet();
    Set s2 = new HashSet();
    Iterator i = s.iterator();
    while (i.hasNext()) s2.add(((Map.Entry) i.next()).getValue());
    Enumeration e = elmVector.elements();
    while (e.hasMoreElements()) assertTrue("Returned incorrect entry set", s2.contains(e.nextElement()));
    // BEGIN android-removed
    // implementation dependent
    //        assertEquals("Not synchronized",
    //                "java.util.Collections$SynchronizedSet", s.getClass().getName());
    // END android-removed
    boolean exception = false;
    try {
        ((Map.Entry) ht10.entrySet().iterator().next()).setValue(null);
    } catch (NullPointerException e1) {
        exception = true;
    }
    assertTrue("Should not be able to assign null to a Hashtable entrySet() Map.Entry", exception);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Enumeration(java.util.Enumeration) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 32 with Enumeration

use of java.util.Enumeration in project j2objc by google.

the class HashtableTest method test_putAllLjava_util_Map.

/**
     * java.util.Hashtable#putAll(java.util.Map)
     */
public void test_putAllLjava_util_Map() {
    // Test for method void java.util.Hashtable.putAll(java.util.Map)
    Hashtable h = new Hashtable();
    h.putAll(ht10);
    Enumeration e = keyVector.elements();
    while (e.hasMoreElements()) {
        Object x = e.nextElement();
        assertTrue("Failed to put all elements", h.get(x).equals(ht10.get(x)));
    }
    try {
        h.putAll(null);
        fail("NullPointerException expected");
    } catch (NullPointerException ee) {
    //expected
    }
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable)

Example 33 with Enumeration

use of java.util.Enumeration in project j2objc by google.

the class HashtableTest method test_clear.

/**
     * java.util.Hashtable#clear()
     */
public void test_clear() {
    // Test for method void java.util.Hashtable.clear()
    Hashtable h = hashtableClone(htfull);
    h.clear();
    assertEquals("Hashtable was not cleared", 0, h.size());
    Enumeration el = h.elements();
    Enumeration keys = h.keys();
    assertTrue("Hashtable improperly cleared", !el.hasMoreElements() && !(keys.hasMoreElements()));
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable)

Example 34 with Enumeration

use of java.util.Enumeration in project j2objc by google.

the class ElemTemplateElement method setPrefixes.

/**
   * Copy the namespace declarations from the NamespaceSupport object.  
   * Take care to call resolveInheritedNamespaceDecls.
   * after all namespace declarations have been added.
   *
   * @param nsSupport non-null reference to NamespaceSupport from 
   * the ContentHandler.
   * @param excludeXSLDecl true if XSLT namespaces should be ignored.
   *
   * @throws TransformerException
   */
public void setPrefixes(NamespaceSupport nsSupport, boolean excludeXSLDecl) throws TransformerException {
    Enumeration decls = nsSupport.getDeclaredPrefixes();
    while (decls.hasMoreElements()) {
        String prefix = (String) decls.nextElement();
        if (null == m_declaredPrefixes)
            m_declaredPrefixes = new ArrayList();
        String uri = nsSupport.getURI(prefix);
        if (excludeXSLDecl && uri.equals(Constants.S_XSLNAMESPACEURL))
            continue;
        // System.out.println("setPrefixes - "+prefix+", "+uri);
        XMLNSDecl decl = new XMLNSDecl(prefix, uri, false);
        m_declaredPrefixes.add(decl);
    }
}
Also used : Enumeration(java.util.Enumeration) ArrayList(java.util.ArrayList)

Example 35 with Enumeration

use of java.util.Enumeration in project j2objc by google.

the class TemplateList method dumpAssociationTables.

/**
   * Dump all patterns and elements that match those patterns
   *
   */
void dumpAssociationTables() {
    Enumeration associations = m_patternTable.elements();
    while (associations.hasMoreElements()) {
        TemplateSubPatternAssociation head = (TemplateSubPatternAssociation) associations.nextElement();
        while (null != head) {
            System.out.print("(" + head.getTargetString() + ", " + head.getPattern() + ")");
            head = head.getNext();
        }
        System.out.println("\n.....");
    }
    TemplateSubPatternAssociation head = m_wildCardPatterns;
    System.out.print("wild card list: ");
    while (null != head) {
        System.out.print("(" + head.getTargetString() + ", " + head.getPattern() + ")");
        head = head.getNext();
    }
    System.out.println("\n.....");
}
Also used : Enumeration(java.util.Enumeration)

Aggregations

Enumeration (java.util.Enumeration)1418 IOException (java.io.IOException)247 ArrayList (java.util.ArrayList)183 File (java.io.File)122 Vector (java.util.Vector)98 Properties (java.util.Properties)97 HashMap (java.util.HashMap)96 List (java.util.List)89 URL (java.net.URL)74 HashSet (java.util.HashSet)71 Map (java.util.Map)71 Hashtable (java.util.Hashtable)70 Iterator (java.util.Iterator)70 Set (java.util.Set)67 InputStream (java.io.InputStream)62 ZipEntry (java.util.zip.ZipEntry)62 ServletContext (javax.servlet.ServletContext)55 ZipFile (java.util.zip.ZipFile)51 FileInputStream (java.io.FileInputStream)48 ServletException (javax.servlet.ServletException)46