KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > version > VersionMatcher


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

7 package fr.jayasoft.ivy.version;
8
9 import fr.jayasoft.ivy.ModuleDescriptor;
10 import fr.jayasoft.ivy.ModuleRevisionId;
11
12 /**
13  * This interface defines a version matcher, i.e. a class able to tell if the revision
14  * asked by a module for a dependency is dynamic (i.e. need to find all revisions to find the good one among them)
15  * and if a found revision matches the asked one.
16  *
17  * Two ways of matching are possible:
18  * - based on the module revision only (known as ModuleRevisionId)
19  * - based on the parsed module descriptor
20  *
21  * The second being much more time consuming than the first, the version matcher should tell if it needs such parsing
22  * or not using the needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) method. Anyway, the first way is always used, and if a revision is not accepted using the first
23  * method, the module descriptor won't be parsed.
24  *
25  * Therefore if a version matcher uses only module descriptors to accept a revision or not it should always return true
26  * to needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) and accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid).
27  *
28  * @author Xavier Hanin
29  */

30 public interface VersionMatcher {
31     /**
32      * Indicates if the given asked ModuleRevisionId should be considered as dynamic for
33      * the current VersionMatcher or not.
34      * @param askedMrid the dependency module revision id as asked by a module
35      * @return true if this revision is considered as a dynamic one, false otherwise
36      */

37     public boolean isDynamic(ModuleRevisionId askedMrid);
38     /**
39      * Indicates if this version matcher considers that the module revision found matches the asked one.
40      * @param askedMrid
41      * @param foundMrid
42      * @return
43      */

44     public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
45     /**
46      * Indicates if this VersionMatcher needs module descriptors to determine if a module revision
47      * matches the asked one.
48      * Note that returning true in this method may imply big performance issues.
49      * @return
50      */

51     public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
52     /**
53      * Indicates if this version matcher considers that the module found matches the asked one.
54      * This method can be called even needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)
55      * returns false, so it is required to implement it in any case, a usual default implementation being:
56      *
57      * return accept(askedMrid, foundMD.getResolvedModuleRevisionId());
58      *
59      * @param askedMrid
60      * @param foundMD
61      * @return
62      */

63     public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD);
64     
65     /**
66      * Returns the version matcher name identifying this version matcher
67      * @return the version matcher name identifying this version matcher
68      */

69     public String JavaDoc getName();
70 }
71
Popular Tags