Package ghidra.features.bsim.query
Class BSimServerInfo
java.lang.Object
ghidra.features.bsim.query.BSimServerInfo
- All Implemented Interfaces:
Comparable<BSimServerInfo>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault port used forBSimServerInfo.DBType.elasticserverstatic final intDefault port used forBSimServerInfo.DBType.postgresserverstatic final StringFile extension imposed forBSimServerInfo.DBType.fileserver. -
Constructor Summary
ConstructorsConstructorDescriptionBSimServerInfo(BSimServerInfo.DBType dbType, String host, int port, String dbName) Construct a newBSimServerInfoobject.BSimServerInfo(BSimServerInfo.DBType dbType, String userinfo, String host, int port, String dbName) Construct a newBSimServerInfoobjectBSimServerInfo(String dbName) Construct a newBSimServerInfoobject for aBSimServerInfo.DBType.filetype database.BSimServerInfo(URL url) Construct a newBSimServerInfoobject from a suitable database URL (i.e.,postgresql:,https:,elastic:,file:). -
Method Summary
Modifier and TypeMethodDescriptionintbooleanGet the DB NamegetFunctionDatabase(boolean async) Get a BSimFunctionDatabaseinstance which corresponds to this DB server info.intgetPort()Get the port number.Get the server hostname or IP address as originally specified.Get the DB Name.Get the remote database user information to be used when establishing a connection.Get the remote database user name to be used when establishing a connection.booleanDetermine if user info was stipulated during constructioninthashCode()booleanDetermine if user information includes password.booleanDetermine if this server info corresponds to Windows OS file path.voidsetUserInfo(org.apache.commons.dbcp2.BasicDataSource bds) toString()toURL()Return BSim server info in URL.Return BSim server info in URL format.
-
Field Details
-
DEFAULT_POSTGRES_PORT
public static final int DEFAULT_POSTGRES_PORTDefault port used forBSimServerInfo.DBType.postgresserver- See Also:
-
DEFAULT_ELASTIC_PORT
public static final int DEFAULT_ELASTIC_PORTDefault port used forBSimServerInfo.DBType.elasticserver- See Also:
-
H2_FILE_EXTENSION
File extension imposed forBSimServerInfo.DBType.fileserver. This is a rigid H2 database convention.- See Also:
-
-
Constructor Details
-
BSimServerInfo
public BSimServerInfo(BSimServerInfo.DBType dbType, String userinfo, String host, int port, String dbName) Construct a newBSimServerInfoobject- Parameters:
dbType- BSim DB typeuserinfo- connection user info,username[:password](ignored forBSimServerInfo.DBType.file). If blank,ClientUtil.getUserName()is used.host- host name (ignored forBSimServerInfo.DBType.file)port- port number (ignored forBSimServerInfo.DBType.file)dbName- name of database (simple database name except forBSimServerInfo.DBType.filewhich should reflect an absolute file path. On Windows OS the path may start with a drive letter.- Throws:
IllegalArgumentException- if invalid arguments are specified
-
BSimServerInfo
Construct a newBSimServerInfoobject. For non-file database the user's defaut username is used (seeClientUtil.getUserName()).- Parameters:
dbType- BSim DB typehost- host name (ignored forBSimServerInfo.DBType.file)port- port number (ignored forBSimServerInfo.DBType.file)dbName- name of database (simple database name except forBSimServerInfo.DBType.filewhich should reflect an absolute file path. On Windows OS the path may start with a drive letter.- Throws:
IllegalArgumentException- if invalid arguments are specified
-
BSimServerInfo
Construct a newBSimServerInfoobject for aBSimServerInfo.DBType.filetype database.- Parameters:
dbName- name of database which should reflect an absolute file path. On Windows OS the path may start with a drive letter.- Throws:
IllegalArgumentException- if invalid arguments are specified
-
BSimServerInfo
Construct a newBSimServerInfoobject from a suitable database URL (i.e.,postgresql:,https:,elastic:,file:).- Parameters:
url- supported BSim database URL. For non-file URLs, the hostname or address may be preceeded by a DB username (e.g., postgresql://user@host:port/dbname- Throws:
IllegalArgumentException- if unsupported URL protocol specified
-
-
Method Details
-
isWindowsFilePath
public boolean isWindowsFilePath()Determine if this server info corresponds to Windows OS file path.- Returns:
- true if this server info corresponds to Windows OS file path.
-
toURLString
Return BSim server info in URL format. Warning: If userinfo with password has been specified it will be returned in the URL.- Returns:
- BSim server info in URL format
-
toURL
Return BSim server info in URL. Warning: If userinfo with password has been specified it will be returned in the URL.- Returns:
- BSim server info in URL
- Throws:
MalformedURLException- if unable to form supported URL
-
getDBType
- Returns:
- BSim database type
-
setUserInfo
public void setUserInfo(org.apache.commons.dbcp2.BasicDataSource bds) -
hasPassword
public boolean hasPassword()Determine if user information includes password. NOTE: Use of passwords with this object and URLs is discouraged.- Returns:
- true if user information includes password which
-
hasDefaultLogin
public boolean hasDefaultLogin()Determine if user info was stipulated during construction- Returns:
- true if user info was stipulated during construction
-
getUserName
Get the remote database user name to be used when establishing a connection. User name obtained from the user information which was provided during instantiation.- Returns:
- remote database user information (null for
BSimServerInfo.DBType.file).
-
getUserInfo
Get the remote database user information to be used when establishing a connection.- Returns:
- remote database user information (null for
BSimServerInfo.DBType.file).
-
getServerName
Get the server hostname or IP address as originally specified.- Returns:
- hostname or IP address as originally specified
-
getPort
public int getPort()Get the port number.- Returns:
- port number
-
getDBName
Get the DB Name- Returns:
- DB name
-
getShortDBName
Get the DB Name. In the case ofBSimServerInfo.DBType.filethe directory path will be excluded from returned name.- Returns:
- shortened DB Name
-
hashCode
public int hashCode() -
equals
-
toString
-
getFunctionDatabase
Get a BSimFunctionDatabaseinstance which corresponds to this DB server info. TheCloseableinstance should be closed when no longer in-use to ensure that any associated database connection and resources are properly closed.- Parameters:
async- true if database commits should be asynchronous (may not be applicable)- Returns:
- BSim function database instance
-
compareTo
- Specified by:
compareToin interfaceComparable<BSimServerInfo>
-