Class GenericFileName

java.lang.Object
org.apache.commons.vfs2.provider.AbstractFileName
org.apache.commons.vfs2.provider.GenericFileName
All Implemented Interfaces:
Comparable<FileName>, FileName
Direct Known Subclasses:
GenericURLFileName, URLFileName

public class GenericFileName extends AbstractFileName
A file name that represents a 'generic' URI, as per RFC 2396. Consists of a scheme, userinfo (typically username and password), hostname, port, and path.
  • Constructor Details

    • GenericFileName

      protected GenericFileName(String scheme, String hostName, int port, int defaultPort, String userName, String password, String path, FileType type)
      Constructs a new instance.
      Parameters:
      scheme - the scheme.
      hostName - the host name.
      port - the port.
      defaultPort - the default port.
      userName - the user name.
      password - the password.
      path - the absolute path, maybe empty or null.
      type - the file type.
  • Method Details

    • appendCredentials

      protected void appendCredentials(StringBuilder buffer, boolean addPassword)
      Append the user credentials.

      If anything was added, it will be '@' terminated.

      Parameters:
      buffer - the string buffer to modify.
      addPassword - flag if password should be added or replaced with placeholder (false).
    • appendRootUri

      protected void appendRootUri(StringBuilder buffer, boolean addPassword)
      Builds the root URI for this file name.
      Specified by:
      appendRootUri in class AbstractFileName
      Parameters:
      buffer - A StringBuilder to use to construct the URI.
      addPassword - true if the password should be added, false otherwise.
    • createName

      public FileName createName(String absPath, FileType type)
      Create a FileName.
      Specified by:
      createName in class AbstractFileName
      Parameters:
      absPath - The absolute path.
      type - The FileType.
      Returns:
      The created FileName.
    • getDefaultPort

      public int getDefaultPort()
      Returns the default port for this file name.
      Returns:
      The default port number.
    • getHostName

      public String getHostName()
      Returns the host name part of this name.
      Returns:
      The host name.
    • getPassword

      public String getPassword()
      Returns the password part of this name.
      Returns:
      The password.
    • getPort

      public int getPort()
      Returns the port part of this name.
      Returns:
      The port number.
    • getUserName

      public String getUserName()
      Returns the user name part of this name.
      Returns:
      The user name.