org.apache.commons.vfs.provider
Class HostFileNameParser

java.lang.Object
  extended byorg.apache.commons.vfs.provider.AbstractFileNameParser
      extended byorg.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 (Mi, 29 Nov 2006) $
Author:
imario@apache.org
See Also:
URLFileNameParser for the implementation which also handles the query string too

Nested Class Summary
protected static class HostFileNameParser.Authority
          Parsed authority info (scheme, hostname, userinfo, port)
 
Constructor Summary
HostFileNameParser(int defaultPort)
           
 
Method Summary
 boolean encodeCharacter(char ch)
          Check if a character needs encoding (%nn)
protected  String extractHostName(StringBuffer name)
          Extracts the hostname from a URI.
protected  int extractPort(StringBuffer name, String uri)
          Extracts the port from a URI.
protected  HostFileNameParser.Authority extractToPath(String uri, StringBuffer name)
          Extracts the scheme, userinfo, hostname and port components of a generic URI.
protected  String extractUserInfo(StringBuffer name)
          Extracts the user info from a URI.
 int getDefaultPort()
           
 FileName parseUri(VfsComponentContext context, FileName base, String filename)
          parses a String into a filename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HostFileNameParser

public HostFileNameParser(int defaultPort)
Method Detail

getDefaultPort

public int getDefaultPort()

encodeCharacter

public boolean encodeCharacter(char ch)
Description copied from interface: FileNameParser
Check if a character needs encoding (%nn)

Specified by:
encodeCharacter in interface FileNameParser
Overrides:
encodeCharacter in class AbstractFileNameParser

parseUri

public FileName parseUri(VfsComponentContext context,
                         FileName base,
                         String filename)
                  throws FileSystemException
Description copied from interface: FileNameParser
parses a String into a filename

Parameters:
base -
filename -
Throws:
FileSystemException

extractToPath

protected HostFileNameParser.Authority extractToPath(String uri,
                                                     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 String extractUserInfo(StringBuffer name)
Extracts the user info from a URI. The scheme:// part has been removed already.


extractHostName

protected String extractHostName(StringBuffer name)
Extracts the hostname from a URI. The scheme://userinfo@ part has been removed.


extractPort

protected int extractPort(StringBuffer name,
                          String uri)
                   throws FileSystemException
Extracts 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


Copyright © 2002-2006 The Apache Software Foundation. All Rights Reserved.