org.eclipse.jgit.ignore
Class IgnoreRule

java.lang.Object
  extended by org.eclipse.jgit.ignore.IgnoreRule

public class IgnoreRule
extends Object

A single ignore rule corresponding to one line in a .gitignore or ignore file. Parses the ignore pattern Inspiration from: Ferry Huberts


Constructor Summary
IgnoreRule(String pattern)
          Create a new ignore rule with the given pattern.
 
Method Summary
 boolean dirOnly()
           
 boolean getNameOnly()
           
 boolean getNegation()
           
 String getPattern()
           
 boolean getResult()
          If a call to isMatch(String, boolean) was previously made, this will return whether or not the target was ignored.
 boolean isMatch(String target, boolean isDirectory)
          Returns true if a match was made.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IgnoreRule

public IgnoreRule(String pattern)
Create a new ignore rule with the given pattern. Assumes that the pattern is already trimmed.

Parameters:
pattern - Base pattern for the ignore rule. This pattern will be parsed to generate rule parameters.
Method Detail

getNameOnly

public boolean getNameOnly()
Returns:
True if the pattern is just a file name and not a path

dirOnly

public boolean dirOnly()
Returns:
True if the pattern should match directories only

getNegation

public boolean getNegation()
Returns:
True if the pattern had a "!" in front of it

getPattern

public String getPattern()
Returns:
The blob pattern to be used as a matcher

isMatch

public boolean isMatch(String target,
                       boolean isDirectory)
Returns true if a match was made.
This function does NOT return the actual ignore status of the target! Please consult getResult() for the ignore status. The actual ignore status may be true or false depending on whether this rule is an ignore rule or a negation rule.

Parameters:
target - Name pattern of the file, relative to the base directory of this rule
isDirectory - Whether the target file is a directory or not
Returns:
True if a match was made. This does not necessarily mean that the target is ignored. Call getResult() for the result.

getResult

public boolean getResult()
If a call to isMatch(String, boolean) was previously made, this will return whether or not the target was ignored. Otherwise this just indicates whether the rule is non-negation or negation.

Returns:
True if the target is to be ignored, false otherwise.


Copyright © 2012. All Rights Reserved.