org.netbeans.modules.versioning.core/1 1.5.0 1

org.netbeans.modules.versioning.core.spi
Class VCSInterceptor

java.lang.Object
  extended by org.netbeans.modules.versioning.core.spi.VCSInterceptor

public abstract class VCSInterceptor
extends Object

Versioning systems that need to intercept or listen to file system operations implement this class.


Constructor Summary
protected VCSInterceptor()
          Protected constructor, does nothing.
 
Method Summary
 void afterChange(VCSFileProxy file)
          Called after a file changed.
 void afterCopy(VCSFileProxy from, VCSFileProxy to)
          Called after a file or folder has been copied.
 void afterCreate(VCSFileProxy file)
          Called after a new file or folder has beed created.
 void afterDelete(VCSFileProxy file)
          Called after a file or folder is deleted.
 void afterMove(VCSFileProxy from, VCSFileProxy to)
          Called after a file or folder has beed moved.
 void beforeChange(VCSFileProxy file)
          Called before a file is changed.
 boolean beforeCopy(VCSFileProxy from, VCSFileProxy to)
          Notifies the interceptor that the file or folder is about to be copied.
 boolean beforeCreate(VCSFileProxy file, boolean isDirectory)
          Notifies the interceptor that the file or folder is about to be created.
 boolean beforeDelete(VCSFileProxy file)
          Notifies the interceptor that the file or folder is about to be deleted.
 void beforeEdit(VCSFileProxy file)
          Called before a file is about to enter Edit mode.
 boolean beforeMove(VCSFileProxy from, VCSFileProxy to)
          Notifies the interceptor that the file or folder is about to be moved.
 void doCopy(VCSFileProxy from, VCSFileProxy to)
          Called if beforeCopy() returns true and delegates the copy operation to this interceptor.
 void doCreate(VCSFileProxy file, boolean isDirectory)
          Called if beforeCreate() returns true and delegates the create operation to this interceptor.
 void doDelete(VCSFileProxy file)
          Called if beforeDelete() returns true and delegates the delete operation to this interceptor.
 void doMove(VCSFileProxy from, VCSFileProxy to)
          Called if beforeMove() returns true and delegates the move operation to this interceptor.
 Object getAttribute(VCSFileProxy file, String attrName)
          Queries the versioning system for a files VCS specific attribute.
 boolean isMutable(VCSFileProxy file)
          Queries the versioning system for file mutability (write, delete, move).
 long refreshRecursively(VCSFileProxy dir, long lastTimeStamp, List<? super VCSFileProxy> children)
          Allows versioning system to exclude some children from recursive listening check.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VCSInterceptor

protected VCSInterceptor()
Protected constructor, does nothing.

Method Detail

isMutable

public boolean isMutable(VCSFileProxy file)
Queries the versioning system for file mutability (write, delete, move). Versioning systems that keep files read-only in working copy can override this method to signal that such files are in fact mutable even if they appear read-only on local file system. When IDE eventually tries to delete or write to these files then the Versioning system should intercept these calls and make requested files writable on-demand.

Parameters:
file - a file to query
Returns:
true if the file is mutable (writable, deletable and movable), false otherwise

getAttribute

public Object getAttribute(VCSFileProxy file,
                           String attrName)
Queries the versioning system for a files VCS specific attribute. At the moment the only supported attribute name is ProvidedExtensions.RemoteLocation

Parameters:
file - a file to get the attribute for
attrName - the attributes name
Returns:
the attributes value or null if not available

beforeDelete

public boolean beforeDelete(VCSFileProxy file)
Notifies the interceptor that the file or folder is about to be deleted. The interceptor MUST NOT delete the file here.

Parameters:
file - a file or an empty folder to be deleted
Returns:
true if this interceptor wants to handle this operation (doDelete will be called), false otherwise

doDelete

public void doDelete(VCSFileProxy file)
              throws IOException
Called if beforeDelete() returns true and delegates the delete operation to this interceptor. The interceptor may decide to either delete the file or leave it intact. In case it does not want to delete the file, it should just return without doing anything.

Parameters:
file - a file or an empty folder to delete; the interceptor will never be asked to delete a non-empty folder
Throws:
IOException - if the delete operation failed

afterDelete

public void afterDelete(VCSFileProxy file)
Called after a file or folder is deleted. In case the file was deleted outside IDE, this is the only method called.

Parameters:
file - deleted file

beforeMove

