Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.team.core.synchronize
Class SyncInfoSet


java.lang.Object
  extended by 
org.eclipse.team.core.synchronize.SyncInfoSet
Direct Known Subclasses:
SyncInfoTree

public class SyncInfoSet
extends Object

A dynamic collection of SyncInfo objects that provides change notification to registered listeners. Batching of change notifications can be accomplished using the beginInput/endInput methods.

Since:
3.0
See Also:
SyncInfoTree, SyncInfo, ISyncInfoSetChangeListener

Constructor Summary
SyncInfoSet ()
          Create an empty set.
SyncInfoSet ( SyncInfo[] infos)
          Create a SyncInfoSet containing the given SyncInfo instances.
 
Method Summary
 void add ( SyncInfo info)
          Add the given SyncInfo to the set.
 void addAll ( SyncInfoSet set)
          Add all the sync info from the given set to this set.
 void addError ( ITeamStatus status)
          Add the error to the set.
 void addSyncSetChangedListener ( ISyncInfoSetChangeListener listener)
          Registers the given listener for sync info set notifications.
 void beginInput ()
          This method is used to obtain a lock on the set which ensures thread safety and batches change notification.
 void clear ()
          Reset the sync set so it is empty.
 void connect ( ISyncInfoSetChangeListener listener, IProgressMonitor monitor)
          Connect the listener to the sync set in such a fashion that the listener will be connected the the sync set using addChangeListener and issued a reset event.
 long countFor (int kind, int mask)
          Return the number of out-of-sync resources in the given set whose sync kind matches the given kind and mask (e.g.
protected   SyncInfoSetChangeEvent createEmptyChangeEvent ()
          Create an empty change event.
 void endInput ( IProgressMonitor monitor)
          This method is used to release the lock on this set.
protected   SyncInfoSetChangeEvent getChangeEvent ()
          Return the change event that is accumulating the changes to the set.
  ITeamStatus[] getErrors ()
          Return an array of the errors the occurred while populating this set.
protected   ISyncInfoSetChangeListener[] getListeners ()
          Return a copy of all the listeners registered with this set
  SyncInfo[] getNodes ( FastSyncInfoFilter filter)
          Return all nodes in this set that match the given filter.
  IResource[] getResources ()
          Return all out-of-sync resources contained in this set.
  SyncInfo getSyncInfo ( IResource resource)
          Return the SyncInfo for the given resource or null if the resource is not contained in the set.
  SyncInfo[] getSyncInfos ()
          Return an array of SyncInfo for all out-of-sync resources that are contained by the set.
 boolean hasConflicts ()
          Returns true if there are any conflicting nodes in the set, and false otherwise.
 boolean hasIncomingChanges ()
          Returns true if this sync set has incoming changes.
 boolean hasNodes ( FastSyncInfoFilter filter)
          Indicate whether the set has nodes matching the given filter.
 boolean hasOutgoingChanges ()
          Returns true if this sync set has outgoing changes.
protected  void internalAdd ( SyncInfo info)
          Add the SyncInfo to the set, replacing any previously existing one.
protected   SyncInfo internalRemove ( IResource resource)
          Remove the resource from the set, updating all internal data structures.
 boolean isEmpty ()
          Return whether the set is empty.
  Iterator iterator ()
          Return an iterator over all SyncInfo contained in this set.
 void rejectNodes ( FastSyncInfoFilter filter)
          Removes all nodes from this set that match the given filter leaving those that do not match the filter.
 void remove ( IResource resource)
          Remove the given local resource from the set.
 void removeAll ( IResource[] resources)
          Remove all the given resources from the set.
 void removeConflictingNodes ()
          Removes all conflicting nodes from this set.
 void removeIncomingNodes ()
          Removes all incoming nodes from this set.
 void removeOutgoingNodes ()
          Removes all outgoing nodes from this set.
 void removeSyncSetChangedListener ( ISyncInfoSetChangeListener listener)
          Removes the given listener from participant notifications.
protected  void resetChanges ()
          Reset the changes accumulated so far by this set.
 void selectNodes ( FastSyncInfoFilter filter)
          Removes all nodes from this set that do not match the given filter leaving only those that do match the filter.
 int size ()
          Return the number of out-of-sync resources contained in this set.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncInfoSet

public SyncInfoSet()
Create an empty set.


SyncInfoSet

public SyncInfoSet(
SyncInfo[] infos)
Create a SyncInfoSet containing the given SyncInfo instances.

Parameters:
infos - the SyncInfo instances to be contained by this set
Method Detail

getSyncInfos

public 
SyncInfo[] getSyncInfos()
Return an array of SyncInfo for all out-of-sync resources that are contained by the set.

Returns:
an array of SyncInfo

getResources

public 
IResource[] getResources()
Return all out-of-sync resources contained in this set. The default implementation uses getSyncInfos() to determine the resources contained in the set. Subclasses may override to optimize.

Returns:
all out-of-sync resources contained in the set

getSyncInfo

public 
SyncInfo getSyncInfo(
IResource resource)
Return the SyncInfo for the given resource or null if the resource is not contained in the set.

Parameters:
resource - the resource
Returns:
the SyncInfo for the resource or null if the resource is in-sync or doesn't have synchronization information in this set.

size

public int size()
Return the number of out-of-sync resources contained in this set.

Returns:
the size of the set.
See Also:
countFor(int, int)

countFor

public long countFor(int kind,
                     int mask)
Return the number of out-of-sync resources in the given set whose sync kind matches the given kind and mask (e.g. (SyncInfo#getKind() & mask) == kind).

For example, this will return the number of outgoing changes in the set:

  long outgoing =  countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
 

Parameters:
kind - the sync kind
mask - the sync kind mask
Returns:
the number of matching resources in the set.

hasConflicts

public boolean hasConflicts()
Returns true if there are any conflicting nodes in the set, and false otherwise.

Returns:
true if there are any conflicting nodes in the set, and false otherwise.

isEmpty

public boolean isEmpty()
Return whether the set is empty.

Returns:
true if the set is empty

internalAdd

protected void internalAdd(
SyncInfo info)
Add the SyncInfo to the set, replacing any previously existing one.

Parameters:
info - the new SyncInfo

internalRemove

protected 
SyncInfo internalRemove(
IResource resource)
Remove the resource from the set, updating all internal data structures.

Parameters:
resource - the resource to be removed
Returns:
the SyncInfo that was just removed

addSyncSetChangedListener

public void addSyncSetChangedListener(
ISyncInfoSetChangeListener listener)
Registers the given listener for sync info set notifications. Has no effect if an identical listener is already registered.

Parameters:
listener - listener to register

removeSyncSetChangedListener

public void removeSyncSetChangedListener(
ISyncInfoSetChangeListener listener)
Removes the given listener from participant notifications. Has no effect if listener is not already registered.

Parameters:
listener - listener to remove

clear

public void clear()
Reset the sync set so it is empty. Listeners are notified of the change.


connect

public void connect(
ISyncInfoSetChangeListener listener,
                    
IProgressMonitor monitor)
Connect the listener to the sync set in such a fashion that the listener will be connected the the sync set using addChangeListener and issued a reset event. This is done to provide a means of connecting to the sync set and initializing a model based on the sync set without worrying about missing events.

The reset event may be done in the context of this method invocation or may be done in another thread at the discretion of the SyncInfoSet implementation.

Disconnecting is done by calling removeChangeListener. Once disconnected, a listener can reconnect to be re-initialized.

Parameters:
listener - the listener that should be connected to this set
monitor - a progress monitor

add

public void add(
SyncInfo info)
Add the given SyncInfo to the set. A change event will be generated unless the call to this method is nested in between calls to beginInput() and endInput(IProgressMonitor) in which case the event for this addition and any other sync set change will be fired in a batched event when endInput is invoked.

Invoking this method outside of the above mentioned block will result in the endInput(IProgressMonitor) being invoked with a null progress monitor. If responsiveness is required, the client should always nest sync set modifications within beginInput/endInput.

Parameters:
info - the sync info to be added to this set.

addAll

public void addAll(
SyncInfoSet set)
Add all the sync info from the given set to this set.

Parameters:
set - the set whose sync info should be added to this set

remove

public void remove(
IResource resource)
Remove the given local resource from the set.

Parameters:
resource - the local resource to remove

removeAll

public void removeAll(
IResource[] resources)
Remove all the given resources from the set.

Parameters:
resources - the resources to be removed

removeConflictingNodes

public void removeConflictingNodes()
Removes all conflicting nodes from this set.


removeOutgoingNodes

public void removeOutgoingNodes()
Removes all outgoing nodes from this set.


removeIncomingNodes

public void removeIncomingNodes()
Removes all incoming nodes from this set.


hasNodes

public boolean hasNodes(
FastSyncInfoFilter filter)
Indicate whether the set has nodes matching the given filter.

Parameters:
filter - a sync info filter
Returns:
whether the set has nodes that match the filter

selectNodes

public void selectNodes(
FastSyncInfoFilter filter)
Removes all nodes from this set that do not match the given filter leaving only those that do match the filter.

Parameters:
filter - a sync info filter

rejectNodes

public void rejectNodes(
FastSyncInfoFilter filter)
Removes all nodes from this set that match the given filter leaving those that do not match the filter.

Parameters:
filter - a sync info filter

getNodes

public 
SyncInfo[] getNodes(
FastSyncInfoFilter filter)
Return all nodes in this set that match the given filter.

Parameters:
filter - a sync info filter
Returns:
the nodes that match the filter

hasIncomingChanges

public boolean hasIncomingChanges()
Returns true if this sync set has incoming changes. Note that conflicts are not considered to be incoming changes.

Returns:
true if this sync set has incoming changes.

hasOutgoingChanges

public boolean hasOutgoingChanges()
Returns true if this sync set has outgoing changes. Note that conflicts are not considered to be outgoing changes.

Returns:
true if this sync set has outgoing changes.

beginInput

public void beginInput()
This method is used to obtain a lock on the set which ensures thread safety and batches change notification. If the set is locked by another thread, the calling thread will block until the lock becomes available. This method uses an org.eclipse.core.runtime.jobs.ILock.

It is important that the lock is released after it is obtained. Calls to endInput should be done in a finally block as illustrated in the following code snippet.

   try {
       set.beginInput();
       // do stuff
   } finally {
      set.endInput(progress);
   }
 

Calls to beginInput and endInput can be nested and must be matched.


endInput

public void endInput(
IProgressMonitor monitor)
This method is used to release the lock on this set. The progress monitor is needed to allow listeners to perform long-running operations is response to the set change. The lock is held while the listeners are notified so listeners must be cautious in order to avoid deadlock.

Parameters:
monitor - a progress monitor

resetChanges

protected void resetChanges()
Reset the changes accumulated so far by this set. This method is not intended to be invoked or implemented by clients.


createEmptyChangeEvent

protected 
SyncInfoSetChangeEvent createEmptyChangeEvent()
Create an empty change event. Subclass may override to provided specialized event types

Returns:
an empty change event
Since:
3.5

getListeners

protected 
ISyncInfoSetChangeListener[] getListeners()
Return a copy of all the listeners registered with this set

Returns:
the listeners

getChangeEvent

protected 
SyncInfoSetChangeEvent getChangeEvent()
Return the change event that is accumulating the changes to the set. This can be called by subclasses to access the event.

Returns:
Returns the changes.
Since:
3.5
Restriction:
This method is not intended to be re-implemented or extended by clients.

addError

public void addError(
ITeamStatus status)
Add the error to the set. Errors should be added to the set when the client populating the set cannot determine the SyncInfo for one or more resources due to an exception or some other problem. Listeners will be notified that an error occurred and can react accordingly.

Only one error can be associated with a resource (which is obtained from the ITeamStatus). It is up to the client populating the set to ensure that the error associated with a resource contains all relevant information. The error will remain in the set until the set is reset.

Parameters:
status - the status that describes the error that occurred.

getErrors

public 
ITeamStatus[] getErrors()
Return an array of the errors the occurred while populating this set. The errors will remain with the set until it is reset.

Returns:
the errors

iterator

public 
Iterator iterator()
Return an iterator over all SyncInfo contained in this set.

Returns:
an iterator over all SyncInfo contained in this set.
Since:
3.1

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire