PTP
Release 7.0

org.eclipse.ptp.rdt.sync.core
Class AbstractSyncFileFilter

java.lang.Object
  extended by org.eclipse.ptp.rdt.sync.core.AbstractSyncFileFilter
Direct Known Subclasses:
PreferenceSyncFileFilterStorage

public abstract class AbstractSyncFileFilter
extends java.lang.Object

Class for filtering files during synchronization. The non-abstract class is provided by the sync provider. All read operations (e.g. shouldIgnore) are thread safe (/need to implemented thread safe by the subclasses).

Since:
3.0

Nested Class Summary
 class AbstractSyncFileFilter.AbstractIgnoreRule
          Abstract class for ignore rules
 
Field Summary
protected  java.util.List<AbstractSyncFileFilter.AbstractIgnoreRule> rules
           
 
Constructor Summary
AbstractSyncFileFilter()
           
 
Method Summary
 void addPattern(org.eclipse.core.resources.IResource resource, boolean exclude)
          Add the resource pattern
abstract  void addPattern(org.eclipse.core.resources.IResource resource, boolean exclude, int index)
          Add resource pattern.
 void addPattern(java.lang.String pattern, boolean exclude)
          Add the pattern
abstract  void addPattern(java.lang.String pattern, boolean exclude, int index)
          Add pattern.
abstract  AbstractSyncFileFilter clone()
           
 boolean demote(AbstractSyncFileFilter.AbstractIgnoreRule pattern)
          Swap a pattern with its higher-index neighbor Assumes pattern appears no more than once
 java.util.List<AbstractSyncFileFilter.AbstractIgnoreRule> getPatterns()
          Get all patterns for this filter
 java.util.List<AbstractSyncFileFilter.AbstractIgnoreRule> getRules()
          Get the rules in this filter.
 boolean promote(AbstractSyncFileFilter.AbstractIgnoreRule pattern)
          Swap a pattern with its lower-index neighbor Assumes pattern only appears once
 void removePattern(AbstractSyncFileFilter.AbstractIgnoreRule pattern)
          Remove a pattern from the filter Assumes pattern appears no more than once
 boolean replacePattern(AbstractSyncFileFilter.AbstractIgnoreRule oldRule, java.lang.String newPattern, boolean exclude)
          Replace pattern with another - useful for when existing patterns are edited
abstract  void saveFilter()
          Save filters
 boolean shouldIgnore(org.eclipse.core.resources.IResource r)
          Apply the filter to the given string
 boolean shouldIgnore(java.lang.String path, boolean isFolder)
          Apply the filter to the given string
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rules

protected final java.util.List<AbstractSyncFileFilter.AbstractIgnoreRule> rules
Constructor Detail

AbstractSyncFileFilter

public AbstractSyncFileFilter()
Method Detail

getRules

public java.util.List<AbstractSyncFileFilter.AbstractIgnoreRule> getRules()
Get the rules in this filter. Highest precedence is last rule (as for Git - reverse from PTP Juno)

Returns:

addPattern

public void addPattern(java.lang.String pattern,
                       boolean exclude)
Add the pattern

Parameters:
pattern - pattern to add
exclude - exclude flag

addPattern

public void addPattern(org.eclipse.core.resources.IResource resource,
                       boolean exclude)
Add the resource pattern

Parameters:
resource - resource
exclude - exclude flag

addPattern

public abstract void addPattern(java.lang.String pattern,
                                boolean exclude,
                                int index)
Add pattern. Pattern format is provider dependent

Parameters:
pattern - pattern to add
exclude - exclude flag
index - location of pattern in the list

addPattern

public abstract void addPattern(org.eclipse.core.resources.IResource resource,
                                boolean exclude,
                                int index)
Add resource pattern. Add rule only matching exactly this resource (not file/path with same name)

Parameters:
resource - resource to add
exclude - true: exclude resource, false: include resource
index - location of pattern in the list

demote

public boolean demote(AbstractSyncFileFilter.AbstractIgnoreRule pattern)
Swap a pattern with its higher-index neighbor Assumes pattern appears no more than once

Parameters:
pattern -
Returns:
whether pattern was actually demoted

getPatterns

public java.util.List<AbstractSyncFileFilter.AbstractIgnoreRule> getPatterns()
Get all patterns for this filter

Returns:
patterns

promote

public boolean promote(AbstractSyncFileFilter.AbstractIgnoreRule pattern)
Swap a pattern with its lower-index neighbor Assumes pattern only appears once

Parameters:
pattern -
Returns:
whether pattern was actually promoted

removePattern

public void removePattern(AbstractSyncFileFilter.AbstractIgnoreRule pattern)
Remove a pattern from the filter Assumes pattern appears no more than once

Parameters:
pattern -

replacePattern

public boolean replacePattern(AbstractSyncFileFilter.AbstractIgnoreRule oldRule,
                              java.lang.String newPattern,
                              boolean exclude)
Replace pattern with another - useful for when existing patterns are edited

Parameters:
oldRule -
newPattern -
type -
Returns:
whether replace was successful (old pattern was found)

shouldIgnore

public boolean shouldIgnore(org.eclipse.core.resources.IResource r)
Apply the filter to the given string

Parameters:
s - - the string
Returns:
whether the string should be ignored

shouldIgnore

public boolean shouldIgnore(java.lang.String path,
                            boolean isFolder)
Apply the filter to the given string

Parameters:
s - - the string
Returns:
whether the string should be ignored

saveFilter

public abstract void saveFilter()
                         throws java.io.IOException
Save filters

Throws:
java.io.IOException

clone

public abstract AbstractSyncFileFilter clone()
Overrides:
clone in class java.lang.Object

PTP
Release 7.0

Copyright (c) 2011 IBM Corporation and others. All Rights Reserved.