1 6 package fr.jayasoft.ivy; 7 8 import java.net.URL ; 9 import java.util.Date ; 10 import java.util.Map ; 11 12 16 public class DefaultArtifact extends AbstractArtifact { 17 18 public static Artifact newIvyArtifact(ModuleRevisionId mrid, Date pubDate) { 19 return new DefaultArtifact(mrid, pubDate, "ivy", "ivy", "xml"); 20 } 21 22 public static Artifact newPomArtifact(ModuleRevisionId mrid, Date pubDate) { 23 return new DefaultArtifact(mrid, pubDate, mrid.getName(), "pom", "pom"); 24 } 25 26 public static Artifact cloneWithAnotherType(Artifact artifact, String 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 newType, String 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 _publicationDate; 39 ArtifactRevisionId _arid; 40 URL _url; 41 42 public DefaultArtifact(ModuleRevisionId mrid, Date publicationDate, String name, String type, String ext) { 43 this(mrid, publicationDate, name, type, ext, null, null); 44 } 45 46 public DefaultArtifact(ModuleRevisionId mrid, Date publicationDate, String name, String type, String ext, Map extraAttributes) { 47 this(mrid, publicationDate, name, type, ext, null, extraAttributes); 48 } 49 public DefaultArtifact(ModuleRevisionId mrid, Date publicationDate, String name, String type, String ext, URL url, Map extraAttributes) { 50 if (mrid == null) { 51 throw new NullPointerException ("null mrid not allowed"); 52 } 53 if (publicationDate == null) { 54 publicationDate = new Date (); 55 } 56 if (name == null) { 57 throw new NullPointerException ("null name not allowed"); 58 } 59 if (type == null) { 60 throw new NullPointerException ("null type not allowed"); 61 } 62 if (ext == null) { 63 throw new NullPointerException ("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 getName() { 75 return _arid.getName(); 76 } 77 public Date getPublicationDate() { 78 return _publicationDate; 79 } 80 public String getType() { 81 return _arid.getType(); 82 } 83 public String getExt() { 84 return _arid.getExt(); 85 } 86 public ArtifactRevisionId getId() { 87 return _arid; 88 } 89 90 public String [] getConfigurations() { 91 return new String [0]; 92 } 93 94 public URL getUrl() { 95 return _url; 96 } 97 98 } 99 | Popular Tags |