Class GhidraURL


  • public class GhidraURL
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getDisplayString​(java.net.URL url)
      Generate preferred display string for Ghidra URLs.
      static java.net.URL getNormalizedURL​(java.net.URL url)
      Get a normalized URL which eliminates use of host names and additional URL refs which may prevent direct comparison.
      static java.lang.String getProjectLocation​(java.net.URL localProjectURL)
      Get the project location path which corresponds to the specified local project URL.
      static java.lang.String getProjectName​(java.net.URL localProjectURL)
      Get the project name which corresponds to the specified local project URL.
      static ProjectLocator getProjectStorageLocator​(java.net.URL localProjectURL)
      Get the project locator which corresponds to the specified local project URL.
      static boolean isLocalProjectURL​(java.net.URL url)
      Determine if the specified URL is a local project URL.
      static boolean isServerRepositoryURL​(java.net.URL url)
      Determine if the specified URL is any type of server "repository" URL.
      static boolean isServerURL​(java.net.URL url)
      Determine if the specified URL is any type of server URL.
      static boolean localProjectExists​(java.net.URL url)
      Determine if the specified URL refers to a local project and it exists.
      static java.net.URL makeURL​(java.io.File projectMarkerFile)
      Create a local project URL for a specified project marker file.
      static java.net.URL makeURL​(java.lang.String host, int port, java.lang.String repositoryName)
      Create a URL which refers to Ghidra Server repository and its root folder
      static java.net.URL makeURL​(java.lang.String host, int port, java.lang.String repositoryName, java.lang.String repositoryPath)
      Create a URL which refers to Ghidra Server repository content.
      static java.net.URL makeURL​(java.lang.String host, int port, java.lang.String repositoryName, java.lang.String repositoryPath, java.lang.String fileName, java.lang.String ref)
      Create a URL which refers to Ghidra Server repository content.
      static java.net.URL makeURL​(java.lang.String dirPath, java.lang.String projectName)
      Create a URL which refers to a local Ghidra project
      static java.net.URL toURL​(java.lang.String projectPathOrURL)
      Create a Ghidra URL from a string form of Ghidra URL or local project path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MARKER_FILE_EXTENSION

        public static final java.lang.String MARKER_FILE_EXTENSION
        See Also:
        Constant Field Values
      • PROJECT_DIRECTORY_EXTENSION

        public static final java.lang.String PROJECT_DIRECTORY_EXTENSION
        See Also:
        Constant Field Values
    • Method Detail

      • localProjectExists

        public static boolean localProjectExists​(java.net.URL url)
        Determine if the specified URL refers to a local project and it exists.
        Parameters:
        url -
        Returns:
        true if specified URL refers to a local project and it exists.
      • isLocalProjectURL

        public static boolean isLocalProjectURL​(java.net.URL url)
        Determine if the specified URL is a local project URL. No checking is performed as to the existence of the project.
        Parameters:
        url -
        Returns:
        true if specified URL refers to a local project (ghidra:/path/projectName...)
      • getProjectName

        public static java.lang.String getProjectName​(java.net.URL localProjectURL)
        Get the project name which corresponds to the specified local project URL.
        Parameters:
        localProjectURL - local Ghidra project URL
        Returns:
        project name
        Throws:
        java.lang.IllegalArgumentException - URL is not a valid local project URL
      • getProjectLocation

        public static java.lang.String getProjectLocation​(java.net.URL localProjectURL)
        Get the project location path which corresponds to the specified local project URL.
        Parameters:
        localProjectURL - local Ghidra project URL
        Returns:
        project location path
        Throws:
        java.lang.IllegalArgumentException - URL is not a valid local project URL
      • getProjectStorageLocator

        public static ProjectLocator getProjectStorageLocator​(java.net.URL localProjectURL)
        Get the project locator which corresponds to the specified local project URL.
        Parameters:
        localProjectURL - local Ghidra project URL
        Returns:
        project locator
        Throws:
        java.lang.IllegalArgumentException - URL is not a valid local project URL
      • isServerRepositoryURL

        public static boolean isServerRepositoryURL​(java.net.URL url)
        Determine if the specified URL is any type of server "repository" URL. No checking is performed as to the existence of the server or repository.
        Parameters:
        url -
        Returns:
        true if specified URL refers to a Ghidra server repository (ghidra://host/repositoryNAME/path...)
      • isServerURL

        public static boolean isServerURL​(java.net.URL url)
        Determine if the specified URL is any type of server URL. No checking is performed as to the existence of the server or repository.
        Parameters:
        url -
        Returns:
        true if specified URL refers to a Ghidra server repository (ghidra://host/repositoryNAME/path...)
      • toURL

        public static java.net.URL toURL​(java.lang.String projectPathOrURL)
        Create a Ghidra URL from a string form of Ghidra URL or local project path. This method can consume strings produced by the getDisplayString method.
        Parameters:
        path - project path (/)
        Returns:
        local Ghidra project URL
        Throws:
        java.lang.IllegalArgumentException - invalid path or URL specified
        See Also:
        getDisplayString(URL)
      • getNormalizedURL

        public static java.net.URL getNormalizedURL​(java.net.URL url)
        Get a normalized URL which eliminates use of host names and additional URL refs which may prevent direct comparison.
        Parameters:
        url -
        Returns:
        normalized url
      • getDisplayString

        public static java.lang.String getDisplayString​(java.net.URL url)
        Generate preferred display string for Ghidra URLs. Form can be parsed by the toURL method.
        Parameters:
        url -
        Returns:
        See Also:
        toURL(String)
      • makeURL

        public static java.net.URL makeURL​(java.io.File projectMarkerFile)
        Create a local project URL for a specified project marker file.
        Parameters:
        projectMarkerFile - project marker file
        Returns:
        local project URL
      • makeURL

        public static java.net.URL makeURL​(java.lang.String dirPath,
                                           java.lang.String projectName)
        Create a URL which refers to a local Ghidra project
        Parameters:
        dirPath - absolute path of project location directory
        projectName - name of project
        Returns:
        local Ghidra project URL
      • makeURL

        public static java.net.URL makeURL​(java.lang.String host,
                                           int port,
                                           java.lang.String repositoryName,
                                           java.lang.String repositoryPath)
        Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.
        Parameters:
        host - server host name/address
        port - optional server port (a value <= 0 refers to the default port)
        repositoryName - repository name
        repositoryPath - absolute folder or file path within repository. Folder paths should end with a '/' character.
        Returns:
        Ghidra Server repository content URL
      • makeURL

        public static java.net.URL makeURL​(java.lang.String host,
                                           int port,
                                           java.lang.String repositoryName,
                                           java.lang.String repositoryPath,
                                           java.lang.String fileName,
                                           java.lang.String ref)
        Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.
        Parameters:
        host - server host name/address
        port - optional server port (a value <= 0 refers to the default port)
        repositoryName - repository name
        repositoryPath - absolute folder path within repository.
        fileName - name of a file contained within the specified repository/path
        ref - optional URL ref or null Folder paths should end with a '/' character.
        Returns:
        Ghidra Server repository content URL
      • makeURL

        public static java.net.URL makeURL​(java.lang.String host,
                                           int port,
                                           java.lang.String repositoryName)
        Create a URL which refers to Ghidra Server repository and its root folder
        Parameters:
        host - server host name/address
        port - optional server port (a value <= 0 refers to the default port)
        repositoryName - repository name
        Returns:
        Ghidra Server repository URL