Package org.apache.commons.vfs.provider
Class HostFileNameParser
- java.lang.Object
-
- org.apache.commons.vfs.provider.AbstractFileNameParser
-
- org.apache.commons.vfs.provider.HostFileNameParser
-
- All Implemented Interfaces:
FileNameParser
- Direct Known Subclasses:
FtpFileNameParser,URLFileNameParser
public class HostFileNameParser extends AbstractFileNameParser
Implementation for any url based filesystem.
Parses the url into user/password/host/port/path
Does not handle a query string (after ?)- Version:
- $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Wed, 29 Nov 2006) $
- Author:
- imario@apache.org
- See Also:
URLFileNameParser for the implementation which also handles the query string too
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classHostFileNameParser.AuthorityParsed authority info (scheme, hostname, userinfo, port)
-
Constructor Summary
Constructors Constructor Description HostFileNameParser(int defaultPort)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanencodeCharacter(char ch)Check if a character needs encoding (%nn)protected java.lang.StringextractHostName(java.lang.StringBuffer name)Extracts the hostname from a URI.protected intextractPort(java.lang.StringBuffer name, java.lang.String uri)Extracts the port from a URI.protected HostFileNameParser.AuthorityextractToPath(java.lang.String uri, java.lang.StringBuffer name)Extracts the scheme, userinfo, hostname and port components of a generic URI.protected java.lang.StringextractUserInfo(java.lang.StringBuffer name)Extracts the user info from a URI.intgetDefaultPort()FileNameparseUri(VfsComponentContext context, FileName base, java.lang.String filename)parses a String into a filename
-
-
-
Method Detail
-
getDefaultPort
public int getDefaultPort()
-
encodeCharacter
public boolean encodeCharacter(char ch)
Description copied from interface:FileNameParserCheck if a character needs encoding (%nn)- Specified by:
encodeCharacterin interfaceFileNameParser- Overrides:
encodeCharacterin classAbstractFileNameParser- Parameters:
ch- the character- Returns:
- true if character should be encoded
-
parseUri
public FileName parseUri(VfsComponentContext context, FileName base, java.lang.String filename) throws FileSystemException
Description copied from interface:FileNameParserparses a String into a filename- Throws:
FileSystemException
-
extractToPath
protected HostFileNameParser.Authority extractToPath(java.lang.String uri, java.lang.StringBuffer name) throws FileSystemException
Extracts the scheme, userinfo, hostname and port components of a generic URI.- Parameters:
uri- The absolute URI to parse.name- Used to return the remainder of the URI.- Throws:
FileSystemException
-
extractUserInfo
protected java.lang.String extractUserInfo(java.lang.StringBuffer name)
Extracts the user info from a URI. The scheme:// part has been removed already.
-
extractHostName
protected java.lang.String extractHostName(java.lang.StringBuffer name)
Extracts the hostname from a URI. The scheme://userinfo@ part has been removed.
-
extractPort
protected int extractPort(java.lang.StringBuffer name, java.lang.String uri) throws FileSystemExceptionExtracts the port from a URI. The scheme://userinfo@hostname part has been removed.- Returns:
- The port, or -1 if the URI does not contain a port.
- Throws:
FileSystemException
-
-