Search in sources :

Example 1 with UEncoder

use of org.apache.tomcat.util.buf.UEncoder in project tomcat70 by apache.

the class DirContextURLConnection method list.

// --------------------------------------------------------- Public Methods
/**
 * List children of this collection. The names given are relative to this
 * URI's path. The full uri of the children is then : path + "/" + name.
 */
public Enumeration<String> list() throws IOException {
    if (!connected) {
        connect();
    }
    if ((resource == null) && (collection == null)) {
        throw new FileNotFoundException(getURL() == null ? "null" : getURL().toString());
    }
    Vector<String> result = new Vector<String>();
    if (collection != null) {
        try {
            NamingEnumeration<NameClassPair> enumeration = collection.list("/");
            UEncoder urlEncoder = new UEncoder(UEncoder.SafeCharsSet.WITH_SLASH);
            while (enumeration.hasMoreElements()) {
                NameClassPair ncp = enumeration.nextElement();
                String s = ncp.getName();
                result.addElement(urlEncoder.encodeURL(s, 0, s.length()).toString());
            }
        } catch (NamingException e) {
            // Unexpected exception
            throw new FileNotFoundException(getURL() == null ? "null" : getURL().toString());
        }
    }
    return result.elements();
}
Also used : NameClassPair(javax.naming.NameClassPair) FileNotFoundException(java.io.FileNotFoundException) UEncoder(org.apache.tomcat.util.buf.UEncoder) NamingException(javax.naming.NamingException) Vector(java.util.Vector)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 Vector (java.util.Vector)1 NameClassPair (javax.naming.NameClassPair)1 NamingException (javax.naming.NamingException)1 UEncoder (org.apache.tomcat.util.buf.UEncoder)1