KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > ArtifactRevisionId


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * #SNAPSHOT#
5  */

6 package fr.jayasoft.ivy;
7
8 import java.util.Map JavaDoc;
9
10 import fr.jayasoft.ivy.extendable.UnmodifiableExtendableItem;
11 import fr.jayasoft.ivy.util.IvyPatternHelper;
12
13 /**
14  * identifies an artifact in a particular module revision
15  */

16 public class ArtifactRevisionId extends UnmodifiableExtendableItem {
17     public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String JavaDoc name, String JavaDoc type, String JavaDoc ext) {
18         return newInstance(mrid, name, type, ext, null);
19     }
20     
21     public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String JavaDoc name, String JavaDoc type, String JavaDoc ext, Map JavaDoc extraAttributes) {
22         return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid, extraAttributes);
23     }
24     
25     private ArtifactId _artifactId;
26     private ModuleRevisionId _mrid;
27     
28     
29     public ArtifactRevisionId(ArtifactId artifactId, ModuleRevisionId mrid) {
30         this(artifactId, mrid, null);
31     }
32     public ArtifactRevisionId(ArtifactId artifactId, ModuleRevisionId mrid, Map JavaDoc extraAttributes) {
33         super(null, extraAttributes);
34         _artifactId = artifactId;
35         _mrid = mrid;
36         
37         setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, getModuleRevisionId().getOrganisation());
38         setStandardAttribute(IvyPatternHelper.MODULE_KEY, getModuleRevisionId().getName());
39         setStandardAttribute(IvyPatternHelper.REVISION_KEY, getModuleRevisionId().getRevision());
40         setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, getName());
41         setStandardAttribute(IvyPatternHelper.TYPE_KEY, getType());
42         setStandardAttribute(IvyPatternHelper.EXT_KEY, getExt());
43     }
44     
45     public boolean equals(Object JavaDoc obj) {
46         if (! (obj instanceof ArtifactRevisionId)) {
47             return false;
48         }
49         ArtifactRevisionId arid = (ArtifactRevisionId)obj;
50         return getArtifactId().equals(arid.getArtifactId())
51             && getModuleRevisionId().equals(arid.getModuleRevisionId())
52             && getExtraAttributes().equals(arid.getExtraAttributes());
53     }
54     
55     public int hashCode() {
56         int hash = 17;
57         hash += getArtifactId().hashCode() * 37;
58         hash += getModuleRevisionId().hashCode() * 37;
59         hash += getExtraAttributes().hashCode() * 37;
60         return hash;
61     }
62     
63     public String JavaDoc toString() {
64         return "[ "+getModuleRevisionId().getOrganisation()+" | "+ getModuleRevisionId().getName()+" | "+getModuleRevisionId().getRevision()+" :: "+getName()+" . "+getExt()+" ( "+getType()+" ) ]";
65     }
66     
67     /**
68      * @return Returns the artifactId.
69      */

70     public ArtifactId getArtifactId() {
71         return _artifactId;
72     }
73     
74     public ModuleRevisionId getModuleRevisionId() {
75         return _mrid;
76     }
77
78     public String JavaDoc getName() {
79         return _artifactId.getName();
80     }
81     
82     public String JavaDoc getType() {
83         return _artifactId.getType();
84     }
85     
86     public String JavaDoc getExt() {
87         return _artifactId.getExt();
88     }
89     
90     /**
91      * @return Returns the revision.
92      */

93     public String JavaDoc getRevision() {
94         return _mrid.getRevision();
95     }
96     
97 }
98
Popular Tags