Class PathAnnotations
java.lang.Object
com.perforce.p4java.impl.generic.core.file.PathAnnotations
Conveniently bundles up possible Perforce path-based metadata
annotations and associated operations. This includes revision,
label, changelist, and date annotations (at least). Most useful
for converting to / from string representations associated with
string file paths.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected Dateprotected intprotected Stringstatic final StringThe string used to start Perforce file label / changelist / date metadata annotations.static final StringThe string used to start Perforce file revision metadata annotations.static final StringThe string used to separate Perforce file revision metadata annotations.protected int -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a PathAnnotations object with default field values:
startRev, endRev = IFileSpec.NO_FILE_REVISION;
date, label = null;
changelist = IChangelist.UNKNOWN.PathAnnotations(int startRevision, int endRevision, Date date, int changelistId, String label) Construct a PathAnnotations object from explicit candidate field values.PathAnnotations(IFileSpec fileSpec) Construct a PathAnnotations object for a specific file spec.PathAnnotations(String pathStr) Construct a PathAnnotations object from the passed-in string, which is assumed to contain a path string with optional Perforce annotations. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanextractNonRevisionData(String pathStr, PathAnnotations pathAnnotations) Extract any non-revision info from the passed-in pathStr and put it into the passed-in pathAnnotations object.static booleanextractRevisionData(String pathStr, PathAnnotations pathAnnotations) Extract any start / end revision info from the passed-in pathStr and put it into the passed-in pathAnnotations object.static PathAnnotationsgetAnnotations(String pathStr) Get all Perforce metadata annotations from the passed-in string.intgetDate()intgetLabel()intstatic inthasNonRevisionAnnotations(String pathStr) Return non-negative index of first non-revision Perforce annotations match in the string if the passed-in string is not null and has label, changelist, date, etc., specs appended.static booleanhasPerforceAnnotations(String pathStr) Return true if the passed-in path is not null and has Perforce file metadata appended to it.static inthasRevisionAnnotations(String pathStr) Return non-negative index of first non-revision Perforce annotations match in the string if the passed-in string is not null has Perforce revision annotations appended to it.voidsetChangelistId(int changelistId) voidvoidsetEndRevision(int endRev) voidvoidsetStartRevision(int startRev) static StringstripAnnotations(String pathStr) Strip any Perforce file metadata annotations from the passed-in string.toString()Return a Perforce-standard string representation of this annotation.
-
Field Details
-
REV_PFX
The string used to start Perforce file revision metadata annotations.- See Also:
-
REV_SEP
The string used to separate Perforce file revision metadata annotations.- See Also:
-
NONREV_PFX
The string used to start Perforce file label / changelist / date metadata annotations.- See Also:
-
startRevision
protected int startRevision -
endRevision
protected int endRevision -
date
-
changelistId
protected int changelistId -
label
-
-
Constructor Details
-
PathAnnotations
public PathAnnotations()Construct a PathAnnotations object with default field values:
startRev, endRev = IFileSpec.NO_FILE_REVISION;
date, label = null;
changelist = IChangelist.UNKNOWN. -
PathAnnotations
public PathAnnotations(int startRevision, int endRevision, Date date, int changelistId, String label) Construct a PathAnnotations object from explicit candidate field values.- Parameters:
startRevision- startRevisionendRevision- endRevisiondate- datechangelistId- changelistIdlabel- label
-
PathAnnotations
Construct a PathAnnotations object for a specific file spec. If fileSpec is null, this is equivalent to calling the default constructor.- Parameters:
fileSpec- fileSpec
-
PathAnnotations
Construct a PathAnnotations object from the passed-in string, which is assumed to contain a path string with optional Perforce annotations. If pathStr is null, or contains no parseable annotations, this is equivalent to calling the default constructor.- Parameters:
pathStr- pathStr
-
-
Method Details
-
stripAnnotations
Strip any Perforce file metadata annotations from the passed-in string. Returns the string as-is if there were no annotations or if the string was null. Will return the empty (not null) string if there was no actual path part of the string and pathStr wasn't null.- Parameters:
pathStr- pathStr- Returns:
- stripped path
-
getAnnotations
Get all Perforce metadata annotations from the passed-in string. If there are no annotations, or the passed-in pathStr argument is null, returns null.- Parameters:
pathStr- pathStr- Returns:
- path annotations
-
hasRevisionAnnotations
Return non-negative index of first non-revision Perforce annotations match in the string if the passed-in string is not null has Perforce revision annotations appended to it. Otherwise returns -1.- Parameters:
pathStr- pathStr- Returns:
- index
-
hasNonRevisionAnnotations
Return non-negative index of first non-revision Perforce annotations match in the string if the passed-in string is not null and has label, changelist, date, etc., specs appended. Otherwise returns -1.- Parameters:
pathStr- pathStr- Returns:
- index
-
hasPerforceAnnotations
Return true if the passed-in path is not null and has Perforce file metadata appended to it.- Parameters:
pathStr- pathStr- Returns:
- has matadata
-
extractRevisionData
Extract any start / end revision info from the passed-in pathStr and put it into the passed-in pathAnnotations object. Returns true if it found any parseable revision information, false otherwise.If either or both pathStr and pathAnnotations is null, returns false.
- Parameters:
pathStr- pathStrpathAnnotations- pathAnnotations- Returns:
- true if parseable revision data
-
extractNonRevisionData
Extract any non-revision info from the passed-in pathStr and put it into the passed-in pathAnnotations object. Returns true if it found any parseable label / changelist / date (etc.) information, false otherwise.Note that the candidate string "@2009/09/12" is ambiguous -- it could be either a date or a label by a generous reading of the Perforce specs -- but we take the "if it looks like a duck..." approach here and parse it as a date if at all possible. Similarly for the string "@12345" which could be a changelist ID or a label ID -- we parse it as a changelist ID if at all possible.
If either or both pathStr and pathAnnotations is null, returns false.
- Parameters:
pathStr- pathStrpathAnnotations- pathAnnotations- Returns:
- false if null
-
toString
Return a Perforce-standard string representation of this annotation. Will return an empty (not null) string if there's nothing to represent. -
getStartRevision
public int getStartRevision() -
setStartRevision
public void setStartRevision(int startRev) -
getEndRevision
public int getEndRevision() -
setEndRevision
public void setEndRevision(int endRev) -
getDate
-
setDate
-
getChangelistId
public int getChangelistId() -
setChangelistId
public void setChangelistId(int changelistId) -
getLabel
-
setLabel
-