Hi Oleg,
Author: ogusakov
Date: Fri Oct 31 16:58:48 2008
New Revision: 709607
URL: http://svn.apache.org/viewvc?rev=709607&view=rev
Log:
fixed a dedupe bug
[...]
Added:
maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java
URL:
http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java?rev=709607&view=auto
==============================================================================
---
maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java
(added)
+++
maven/mercury/trunk/mercury-repo/mercury-repo-local-flat/src/main/java/org/apache/maven/mercury/repository/local/m2/ArtifactLocation.java
Fri Oct 31 16:58:48 2008
@@ -0,0 +1,161 @@
+package org.apache.maven.mercury.repository.local.m2;
+
+import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.artifact.version.DefaultArtifactVersion;
+import org.apache.maven.mercury.util.FileUtil;
+
+/**
+ * artifact relative location data object - used by repositories to hold on to intermediate path calculations
+ *
+ *
+ * @author Oleg Gusakov
+ * @version $Id$
+ *
+ */
+public class ArtifactLocation
+{
+ public static final String POM_EXT = ".pom";
+
+ private String prefix;
+
+ private String gaPath;
+ private String versionDir;
+ private String baseName;
+ private String version;
+ private String classifier;
+ private String type;
+
+ private ArtifactBasicMetadata bmd;
+
+ public ArtifactLocation( String prefix, ArtifactBasicMetadata bmd )
+ {
+ if( prefix == null || bmd == null || bmd.getGroupId() == null ||
bmd.getArtifactId() == null || bmd.getVersion() == null )
+ return;
+
+ this.bmd = bmd;
+
+ this.prefix = prefix;
+ this.gaPath = bmd.getGroupId().replace( '.', FileUtil.SEP_CHAR ) +
FileUtil.SEP + bmd.getArtifactId();
+ this.version = bmd.getVersion();
+ this.baseName = bmd.getArtifactId();
+ this.versionDir = this.version;
+ this.classifier = bmd.getClassifier();
+ this.type = bmd.getType();
+ }
+
+ public String getRelPath()
+ {
+ return
gaPath+FileUtil.SEP+versionDir+FileUtil.SEP+baseName+FileUtil.DASH+version+getDashedClassifier()+'.'+type;
+ }
+
+ public String getRelPomPath()
+ {
+ return
gaPath+FileUtil.SEP+versionDir+FileUtil.SEP+baseName+FileUtil.DASH+version+POM_EXT;
+ }
+
+ public String getAbsPath()
+ {
+ if( prefix == null )
+ return null;
+
+ return getSeparatedPrefix() + getRelPath();
+ }
+
+ public String getAbsPomPath()
+ {
+ if( prefix == null )
+ return null;
+
+ return getSeparatedPrefix() + getRelPomPath();
+ }
+
+ public String getGavPath()
+ {
+ return getGaPath()+FileUtil.SEP+versionDir;
+ }
+
+ public String getBaseVersion()
+ {
+ if( version == null )
+ return null;
+
+ DefaultArtifactVersion dav = new DefaultArtifactVersion( version );
+ return dav.getBase();
+ }
+
+ //---------------------------------------------------------
+ public String getGaPath()
+ {
+ return gaPath;
+ }
+ public void setGaPath( String gaPath )
+ {
+ this.gaPath = gaPath;
+ }
+ public String getVersionDir()
+ {
+ return versionDir;
+ }
+ public void setVersionDir( String versionDir )
+ {
+ this.versionDir = versionDir;
+ }
+ public String getBaseName()
+ {
+ return baseName;
+ }
+ public void setBaseName( String baseName )
+ {
+ this.baseName = baseName;
+ }
+ public String getVersion()
+ {
+ return version;
+ }
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+ public String getClassifier()
+ {
+ return classifier;
+ }
+ public String getDashedClassifier()
+ {
+ return (classifier == null||classifier.length()<1) ? "" :
FileUtil.DASH+classifier;
+ }
+ public void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+ public String getType()
+ {
+ return type;
+ }
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+ public String getPrefix()
+ {
+ return prefix;
+ }
+ public String getSeparatedPrefix()
+ {
+ if( prefix == null )
+ return null;
+
+ return prefix+(prefix.endsWith( FileUtil.SEP ) ? "" : FileUtil.SEP);
+ }
+ public void setPrefix( String prefix )
+ {
+ this.prefix = prefix;
+ }
+
+ @Override
+ public String toString()
+ {
+ return bmd == null ? "no ArtifactBasicMetadata" : bmd.toString();
+ }
+
+}
\ No newline at end of file
The recommended indentation for Java sources is 4 spaces per level [0].
The mentioned page also provides ready-made code styles for IDEA and
Eclipse that might be useful. Not sure whether Milos has some code style
for NetBeans around ;-)
Benjamin
[0] http://maven.apache.org/developers/conventions/code.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]