KickJava   Java API By Example, From Geeks To Geeks.

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


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.net.URL JavaDoc;
9 import java.util.Date JavaDoc;
10 import java.util.Map JavaDoc;
11
12 /**
13  * @author Hanin
14  *
15  */

16 public class DefaultArtifact extends AbstractArtifact {
17
18     public static Artifact newIvyArtifact(ModuleRevisionId mrid, Date JavaDoc pubDate) {
19         return new DefaultArtifact(mrid, pubDate, "ivy", "ivy", "xml");
20     }
21     
22     public static Artifact newPomArtifact(ModuleRevisionId mrid, Date JavaDoc pubDate) {
23         return new DefaultArtifact(mrid, pubDate, mrid.getName(), "pom", "pom");
24     }
25     
26     public static Artifact cloneWithAnotherType(Artifact artifact, String JavaDoc newType) {
27         return new DefaultArtifact(artifact.getModuleRevisionId(), artifact.getPublicationDate(), artifact.getName(), newType, artifact.getExt(), artifact.getUrl(), artifact.getExtraAttributes());
28     }
29     
30     public static Artifact cloneWithAnotherTypeAndExt(Artifact artifact, String JavaDoc newType, String JavaDoc newExt) {
31         return new DefaultArtifact(artifact.getModuleRevisionId(), artifact.getPublicationDate(), artifact.getName(), newType, newExt, artifact.getUrl(), artifact.getExtraAttributes());
32     }
33
34     public static Artifact cloneWithAnotherMrid(Artifact artifact, ModuleRevisionId mrid) {
35         return new DefaultArtifact(mrid, artifact.getPublicationDate(), artifact.getName(), artifact.getType(), artifact.getExt(), artifact.getUrl(), artifact.getExtraAttributes());
36     }
37     
38     Date JavaDoc _publicationDate;
39     ArtifactRevisionId _arid;
40     URL JavaDoc _url;
41     
42     public DefaultArtifact(ModuleRevisionId mrid, Date JavaDoc publicationDate, String JavaDoc name, String JavaDoc type, String JavaDoc ext) {
43         this(mrid, publicationDate, name, type, ext, null, null);
44     }
45     
46     public DefaultArtifact(ModuleRevisionId mrid, Date JavaDoc publicationDate, String JavaDoc name, String JavaDoc type, String JavaDoc ext, Map JavaDoc extraAttributes) {
47         this(mrid, publicationDate, name, type, ext, null, extraAttributes);
48     }
49     public DefaultArtifact(ModuleRevisionId mrid, Date JavaDoc publicationDate, String JavaDoc name, String JavaDoc type, String JavaDoc ext, URL JavaDoc url, Map JavaDoc extraAttributes) {
50         if (mrid == null) {
51             throw new NullPointerException JavaDoc("null mrid not allowed");
52         }
53         if (publicationDate == null) {
54             publicationDate = new Date JavaDoc();
55         }
56         if (name == null) {
57             throw new NullPointerException JavaDoc("null name not allowed");
58         }
59         if (type == null) {
60             throw new NullPointerException JavaDoc("null type not allowed");
61         }
62         if (ext == null) {
63             throw new NullPointerException JavaDoc("null ext not allowed");
64         }
65         _publicationDate = publicationDate;
66         _arid = ArtifactRevisionId.newInstance(mrid, name, type, ext, extraAttributes);
67         _url = url;
68     }
69
70
71     public ModuleRevisionId getModuleRevisionId() {
72         return _arid.getModuleRevisionId();
73     }
74     public String JavaDoc getName() {
75         return _arid.getName();
76     }
77     public Date JavaDoc getPublicationDate() {
78         return _publicationDate;
79     }
80     public String JavaDoc getType() {
81         return _arid.getType();
82     }
83     public String JavaDoc getExt() {
84         return _arid.getExt();
85     }
86     public ArtifactRevisionId getId() {
87         return _arid;
88     }
89
90     public String JavaDoc[] getConfigurations() {
91         return new String JavaDoc[0];
92     }
93
94     public URL JavaDoc getUrl() {
95         return _url;
96     }
97
98 }
99
Popular Tags