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

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

Introduction

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

Prototype

public static String extractScheme(final String uri, final StringBuilder buffer) 

Source Link

Document

Extracts the scheme from a URI.

Usage

From source file:cz.lbenda.rcp.config.ConfigurationFileProvider.java

@Override
public FileObject findFile(FileObject fileObject, String uri, FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    final StringBuilder buffer = new StringBuilder(uri);
    UriParser.extractScheme(uri, buffer);
    UriParser.fixSeparators(buffer);//from  ww  w.  jav  a 2  s  . c  o  m

    UriParser.normalisePath(buffer);
    final String path = buffer.toString();

    FileSystemManager fsManager = VFS.getManager();
    return fsManager.resolveFile("file://" + configurationRW.configPath(path));
}

From source file:org.pentaho.big.data.impl.vfs.hdfs.HDFSFileNameParser.java

/**
 * PDI-15565//from   w w w .  j  a v  a  2 s  .com
 * <p>
 * the same logic as for extracting in org.apache.commons.vfs2.provider.HostFileNameParser.extractToPath
 *
 * @param fileUri file uri for hdfs file
 * @return case sensitive host name
 * @throws FileSystemException when format of url is not correct
 */
private String getHostNameCaseSensitive(String fileUri) throws FileSystemException {
    StringBuilder fullNameBuilder = new StringBuilder();
    UriParser.extractScheme(fileUri, fullNameBuilder);
    if (fullNameBuilder.length() < 2 || fullNameBuilder.charAt(0) != '/' || fullNameBuilder.charAt(1) != '/') {
        throw new FileSystemException("vfs.provider/missing-double-slashes.error", fileUri);
    }
    fullNameBuilder.delete(0, 2);
    extractPort(fullNameBuilder, fileUri);
    extractUserInfo(fullNameBuilder);
    return extractHostName(fullNameBuilder);
}

From source file:org.renjin.appengine.AppEngineLocalFilesSystemProvider.java

@Override
public FileObject findFile(FileObject baseFile, String uri, FileSystemOptions properties)
        throws FileSystemException {

    // Parse the name
    final StringBuilder buffer = new StringBuilder(uri);
    String scheme = UriParser.extractScheme(uri, buffer);
    if (scheme == null) {
        scheme = "file";
    }/*from   w  w w  .j ava  2  s .  com*/

    UriParser.fixSeparators(buffer);

    FileType fileType = UriParser.normalisePath(buffer);
    final String path = buffer.toString();

    // Create the temp file system if it does not exist
    // FileSystem filesystem = findFileSystem( this, (Properties) null);
    FileSystem filesystem = findFileSystem(this, properties);
    if (filesystem == null) {
        final FileName rootName = getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);

        filesystem = new AppEngineLocalFileSystem(rootName, rootFile.getAbsolutePath(), properties);
        addFileSystem(this, filesystem);
    }

    // Find the file
    return filesystem.resolveFile(path);
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.file.MockFileNameParser.java

public FileName parseUri(VfsComponentContext context, FileName base, String filename)
        throws FileSystemException {
    StringBuilder name = new StringBuilder();
    String scheme = UriParser.extractScheme(filename.split("\\?")[0], name);
    if (scheme == null) {
        scheme = "test";
    }//from ww  w.j  ava2 s  .com

    UriParser.canonicalizePath(name, 0, name.length(), this);
    UriParser.fixSeparators(name);
    String rootFile = this.extractRootPrefix(filename, name);
    FileType fileType = UriParser.normalisePath(name);
    String path = name.toString();
    return new MockFileName(scheme, "", path, fileType);
}