public boolean beforeMove(VCSFileProxy from,
                          VCSFileProxy to)
Notifies the interceptor that the file or folder is about to be moved. The interceptor MUST NOT move the file here.

Parameters:
from - the file or folder to be moved
to - destination of the file being moved
Returns:
true if this interceptor wants to handle this operation (doMove will be called), false otherwise

doMove

public void doMove(VCSFileProxy from,
                   VCSFileProxy to)
            throws IOException
Called if beforeMove() returns true and delegates the move operation to this interceptor.

Parameters:
from - the file or folder to be moved
to - destination of the file being moved
Throws:
IOException - if the move operation failed

afterMove

public void afterMove(VCSFileProxy from,
                      VCSFileProxy to)
Called after a file or folder has beed moved. In case the file was moved outside IDE, this method is not called but a pair or afterDelete() / afterCreate() is called instead.

Parameters:
from - original location of the file
to - current location of the file

beforeCopy

public boolean beforeCopy(VCSFileProxy from,
                          VCSFileProxy to)
Notifies the interceptor that the file or folder is about to be copied. The interceptor MUST NOT copy the file here.

Parameters:
from - the file or folder to be copied
to - destination of the file being copied
Returns:
true if this interceptor wants to handle this operation (doCopy will be called), false otherwise

doCopy

public void doCopy(VCSFileProxy from,
                   VCSFileProxy to)
            throws IOException
Called if beforeCopy() returns true and delegates the copy operation to this interceptor.

Parameters:
from - the file or folder to be copied
to - destination of the file being copied
Throws:
IOException - if the copy operation failed

afterCopy

public void afterCopy(VCSFileProxy from,
                      VCSFileProxy to)
Called after a file or folder has been copied. In case the file was copied outside IDE, this method is not called and only afterCreate() is called instead.

Parameters:
from - original location of the file
to - current location of the file

beforeCreate

public boolean beforeCreate(VCSFileProxy file,
                            boolean isDirectory)
Notifies the interceptor that the file or folder is about to be created. The interceptor MUST NOT create the file here. Beware: It may happen on some filesystems that the file will be ALREADY created.

Parameters:
file - file or folder to be created
Returns:
true if this interceptor wants to handle this operation (doCreate will be called), false otherwise

doCreate

public void doCreate(VCSFileProxy file,
                     boolean isDirectory)
              throws IOException
Called if beforeCreate() returns true and delegates the create operation to this interceptor. Beware: It may happen on some filesystems that the file will be ALREADY created.

Parameters:
file - the file to create
isDirectory - true if the new file should be a directory, false otherwise
Throws:
IOException - if the create operation failed

afterCreate

public void afterCreate(VCSFileProxy file)
Called after a new file or folder has beed created. In case the file was created outside IDE, this is the only method called.

Parameters:
file - the new file

afterChange

public void afterChange(VCSFileProxy file)
Called after a file changed.

Parameters:
file - changed file

beforeChange

public void beforeChange(VCSFileProxy file)
Called before a file is changed. Each series of beforeChange/afterChange events is preceded by at least one beforeEdit event.

Parameters:
file - to be changed file

beforeEdit

public void beforeEdit(VCSFileProxy file)
                throws IOException
Called before a file is about to enter Edit mode. In case the versioning system uses file locking this is the time when to check-out (edit) the file and make it read/write. CVS would execute 'cvs edit' here. If you do not (wish to) support automatic file check-out, do nothing here. Each series of beforeChange/afterChange events is preceded by at least one beforeEdit event.

Parameters:
file - file that was just locked and is expected to change
Throws:
IOEexceptin - in case it wasn't possible to unlock the file.
IOException

refreshRecursively

public long refreshRecursively(VCSFileProxy dir,
                               long lastTimeStamp,
                               List<? super VCSFileProxy> children)
Allows versioning system to exclude some children from recursive listening check. Also notifies the versioning whenever a refresh is required and allows the versiniong to provide special timestamp for a directory.

Default implementation of this method returns -1.

Parameters:
dir - the directory to check timestamp for
lastTimeStamp - the previously known timestamp or -1
children - add subfiles that shall be iterated into this array
Returns:
the timestamp that shall represent this directory, it will be compared with timestamps of all children and the newest one will be kept and next time passed as lastTimeStamp. Return 0 if the directory does not have any special timestamp. Return -1 if you are not providing any special implementation

org.netbeans.modules.versioning.core/1 1.5.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.