Class UriInfo

java.lang.Object
com.deltawalker.script.UriInfo

public class UriInfo extends Object
The location of a resource together with the information needed to access and read it: for a resource on a remote (S)FTP(S) server, the user name and password, or the SSH key and passphrase; for a text file, the character encoding and line ending to read or save it with.

The URI can be a local path or a URL such as ftp://host/path or sftp://host/path. The optional properties are passed as a JavaScript object whose property names are the names listed for each UriInfo.Key constant:


 const UriInfo = Java.type('com.deltawalker.script.UriInfo');

 const local = new UriInfo('/Users/me/project');
 const remote = new UriInfo('sftp://example.com/var/www',
         {username: 'me', password: 'secret'});
 const text = new UriInfo('/Users/me/notes.txt', {encoding: 'UTF-8'});
 

An unsupported property name makes the comparison or report that uses this UriInfo fail with an IllegalArgumentException.

See Also:
  • Constructor Details

    • UriInfo

      public UriInfo(String uri)
      Creates a UriInfo for the specified URI or path, with no properties. For instance, for an FTP server that does not require authentication:
      
       new UriInfo('ftp://example.com')
       
      Parameters:
      uri - the URI or path; cannot be null or empty
      Throws:
      NullPointerException - if uri is null
      IllegalArgumentException - if uri is empty
      Since:
      2.0
    • UriInfo

      public UriInfo(String uri, Map<String,String> props)
      Creates a UriInfo for the specified URI or path with the specified properties. For instance, for an SFTP server:
      
       new UriInfo('sftp://example.com', {username: 'me', password: 'secret'})
       
      Parameters:
      uri - the URI or path; cannot be null or empty
      props - the properties, as a JavaScript object whose property names are those listed for the UriInfo.Key constants and whose values are strings; can be null for no properties
      Throws:
      NullPointerException - if uri is null
      IllegalArgumentException - if uri is empty
      Since:
      2.0
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getUri

      public String getUri()
      Returns the URI or path of this UriInfo, as passed to the constructor.
      Returns:
      the URI or path
      Since:
      2.0
    • properties

      public Map<String,String> properties()
      Returns the properties of this UriInfo.
      Returns:
      the map of property names to values; empty, never null, when there are no properties
      Since:
      2.0
    • property

      public Object property(String key, Object defValue)
      Returns the value of the property with the specified name.
      Parameters:
      key - the name of the property, for example "username"; cannot be null or empty
      defValue - the value to return if this UriInfo has no such property; can be null
      Returns:
      the value of the property, or defValue
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if key is empty
      Since:
      2.0
    • toString

      public String toString()
      Overrides:
      toString in class Object