mirror of https://github.com/apache/ant-ivy
IMPROVE: add possibility to choose matcher on include exclude and conflict manager rules (IVY-161)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484195 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
416a39c7da
commit
d297eaef94
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.matcher;
|
||||
|
||||
public class AnyMatcher implements Matcher {
|
||||
private final static Matcher INSTANCE = new AnyMatcher();
|
||||
|
||||
public static Matcher getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private AnyMatcher() {
|
||||
|
||||
}
|
||||
|
||||
public boolean matches(String str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isExact() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.matcher;
|
||||
|
||||
import org.apache.oro.text.GlobCompiler;
|
||||
import org.apache.oro.text.regex.MalformedPatternException;
|
||||
import org.apache.oro.text.regex.Pattern;
|
||||
import org.apache.oro.text.regex.Perl5Matcher;
|
||||
|
||||
import fr.jayasoft.ivy.util.Message;
|
||||
|
||||
|
||||
public final class GlobPatternMatcher implements PatternMatcher {
|
||||
public static class GlobMatcher implements Matcher {
|
||||
private Pattern _p;
|
||||
|
||||
public GlobMatcher(String exp) {
|
||||
try {
|
||||
_p = new GlobCompiler().compile(exp);
|
||||
} catch (MalformedPatternException e) {
|
||||
Message.error("impossible to compile glob pattern: "+exp);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matches(String str) {
|
||||
return _p != null && new Perl5Matcher().matches(str, _p);
|
||||
}
|
||||
|
||||
public boolean isExact() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private static final GlobPatternMatcher INSTANCE = new GlobPatternMatcher();
|
||||
public static PatternMatcher getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private GlobPatternMatcher() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return GLOB;
|
||||
}
|
||||
|
||||
public Matcher getMatcher(String exp) {
|
||||
if (ANY_EXPRESSION.equals(exp)) {
|
||||
return AnyMatcher.getInstance();
|
||||
}
|
||||
return new GlobMatcher(exp);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.matcher;
|
||||
|
||||
public interface Matcher {
|
||||
public boolean matches(String str);
|
||||
public boolean isExact();
|
||||
}
|
||||
Loading…
Reference in New Issue