Package org.apache.ivy.plugins.version
Class VersionRangeMatcher
- java.lang.Object
-
- org.apache.ivy.plugins.version.AbstractVersionMatcher
-
- org.apache.ivy.plugins.version.VersionRangeMatcher
-
- All Implemented Interfaces:
IvySettingsAware,VersionMatcher
public class VersionRangeMatcher extends AbstractVersionMatcher
Matches version ranges: [1.0,2.0] matches all versions greater or equal to 1.0 and lower or equal to 2.0 [1.0,2.0[ matches all versions greater or equal to 1.0 and lower than 2.0 ]1.0,2.0] matches all versions greater than 1.0 and lower or equal to 2.0 ]1.0,2.0[ matches all versions greater than 1.0 and lower than 2.0 [1.0,) matches all versions greater or equal to 1.0 ]1.0,) matches all versions greater than 1.0 (,2.0] matches all versions lower or equal to 2.0 (,2.0[ matches all versions lower than 2.0 This class uses a latest strategy to compare revisions. If none is set, it uses the default one of the ivy instance set through setIvy(). If neither a latest strategy nor a ivy instance is set, an IllegalStateException will be thrown when calling accept(). Note that it can't work with latest time strategy, cause no time is known for the limits of the range. Therefore only purely revision based LatestStrategy can be used.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classVersionRangeMatcher.MRIDArtifactInfo
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternALL_RANGEprivate static java.lang.StringANY_NON_SPECIAL_PATTERNprivate static java.lang.StringCLOSE_EXCprivate static java.lang.StringCLOSE_EXC_MAVENprivate static java.lang.StringCLOSE_EXC_PATTERNprivate static java.lang.StringCLOSE_INCprivate static java.lang.StringCLOSE_INC_PATTERNprivate static java.lang.StringCLOSE_PATTERNprivate java.util.Comparator<ModuleRevisionId>comparatorprivate static java.lang.StringFINITE_PATTERNprivate static java.util.regex.PatternFINITE_RANGEprivate LatestStrategylatestStrategyprivate java.lang.StringlatestStrategyNameprivate static java.lang.StringLI_PATTERNprivate static java.lang.StringLOWER_INFINITEprivate static java.lang.StringLOWER_INFINITE_PATTERNprivate static java.util.regex.PatternLOWER_INFINITE_RANGEprivate static java.lang.StringOPEN_EXCprivate static java.lang.StringOPEN_EXC_MAVENprivate static java.lang.StringOPEN_EXC_PATTERNprivate static java.lang.StringOPEN_INCprivate static java.lang.StringOPEN_INC_PATTERNprivate static java.lang.StringOPEN_PATTERNprivate static java.lang.StringSEP_PATTERNprivate static java.lang.StringSEPARATORprivate static java.lang.StringUI_PATTERNprivate static java.lang.StringUPPER_INFINITEprivate static java.lang.StringUPPER_INFINITE_PATTERNprivate static java.util.regex.PatternUPPER_INFINITE_RANGE
-
Constructor Summary
Constructors Constructor Description VersionRangeMatcher()VersionRangeMatcher(java.lang.String name)VersionRangeMatcher(java.lang.String name, LatestStrategy strategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)Indicates if this version matcher considers that the module revision found matches the asked one.intcompare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, java.util.Comparator<ModuleRevisionId> staticComparator)This method should be overridden in most cases, because it uses the default contract to return 1 when it's not possible to know which revision is greater.LatestStrategygetLatestStrategy()booleanisDynamic(ModuleRevisionId askedMrid)Indicates if the given asked ModuleRevisionId should be considered as dynamic for the current VersionMatcher or not.private booleanisLower(ModuleRevisionId askedMrid, java.lang.String revision, ModuleRevisionId foundMrid, boolean inclusive)private booleanisUpper(ModuleRevisionId askedMrid, java.lang.String revision, ModuleRevisionId foundMrid, boolean inclusive)voidsetLatest(java.lang.String latestStrategyName)voidsetLatestStrategy(LatestStrategy latestStrategy)-
Methods inherited from class org.apache.ivy.plugins.version.AbstractVersionMatcher
accept, getName, getSettings, needModuleDescriptor, setName, setSettings, toString
-
-
-
-
Field Detail
-
OPEN_INC
private static final java.lang.String OPEN_INC
- See Also:
- Constant Field Values
-
OPEN_EXC
private static final java.lang.String OPEN_EXC
- See Also:
- Constant Field Values
-
OPEN_EXC_MAVEN
private static final java.lang.String OPEN_EXC_MAVEN
- See Also:
- Constant Field Values
-
CLOSE_INC
private static final java.lang.String CLOSE_INC
- See Also:
- Constant Field Values
-
CLOSE_EXC
private static final java.lang.String CLOSE_EXC
- See Also:
- Constant Field Values
-
CLOSE_EXC_MAVEN
private static final java.lang.String CLOSE_EXC_MAVEN
- See Also:
- Constant Field Values
-
LOWER_INFINITE
private static final java.lang.String LOWER_INFINITE
- See Also:
- Constant Field Values
-
UPPER_INFINITE
private static final java.lang.String UPPER_INFINITE
- See Also:
- Constant Field Values
-
SEPARATOR
private static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
OPEN_INC_PATTERN
private static final java.lang.String OPEN_INC_PATTERN
- See Also:
- Constant Field Values
-
OPEN_EXC_PATTERN
private static final java.lang.String OPEN_EXC_PATTERN
- See Also:
- Constant Field Values
-
CLOSE_INC_PATTERN
private static final java.lang.String CLOSE_INC_PATTERN
- See Also:
- Constant Field Values
-
CLOSE_EXC_PATTERN
private static final java.lang.String CLOSE_EXC_PATTERN
- See Also:
- Constant Field Values
-
LI_PATTERN
private static final java.lang.String LI_PATTERN
- See Also:
- Constant Field Values
-
UI_PATTERN
private static final java.lang.String UI_PATTERN
- See Also:
- Constant Field Values
-
SEP_PATTERN
private static final java.lang.String SEP_PATTERN
- See Also:
- Constant Field Values
-
OPEN_PATTERN
private static final java.lang.String OPEN_PATTERN
- See Also:
- Constant Field Values
-
CLOSE_PATTERN
private static final java.lang.String CLOSE_PATTERN
- See Also:
- Constant Field Values
-
ANY_NON_SPECIAL_PATTERN
private static final java.lang.String ANY_NON_SPECIAL_PATTERN
- See Also:
- Constant Field Values
-
FINITE_PATTERN
private static final java.lang.String FINITE_PATTERN
- See Also:
- Constant Field Values
-
LOWER_INFINITE_PATTERN
private static final java.lang.String LOWER_INFINITE_PATTERN
- See Also:
- Constant Field Values
-
UPPER_INFINITE_PATTERN
private static final java.lang.String UPPER_INFINITE_PATTERN
- See Also:
- Constant Field Values
-
FINITE_RANGE
private static final java.util.regex.Pattern FINITE_RANGE
-
LOWER_INFINITE_RANGE
private static final java.util.regex.Pattern LOWER_INFINITE_RANGE
-
UPPER_INFINITE_RANGE
private static final java.util.regex.Pattern UPPER_INFINITE_RANGE
-
ALL_RANGE
private static final java.util.regex.Pattern ALL_RANGE
-
comparator
private final java.util.Comparator<ModuleRevisionId> comparator
-
latestStrategy
private LatestStrategy latestStrategy
-
latestStrategyName
private java.lang.String latestStrategyName
-
-
Constructor Detail
-
VersionRangeMatcher
public VersionRangeMatcher()
-
VersionRangeMatcher
public VersionRangeMatcher(java.lang.String name)
-
VersionRangeMatcher
public VersionRangeMatcher(java.lang.String name, LatestStrategy strategy)
-
-
Method Detail
-
isDynamic
public boolean isDynamic(ModuleRevisionId askedMrid)
Description copied from interface:VersionMatcherIndicates if the given asked ModuleRevisionId should be considered as dynamic for the current VersionMatcher or not.- Parameters:
askedMrid- the dependency module revision id as asked by a module- Returns:
- true if this revision is considered as a dynamic one, false otherwise
-
accept
public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)
Description copied from interface:VersionMatcherIndicates if this version matcher considers that the module revision found matches the asked one.- Parameters:
askedMrid- ModuleRevisionIdfoundMrid- ModuleRevisionId- Returns:
- boolean
-
isLower
private boolean isLower(ModuleRevisionId askedMrid, java.lang.String revision, ModuleRevisionId foundMrid, boolean inclusive)
-
isUpper
private boolean isUpper(ModuleRevisionId askedMrid, java.lang.String revision, ModuleRevisionId foundMrid, boolean inclusive)
-
compare
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, java.util.Comparator<ModuleRevisionId> staticComparator)
Description copied from class:AbstractVersionMatcherThis method should be overridden in most cases, because it uses the default contract to return 1 when it's not possible to know which revision is greater.- Specified by:
comparein interfaceVersionMatcher- Overrides:
comparein classAbstractVersionMatcher- Parameters:
askedMrid- ModuleRevisionIdfoundMrid- ModuleRevisionIdstaticComparator- Comparator- Returns:
- int
-
getLatestStrategy
public LatestStrategy getLatestStrategy()
-
setLatestStrategy
public void setLatestStrategy(LatestStrategy latestStrategy)
-
setLatest
public void setLatest(java.lang.String latestStrategyName)
-
-