public IrodsCollection asCollection() throws IrodsException {
        if (exists()) {
            if (irodsFile.isDirectory()) {
                return (this instanceof JargonCollection) ? (IrodsCollection) this : new JargonCollection(conn, irodsFile);
            } else {
                throw new IrodsException("irods object already exists and is not a collection: " + getFullPath());
            }
        } else {
            return new JargonCollection(conn, irodsFile);
        }
    }