Class HostFileNameParser

java.lang.Object
org.apache.commons.vfs2.provider.AbstractFileNameParser
org.apache.commons.vfs2.provider.HostFileNameParser
All Implemented Interfaces:
FileNameParser
Direct Known Subclasses:
FtpFileNameParser, URLFileNameParser

Implementation for any url based filesystem.

Parses the url into user/password/host/port/path. Does not handle a query string (after ?)

See Also:
  • Constructor Details

  • Method Details

    • getDefaultPort

      public int getDefaultPort()
    • parseUri

      public FileName parseUri(VfsComponentContext context, FileName base, String filename) throws FileSystemException
      Description copied from interface: FileNameParser
      parses a String into a filename.
      Parameters:
      context - The component context.
      base - The base FileName.
      filename - The target file name.
      Returns:
      A FileName that represents the taret file.
      Throws:
      FileSystemException - if an error occurs parsing the URI.
    • extractToPath

      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.
      Returns:
      Authority extracted host authority, never null.
      Throws:
      FileSystemException - if authority cannot be extracted.
    • extractUserInfo

      Extracts the user info from a URI.
      Parameters:
      name - string buffer with the "scheme://" part has been removed already. Will be modified.
      Returns:
      the user information up to the '@' or null.
    • extractHostName

      Extracts the hostname from a URI.
      Parameters:
      name - string buffer with the "scheme://[userinfo@]" part has been removed already. Will be modified.
      Returns:
      the host name or null.
    • extractPort

      protected int extractPort(StringBuilder name, String uri) throws FileSystemException
      Extracts the port from a URI.
      Parameters:
      name - string buffer with the "scheme://[userinfo@]hostname" part has been removed already. Will be modified.
      uri - full URI for error reporting.
      Returns:
      The port, or -1 if the URI does not contain a port.
      Throws:
      FileSystemException - if URI is malformed.
      NumberFormatException - if port number cannot be parsed.