本文整理汇总了Java中org.apache.commons.vfs2.provider.UriParser类的典型用法代码示例。如果您正苦于以下问题:Java UriParser类的具体用法?Java UriParser怎么用?Java UriParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriParser类属于org.apache.commons.vfs2.provider包,在下文中一共展示了UriParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doListChildren
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Lists the children of the file.
*
* @return the string[]
*
* @throws Exception the exception
*/
@Override
protected String[] doListChildren() throws Exception {
// List the children of this file
doGetChildren();
final String[] childNames = new String[children.size()];
int childNum = -1;
Iterator<FileInfo> iterChildren = children.values().iterator();
while (iterChildren.hasNext()) {
childNum++;
final FileInfo child = iterChildren.next();
childNames[childNum] = child.getName();
}
return UriParser.encode(childNames);
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
示例5: isAbsoluteName
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Determines if a name is an absolute file name.
* @param name The file name.
* @return true if the name is absolute, false otherwise.
*/
public boolean isAbsoluteName(final String name)
{
// TODO - this is yucky
StringBuilder b = new StringBuilder(name);
try
{
UriParser.fixSeparators(b);
extractRootPrefix(name, b);
return true;
}
catch (FileSystemException e)
{
return false;
}
}
示例6: FtpFileObject
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
protected FtpFileObject(final AbstractFileName name,
final FtpFileSystem fileSystem,
final FileName rootName)
throws FileSystemException
{
super(name, fileSystem);
ftpFs = fileSystem;
String relPath = UriParser.decode(rootName.getRelativeName(name));
if (".".equals(relPath))
{
// do not use the "." as path against the ftp-server
// e.g. the uu.net ftp-server do a recursive listing then
// this.relPath = UriParser.decode(rootName.getPath());
// this.relPath = ".";
this.relPath = null;
}
else
{
this.relPath = relPath;
}
}
示例7: getInfo
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Fetches the info for this file.
*/
private void getInfo(boolean flush) throws IOException
{
final FtpFileObject parent = (FtpFileObject) FileObjectUtils.getAbstractFileObject(getParent());
FTPFile newFileInfo;
if (parent != null)
{
newFileInfo = parent.getChildFile(UriParser.decode(getName().getBaseName()), flush);
}
else
{
// Assume the root is a directory and exists
newFileInfo = new FTPFile();
newFileInfo.setType(FTPFile.DIRECTORY_TYPE);
}
if (newFileInfo == null)
{
this.fileInfo = UNKNOWN;
}
else
{
this.fileInfo = newFileInfo;
}
}
示例8: 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;
}
示例9: parseUri
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base,
final String filename) throws FileSystemException
{
final StringBuilder name = new StringBuilder();
// Extract the scheme and authority parts
final Authority auth = extractToPath(filename, name);
// extract domain
String username = auth.getUserName();
final String domain = extractDomain(username);
if (domain != null)
{
username = username.substring(domain.length() + 1);
}
// Decode and adjust separators
UriParser.canonicalizePath(name, 0, name.length(), this);
UriParser.fixSeparators(name);
// Normalise the path. Do this after extracting the share name,
// to deal with things like Nfs://hostname/share/..
final FileType fileType = UriParser.normalisePath(name);
final String path = name.toString();
return new NfsFileName(
auth.getScheme(),
auth.getHostName(),
auth.getPort(),
username,
auth.getPassword(),
path,
fileType);
}
示例10: doListChildren
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Lists the children of the file. Is only called if {@link #doGetType}
* returns {@link FileType#FOLDER}.
*/
@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());
}
示例11: GsiFtpFileObject
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Instantiates a new gsi ftp file object.
*
* @param name the name
* @param fileSystem the file system
* @param rootName the root name
*
* @throws FileSystemException the file system exception
*/
protected GsiFtpFileObject(final AbstractFileName name, final GsiFtpFileSystem fileSystem, final FileName rootName) throws FileSystemException {
super(name, fileSystem);
ftpFs = fileSystem;
String relPathTmp = UriParser.decode(rootName.getRelativeName(name));
// log.debug("FileName=" + name + " Root=" + rootName
// + " Relative path=" + relPath );
if (".".equals(relPathTmp)) {
// do not use the "." as path against the ftp-server
// e.g. the uu.net ftp-server do a recursive listing then
// this.relPath = UriParser.decode(rootName.getPath());
// this.relPath = ".";
// boolean ok = true;
// try {
// cwd = ftpFs.getClient().getCurrentDir();
// }
// catch (ServerException se) { ok = false;}
// catch (IOException se) { ok = false;}
// if ( ! ok ) {
// throw new FileSystemException("vfs.provider.gsiftp/get-type.error", getName());
// }
this.relPath = "/"; // cwd;
} else {
this.relPath = relPathTmp;
}
}
示例12: onChildrenChanged
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Called when the children of this file change.
*
* @param child the child
* @param newType the new type
*/
@Override
protected void onChildrenChanged(FileName child, FileType newType) {
if (children != null && newType.equals(FileType.IMAGINARY)) {
try {
children.remove(UriParser.decode(child.getBaseName()));
} catch (FileSystemException e) {
throw new RuntimeException(e.getMessage());
}
} else {
// if child was added we have to rescan the children
children = null;
}
}
示例13: 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;
}
示例14: 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);
}
示例15: findLocalFile
import org.apache.commons.vfs2.provider.UriParser; //导入依赖的package包/类
/**
* Finds a local file.
* @param file The File to locate.
* @return the located FileObject.
* @throws FileSystemException if an error occurs.
*/
public FileObject findLocalFile(final File file)
throws FileSystemException
{
return findLocalFile(UriParser.encode(file.getAbsolutePath()));
// return findLocalFile(file.getAbsolutePath());
}