You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by mm...@apache.org on 2004/07/14 19:56:51 UTC
svn commit: rev 22915 - in incubator/depot/trunk/update/src: java/org/apache/depot/update java/org/apache/depot/update/artifact java/org/apache/depot/update/files test/org/apache/depot/update/artifact
Author: mmay
Date: Wed Jul 14 12:56:50 2004
New Revision: 22915
Modified:
incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/artifact/ArtifactLocator.java
incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java
incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java
Log:
Added JavaDoc and clone() methods for the classes, where needed. The
clone method is not really typesafe, so casting is necessary :-(
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/Artifact.java Wed Jul 14 12:56:50 2004
@@ -26,7 +26,15 @@
import org.apache.depot.version.Version;
/**
- * @author arb_jack
+ * An entity in a repository (e.g. junit-3.8.1.jar). An Artifact has (at least in the apache.org environment)
+ * also a version. Also an Artifact has a security mechanism, which is nowadays mostly a file with an
+ * .asc or (better) .md5-Extension.
+ * The basic attributes of an artifact are the group, this artifact belongs to (in the above example the group
+ * would be junit). The type of the artifact provides the type (e.g. jar or tar.gz) of the artifact. The identifier
+ * is a unique identifier of the artifact (the unique name). Also the artifact can provide some version information
+ * (3.8.1 in the above example).
+ *
+ * @author <a href="http://incubator.apache.org/depot">The Apache Incubator Depot Project</a>
*/
public class Artifact implements Dumpable {
@@ -39,12 +47,20 @@
super(ARTIFACT_URI, ARTIFACT_PREFIX, id);
}
}
-
+
private ArtifactGroup m_group = null;
private Artifact.Identifier m_identifier = null;
private ArtifactType m_type = null;
private Version m_version = null;
+ /**
+ * Constructor
+ * Creates an artifact with the given name as the group of the artifact, as well as
+ * the identifier of the artifact. The type is set to java-binary. The version is set
+ * to null.
+ *
+ * @param name Name of the artifact and the group
+ */
public Artifact(String name) {
m_group = new ArtifactGroup(name);
m_identifier = new Artifact.Identifier(name);
@@ -52,6 +68,16 @@
m_version = null;
}
+ /**
+ * Constructor
+ * Basically creates an artifact with the attributes of another artifact (pretty much an
+ * clone)
+ *
+ * :TODO: should be deleted, see the clone method of this class
+ *
+ * @param other another artifact
+ * @deprecated
+ */
public Artifact(Artifact other) {
m_group = other.m_group;
m_identifier = other.m_identifier;
@@ -59,18 +85,42 @@
m_version = other.m_version;
}
+ /**
+ *
+ *
+ * @param group
+ * @param identifier
+ * @param type
+ * @param version
+ */
public Artifact(String group, String identifier, String type,
Version version) {
this(new ArtifactGroup(group), new Artifact.Identifier(identifier),
ArtifactType.getFromString(type), version);
}
+ /**
+ *
+ *
+ * @param group
+ * @param identifier
+ * @param type
+ * @param version
+ */
public Artifact(String group, String identifier, ArtifactType type,
Version version) {
this(new ArtifactGroup(group), new Artifact.Identifier(identifier),
type, version);
}
+ /**
+ *
+ *
+ * @param group
+ * @param identifier
+ * @param type
+ * @param version
+ */
public Artifact(ArtifactGroup group, Artifact.Identifier identifier,
ArtifactType type, Version version) {
m_group = group;
@@ -79,6 +129,14 @@
m_version = version;
}
+ /**
+ *
+ *
+ * @param group
+ * @param identifier
+ * @param type
+ * @param version
+ */
public Artifact(ArtifactGroup group, String identifier,
ArtifactType type, Version version) {
m_group = group;
@@ -166,5 +224,11 @@
out.print(indent);
out.println("Resource Version: " + m_version);
}
+ }
+
+ public Object clone() {
+ Artifact anotherArtifact = new Artifact(this.m_group,
+ this.m_identifier, this.m_type, this.m_version);
+ return anotherArtifact;
}
}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ArtifactInstance.java Wed Jul 14 12:56:50 2004
@@ -58,7 +58,14 @@
m_locator = locator;
}
- // Clone
+ /**
+ * Constructor
+ * Creates an ArtifactInstance from another instance of this class.
+ *
+ * :TODO: should be provided by a clone method
+ *
+ * @param other
+ */
public ArtifactInstance(ArtifactInstance other) {
m_artifact = new Artifact(other.m_artifact);
@@ -217,4 +224,12 @@
new VirtualResourceLocator("http://somewhere/" + name)));
}
+ /**
+ * Provides a clone of this object
+ */
+ public Object clone() {
+ ArtifactInstance aInstance = new ArtifactInstance((Artifact)this.m_artifact.clone(),
+ (ArtifactLocator)this.m_locator.clone());
+ return aInstance;
+ }
}
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/artifact/ArtifactLocator.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/artifact/ArtifactLocator.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/artifact/ArtifactLocator.java Wed Jul 14 12:56:50 2004
@@ -53,9 +53,15 @@
m_location = location;
}
- //
- // Construct an ArtifactLocator
- //
+ /**
+ * Constructor
+ * Creates a new ArtifactLocator from another ArtifactLocator
+ *
+ * :TODO: should be deleted, see the clone method of the class
+ *
+ * @param other
+ * @deprecated see clone()
+ */
public ArtifactLocator(ArtifactLocator other) {
m_filename = other.m_filename;
@@ -136,6 +142,14 @@
}
+ /**
+ * Clones the current Object into another Object
+ */
+ public Object clone() {
+ ArtifactLocator aLocator = new ArtifactLocator(this.m_filename,
+ this.m_extension, this.m_location);
+ return aLocator;
+ }
/**
* @return Returns the filename.
Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java (original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/files/DefaultArtifactFilenameAnalyzer.java Wed Jul 14 12:56:50 2004
@@ -96,7 +96,7 @@
&& (extension.endsWith(UpdateConstants.MD5_EXTN))
&& (extension.length() > UpdateConstants.MD5_EXTN.length())) {
- ArtifactInstance orig = new ArtifactInstance(instance);
+ ArtifactInstance orig = (ArtifactInstance)instance.clone();
String newExtn =
extension.substring(
@@ -111,7 +111,7 @@
&& (extension.endsWith(UpdateConstants.ASC_EXTN))
&& (extension.length() > UpdateConstants.ASC_EXTN.length())) {
- ArtifactInstance orig = new ArtifactInstance(instance);
+ ArtifactInstance orig = (ArtifactInstance)instance.clone();
String newExtn =
extension.substring(
Modified: incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java
==============================================================================
--- incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java (original)
+++ incubator/depot/trunk/update/src/test/org/apache/depot/update/artifact/ArtifactTests.java Wed Jul 14 12:56:50 2004
@@ -59,7 +59,7 @@
public void testArtifactEquality3() throws Exception {
ArtifactInstance i1 = ArtifactInstance.getTestArtifact();
- ArtifactInstance i2 = new ArtifactInstance(i1);
+ ArtifactInstance i2 = (ArtifactInstance)i1.clone();
assertEquals("Clones are equal", i1, i2);
assertTrue("Clones are equal", i1.equals(i2));
@@ -68,7 +68,9 @@
public void testArtifactEquality4() throws Exception {
ArtifactInstance i1 = ArtifactInstance.getTestArtifact();
- ArtifactInstance i2 = new ArtifactInstance(i1); i2.getLocator().setExtension("bogus");
+ ArtifactInstance i2 = (ArtifactInstance)i1.clone();
+
+ i2.getLocator().setExtension("bogus");
assertFalse("Different are NOT equal", i1.equals(i2));
assertFalse(