KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
10 import java.util.Date JavaDoc;
11 import java.util.List JavaDoc;
12 import java.util.Map JavaDoc;
13
14 /**
15  * @author x.hanin
16  *
17  */

18 public class MDArtifact extends AbstractArtifact {
19
20     public static Artifact newIvyArtifact(ModuleDescriptor md) {
21         return new MDArtifact(md, "ivy", "ivy", "xml");
22     }
23     
24     private ModuleDescriptor _md;
25     private String JavaDoc _name;
26     private String JavaDoc _type;
27     private String JavaDoc _ext;
28     private List JavaDoc _confs = new ArrayList JavaDoc();
29     private ArtifactRevisionId _arid;
30     private Map JavaDoc _extraAttributes = null;
31     private URL JavaDoc _url;
32
33     public MDArtifact(ModuleDescriptor md, String JavaDoc name, String JavaDoc type, String JavaDoc ext) {
34         this(md, name, type, ext, null, null);
35     }
36     public MDArtifact(ModuleDescriptor md, String JavaDoc name, String JavaDoc type, String JavaDoc ext, URL JavaDoc url, Map JavaDoc extraAttributes) {
37         if (md == null) {
38             throw new NullPointerException JavaDoc("null module descriptor not allowed");
39         }
40         if (name == null) {
41             throw new NullPointerException JavaDoc("null name not allowed");
42         }
43         if (type == null) {
44             throw new NullPointerException JavaDoc("null type not allowed");
45         }
46         if (ext == null) {
47             throw new NullPointerException JavaDoc("null ext not allowed");
48         }
49         _md = md;
50         _name = name;
51         _type = type;
52         _ext = ext;
53         _url = url;
54         _extraAttributes = extraAttributes;
55     }
56     
57     public ModuleRevisionId getModuleRevisionId() {
58         return _md.getResolvedModuleRevisionId();
59     }
60     
61     public Date JavaDoc getPublicationDate() {
62         return _md.getResolvedPublicationDate();
63     }
64     public ArtifactRevisionId getId() {
65         if (_arid == null) {
66             _arid = ArtifactRevisionId.newInstance(_md.getResolvedModuleRevisionId(), _name, _type, _ext, _extraAttributes);
67         }
68         return _arid;
69     }
70
71     public String JavaDoc getName() {
72         return _name;
73     }
74
75     public String JavaDoc getType() {
76         return _type;
77     }
78
79     public String JavaDoc getExt() {
80         return _ext;
81     }
82
83     public String JavaDoc[] getConfigurations() {
84         return (String JavaDoc[])_confs.toArray(new String JavaDoc[_confs.size()]);
85     }
86
87     public void addConfiguration(String JavaDoc conf) {
88         _confs.add(conf);
89     }
90     
91     public URL JavaDoc getUrl() {
92         return _url;
93     }
94     
95 }
96
Popular Tags