Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * ====================================================================
   * Copyright (c) 2004-2006 TMate Software Ltd.  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://svnkit.com/license.html
   * If newer versions of this license are posted there, you may use a
   * newer version instead, at your option.
  * ====================================================================
  */
 package org.tmatesoft.svn.core.wc;
 
 import java.io.File;
 import java.util.Date;
 import java.util.Map;
 
The SVNStatus class is used to provide detailed status information for a Working Copy item as a result of a status operation invoked by a doStatus() method of SVNStatusClient. SVNStatus objects are generated for each 'interesting' local item and depending on the doStatus() method in use either passed for notification to an ISVNStatusHandler implementation or such an object is just returned by the method as a status info for a single item.

Within the status handler implementation a developer decides how to interpret status information. For some purposes this way may be more flexible in comparison with calling doStatus() that returns an SVNStatus per one local item. However the latter one may be useful when needing to find out the status of the concrete item.

There are two approaches how to process SVNStatus objects:
1. Implementing an ISVNStatusHandler:

 import org.tmatesoft.svn.core.wc.ISVNStatusHandler;
 import org.tmatesoft.svn.core.wc.SVNStatus;
 import org.tmatesoft.svn.core.wc.SVNStatusType;
 ...
 
 public class MyCustomStatusHandler implements ISVNStatusHandler {
     public void handleStatus(SVNStatus status) {
         //parse the item's contents status
         if(status.getContentsStatus() == SVNStatusType.STATUS_MODIFIED) {
             ...
         } else if(status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED) {
             ...        
         }
         ...
         //parse properties status
         if(status.getPropertiesStatus() == SVNStatusType.STATUS_MODIFIED) {
             ...
         }
         ...
     }
 }

...and providing a status handler implementation to an SVNStatusClient's doStatus() method:
 ...
 import org.tmatesoft.svn.core.wc.SVNStatusClient;
 ...
 
 SVNStatusClient statusClient;
 ...
 
 statusClient.doStatus(...., new MyCustomStatusHandler());
 ...

2. Or process an SVNStatus like this:
 ...
 SVNStatus status = statusClient.doStatus(new File(myPath), false);
 //parsing status info here
 ...

SVNStatus's methods which names start with getRemote are relevant for remote status invocations - that is when a doStatus() method of SVNStatusClient is called with the flag remote set to true.

Author(s):
TMate Software Ltd.
Version:
1.1.0
See also:
ISVNStatusHandler
SVNStatusType
Examples
 
 public class SVNStatus {
     
     private SVNURL myURL;
     private File myFile;
    private SVNNodeKind myKind;
    private SVNRevision myRevision;
    private Date myCommittedDate;
    private String myAuthor;
    private boolean myIsLocked;
    private boolean myIsCopied;
    private boolean myIsSwitched;
    private File myConflictNewFile;
    private File myConflictOldFile;
    private File myConflictWrkFile;
    private File myPropRejectFile;
    private String myCopyFromURL;
    private SVNLock myRemoteLock;
    private SVNLock myLocalLock;
    private Map myEntryProperties;
    private SVNRevision myRemoteRevision;
    private SVNURL myRemoteURL;
    private SVNNodeKind myRemoteKind;
    private String myRemoteAuthor;
    private Date myRemoteDate;
    private Date myLocalContentsDate;
    private Date myLocalPropertiesDate;
    private SVNEntry myEntry;

    
Constructs an SVNStatus object filling it with status information details.

Used by SVNKit internals to construct and initialize an SVNStatus object. It's not intended for users (from an API point of view).

Parameters:
url item's repository location
file item's path in a File representation
kind item's node kind
revision item's working revision
committedRevision item's last changed revision
committedDate item's last changed date
author item's last commit author
contentsStatus local status of item's contents
propertiesStatus local status of item's properties
remoteContentsStatus status of item's contents against a repository
remotePropertiesStatus status of item's properties against a repository
isLocked if the item is locked by the driver (not a user lock)
isCopied if the item is added with history
isSwitched if the item is switched to a different URL
conflictNewFile temp file with latest changes from the repository
conflictOldFile temp file just as the conflicting one was at the BASE revision
conflictWrkFile temp file with all user's current local modifications
projRejectFile temp file describing properties conflicts
copyFromURL url of the item's ancestor from which the item was copied
copyFromRevision item's ancestor revision from which the item was copied
remoteLock item's lock in the repository
localLock item's local lock
entryProperties item's SVN specific '<entry' properties
    public SVNStatus(SVNURL urlFile fileSVNNodeKind kind,
            SVNRevision revisionSVNRevision committedRevision,
            Date committedDateString authorSVNStatusType contentsStatus,
            SVNStatusType propertiesStatusSVNStatusType remoteContentsStatus,
            SVNStatusType remotePropertiesStatusboolean isLocked,
            boolean isCopiedboolean isSwitchedFile conflictNewFile,
            File conflictOldFileFile conflictWrkFileFile projRejectFile,
            String copyFromURLSVNRevision copyFromRevision,
            SVNLock remoteLockSVNLock localLockMap entryProperties) {
         = url;
         = file;
         = kind == null ? . : kind;
         = revision == null ? . : revision;
         = committedRevision == null ? .
                : committedRevision;
         = committedDate;
         = author;
         = contentsStatus == null ? .
                : contentsStatus;
         = propertiesStatus == null ? .
                : propertiesStatus;
         = remoteContentsStatus == null ? .
                : remoteContentsStatus;
         = remotePropertiesStatus == null ? .
                : remotePropertiesStatus;
         = isLocked;
         = isCopied;
         = isSwitched;
         = conflictNewFile;
         = conflictOldFile;
         = conflictWrkFile;
         = copyFromURL;
         = copyFromRevision == null ? .
                : copyFromRevision;
         = remoteLock;
         = localLock;
         = projRejectFile;
         = entryProperties;
    }
    
    
Gets the item's repository location. URL is taken from the org.tmatesoft.svn.core.SVNProperty.URL property.

Returns:
the item's URL represented as an SVNURL object
    public SVNURL getURL() {
        return ;
    }
    
    
Gets the item's latest repository location. For example, the item could have been moved in the repository, but getURL() returns the item's URL as it's defined in a URL entry property. Applicable for a remote status invocation.

Returns:
the item's URL as it's real repository location
    public SVNURL getRemoteURL() {
        return ;
    }

    
Gets the item's path in the filesystem.

Returns:
a File representation of the item's path
    public File getFile() {
        return ;
    }
    
    
Gets the item's node kind characterizing it as an entry.

Returns:
the item's node kind (whether it's a file, directory, etc.)
    public SVNNodeKind getKind() {
        return ;
    }
    
    
