public class UsageOptions
extends java.lang.Object
Intended to implement some of the options described in the main Perforce p4 usage and p4 undoc documentation on a per-IOptionsServer object basis, and also implements some of the broader environment settings (such as the client name used by the P4Java server implementation when no client has been associated with the server).
The UsageOptions object associated with a server is read and used for a small number of usage values (currently programName, programVersion, unsetUserName, and unsetClientName) each time a command is issued to the corresponding Perforce server, so updates to the UsageOptions object and / or any associated Properties object will be reflected at the next command execution except where noted. Note that this means that UsageOption objects shared between multiple servers are sensitive to such changes, and that changes that occur when a server is processing command requests may cause unexpected results.
A UsageOption object is associated with a server instance when the server is issued by the server factory; this can be the default object or one passed-in to the server factory specifically for that server.
Note that the UsageOptions class should be used with some care as the possible side effects of setting some of the usage parameters to the wrong value can lead to unexpected or odd behaviour.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
defaultWorkingDirectory
Default working directory from the JVM to fall back to if not working
directory is set on the usage options
|
protected java.lang.String |
hostName
If not null, specifies the host name used by the server's commands.
|
protected java.lang.String |
programName
If not null, will be used to identify the P4Java application's
program name to the Perforce server.
|
protected java.lang.String |
programVersion
If not null, will be used to identify the P4Java application's
program version to the Perforce server.
|
protected java.util.Properties |
props
Properties object used to get default field values from.
|
protected java.lang.String |
textLanguage
If not null, use this field to tell the server which language to
use in text messages it sends back to the client.
|
protected java.lang.String |
unsetClientName
If set, this will be used as the name of the client when no
client has actually been explicitly set for the associated server(s).
|
protected java.lang.String |
unsetUserName
What will be sent to the Perforce server with each command as the user
name if no user name has been explicitly set for servers associated with
this UsageOption.
|
static java.lang.String |
WORKING_DIRECTORY_PROPNAME
The name of the system property used to determine the JVM's current
working directory.
|
protected java.lang.String |
workingDirectory
If not null, this specifies the Perforce server's idea of each command's
working directory for the associated server object.
|
Constructor and Description |
---|
UsageOptions(java.util.Properties props)
Default constructor.
|
UsageOptions(java.util.Properties props,
java.lang.String programName,
java.lang.String programVersion,
java.lang.String workingDirectory,
java.lang.String hostName,
java.lang.String textLanguage,
java.lang.String unsetUserName,
java.lang.String noClientName)
Explicit value constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getHostName() |
java.lang.String |
getProgramName()
Return the program name.
|
protected java.lang.String |
getProgramNameDefault(java.util.Properties props)
Get a suitable default value for the programName field.
|
java.lang.String |
getProgramVersion()
Return the program version.
|
protected java.lang.String |
getProgramVersionDefault(java.util.Properties props)
Get a suitable default value for the programVersion field.
|
java.util.Properties |
getProps() |
java.lang.String |
getTextLanguage() |
java.lang.String |
getUnsetClientName()
Return the unset client name.
|
protected java.lang.String |
getUnsetClientNameDefault(java.util.Properties props)
Get a suitable default value for the unsetClientName field.
|
java.lang.String |
getUnsetUserName()
Return the unset user name.
|
protected java.lang.String |
getUnsetUserNameDefault(java.util.Properties props)
Get a suitable default value for the unsetUserName field.
|
java.lang.String |
getWorkingDirectory()
Return the current value of the working directory; this can be dynamically
set explicitly using the setter method or implicitly when the object is
constructed using the JVM's working directory as reflected in the
System properties.
|
protected java.lang.String |
getWorkingDirectoryDefault(java.util.Properties props)
Get a suitable default value for the workingDirectory field.
|
protected void |
setFieldDefaults(java.util.Properties props)
Set any non-null default values when the object
is constructed.
|
UsageOptions |
setHostName(java.lang.String hostName)
Set the host name.
|
UsageOptions |
setProgramName(java.lang.String programName) |
UsageOptions |
setProgramVersion(java.lang.String programVersion) |
UsageOptions |
setProps(java.util.Properties props) |
UsageOptions |
setTextLanguage(java.lang.String textLanguage) |
UsageOptions |
setUnsetClientName(java.lang.String unsetClientName) |
UsageOptions |
setUnsetUserName(java.lang.String unsetUserName) |
UsageOptions |
setWorkingDirectory(java.lang.String workingDirectory) |
public static final java.lang.String WORKING_DIRECTORY_PROPNAME
protected java.util.Properties props
protected java.lang.String programName
protected java.lang.String programVersion
protected java.lang.String workingDirectory
This affects all commands on the associated server from this point on, and the passed-in path should be both absolute and valid, otherwise strange errors may appear from the server. If workingDirectory is null, the Java VM's actual current working directory at the time this object is constructed is used instead (which is almost always a safe option unless you're using Perforce alt roots).
Note: no checking is done at any time for correctness (or otherwise) of the workingDirectory option.
protected java.lang.String hostName
protected java.lang.String textLanguage
protected java.lang.String unsetUserName
protected java.lang.String unsetClientName
protected java.lang.String defaultWorkingDirectory
public UsageOptions(java.util.Properties props)
props
- propertiespublic UsageOptions(java.util.Properties props, java.lang.String programName, java.lang.String programVersion, java.lang.String workingDirectory, java.lang.String hostName, java.lang.String textLanguage, java.lang.String unsetUserName, java.lang.String noClientName)
props
- propertiesprogramName
- program nameprogramVersion
- program versionworkingDirectory
- working directoryhostName
- host nametextLanguage
- languageunsetUserName
- user namenoClientName
- client nameprotected void setFieldDefaults(java.util.Properties props)
Fields set here: workingDirectory.
props
- propertiesprotected java.lang.String getProgramNameDefault(java.util.Properties props)
props
- propertiesprotected java.lang.String getProgramVersionDefault(java.util.Properties props)
props
- propertiesprotected java.lang.String getWorkingDirectoryDefault(java.util.Properties props)
props
- propertiesprotected java.lang.String getUnsetUserNameDefault(java.util.Properties props)
props
- propertiesprotected java.lang.String getUnsetClientNameDefault(java.util.Properties props)
props
- propertiespublic java.lang.String getProgramName()
public UsageOptions setProgramName(java.lang.String programName)
public java.lang.String getProgramVersion()
public UsageOptions setProgramVersion(java.lang.String programVersion)
programVersion
- program versionpublic java.lang.String getWorkingDirectory()
public UsageOptions setWorkingDirectory(java.lang.String workingDirectory)
workingDirectory
- working directorypublic java.lang.String getHostName()
public UsageOptions setHostName(java.lang.String hostName)
hostName
- host namepublic java.lang.String getTextLanguage()
public UsageOptions setTextLanguage(java.lang.String textLanguage)
textLanguage
- languagepublic java.util.Properties getProps()
public UsageOptions setProps(java.util.Properties props)
props
- propertiespublic java.lang.String getUnsetClientName()
public UsageOptions setUnsetClientName(java.lang.String unsetClientName)
unsetClientName
- client namepublic java.lang.String getUnsetUserName()
public UsageOptions setUnsetUserName(java.lang.String unsetUserName)
unsetUserName
- user name