Class MapEntry
- All Implemented Interfaces:
IMapEntry
- Direct Known Subclasses:
BranchSpec.BranchViewMapping,ClientView.ClientViewMapping,Label.LabelMapping,ProtectionEntry,ReviewSubscription,Stream.StreamComponentMapping,Stream.StreamIgnoredMapping,Stream.StreamRemappedMapping,Stream.StreamViewMapping,TriggerEntry
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.perforce.p4java.core.IMapEntry
IMapEntry.EntryType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected static Patternprotected static Stringprotected Stringprotected intprotected Stringprotected IMapEntry.EntryTypeFields inherited from interface com.perforce.p4java.core.IMapEntry
ORDER_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionMapEntry()Default constructor.MapEntry(int order, IMapEntry.EntryType type, String left, String right) Explicit-value constructor.Attempts to construct a new MapEntry by parsing the passed-in string into type, left, and right components; assumes that the passed-in string is in the format specified by parseViewString (below).Construct a suitable MapEntry from the passed-in arguments, inferring the entry type from any suitable prefixes on the passed-in left string.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the "comment" entry for this mapping; equivalent to getComment(false).getComment(boolean quoteBlanks) Get the "comment" entry for this mapping.getLeft()Get the "left" entry for this mapping; equivalent to getLeft(false).getLeft(boolean quoteBlanks) Get the "left" entry for this mapping.intgetOrder()Get the order of this entry in the entry list, if known.getRight()Get the "right" entry for this mapping; equivalent to getRight(false).getRight(boolean quoteBlanks) Get the "right" entry for this mapping.getType()Return the view map type of this entry.static StringparseComments(String str) static String[]parseViewMappingString(String rawStr) Attempt to parse a string to get left and right view mapping elements out of it along with the optional EntryType spec on any left view strings.protected static StringPut double quotes around file path with whitespace.voidsetComment(String comment) Set the "comment" entry for this mapping.voidSet the "left" entry for this mapping.voidsetOrder(int position) NOTE: does not affect actual order in the list on its own...voidSet the "right" entry for this mapping.voidsetType(IMapEntry.EntryType type) Set this entry's type.static StringstripComments(String str) static StringstripTypePrefix(String str) Strip any Perforce entry type prefix from the passed-in string.toString()An alias for this.toString(" ", true).Return a canonical String representation of this entry.
-
Field Details
-
elementPatternStr
-
elementPattern
-
order
protected int order -
type
-
left
-
right
-
comment
-
-
Constructor Details
-
MapEntry
public MapEntry()Default constructor. Sets all fields to null, and order to ORDER_UNKNOWN. -
MapEntry
Construct a suitable MapEntry from the passed-in arguments, inferring the entry type from any suitable prefixes on the passed-in left string. Left and right strings have any type prefixes stripped from them.- Parameters:
order- orderleft- left mappingright- right mapping
-
MapEntry
Explicit-value constructor. Left and right strings have any type prefixes stripped from them before being assigned to the new entry.- Parameters:
order- ordertype- typeleft- left mappingright- right mapping
-
MapEntry
Attempts to construct a new MapEntry by parsing the passed-in string into type, left, and right components; assumes that the passed-in string is in the format specified by parseViewString (below). If the passed-in string is null, only the order field is set; the other fields are set to null or ORDER_UNKNOWN.- Parameters:
order- ordermappingStr- mapping
-
MapEntry
Copy constructor. Constructs a new MapEntry from the passed-in version. If entry is null, this is equivalent to calling the default constructor.- Parameters:
entry- map entry
-
-
Method Details
-
getOrder
public int getOrder()Description copied from interface:IMapEntryGet the order of this entry in the entry list, if known. Returns ORDER_UNKNOWN if the order is unknown or this entry is not currently associated with a map. -
setOrder
public void setOrder(int position) NOTE: does not affect actual order in the list on its own... -
getType
Description copied from interface:IMapEntryReturn the view map type of this entry. -
setType
Description copied from interface:IMapEntrySet this entry's type. -
getLeft
Description copied from interface:IMapEntryGet the "left" entry for this mapping; equivalent to getLeft(false). -
getLeft
Description copied from interface:IMapEntryGet the "left" entry for this mapping. Will not include any prefixes. If quoteBlanks is true and the left string contains spaces or tabs the entire string is returned surrounded by quote characters. -
setLeft
Description copied from interface:IMapEntrySet the "left" entry for this mapping. Will strip off any exclude (etc.) prefix before assigning it. -
getRight
Description copied from interface:IMapEntryGet the "right" entry for this mapping; equivalent to getRight(false). -
getRight
Description copied from interface:IMapEntryGet the "right" entry for this mapping. Will not include any prefixes. If quoteBlanks is true and the right string contains spaces or tabs the entire string is returned surrounded by quote characters. -
setRight
Description copied from interface:IMapEntrySet the "right" entry for this mapping. Will strip off any exclude (etc.) prefix before assigning it. -
getComment
Description copied from interface:IMapEntryGet the "comment" entry for this mapping; equivalent to getComment(false).- Specified by:
getCommentin interfaceIMapEntry- Returns:
- possibly-null comment mapping entry.
- See Also:
-
getComment
Description copied from interface:IMapEntryGet the "comment" entry for this mapping. Will not include any prefixes. If quoteBlanks is true and the comment string contains spaces or tabs the entire string is returned surrounded by quote characters.- Specified by:
getCommentin interfaceIMapEntry- Parameters:
quoteBlanks- if true, and the comment string contains spaces or tabs the entire string is returned surrounded by quote characters.- Returns:
- possibly-null comment mapping entry.
- See Also:
-
setComment
Description copied from interface:IMapEntrySet the "comment" entry for this mapping. Will strip off any exclude (etc.) prefix before assigning it.- Specified by:
setCommentin interfaceIMapEntry- Parameters:
comment- possibly-null new comment mapping entry- See Also:
-
toString
Description copied from interface:IMapEntryReturn a canonical String representation of this entry. This is in the form [type prefix]leftpath[specstring]rightpath, e.g. "-//depot/dev/test/... //clientname/newpath/..."If the passed-in string is null, the left and right strings (if they exist) will be concatenated into one long separator-less string.
If the quoteBlanks parameter is true, if either or both the left or right entries contain spaces, the entries are quoted in full, i.e. the mapping //depot/test/space test 01/... //depot/test/space test 02/... becomes "//depot/test/space test 01/..." "//depot/test/space test 02/...".
-
toString
An alias for this.toString(" ", true). -
stripTypePrefix
Strip any Perforce entry type prefix from the passed-in string. If the string is null, this returns null; if there's no such prefix, the original string is returned.- Parameters:
str- prefix- Returns:
- formatted string
-
parseComments
-
stripComments
-
parseViewMappingString
Attempt to parse a string to get left and right view mapping elements out of it along with the optional EntryType spec on any left view strings.The incoming string format is described semi-formally as follows:
[whitespace] leftentry [whitespace rightentry] [whitespace] where leftentry = ([entrytype] non-whitespace-string) | (quote [entrytype] anystring quote) and rightentry = (non-whitespace-string) | (quote anystring quote)
Even less formally, if a left or right string has embedded spaces in it, it should be quoted with a double quote character; any left-entry entry type character must be within the quotes if they exist. The quotes are always stripped from the associated element before being returned.The left string is returned as the first element of the returned array; the right (if it exists) is the second. Either or both can be null, but the array itself will never be null. The left string will still contain any entry type spec prepended (if it exists), and will need further processing to get the entry type (and or remove the entry type character).
- Parameters:
rawStr- if not null, string to be parsed; if null, this method returns an empty (but not null) array- Returns:
- non-null two-element string array; element 0 contains the left element, element 1 contains the right. Either or both can be null, but except in pathological cases, it's unusual for the left to be null and the right to be non-null.
-
quoteWhitespaceString
Put double quotes around file path with whitespace. If quotes exist, don't quoted again.- Parameters:
str- with whitespace- Returns:
- quoted str with whitespace
-