本文整理汇总了Java中org.apache.commons.vfs2.provider.UriParser.extractScheme方法的典型用法代码示例。如果您正苦于以下问题:Java UriParser.extractScheme方法的具体用法?Java UriParser.extractScheme怎么用?Java UriParser.extractScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs2.provider.UriParser
的用法示例。
在下文中一共展示了UriParser.extractScheme方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSchemeFileOptions
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
/**
* Get file options specific to a particular scheme.
*
* @param fileURI URI of file to get file options
* @return File options related to scheme.
*/
private Map<String, String> parseSchemeFileOptions(String fileURI) {
String scheme;
if ((scheme = UriParser.extractScheme(fileURI)) == null) {
return null;
}
HashMap<String, String> schemeFileOptions = new HashMap<>();
schemeFileOptions.put(Constants.SCHEME, scheme);
if (scheme.equals(Constants.SCHEME_SFTP)) {
for (Constants.SftpFileOption option : Constants.SftpFileOption.values()) {
String strValue = fileProperties.get(Constants.SFTP_PREFIX + option.toString());
if (strValue != null && !strValue.isEmpty()) {
schemeFileOptions.put(option.toString(), strValue);
}
}
}
return schemeFileOptions;
}
示例2: checkURIProtocolSupported
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
private boolean checkURIProtocolSupported(String uri) {
Map<String, String> environment = this.ctx.getExecMasterContext().getDpuContext().getEnvironment();
String supportedProtocols = environment.get(SUPPORTED_PROTOCOLS);
if (StringUtils.isEmpty(supportedProtocols)) {
return true;
}
final String scheme = UriParser.extractScheme(uri);
String[] supportedSchemes = supportedProtocols.trim().split(",");
Set<String> supportedSet = new HashSet<>();
for (String s : supportedSchemes) {
supportedSet.add(s);
}
if (StringUtils.isEmpty(scheme) && !supportedSet.contains("file")) {
return false;
}
return supportedSet.contains(scheme);
}
示例3: checkURIProtocolSupported
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
private boolean checkURIProtocolSupported(String uri) {
Map<String, String> environment = this.ctx.getDialogMasterContext().getDialogContext().getEnvironment();
String supportedProtocols = environment.get(FilesDownload.SUPPORTED_PROTOCOLS);
if (StringUtils.isEmpty(supportedProtocols)) {
return true;
}
final String scheme = UriParser.extractScheme(uri);
String[] supportedSchemes = supportedProtocols.trim().split(",");
Set<String> supportedSet = new HashSet<>();
for (String s : supportedSchemes) {
supportedSet.add(s);
}
if (StringUtils.isEmpty(scheme) && !supportedSet.contains("file")) {
return false;
}
return supportedSet.contains(scheme);
}
示例4: findFile
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
/**
* Locates a file object, by absolute URI.
* @param baseFile The base file.
* @param uri The URI of the file to locate.
* @param fileSystemOptions The FileSystem options.
* @return the FileObject.
* @throws FileSystemException if an error occurs.
*/
public FileObject findFile(final FileObject baseFile,
final String uri,
final FileSystemOptions fileSystemOptions)
throws FileSystemException
{
StringBuilder buf = new StringBuilder(80);
UriParser.extractScheme(uri, buf);
String resourceName = buf.toString();
ClassLoader cl = ResourceFileSystemConfigBuilder.getInstance().getClassLoader(fileSystemOptions);
if (cl == null)
{
cl = getClass().getClassLoader();
}
final URL url = cl.getResource(resourceName);
if (url == null)
{
throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri);
}
FileObject fo = getContext().getFileSystemManager().resolveFile(url.toExternalForm());
return fo;
}
示例5: parseSchemeFileOptions
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
private Map<String, String> parseSchemeFileOptions(String fileURI) {
String scheme = UriParser.extractScheme(fileURI);
if (scheme == null) {
return null;
}
HashMap<String, String> schemeFileOptions = new HashMap<>();
schemeFileOptions.put(Constants.SCHEME, scheme);
addOptions(scheme, schemeFileOptions);
return schemeFileOptions;
}
示例6: parseUri
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
public FileName parseUri(final VfsComponentContext context, FileName base, final String filename)
throws FileSystemException
{
final StringBuilder name = new StringBuilder();
// Extract the scheme
String scheme = UriParser.extractScheme(filename, name);
if (scheme == null)
{
scheme = "file";
}
// Remove encoding, and adjust the separators
UriParser.canonicalizePath(name, 0, name.length(), this);
UriParser.fixSeparators(name);
// Extract the root prefix
final String rootFile = extractRootPrefix(filename, name);
// Normalise the path
FileType fileType = UriParser.normalisePath(name);
final String path = name.toString();
return createFileName(
scheme,
rootFile,
path,
fileType);
}
示例7: findFile
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
/**
* Locates a file object, by absolute URI.
* @param baseFile The base FileObject.
* @param uri The URI of the file to be located.
* @param properties FileSystemOptions to use to locate or create the file.
* @return The FileObject.
* @throws FileSystemException if an error occurs.
*/
public synchronized FileObject findFile(final FileObject baseFile, final String uri,
final FileSystemOptions properties)
throws FileSystemException
{
// Parse the name
final StringBuilder buffer = new StringBuilder(uri);
final String scheme = UriParser.extractScheme(uri, buffer);
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)
{
if (rootFile == null)
{
rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs");
}
final FileName rootName =
getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
// final FileName rootName =
// new LocalFileName(scheme, scheme + ":", FileName.ROOT_PATH);
filesystem = new LocalFileSystem(rootName, rootFile.getAbsolutePath(), properties);
addFileSystem(this, filesystem);
}
// Find the file
return filesystem.resolveFile(path);
}
示例8: resolveURI
import org.apache.commons.vfs2.provider.UriParser; //导入方法依赖的package包/类
/**
* Resolve the uri to a filename.
* @param uri The URI to resolve.
* @return The FileName of the file.
* @throws FileSystemException if an error occurs.
*/
public FileName resolveURI(String uri) throws FileSystemException
{
UriParser.checkUriEncoding(uri);
if (uri == null)
{
throw new IllegalArgumentException();
}
// Extract the scheme
final String scheme = UriParser.extractScheme(uri);
if (scheme != null)
{
// An absolute URI - locate the provider
final FileProvider provider = providers.get(scheme);
if (provider != null)
{
return provider.parseUri(null, uri);
}
// Otherwise, assume a local file
}
// Handle absolute file names
if (localFileProvider != null
&& localFileProvider.isAbsoluteLocalName(uri))
{
return localFileProvider.parseUri(null, uri);
}
if (scheme != null)
{
// An unknown scheme - hand it to the default provider
if (defaultProvider == null)
{
throw new FileSystemException("vfs.impl/unknown-scheme.error",
new Object[] {scheme, uri});
}
return defaultProvider.parseUri(null, uri);
}
// Assume a relative name - use the supplied base file
if (baseFile == null)
{
throw new FileSystemException("vfs.impl/find-rel-file.error", uri);
}
return resolveName(baseFile.getName(), uri, NameScope.FILE_SYSTEM);
}