Perforce

com.perforce.api
Class Change

java.lang.Object
  |
  +--com.perforce.api.SourceControlObject
        |
        +--com.perforce.api.Change
All Implemented Interfaces:
Cacheable

public final class Change
extends SourceControlObject

Representation of a source control change. This class can be used to determine information for a particular p4 change. It can be constructed using the change number, but will not contain any additional change information until the sync() method is called.

Version:
$Date: 2002/08/05 $ $Revision: #8 $
Author:
David Markley

Field Summary
static int PENDING
          Indicates that the Change is pending submission.
static int SUBMITTED
          Indicates that the Change has been submitted.
 
Constructor Summary
Change()
          Default no-argument constructor.
Change(Env environ)
           
Change(int number)
          Constructor that accepts the change number.
Change(String number)
           
 
Method Summary
 void addFile(FileEntry fent)
          Adds the given FileEntry to the changelist.
 void commit()
          Stores this object back into Perforce, creating it if it didn't already exist.
 String delete()
          Delete the pending changelist.
 HashDecay getCache()
          Returns the HashDecay instance for this class
static Change getChange(Env env, int number, boolean force)
           
static Change getChange(Env env, String number, boolean force)
           
static Change getChange(int number)
           
static Change getChange(int number, boolean force)
           
static Change getChange(String number)
           
static Change getChange(String number, boolean force)
           
static Change[] getChanges(Env env, String path)
           
static Change[] getChanges(Env env, String path, int max, String start, String end, boolean use_integs, String ufilter)
           
static Change[] getChanges(String path)
           
 String getClientName()
           
 String getDescription()
          Returns the description for the Change.
 Vector getFileEntries()
          Returns a Vector filled with the files (including revision numbers) that were affected by this change.
 Vector getFiles()
          Returns a Vector filled with the files (including revision numbers) that were affected by this change.
 String getModtimeString()
           
 int getNumber()
          Returns the number of this Change.
 String getShortDescription()
           
 String getShortDescription(boolean blurb)
           
 int getStatus()
          Returns the status for the Change.
 User getUser()
          Returns the User that owns this Change.
 String resolve(boolean force)
          Resolves this file.
 void revert()
          Reverts all the files associated with a pending changelist.
 User[] reviews()
          Determine the users that review this changelist.
 void setClientName(String name)
           
 void setDescription(String description)
          Sets the description for the change.
 void setModtimeString(String modtime)
           
 void setNumber(int number)
          Sets the change number for the Change.
 void setStatus(int status)
          Sets status for the Change.
 void setUser(User user)
          Sets the User that owns this Change.
 String submit()
          Submits the change, if it is pending.
 void sync()
          Synchronizes the Change with the correct information from P4, using whatever change number has already been set in the Change.
 void sync(int number)
          Sycnhronizes the Change with the correct information from P4.
 String toString()
          Overrides the default toString() method.
 String toXML()
          Returns a string containing the object in XML form.
 
Methods inherited from class com.perforce.api.SourceControlObject
clearCache, getEnv, getSyncTime, getUpdateTime, inSync, invalidate, outOfSync, refreshUpdateTime, setEnv
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PENDING

public static final int PENDING
Indicates that the Change is pending submission.

SUBMITTED

public static final int SUBMITTED
Indicates that the Change has been submitted.
Constructor Detail

Change

public Change()
Default no-argument constructor.

Change

public Change(Env environ)

Change

public Change(int number)
Constructor that accepts the change number. This change is not populated with the correct information until the sync() method is called on it.
Parameters:
number - Change number

Change

public Change(String number)
Method Detail

addFile

public void addFile(FileEntry fent)
             throws PerforceException
Adds the given FileEntry to the changelist. If the changelist has not been committed to the server, that is done first.
Parameters:
fent - file entry to be added.

commit

public void commit()
            throws CommitException
Description copied from class: SourceControlObject
Stores this object back into Perforce, creating it if it didn't already exist.
Overrides:
commit in class SourceControlObject

delete

