Class MapEntry

    • Constructor Summary

      Constructors 
      Constructor Description
      MapEntry()
      Default constructor.
      MapEntry​(int order, IMapEntry.EntryType type, java.lang.String left, java.lang.String right)
      Explicit-value constructor.
      MapEntry​(int order, java.lang.String mappingStr)
      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).
      MapEntry​(int order, java.lang.String left, java.lang.String right)
      Construct a suitable MapEntry from the passed-in arguments, inferring the entry type from any suitable prefixes on the passed-in left string.
      MapEntry​(IMapEntry entry)
      Copy constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getComment()
      Get the "comment" entry for this mapping; equivalent to getComment(false).
      java.lang.String getComment​(boolean quoteBlanks)
      Get the "comment" entry for this mapping.
      java.lang.String getLeft()
      Get the "left" entry for this mapping; equivalent to getLeft(false).
      java.lang.String getLeft​(boolean quoteBlanks)
      Get the "left" entry for this mapping.
      int getOrder()
      Get the order of this entry in the entry list, if known.
      java.lang.String getRight()
      Get the "right" entry for this mapping; equivalent to getRight(false).
      java.lang.String getRight​(boolean quoteBlanks)
      Get the "right" entry for this mapping.
      IMapEntry.EntryType getType()
      Return the view map type of this entry.
      static java.lang.String parseComments​(java.lang.String str)  
      static java.lang.String[] parseViewMappingString​(java.lang.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 java.lang.String quoteWhitespaceString​(java.lang.String str)
      Put double quotes around file path with whitespace.
      void setComment​(java.lang.String comment)
      Set the "comment" entry for this mapping.
      void setLeft​(java.lang.String left)
      Set the "left" entry for this mapping.
      void setOrder​(int position)
      NOTE: does not affect actual order in the list on its own...
      void setRight​(java.lang.String right)
      Set the "right" entry for this mapping.
      void setType​(IMapEntry.EntryType type)
      Set this entry's type.
      static java.lang.String stripComments​(java.lang.String str)  
      static java.lang.String stripTypePrefix​(java.lang.String str)
      Strip any Perforce entry type prefix from the passed-in string.
      java.lang.String toString()
      An alias for this.toString(" ", true).
      java.lang.String toString​(java.lang.String sepString, boolean quoteBlanks)
      Return a canonical String representation of this entry.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • elementPatternStr

        protected static java.lang.String elementPatternStr
      • elementPattern

        protected static java.util.regex.Pattern elementPattern
      • order

        protected int order
      • left

        protected java.lang.String left
      • right

        protected java.lang.String right
      • comment

        protected java.lang.String comment
    • Constructor Detail

      • MapEntry

        public MapEntry()
        Default constructor. Sets all fields to null, and order to ORDER_UNKNOWN.
      • MapEntry

        public MapEntry​(int order,
                        java.lang.String left,
                        java.lang.String right)
        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 - order
        left - left mapping
        right - right mapping
      • MapEntry

        public MapEntry​(int order,
                        IMapEntry.EntryType type,
                        java.lang.String left,
                        java.lang.String right)
        Explicit-value constructor. Left and right strings have any type prefixes stripped from them before being assigned to the new entry.
        Parameters:
        order - order
        type - type
        left - left mapping
        right - right mapping
      • MapEntry

        public MapEntry​(int order,
                        java.lang.String mappingStr)
        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 - order
        mappingStr - mapping
      • MapEntry

        public MapEntry​(IMapEntry entry)
        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 Detail

      • getOrder

        public int getOrder()
        Description copied from interface: IMapEntry
        Get 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.
        Specified by:
        getOrder in interface IMapEntry
        Returns:
        ORDER_UNKNOWN or current order.
        See Also:
        IMapEntry.getOrder()
      • setOrder

        public void setOrder​(int position)
        NOTE: does not affect actual order in the list on its own...
        Specified by:
        setOrder in interface IMapEntry
        Parameters:
        position - new order
        See Also:
        IMapEntry.setOrder(int)
      • getLeft

        public java.lang.String getLeft()
        Description copied from interface: IMapEntry
        Get the "left" entry for this mapping; equivalent to getLeft(false).
        Specified by:
        getLeft in interface IMapEntry
        Returns:
        possibly-null left mapping entry.
        See Also:
        IMapEntry.getLeft()
      • getLeft

        public java.lang.String getLeft​(boolean quoteBlanks)
        Description copied from interface: IMapEntry
        Get 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.
        Specified by:
        getLeft in interface IMapEntry
        Parameters:
        quoteBlanks - if true, and the left string contains spaces or tabs the entire string is returned surrounded by quote characters.
        Returns:
        possibly-null left mapping entry.
        See Also:
        IMapEntry.getLeft(boolean)
      • setLeft

        public void setLeft​(java.lang.String left)
        Description copied from interface: IMapEntry
        Set the "left" entry for this mapping. Will strip off any exclude (etc.) prefix before assigning it.
        Specified by:
        setLeft in interface IMapEntry
        Parameters:
        left - possibly-null new left mapping entry
        See Also:
        IMapEntry.setLeft(java.lang.String)
      • getRight

        public java.lang.String getRight()
        Description copied from interface: IMapEntry
        Get the "right" entry for this mapping; equivalent to getRight(false).
        Specified by:
        getRight in interface IMapEntry
        Returns:
        possibly-null right mapping entry.
        See Also:
        IMapEntry.getRight()
      • getRight

        public java.lang.String getRight​(boolean quoteBlanks)
        Description copied from interface: IMapEntry
        Get 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.
        Specified by:
        getRight in interface IMapEntry
        Parameters:
        quoteBlanks - if true, and the right string contains spaces or tabs the entire string is returned surrounded by quote characters.
        Returns:
        possibly-null right mapping entry.
        See Also:
        IMapEntry.getRight(boolean)
      • setRight

        public void setRight​(java.lang.String right)
        Description copied from interface: IMapEntry
        Set the "right" entry for this mapping. Will strip off any exclude (etc.) prefix before assigning it.
        Specified by:
        setRight in interface IMapEntry
        Parameters:
        right - possibly-null new right mapping entry
        See Also:
        IMapEntry.setRight(java.lang.String)
      • getComment

        public java.lang.String getComment()
        Description copied from interface: IMapEntry
        Get the "comment" entry for this mapping; equivalent to getComment(false).
        Specified by:
        getComment in interface IMapEntry
        Returns:
        possibly-null comment mapping entry.
        See Also:
        IMapEntry.getComment()
      • getComment

        public java.lang.String getComment​(boolean quoteBlanks)
        Description copied from interface: IMapEntry
        Get 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:
        getComment in interface IMapEntry
        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:
        IMapEntry.getComment(boolean)
      • setComment

        public void setComment​(java.lang.String comment)
        Description copied from interface: IMapEntry
        Set the "comment" entry for this mapping. Will strip off any exclude (etc.) prefix before assigning it.
        Specified by:
        setComment in interface IMapEntry
        Parameters:
        comment - possibly-null new comment mapping entry
        See Also:
        IMapEntry.setComment(java.lang.String)
      • toString

        public java.lang.String toString​(java.lang.String sepString,
                                         boolean quoteBlanks)
        Description copied from interface: IMapEntry
        Return 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/...".

        Specified by:
        toString in interface IMapEntry
        Parameters:
        sepString - separator string
        quoteBlanks - quotes if spaces are used
        Returns:
        formatted string
        See Also:
        IMapEntry.toString(String, boolean)
      • toString

        public java.lang.String toString()
        An alias for this.toString(" ", true).
        Specified by:
        toString in interface IMapEntry
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • stripTypePrefix

        public static java.lang.String stripTypePrefix​(java.lang.String str)
        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

        public static java.lang.String parseComments​(java.lang.String str)
      • stripComments

        public static java.lang.String stripComments​(java.lang.String str)
      • parseViewMappingString

        public static java.lang.String[] parseViewMappingString​(java.lang.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.

        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

        protected static java.lang.String quoteWhitespaceString​(java.lang.String str)
        Put double quotes around file path with whitespace. If quotes exist, don't quoted again.
        Parameters:
        str - with whitespace
        Returns:
        quoted str with whitespace