Class UrlFileNameParser
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractFileNameParser
-
- org.apache.commons.vfs2.provider.url.UrlFileNameParser
-
- All Implemented Interfaces:
FileNameParser
public class UrlFileNameParser extends AbstractFileNameParser
Implementation for any java.net.url based filesystem.Composite of URLFilenameParser and GenericFilenameParser
-
-
Constructor Summary
Constructors Constructor Description UrlFileNameParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
countSlashes(java.lang.String filename)
This method counts the slashes after the scheme.boolean
encodeCharacter(char ch)
Check if a character needs encoding (%nn).protected boolean
isUrlBased(FileName base, java.lang.String filename)
Guess if the given file name is an URL with host or not.FileName
parseUri(VfsComponentContext context, FileName base, java.lang.String uri)
Parse a URI.
-
-
-
Constructor Detail
-
UrlFileNameParser
public UrlFileNameParser()
-
-
Method Detail
-
encodeCharacter
public boolean encodeCharacter(char ch)
Description copied from interface:FileNameParser
Check if a character needs encoding (%nn).- Specified by:
encodeCharacter
in interfaceFileNameParser
- Overrides:
encodeCharacter
in classAbstractFileNameParser
- Parameters:
ch
- the character- Returns:
- true if character should be encoded
-
parseUri
public FileName parseUri(VfsComponentContext context, FileName base, java.lang.String uri) throws FileSystemException
Parse a URI.- Parameters:
context
- The component context.base
- The base FileName.uri
- The target file name.- Returns:
- The FileName.
- Throws:
FileSystemException
- if an error occurs
-
isUrlBased
protected boolean isUrlBased(FileName base, java.lang.String filename)
Guess if the given file name is an URL with host or not.VFS treats such URLs differently.
A file name is URL-based if the base is a
URLFileName
or there are only 2 slashes after the scheme. e.g:http://host/path
,file:/path/to/file
,file:///path/to/file
.- Parameters:
base
- The filename is relative to this base.filename
- The filename.- Returns:
- true if filename contains two slashes or base was URLFileName.
-
countSlashes
protected int countSlashes(java.lang.String filename)
This method counts the slashes after the scheme.- Parameters:
filename
- The file name.- Returns:
- number of slashes
-
-