com.tek42.perforce
Class Depot

java.lang.Object
  extended by com.tek42.perforce.Depot

public class Depot
extends java.lang.Object

Represents the root object from which to interact with a Perforce server.

As an example of usage:

  
 // Setup
 Depot depot = new Depot();
 depot.setPort("perforce.com:1666");
 depot.setUser("username");
 depot.setPassword("password");
 depot.setWorkspace("workspace");
 
 // Test
 depot.isValid()  // returns true if so 
 
 // Look at the last change for a project...
 List<Changelist> changes = depot.getChanges().getChangelists("//depot/ProjectName/...", -1, 1);
 System.out.println(Last Change is: " + changes.get(0));
 

Author:
Mike Wille

Constructor Summary
Depot()
           
Depot(ExecutorFactory factory)
           
 
Method Summary
 void appendPath(java.lang.String path)
          Append the path element to the existing path.
 Changes getChanges()
          Retrieves the Changes object for interacting with this depot's changelists
 java.lang.String getClient()
          Returns the P4CLIENT.
 Counters getCounters()
          Retrieves the Counters object for interacting with this depot's counters.
 ExecutorFactory getExecFactory()
          Ensures that the latest settings are reflected in the ExecutorFactory before it is used.
 java.lang.String getExecutable()
          Returns the path to the executable.
 Groups getGroups()
          Retrieves the Groups object for interacting with this depot's groups.
 Labels getLabels()
          Retrieves the labels object for interacting with this depot's labels.
 org.slf4j.Logger getLogger()
           
 java.lang.String getP4Ticket()
          Returns the ticket value for this depot's user.
 java.lang.String getPassword()
          Returns the P4PASSWORD.
 java.lang.String getPath()
          Returns the path
 Env getPerforceEnv()
          Obtain a legacy perforce Env object for using legacy API.
 java.lang.String getPort()
          Returns the P4PORT.
 java.lang.String getProperty(java.lang.String key)
          Gets a property specified by key
 java.lang.String getProperty(java.lang.String key, java.lang.String def)
          Gets a value specified by key.
 long getServerTimeout()
          Return the server timeout threshold.
 Status getStatus()
          Retrieves the status object for interacting with the depot's status.
 java.lang.String getSystemDrive()
          Returns the system drive
 java.lang.String getSystemRoot()
          Returns the system root.
 java.lang.String getUser()
          Returns the P4USER.
 Users getUsers()
          Retrieves the Users object for interacting with this depot's users.
 Workspaces getWorkspaces()
          Retrieves the Workspaces object for interacting with this depot's workspaces
 java.lang.String info()
          Returns the output created by "p4 info"
static boolean safeEquals(java.lang.String newValue, java.lang.String currentValue)
           
 void setClient(java.lang.String client)
          Sets the P4CLIENT in the class information.
 void setExecutable(java.lang.String exe)
          Sets up the path to reach the p4 executable.
 void setP4Ticket(java.lang.String ticket)
          If using tickets, set the value of the ticket for this depot's user.
 void setPassword(java.lang.String password)
          Sets the P4PASSWD in the class information.
 void setPath(java.lang.String path)
          Sets the PATH in the class information.
 void setPort(java.lang.String port)
          Sets the P4PORT in the class information.
 void setServerTimeout(long threshold)
          Set the server timeout threshold.
 void setSystemDrive(java.lang.String drive)
          Sets the SystemDrive in the class information.
 void setSystemRoot(java.lang.String root)
          Sets the SystemRoot in the class information.
 void setUser(java.lang.String user)
          Sets the P4USER in the class information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Depot

public Depot()

Depot

public Depot(ExecutorFactory factory)
Method Detail

getExecFactory

public ExecutorFactory getExecFactory()
Ensures that the latest settings are reflected in the ExecutorFactory before it is used.

Returns:

getLogger

public org.slf4j.Logger getLogger()

getPerforceEnv

public Env getPerforceEnv()
Obtain a legacy perforce Env object for using legacy API. Useful if you need to leverage a feature not present in com.tek42.perforce but one that does exist in com.perforce.api.

Returns:
Env object

getChanges

public Changes getChanges()
Retrieves the Changes object for interacting with this depot's changelists

Returns:
Changes object

getWorkspaces

public Workspaces getWorkspaces()
Retrieves the Workspaces object for interacting with this depot's workspaces

Returns:
Workspaces object

getUsers

public Users getUsers()
Retrieves the Users object for interacting with this depot's users.

Returns:
Users object

getLabels

public Labels getLabels()
Retrieves the labels object for interacting with this depot's labels.

Returns:
Labels object

getGroups

public Groups getGroups()
Retrieves the Groups object for interacting with this depot's groups.

Returns:
Groups object

getCounters

public Counters getCounters()
Retrieves the Counters object for interacting with this depot's counters.

Returns:
Counters object

getStatus

public Status getStatus()
Retrieves the status object for interacting with the depot's status.

E.g., depot.getStatus().isValid() for checking if the settings are correct.

Returns:
Status object

info

public java.lang.String info()
                      throws java.lang.Exception
Returns the output created by "p4 info"

Returns:
The string output of p4 info
Throws:
java.lang.Exception

getProperty

public java.lang.String getProperty(java.lang.String key)
Gets a property specified by key

Parameters:
key -
Returns:

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String def)
Gets a value specified by key. If the value is empty, it will return the specified default.

