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 int
Default port used forBSimServerInfo.DBType.elastic
serverstatic final int
Default port used forBSimServerInfo.DBType.postgres
serverstatic final String
File extension imposed forBSimServerInfo.DBType.file
server. -
Constructor Summary
ConstructorsConstructorDescriptionBSimServerInfo
(BSimServerInfo.DBType dbType, String host, int port, String dbName) Construct a newBSimServerInfo
object.BSimServerInfo
(BSimServerInfo.DBType dbType, String userinfo, String host, int port, String dbName) Construct a newBSimServerInfo
objectBSimServerInfo
(String dbName) Construct a newBSimServerInfo
object for aBSimServerInfo.DBType.file
type database.BSimServerInfo
(URL url) Construct a newBSimServerInfo
object from a suitable database URL (i.e.,postgresql:
,https:
,elastic:
,file:
). -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Get the DB NamegetFunctionDatabase
(boolean async) Get a BSimFunctionDatabase
instance which corresponds to this DB server info.int
getPort()
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.boolean
Determine if user info was stipulated during constructionint
hashCode()
boolean
Determine if user information includes password.boolean
Determine if this server info corresponds to Windows OS file path.void
setUserInfo
(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.postgres
server- See Also:
-
DEFAULT_ELASTIC_PORT
public static final int DEFAULT_ELASTIC_PORTDefault port used forBSimServerInfo.DBType.elastic
server- See Also:
-
H2_FILE_EXTENSION
File extension imposed forBSimServerInfo.DBType.file
server. 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 newBSimServerInfo
object- 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.file
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 newBSimServerInfo
object. 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.file
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 newBSimServerInfo
object for aBSimServerInfo.DBType.file
type 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 newBSimServerInfo
object 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.file
the directory path will be excluded from returned name.- Returns:
- shortened DB Name
-
hashCode
public int hashCode() -
equals
-
toString
-
getFunctionDatabase
Get a BSimFunctionDatabase
instance which corresponds to this DB server info. TheCloseable
instance 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:
compareTo
in interfaceComparable<BSimServerInfo>
-