Package ghidra.framework.protocol.ghidra
Class GhidraURL
- java.lang.Object
-
- ghidra.framework.protocol.ghidra.GhidraURL
-
public class GhidraURL extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMARKER_FILE_EXTENSIONstatic java.lang.StringPROJECT_DIRECTORY_EXTENSIONstatic java.lang.StringPROTOCOL
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetDisplayString(java.net.URL url)Generate preferred display string for Ghidra URLs.static java.net.URLgetNormalizedURL(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.StringgetProjectLocation(java.net.URL localProjectURL)Get the project location path which corresponds to the specified local project URL.static java.lang.StringgetProjectName(java.net.URL localProjectURL)Get the project name which corresponds to the specified local project URL.static ProjectLocatorgetProjectStorageLocator(java.net.URL localProjectURL)Get the project locator which corresponds to the specified local project URL.static booleanisLocalProjectURL(java.net.URL url)Determine if the specified URL is a local project URL.static booleanisServerRepositoryURL(java.net.URL url)Determine if the specified URL is any type of server "repository" URL.static booleanisServerURL(java.net.URL url)Determine if the specified URL is any type of server URL.static booleanlocalProjectExists(java.net.URL url)Determine if the specified URL refers to a local project and it exists.static java.net.URLmakeURL(java.io.File projectMarkerFile)Create a local project URL for a specified project marker file.static java.net.URLmakeURL(java.lang.String host, int port, java.lang.String repositoryName)Create a URL which refers to Ghidra Server repository and its root folderstatic java.net.URLmakeURL(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.URLmakeURL(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.URLmakeURL(java.lang.String dirPath, java.lang.String projectName)Create a URL which refers to a local Ghidra projectstatic java.net.URLtoURL(java.lang.String projectPathOrURL)Create a Ghidra URL from a string form of Ghidra URL or local project path.
-
-
-
Field Detail
-
PROTOCOL
public static final java.lang.String PROTOCOL
- See Also:
- Constant Field Values
-
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 directoryprojectName- 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/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository namerepositoryPath- 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/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository namerepositoryPath- absolute folder path within repository.fileName- name of a file contained within the specified repository/pathref- 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/addressport- optional server port (a value <= 0 refers to the default port)repositoryName- repository name- Returns:
- Ghidra Server repository URL
-
-