Parameters:
key -
def -
Returns:

setUser

public void setUser(java.lang.String user)
Sets the P4USER in the class information.

Parameters:
user - P4USER value.

getUser

public java.lang.String getUser()
Returns the P4USER.

Returns:

setClient

public void setClient(java.lang.String client)
Sets the P4CLIENT in the class information.

Parameters:
user - P4CLIENT value.

getClient

public java.lang.String getClient()
Returns the P4CLIENT.

Returns:

setPort

public void setPort(java.lang.String port)
Sets the P4PORT in the class information.

Parameters:
user - P4PORT value.

getPort

public java.lang.String getPort()
Returns the P4PORT.

Returns:

setPassword

public void setPassword(java.lang.String password)
Sets the P4PASSWD in the class information.

Parameters:
user - P4PASSWD value.

getPassword

public java.lang.String getPassword()
Returns the P4PASSWORD.

Returns:

setPath

public void setPath(java.lang.String path)
Sets the PATH in the class information.

Parameters:
path - PATH value.

appendPath

public void appendPath(java.lang.String path)
Append the path element to the existing path. If the path element given is already in the path, no change is made.

Parameters:
path - the path element to be appended.

getPath

public java.lang.String getPath()
Returns the path

Returns:

setSystemDrive

public void setSystemDrive(java.lang.String drive)
Sets the SystemDrive in the class information. This is only meaningful under Windows.

Parameters:
user - SystemDrive value.

getSystemDrive

public java.lang.String getSystemDrive()
Returns the system drive

Returns:

setSystemRoot

public void setSystemRoot(java.lang.String root)
Sets the SystemRoot in the class information. This is only meaningful under Windows.

Parameters:
user - SystemRoot value.

getSystemRoot

public java.lang.String getSystemRoot()
Returns the system root.

Returns:

setExecutable

public void setExecutable(java.lang.String exe)
Sets up the path to reach the p4 executable. The full path passed in must contain the executable or at least end in the system's file separator character. This gotten from the file.separator property. For example:
 p4.executable=/usr/bin/p4   # This will work
 p4.executable=/usr/bin/     # This will work
 p4.executable=/usr/bin      # This won't work
 

Parameters:
exe - Full path to the p4 executable.

getExecutable

public java.lang.String getExecutable()
Returns the path to the executable.

Returns:

setServerTimeout

public void setServerTimeout(long threshold)
Set the server timeout threshold.

Parameters:
threshold -

getServerTimeout

public long getServerTimeout()
Return the server timeout threshold.

Returns:

getP4Ticket

public java.lang.String getP4Ticket()
Returns the ticket value for this depot's user.

Returns:
the p4Ticket

setP4Ticket

public void setP4Ticket(java.lang.String ticket)
If using tickets, set the value of the ticket for this depot's user. Example value would be: 875477B92937E4AF7B20C5234C8905E2

Parameters:
ticket - the p4Ticket to set

safeEquals

public static boolean safeEquals(java.lang.String newValue,
                                 java.lang.String currentValue)


Copyright © 2009. All Rights Reserved.