public String delete()
              throws PerforceException
Delete the pending changelist. This method will revert any open files associated with the changelist and then delete it.
Returns:
log of delete command.

getCache

public HashDecay getCache()
Description copied from class: SourceControlObject
Returns the HashDecay instance for this class
Overrides:
getCache in class SourceControlObject

getChange

public static Change getChange(Env env,
                               int number,
                               boolean force)

getChange

public static Change getChange(Env env,
                               String number,
                               boolean force)

getChange

public static Change getChange(int number)

getChange

public static Change getChange(int number,
                               boolean force)

getChange

public static Change getChange(String number)

getChange

public static Change getChange(String number,
                               boolean force)

getChanges

public static Change[] getChanges(Env env,
                                  String path)
                           throws PerforceException

getChanges

public static Change[] getChanges(Env env,
                                  String path,
                                  int max,
                                  String start,
                                  String end,
                                  boolean use_integs,
                                  String ufilter)
                           throws PerforceException

getChanges

public static Change[] getChanges(String path)
                           throws PerforceException

getClientName

public String getClientName()

getDescription

public String getDescription()
Returns the description for the Change. This description includes not only the textual description provided by the user, but also the list of affected files and how they were affected. The String returned includes newline characters.

getFileEntries

public Vector getFileEntries()
Returns a Vector filled with the files (including revision numbers) that were affected by this change. What was done to each file as a result of this Change is stripped off. This method uses the value of the Change's description to determine the files that are affected.
Returns:
Vector of FileEntry objects of files affected.

getFiles

public Vector getFiles()
Returns a Vector filled with the files (including revision numbers) that were affected by this change. What was done to each file as a result of this Change is stripped off. This method uses the value of the Change's description to determine the files that are affected.
Returns:
Vector of Strings of files affected.

getModtimeString

public String getModtimeString()

getNumber

public int getNumber()
Returns the number of this Change.

getShortDescription

public String getShortDescription()

getShortDescription

public String getShortDescription(boolean blurb)

getStatus

public int getStatus()
Returns the status for the Change. This can be either PENDING or SUBMITTED.

getUser

public User getUser()
Returns the User that owns this Change.

resolve

public String resolve(boolean force)
               throws PerforceException
Resolves this file. If the force flag is false, and auto-resolve is attempted (p4 resolve -am). If the force flag is true, an "accept theirs" resolve is completed (p4 resolve -at).
Parameters:
force - Indicates whether the resolve should be forced.
See Also:
FileEntry.resolve(boolean)

revert

public void revert()
            throws PerforceException
Reverts all the files associated with a pending changelist.

reviews

public User[] reviews()
               throws PerforceException
Determine the users that review this changelist. This method returns an array of Users that need to be informed.

setClientName

public void setClientName(String name)

setDescription

public void setDescription(String description)
Sets the description for the change.

setModtimeString

public void setModtimeString(String modtime)

setNumber

public void setNumber(int number)
Sets the change number for the Change. This invalidates all the other data for the Change.
Parameters:
number - Change number

setStatus

public void setStatus(int status)
Sets status for the Change. This can be either PENDING or SUBMITTED.

setUser

public void setUser(User user)
Sets the User that owns this Change.
Parameters:
user - Owning user.

submit

public String submit()
              throws SubmitException
Submits the change, if it is pending.
Throws:
SubmitException - If the submit fails.

sync

public void sync()
Synchronizes the Change with the correct information from P4, using whatever change number has already been set in the Change. After this method is called, all the information in the Change is valid.
Overrides:
sync in class SourceControlObject

sync

public void sync(int number)
Sycnhronizes the Change with the correct information from P4. After this method is called, all the information in the Change is valid.
Parameters:
number - Change number

toString

public String toString()
Overrides the default toString() method.
Overrides:
toString in class Object

toXML

public String toXML()
Description copied from class: SourceControlObject
Returns a string containing the object in XML form.
Overrides:
toXML in class SourceControlObject

Perforce

Copyright © 2001, Perforce Software, All rights reserved.