Change-Id: I1a81d371420cd4cf90ab9e048026c0ab8a763018 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>tags/v4.10.0.201712302008-r
@@ -77,6 +77,7 @@ public class FastIgnoreRule { | |||
private final boolean dirOnly; | |||
/** | |||
* Constructor for FastIgnoreRule | |||
* | |||
* @param pattern | |||
* ignore pattern as described in <a href= | |||
@@ -160,15 +161,18 @@ public class FastIgnoreRule { | |||
} | |||
/** | |||
* @return True if the pattern is just a file name and not a path | |||
* Whether the pattern is just a file name and not a path | |||
* | |||
* @return {@code true} if the pattern is just a file name and not a path | |||
*/ | |||
public boolean getNameOnly() { | |||
return !(matcher instanceof PathMatcher); | |||
} | |||
/** | |||
* Whether the pattern should match directories only | |||
* | |||
* @return True if the pattern should match directories only | |||
* @return {@code true} if the pattern should match directories only | |||
*/ | |||
public boolean dirOnly() { | |||
return dirOnly; | |||
@@ -193,13 +197,17 @@ public class FastIgnoreRule { | |||
} | |||
/** | |||
* @return true if the rule never matches (comment line or broken pattern) | |||
* Whether the rule never matches | |||
* | |||
* @return {@code true} if the rule never matches (comment line or broken | |||
* pattern) | |||
* @since 4.1 | |||
*/ | |||
public boolean isEmpty() { | |||
return matcher == NO_MATCH; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String toString() { | |||
StringBuilder sb = new StringBuilder(); | |||
@@ -212,6 +220,7 @@ public class FastIgnoreRule { | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int hashCode() { | |||
final int prime = 31; | |||
@@ -222,6 +231,7 @@ public class FastIgnoreRule { | |||
return result; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean equals(Object obj) { | |||
if (this == obj) |
@@ -81,7 +81,9 @@ public class IgnoreNode { | |||
/** The rules that have been parsed into this node. */ | |||
private final List<FastIgnoreRule> rules; | |||
/** Create an empty ignore node with no rules. */ | |||
/** | |||
* Create an empty ignore node with no rules. | |||
*/ | |||
public IgnoreNode() { | |||
rules = new ArrayList<>(); | |||
} | |||
@@ -91,7 +93,7 @@ public class IgnoreNode { | |||
* | |||
* @param rules | |||
* list of rules. | |||
**/ | |||
*/ | |||
public IgnoreNode(List<FastIgnoreRule> rules) { | |||
this.rules = rules; | |||
} | |||
@@ -102,7 +104,7 @@ public class IgnoreNode { | |||
* @param in | |||
* input stream holding the standard ignore format. The caller is | |||
* responsible for closing the stream. | |||
* @throws IOException | |||
* @throws java.io.IOException | |||
* Error thrown when reading an ignore file. | |||
*/ | |||
public void parse(InputStream in) throws IOException { | |||
@@ -122,7 +124,11 @@ public class IgnoreNode { | |||
return new BufferedReader(new InputStreamReader(in, Constants.CHARSET)); | |||
} | |||
/** @return list of all ignore rules held by this node. */ | |||
/** | |||
* Get list of all ignore rules held by this node | |||
* | |||
* @return list of all ignore rules held by this node | |||
*/ | |||
public List<FastIgnoreRule> getRules() { | |||
return Collections.unmodifiableList(rules); | |||
} | |||
@@ -194,6 +200,7 @@ public class IgnoreNode { | |||
return MatchResult.CHECK_PARENT; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String toString() { | |||
return rules.toString(); |
@@ -64,16 +64,19 @@ public abstract class AbstractMatcher implements IMatcher { | |||
this.dirOnly = dirOnly; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String toString() { | |||
return pattern; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int hashCode() { | |||
return pattern.hashCode(); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean equals(Object obj) { | |||
if (this == obj) |
@@ -74,9 +74,10 @@ public interface IMatcher { | |||
* with a slash) | |||
* @param pathMatch | |||
* {@code true} if the match is for the full path: prefix-only | |||
* matches are not allowed, and {@link NameMatcher}s must match | |||
* only the last component (if they can -- they may not, if they | |||
* are anchored at the beginning) | |||
* matches are not allowed, and | |||
* {@link org.eclipse.jgit.ignore.internal.NameMatcher}s must | |||
* match only the last component (if they can -- they may not, if | |||
* they are anchored at the beginning) | |||
* @return true if this matcher pattern matches given string | |||
*/ | |||
boolean matches(String path, boolean assumeDirectory, boolean pathMatch); |
@@ -55,6 +55,7 @@ public class LeadingAsteriskMatcher extends NameMatcher { | |||
"Pattern must have leading asterisk: " + pattern); //$NON-NLS-1$ | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String segment, int startIncl, int endExcl, | |||
boolean assumeDirectory) { |
@@ -71,6 +71,7 @@ public class NameMatcher extends AbstractMatcher { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String path, boolean assumeDirectory, | |||
boolean pathMatch) { | |||
@@ -120,6 +121,7 @@ public class NameMatcher extends AbstractMatcher { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String segment, int startIncl, int endExcl, | |||
boolean assumeDirectory) { |
@@ -105,14 +105,17 @@ public class PathMatcher extends AbstractMatcher { | |||
} | |||
/** | |||
* Create path matcher | |||
* | |||
* @param pattern | |||
* a pattern | |||
* @param pathSeparator | |||
* if this parameter isn't null then this character will not | |||
* match at wildcards(* and ? are wildcards). | |||
* @param dirOnly | |||
* a boolean. | |||
* @return never null | |||
* @throws InvalidPatternException | |||
* @throws org.eclipse.jgit.errors.InvalidPatternException | |||
*/ | |||
public static IMatcher createPathMatcher(String pattern, | |||
Character pathSeparator, boolean dirOnly) | |||
@@ -170,6 +173,7 @@ public class PathMatcher extends AbstractMatcher { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String path, boolean assumeDirectory, | |||
boolean pathMatch) { | |||
@@ -212,6 +216,7 @@ public class PathMatcher extends AbstractMatcher { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String segment, int startIncl, int endExcl, | |||
boolean assumeDirectory) { |
@@ -56,8 +56,8 @@ import org.eclipse.jgit.ignore.FastIgnoreRule; | |||
import org.eclipse.jgit.internal.JGitText; | |||
/** | |||
* Various {@link String} related utility methods, written mostly to avoid | |||
* generation of new String objects (e.g. via splitting Strings etc). | |||
* Various {@link java.lang.String} related utility methods, written mostly to | |||
* avoid generation of new String objects (e.g. via splitting Strings etc). | |||
*/ | |||
public class Strings { | |||
@@ -67,6 +67,8 @@ public class Strings { | |||
} | |||
/** | |||
* Strip trailing characters | |||
* | |||
* @param pattern | |||
* non null | |||
* @param c | |||
@@ -87,6 +89,8 @@ public class Strings { | |||
} | |||
/** | |||
* Strip trailing whitespace characters | |||
* | |||
* @param pattern | |||
* non null | |||
* @return new string with all trailing whitespace removed | |||
@@ -105,10 +109,12 @@ public class Strings { | |||
} | |||
/** | |||
* Check if pattern is a directory pattern ending with a path separator | |||
* | |||
* @param pattern | |||
* non null | |||
* @return true if the last character, which is not whitespace, is a path | |||
* separator | |||
* @return {@code true} if the last character, which is not whitespace, is a | |||
* path separator | |||
*/ | |||
public static boolean isDirectoryPattern(String pattern) { | |||
for (int i = pattern.length() - 1; i >= 0; i--) { |
@@ -55,6 +55,7 @@ public class TrailingAsteriskMatcher extends NameMatcher { | |||
"Pattern must have trailing asterisk: " + pattern); //$NON-NLS-1$ | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String segment, int startIncl, int endExcl, | |||
boolean assumeDirectory) { |
@@ -50,7 +50,7 @@ import org.eclipse.jgit.errors.InvalidPatternException; | |||
/** | |||
* Matcher built from path segments containing wildcards. This matcher converts | |||
* glob wildcards to Java {@link Pattern}'s. | |||
* glob wildcards to Java {@link java.util.regex.Pattern}'s. | |||
* <p> | |||
* This class is immutable and thread safe. | |||
*/ | |||
@@ -64,6 +64,7 @@ public class WildCardMatcher extends NameMatcher { | |||
p = convertGlob(subPattern); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean matches(String segment, int startIncl, int endExcl, | |||
boolean assumeDirectory) { |
@@ -61,12 +61,14 @@ public final class WildMatcher extends AbstractMatcher { | |||
super(WILDMATCH, false); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public final boolean matches(String path, boolean assumeDirectory, | |||
boolean pathMatch) { | |||
return true; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public final boolean matches(String segment, int startIncl, int endExcl, | |||
boolean assumeDirectory) { |