Gets the item's current working revision.

Returns:
the item's working revision
    public SVNRevision getRevision() {
        return ;
    }
    
    
Gets the revision when the item was last changed (committed).

Returns:
the last committed revision
    public SVNRevision getCommittedRevision() {
        return ;
    }
    
    
Gets the timestamp when the item was last changed (committed).

Returns:
the last committed date
    public Date getCommittedDate() {
        return ;
    }
    
    
Gets the author who last changed the item.

Returns:
the item's last commit author
    public String getAuthor() {
        return ;
    }

    
Gets the Working Copy local item's contents status type.

Returns:
the local contents status type
    public SVNStatusType getContentsStatus() {
        return ;
    }
    
    
Gets the Working Copy local item's properties status type.

Returns:
the local properties status type
        return ;
    }
    
    
Gets the Working Copy item's contents status type against the repository - that is comparing the item's BASE revision and the latest one in the repository when the item was changed. Applicable for a remote status invocation.

If the remote contents status type != SVNStatusType.STATUS_NONE the local file may be out of date.

Returns:
the remote contents status type
        return ;
    }
    
    
Gets the Working Copy item's properties status type against the repository - that is comparing the item's BASE revision and the latest one in the repository when the item was changed. Applicable for a remote status invocation.

If the remote properties status type != SVNStatusType.STATUS_NONE the local file may be out of date.

Returns:
the remote properties status type
        return ;
    }
    
    
