Class SVNRevision


  • public class SVNRevision
    extends java.lang.Object
    SVNRevision is a revision wrapper used for an abstract representation of revision information.

    Most of high-level API classes' methods receive revision parameters as SVNRevision objects to get information on SVN revisions and use it in version control operations.

    This class provides advantages of specifying revisions either as just long numbers or dated revisions (when a revision is determined according to a particular timestamp) or SVN compatible keywords denoting the latest revision (HEAD), Working Copy pristine revision (BASE) and so on. And one more feature is that SVNRevision can parse strings (that can be anything: string representations of numbers, dates, keywords) to construct an SVNRevision to use.

    Since:
    1.2
    Version:
    1.3
    • Field Detail

      • HEAD

        public static final SVNRevision HEAD
        Denotes the latest repository revision. SVN's analogue keyword: HEAD.
      • WORKING

        public static final SVNRevision WORKING
        Denotes an item's working (current) revision. This is a SVNKit constant that should be provided to mean working revisions (what the native SVN client assumes by default).
      • PREVIOUS

        public static final SVNRevision PREVIOUS
        Denotes the revision just before the one when an item was last changed (technically, COMMITTED - 1). SVN's analogue keyword: PREV.
      • BASE

        public static final SVNRevision BASE
        Denotes the 'pristine' revision of a Working Copy item. SVN's analogue keyword: BASE.
      • COMMITTED

        public static final SVNRevision COMMITTED
        Denotes the last revision in which an item was changed before (or at) BASE. SVN's analogue keyword: COMMITTED.
      • UNDEFINED

        public static final SVNRevision UNDEFINED
        Used to denote that a revision is undefined (not available or not valid).
      • ourValidRevisions

        private static final java.util.Map ourValidRevisions
      • ISO_8601_EXTENDED_DATE_ONLY_PATTERN

        private static java.util.regex.Pattern ISO_8601_EXTENDED_DATE_ONLY_PATTERN
      • ISO_8601_EXTENDED_UTC_PATTERN

        private static java.util.regex.Pattern ISO_8601_EXTENDED_UTC_PATTERN
      • ISO_8601_EXTENDED_OFFSET_PATTERN

        private static java.util.regex.Pattern ISO_8601_EXTENDED_OFFSET_PATTERN
      • ISO_8601_BASIC_DATE_ONLY_PATTERN

        private static java.util.regex.Pattern ISO_8601_BASIC_DATE_ONLY_PATTERN
      • ISO_8601_BASIC_UTC_PATTERN

        private static java.util.regex.Pattern ISO_8601_BASIC_UTC_PATTERN
      • ISO_8601_BASIC_OFFSET_PATTERN

        private static java.util.regex.Pattern ISO_8601_BASIC_OFFSET_PATTERN
      • ISO_8601_GNU_FORMAT_PATTERN

        private static java.util.regex.Pattern ISO_8601_GNU_FORMAT_PATTERN
      • SVN_LOG_DATE_FORMAT_PATTERN

        private static java.util.regex.Pattern SVN_LOG_DATE_FORMAT_PATTERN
      • TIME_ONLY_PATTERN

        private static java.util.regex.Pattern TIME_ONLY_PATTERN
      • ourTimeFormatPatterns

        private static final java.util.Collection ourTimeFormatPatterns
      • myRevision

        private long myRevision
      • myName

        private java.lang.String myName
      • myDate

        private java.util.Date myDate
      • myID

        private int myID
    • Constructor Detail

      • SVNRevision

        private SVNRevision​(long number)
      • SVNRevision

        private SVNRevision​(java.lang.String name,
                            int id)
      • SVNRevision

        private SVNRevision​(java.util.Date date)
    • Method Detail

      • getName

        public java.lang.String getName()
        Gets the revision keyword name. Each of SVNRevision's constant fields that represent revision keywords also have its own name.
        Returns:
        a revision keyword name
      • getNumber

        public long getNumber()
        Gets the revision number represented by this object.
        Returns:
        a revision number; -1 is returned when this object represents a revision information not using a revision number.
      • getDate

        public java.util.Date getDate()
        Gets the timestamp used to specify a revision.
        Returns:
        a timestamp if any specified for this object
      • isValid

        public boolean isValid()
        Checks if the revision information represented by this object is valid.

        UNDEFINED is not a valid revision.

        Returns:
        true if valid, otherwise false
      • getID

        public int getID()
        Gets the identifier of the revision information kind this object represents.
        Returns:
        this object's id
      • hashCode

        public int hashCode()
        Evaluates the hash code for this object. A hash code is evaluated in this way:
        • if this object represents revision info as a revision number then hash code = (int) revisionNumber & 0xFFFFFFFF;
        • if this object represents revision info as a timestamp then Date.hashCode() is used;
        • if this object represents revision info as a keyword then String.hashCode() is used for the keyword name;
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        this object's hash code
      • equals

        public boolean equals​(java.lang.Object o)
        Compares this object with another SVNRevision object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object to be compared with; if it's not an SVNRevision then this method certainly returns false
        Returns:
        true if equal, otherwise false
      • isValidRevisionNumber

        public static boolean isValidRevisionNumber​(long revision)
        Checks whether a revision number is valid.
        Parameters:
        revision - a revision number
        Returns:
        true if valid (>=0), otherwise false
      • create

        public static SVNRevision create​(long revisionNumber)
        Creates an SVNRevision object given a revision number.
        Parameters:
        revisionNumber - a definite revision number
        Returns:
        the constructed SVNRevision object
      • create

        public static SVNRevision create​(java.util.Date date)
        Creates an SVNRevision object given a particular timestamp.
        Parameters:
        date - a timestamp represented as a Date instance
        Returns:
        the constructed SVNRevision object
      • isLocal

        public boolean isLocal()
        Determines if the revision represented by this abstract object is Working Copy specific - that is one of BASE or WORKING.
        Returns:
        true if this object represents a kind of a local revision, otherwise false
      • parse

        public static SVNRevision parse​(java.lang.String value)
        Parses an input string and be it a representation of either a revision number, or a timestamp, or a revision keyword, constructs an SVNRevision representation of the revision.
        Parameters:
        value - a string to be parsed
        Returns:
        an SVNRevision object that holds the revision information parsed from value; however if an input string is not a valid one which can be successfully transformed to an SVNRevision the return value is UNDEFINED
      • toString

        public java.lang.String toString()
        Gives a string representation of this object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representing this object