Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions

Copyright:
==================================================================== Copyright (c) 2003-2004 CollabNet. All rights reserved. This software is licensed as described in the file COPYING, which you should have received as part of this distribution. The terms are also available at http://subversion.tigris.org/license-1.html. If newer versions of this license are posted there, you may use a newer version instead, at your option. This software consists of voluntary contributions made by many individuals. For exact contribution history, see the revision history and logs, available at http://subversion.tigris.org/. ====================================================================
Endcopyright:
 
 package org.tigris.subversion.javahl;
 
 import java.util.Date;
Class to specify a revision in a svn command.
 
 public class Revision
 {
    
kind of revision specified
 
     protected int revKind;

    
Create a new revision

Deprecated:
Parameters:
kind kind of revision
 
     public Revision(int kind)
     {
         if(kind < . || kind > .)
             throw new IllegalArgumentException(
                     kind+" is not a legel revision kind");
          = kind;
     }

    
Internally create a new revision

Parameters:
kind kind of revision
marker marker to differtiate from the public deprecated version
 
     protected Revision(int kindboolean marker)
     {
         if(kind < . || kind > .)
             throw new IllegalArgumentException(
                     kind+" is not a legel revision kind");
          = kind;
     }

    
Returns the kind of the Revsion

Returns:
kind
 
     public int getKind()
     {
         return ;
     }

    
return the textual representation of the revision

Returns:
english text
 
     public String toString()
     {
         switch() {
             case . : return "BASE";
             case . : return "COMMITTED";
             case . : return "HEAD";
             case . : return "PREV";
             case . : return "WORKING";
         }
         return super.toString();
     }

    
compare to revision objects

Parameters:
target
Returns:
if both object have equal content
 
     public boolean equals(Object target) {
         if (this == target)
             return true;
         if (!(target instanceof Revision))
             return false;
 
         return ((Revision)target). == ;        
     }

    
Creates a Revision.Number object

Parameters:
revisionNumber the revision number of the new object
Returns:
the new object
Throws:
java.lang.IllegalArgumentException If the specified revision number is invalid.
    public static Revision getInstance(long revisionNumber)
    {
        return new Revision.Number(revisionNumber);
    }

    
Factory which creates Number objects for valid revision numbers only (those greater than zero). For internal usage to avoid an IllegalArgumentException, where no external consumer of the javahl API passed an invalid revision number.

Parameters:
revNumber The revision number to create an object for.
Returns:
An object representing revNumber, or null if the revision number was invalid.
Since:
1.2
    static Number createNumber(long revNumber)
    {
        return (revNumber < 0 ? null : new Number(revNumber));
    }

    
Creates a Revision.DateSpec objet

Parameters:
revisionDate the date of the new object
Returns:
the new object
    public static Revision getInstance(Date revisionDate)
    {
        return new Revision.DateSpec(revisionDate);
    }

    
last commited revision
    public static final Revision HEAD = new Revision(.true);
    
first existing revision
    public static final Revision START = new Revision(.true);
    
last committed revision, needs working copy
    public static final Revision COMMITTED = new Revision(.true);
    
previous committed revision, needs working copy
    public static final Revision PREVIOUS = new Revision(.true);
    
base revision of working copy
    public static final Revision BASE = new Revision(.true);
    
working version in working copy
    public static final Revision WORKING = new Revision(.true);
    
Marker revision number for no real revision
    public static final int SVN_INVALID_REVNUM = -1;

    
class to specify a Revision by number
    public static class Number extends Revision
    {
        
the revision number
        protected long revNumber;

        
create a revision by number object

Parameters:
number the number
Throws:
java.lang.IllegalArgumentException If the specified revision number is invalid.
        public Number(long number)
        {
            super(.true);
            if(number < 0)
                throw new IllegalArgumentException(
                        "negative revision numbers are not allowed");
             = number;
        }

        
Returns the revision number

Returns:
number
        public long getNumber()
        {
            return ;
        }

        
return the textual representation of the revision

Returns:
english text
        public String toString() {
            return Long.toString();
        }

        
compare to revision objects

Parameters:
target
Returns:
if both object have equal content
        public boolean equals(Object target) {
            if (!super.equals(target))
                return false;
            return ((Revision.Number)target). == ;        
        }
    }

    
class to specify a revision by a date
    public static class DateSpec extends Revision
    {
        
the date
        protected Date revDate;

        
create a revision by date object

Parameters:
date
        public DateSpec(Date date)
        {
            super(.true);
            if(date == null)
                throw new IllegalArgumentException("a date must be specified");
             = date;
        }
        
Returns the date of the revision

Returns:
the date
        public Date getDate()
        {
            return ;
        }

        
return the textual representation of the revision

Returns:
english text
        public String toString() {
            
            SimpleDateFormat dateFormat =
                    new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z",
                            .);
            return '{'+dateFormat.format()+'}';
        }

        
compare to revision objects

Parameters:
target
Returns:
if both object have equal content
        public boolean equals(Object target) {
            if (!super.equals(target))
                return false;
            return ((Revision.DateSpec)target)..equals();        
        }
        
    }

    
Various ways of specifying revisions. Note: In contexts where local mods are relevant, the `working' kind refers to the uncommitted "working" revision, which may be modified with respect to its base revision. In other contexts, `working' should behave the same as `committed' or `current'. the values are defined in RevisionKind because of building reasons
    public static final class Kind implements RevisionKind
    {
    }
New to GrepCode? Check out our FAQ X