Finds out if the item is locked (not a user lock but a driver's one when during an operation a Working Copy is locked in .svn administrative areas to prevent from other operations interrupting until the running one finishes).

To clean up a Working Copy use doCleanup().

Returns:
true if locked, otherwise false
    public boolean isLocked() {
        return ;
    }
    
    
Finds out if the item is added with history.

Returns:
true if the item is added with history, otherwise false
    public boolean isCopied() {
        return ;
    }
    
    
Finds out whether the item is switched to a different repository location.

Returns:
true if switched, otherwise false
    public boolean isSwitched() {
        return ;
    }
    
    
Gets the temporary file that contains all latest changes from the repository which led to a conflict with local changes. This file is at the HEAD revision.

Returns:
an autogenerated temporary file just as it is in the latest revision in the repository
    public File getConflictNewFile() {
        return ;
    }
    
    
Gets the temporary BASE revision file of that working file that is currently in conflict with changes received from the repository. This file does not contain the latest user's modifications, only 'pristine' contents.

Returns:
an autogenerated temporary file just as the conflicting file was before any modifications to it
    public File getConflictOldFile() {
        return ;
    }
    
    
Gets the temporary '.mine' file with all current local changes to the original file. That is if the file item is in conflict with changes that came during an update this temporary file is created to get the snapshot of the user's file with only the user's local modifications and nothing more.

Returns:
an autogenerated temporary file with only the user's modifications
    public File getConflictWrkFile() {
        return ;
    }
    
    
Gets the '.prej' file containing details on properties conflicts. If the item's properties are in conflict with those that came during an update this file will contain a conflict description.

Returns:
the properties conflicts file
    public File getPropRejectFile() {
        return ;
    }
    
    
Gets the URL (repository location) of the ancestor from which the item was copied. That is when the item is added with history.

Returns:
the item ancestor's URL
    public String getCopyFromURL() {
        return ;
    }
    
    
Gets the revision of the item's ancestor from which the item was copied (the item is added with history).

Returns:
the ancestor's revision
    public SVNRevision getCopyFromRevision() {
        return ;
    }
    
    
Gets the file item's repository lock - applicable for a remote status invocation.

Returns:
file item's repository lock
    public SVNLock getRemoteLock() {
        return ;
    }
    
    
Gets the file item's local lock.

Returns:
file item's local lock
    public SVNLock getLocalLock() {
        return ;
    }
    
    
Gets the item's SVN specific '<entry' properties. These properties' names start with org.tmatesoft.svn.core.SVNProperty.SVN_ENTRY_PREFIX.

Returns:
a Map which keys are names of SVN entry properties mapped against their values (both strings)
    public Map getEntryProperties() {
        return ;
    }
    
    
Gets the item's last committed repository revision. Relevant for a remote status invocation.

Returns:
the latest repository revision when the item was changed; null or SVNRevision.UNDEFINED if the repository revision is unavailable
    public SVNRevision getRemoteRevision() {
        return ;
    }
    
    
Returns the kind of the item got from the repository. Relevant for a remote status invocation.

Returns:
a remote item kind
    public SVNNodeKind getRemoteKind() {
        return ;
    }

    
Gets the item's last changed date. Relevant for a remote status invocation.

Returns:
a repository last changed date
    public Date getRemoteDate() {
        return ;
    }
    
    
Gets the item's last changed author. Relevant for a remote status invocation.

Returns:
a last commit author
    public String getRemoteAuthor() {
        return ;
    }
    
    
Returns the last modified local time of the file item. Irrelevant for directories (for directories returns Date(0)).

Returns:
last modified time of the file
    public Date getWorkingContentsDate() {
        if ( == null) {
            if (getFile() != null && getKind() == .) {
                 = new Date(getFile().lastModified());
            } else {
                 = new Date(0);
            }
        }
        return ;
    }
    
    
Returns the last modified local time of file or directory properties.

Returns:
last modified time of the item properties
    public Date getWorkingPropertiesDate() {
        if ( == null) {
            File propFile = null;
            if (getFile() != null && getKind() == .) {
                propFile = new File(getFile().getAbsoluteFile().getParentFile(), SVNFileUtil.getAdminDirectoryName());
                propFile = new File(propFile"dir-props");
            } else if (getFile() != null && getKind() == .) {
                propFile = new File(getFile().getAbsoluteFile().getParentFile(), SVNFileUtil.getAdminDirectoryName());
                propFile = new File(propFile"props/" + getFile().getName() + ".svn-work");
            }
             = propFile != null ? new Date(propFile.lastModified()) : new Date(0);
        }
        return ;
    }
    
    
Marks the item as an external. This method is used by SVNKit internals and not intended for users (from an API point of view).
    public void markExternal() {
    }
    
    
Sets the item's remote status. Used by SVNKit internals and not intended for users (from an API point of view).

Parameters:
contents item's contents status type against the repository
props item's properties status type against the repository
lock item's lock in the repository
kind item's node kind
    public void setRemoteStatus(SVNStatusType contentsSVNStatusType propsSVNLock lockSVNNodeKind kind) {
        if (contents == . &&  == .) {
            contents = .;
        }
         = contents != null ? contents : ;
         = props != null ? props : ;
        if (lock != null) {
             = lock;
        }
        if (kind != null) {
             = kind;
        }
    }
    
    
Sets the item's remote status. Used by SVNKit internals and not intended for users (from an API point of view).

Parameters:
url item's repository URL
contents item's contents status type against the repository
props item's properties status type against the repository
lock item's lock in the repository
kind item's node kind
revision item's latest revision when it was last committed
date last item's committed date
author last item's committed author
    public void setRemoteStatus(SVNURL urlSVNStatusType contentsSVNStatusType propsSVNLock lockSVNNodeKind kindSVNRevision revision,
            Date dateString author) {
        setRemoteStatus(contentspropslockkind);
         = url;
         = revision == null ? . : revision;
         = date;
         = author;
         = kind;
    }
    
    
Sets the item's contents status type. Used by SVNKit internals and not intended for users (from an API point of view).

Parameters:
statusType status type of the item's contents
    public void setContentsStatus(SVNStatusType statusType) {
         = statusType;
    }
    
    
Sets a WC entry for which this object is generated. Used in internals.

Parameters:
entry a WC entry
    public void setEntry(SVNEntry entry) {
         = entry;
    }
    
    
Returns a WC entry for which this object is generated.

Returns:
a WC entry (if set)
    public SVNEntry getEntry() {
        return ;
    }
New to GrepCode? Check out our FAQ X