NamespaceSupport getPrefixes - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for NamespaceSupport getPrefixes method.

This code example shows how to use the following methods:getPrefixes
 
    @SuppressWarnings("unchecked") 
    public void testGetPrefixesLjava_lang_String() { 
        ArrayList<String> prefixes;
 
        prefixes = Collections.list(ns.getPrefixes(marketUri));
        assertTrue("Test 1: Incorrect set of prefixes returned.",
                expected.containsAll(prefixes) && prefixes.containsAll(expected));
 
        prefixes = Collections.list(ns.getPrefixes(defaultUri));
        assertTrue("Test 2: Default namespace prefix should not be returned.",
                prefixes.size() == 0);
 
        prefixes = Collections.list(ns.getPrefixes(NamespaceSupport.XMLNS));
        assertTrue("Test 3: xml prefix is missing.",
                prefixes.contains("xml") && prefixes.size() == 1);
 
        prefixes = Collections.list(ns.getPrefixes(defaultUri + "/42"));
        assertTrue("Test 4: Non-empty enumeration returned for an unassigned URI.",
                prefixes.size() == 0);

8
CodeRank
This code example shows how to use the following methods:getPrefixes
 
    @SuppressWarnings("unchecked") 
    public void testGetPrefixesLjava_lang_String() { 
        ArrayList<String> prefixes;
 
        prefixes = Collections.list(ns.getPrefixes(marketUri));
        assertTrue("Test 1: Incorrect set of prefixes returned.",
                expected.containsAll(prefixes) && prefixes.containsAll(expected));
 
        prefixes = Collections.list(ns.getPrefixes(defaultUri));
        assertTrue("Test 2: Default namespace prefix should not be returned.",
                prefixes.size() == 0);
 
        prefixes = Collections.list(ns.getPrefixes(NamespaceSupport.XMLNS));
        assertTrue("Test 3: xml prefix is missing.",
                prefixes.contains("xml") && prefixes.size() == 1);
 
        prefixes = Collections.list(ns.getPrefixes(defaultUri + "/42"));
        assertTrue("Test 4: Non-empty enumeration returned for an unassigned URI.",
                prefixes.size() == 0);

6
CodeRank
This code example shows how to use the following methods:getPrefixes
    public String getPrefix(String namespaceURI) {
        return namespaceSupport.getPrefix(namespaceURI);
    } 
 
    public Iterator getPrefixes(String namespaceURI) {
        final Enumeration e = namespaceSupport.getPrefixes(namespaceURI);
 
        return new Iterator() {
                public void remove() { 
                    throw new UnsupportedOperationException();
                } 
 
                public boolean hasNext() { 
                    return e.hasMoreElements();
                } 
 
                public Object next() {
                    return e.nextElement();
                } 
            }; 
4
CodeRank
getPrefixes Method Overview
Return an enumeration of all prefixes whose declarations are active in the current context.
See Code Examples for other Java 8 NamespaceSupport Methods: