Example usage for org.apache.commons.vfs2.provider UriParser encode

List of usage examples for org.apache.commons.vfs2.provider UriParser encode

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.provider UriParser encode.

Prototype

public static String[] encode(final String[] strings) 

Source Link

Document

Encode an array of Strings.

Usage

From source file:com.github.junrar.vfs2.provider.rar.RARFileSystem.java

@Override
public void init() throws FileSystemException {
    super.init();

    try {//from   ww w .  j av  a  2 s  .  c  o  m
        try {
            archive = new Archive(new VFSVolumeManager(parentLayer));
            // Build the index
            List<RARFileObject> strongRef = new ArrayList<RARFileObject>(100);
            for (final FileHeader header : archive.getFileHeaders()) {
                AbstractFileName name = (AbstractFileName) getFileSystemManager().resolveName(getRootName(),
                        UriParser.encode(header.getFileNameString()));

                // Create the file
                RARFileObject fileObj;
                if (header.isDirectory() && getFileFromCache(name) != null) {
                    fileObj = (RARFileObject) getFileFromCache(name);
                    fileObj.setHeader(header);
                    continue;
                }

                fileObj = createRARFileObject(name, header);
                putFileToCache(fileObj);
                strongRef.add(fileObj);
                fileObj.holdObject(strongRef);

                // Make sure all ancestors exist
                RARFileObject parent;
                for (AbstractFileName parentName = (AbstractFileName) name
                        .getParent(); parentName != null; fileObj = parent, parentName = (AbstractFileName) parentName
                                .getParent()) {
                    // Locate the parent
                    parent = (RARFileObject) getFileFromCache(parentName);
                    if (parent == null) {
                        parent = createRARFileObject(parentName, null);
                        putFileToCache(parent);
                        strongRef.add(parent);
                        parent.holdObject(strongRef);
                    }

                    // Attach child to parent
                    parent.attachChild(fileObj.getName());
                }
            }

        } catch (RarException e) {
            throw new FileSystemException(e);
        } catch (IOException e) {
            throw new FileSystemException(e);
        }
    } finally {
        // closeCommunicationLink();
    }
}

From source file:com.github.songsheng.vfs2.provider.nfs.NfsFileObject.java

/**
 * Lists the children of the file.  Is only called if {@link #doGetType}
 * returns {@link FileType#FOLDER}./*from   ww w .ja  va  2  s  .  c o m*/
 */
@Override
protected String[] doListChildren() throws Exception {
    // VFS-210: do not try to get listing for anything else than directories
    if (!file.isDirectory()) {
        return null;
    }

    return UriParser.encode(file.list());
}

From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GsiFtpFileObject.java

/**
 * Lists the children of the file./*from w  w w.  j  a  v  a2  s  . co  m*/
 * 
 * @return the string[]
 * 
 * @throws Exception the exception
 */
@Override
protected String[] doListChildren() throws Exception {
    // List the children of this file
    doGetChildren();

    // TODO - get rid of this children stuff
    final String[] childNames = new String[children.size()];
    int childNum = -1;
    Iterator iterChildren = children.values().iterator();

    while (iterChildren.hasNext()) {
        childNum++;
        final FileInfo child = (FileInfo) iterChildren.next();
        childNames[childNum] = child.getName();
    }

    return UriParser.encode(childNames);
}

From source file:org.ysb33r.groovy.vfsplugin.cpio.CpioFileSystem.java

@Override
public void init() throws FileSystemException {
    super.init();

    // Build the index
    try {/*from  ww w.  j a v a2 s  .  c  o m*/
        final List<CpioFileObject> strongRef = new ArrayList<CpioFileObject>(DEFAULT_INDEX_SIZE);
        CpioArchiveEntry entry;

        while ((entry = getCpioFile().getNextCPIOEntry()) != null) {
            final AbstractFileName name = (AbstractFileName) getFileSystemManager().resolveName(getRootName(),
                    UriParser.encode(entry.getName()));

            // Create the file
            CpioFileObject fileObj;
            if (entry.isDirectory() && getFileFromCache(name) != null) {
                fileObj = (CpioFileObject) getFileFromCache(name);
                fileObj.setCpioEntry(entry);
                continue;
            }

            fileObj = createCpioFileObject(name, entry);
            putFileToCache(fileObj);
            strongRef.add(fileObj);
            fileObj.holdObject(strongRef);

            // Make sure all ancestors exist
            // TODO - create these on demand
            CpioFileObject parent = null;
            for (AbstractFileName parentName = (AbstractFileName) name
                    .getParent(); parentName != null; fileObj = parent, parentName = (AbstractFileName) parentName
                            .getParent()) {
                // Locate the parent
                parent = (CpioFileObject) getFileFromCache(parentName);
                if (parent == null) {
                    parent = createCpioFileObject(parentName, null);
                    putFileToCache(parent);
                    strongRef.add(parent);
                    parent.holdObject(strongRef);
                }

                // Attach child to parent
                parent.attachChild(fileObj.getName());
            }
        }
    } catch (final IOException e) {
        throw new FileSystemException(e);
    } finally {
        closeCommunicationLink();
    }
}