org.jboss.dna.maven
Class MavenId

java.lang.Object
  extended by org.jboss.dna.maven.MavenId
All Implemented Interfaces:
Cloneable, Comparable<MavenId>

public class MavenId
extends Object
implements Comparable<MavenId>, Cloneable

Identifier of a Maven 2 artifact.


Nested Class Summary
 class MavenId.Version
           
 
Constructor Summary
MavenId(String coordinates)
          Create an Maven ID from the supplied string containing the coordinates for a Maven artifact.
MavenId(String groupId, String artifactId)
          Create a Maven ID from the supplied group and artifact IDs.
MavenId(String groupId, String artifactId, String version)
          Create a Maven ID from the supplied group and artifact IDs and the version.
MavenId(String groupId, String artifactId, String version, String classifier)
          Create a Maven ID from the supplied group ID, artifact ID, version, and classifier.
 
Method Summary
 MavenId clone()
          
 int compareTo(MavenId that)
          
static MavenId[] createClasspath(MavenId... mavenIds)
          Create a classpath of MavenIds by examining the supplied IDs and removing any duplicates.
static MavenId[] createClasspath(String... mavenCoordinates)
          Build a classpath of MavenIds by parsing the supplied Maven artifact coordinates.
static MavenId[] createClasspath(String commaSeparatedCoordinates)
          Build a classpath of MavenIds by parsing the supplied string containing comma-separated Maven artifact coordinates.
static MavenId createFromCoordinates(String coordinates)
           
 boolean equals(Object obj)
          
 String getArtifactId()
          The identifier for this artifact that is unique within the group given by the group ID.
 String getClassifier()
           
 String getCoordinates()
           
 String getGroupId()
          A universally unique identifier for a project.
 String getRelativePath()
          Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.
 String getRelativePath(boolean includeVersion)
          Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.
 String getRelativePath(TextEncoder escapingStrategy)
          Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.
 String getRelativePath(TextEncoder escapingStrategy, boolean includeVersion)
          Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.
 String getVersion()
           
 int hashCode()
          
 String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MavenId

public MavenId(String coordinates)
Create an Maven ID from the supplied string containing the coordinates for a Maven artifact. Coordinates are of the form:
         groupId:artifactId[:version[:classifier]]
 
where
groupId
is the group identifier (e.g., org.jboss.dna), which may not be empty
artifactId
is the artifact identifier (e.g., dna-maven), which may not be empty
version
is the optional version (e.g., org.jboss.dna)
classifier
is the optional classifier (e.g., test or jdk1.4)

Parameters:
coordinates - the string containing the Maven coordinates
Throws:
IllegalArgumentException - if the supplied string is null or if the string does not match the expected format

MavenId

public MavenId(String groupId,
               String artifactId)
Create a Maven ID from the supplied group and artifact IDs.

Parameters:
groupId - the group identifier
artifactId - the artifact identifier
Throws:
IllegalArgumentException - if the group or artifact identifiers are null, empty or blank

MavenId

public MavenId(String groupId,
               String artifactId,
               String version)
Create a Maven ID from the supplied group and artifact IDs and the version.

Parameters:
groupId - the group identifier
artifactId - the artifact identifier
version - the version; may be null or empty
Throws:
IllegalArgumentException - if the group or artifact identifiers are null, empty or blank

MavenId

public MavenId(String groupId,
               String artifactId,
               String version,
               String classifier)
Create a Maven ID from the supplied group ID, artifact ID, version, and classifier.

Parameters:
groupId - the group identifier
artifactId - the artifact identifier
version - the version; may be null or empty
classifier - the classifier; may be null or empty
Throws:
IllegalArgumentException - if the group or artifact identifiers are null, empty or blank
Method Detail

createClasspath

public static MavenId[] createClasspath(String commaSeparatedCoordinates)
Build a classpath of MavenIds by parsing the supplied string containing comma-separated Maven artifact coordinates. Any duplicates in the classpath are excluded.

Parameters:
commaSeparatedCoordinates - the string of Maven artifact coordinates
Returns:
the array of MavenId instances representing the classpath

createClasspath

public static MavenId[] createClasspath(String... mavenCoordinates)
Build a classpath of MavenIds by parsing the supplied Maven artifact coordinates. Any duplicates in the classpath are excluded.

Parameters:
mavenCoordinates - the array of Maven artifact coordinates
Returns:
the array of MavenId instances representing the classpath

createClasspath

public static MavenId[] createClasspath(MavenId... mavenIds)
Create a classpath of MavenIds by examining the supplied IDs and removing any duplicates.

Parameters:
mavenIds - the Maven IDs
Returns:
the array of MavenId instances representing the classpath

getGroupId

public String getGroupId()
A universally unique identifier for a project. It is normal to use a fully-qualified package name to distinguish it from other projects with a similar name (eg. org.apache.maven).

Returns:
the group identifier

getArtifactId

public String getArtifactId()
The identifier for this artifact that is unique within the group given by the group ID. An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.

Returns:
the artifact identifier

getClassifier

public String getClassifier()
Returns:
classifier

getVersion

public String getVersion()
Returns:
version

getRelativePath

public String getRelativePath()
Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.

Returns:
the path; never null

getRelativePath

public String getRelativePath(TextEncoder escapingStrategy)
Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.

Parameters:
escapingStrategy - the strategy to use for escaping characters that are not allowed in JCR names.
Returns:
the path; never null

getRelativePath

public String getRelativePath(boolean includeVersion)
Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.

Parameters:
includeVersion - true if the version is to be included in the path
Returns:
the path; never null

getRelativePath

public String getRelativePath(TextEncoder escapingStrategy,
                              boolean includeVersion)
Return the relative JCR path for this resource, built from the components of the group ID, the artifact ID, and the version.

Parameters:
escapingStrategy - the strategy to use for escaping characters that are not allowed in JCR names.
includeVersion - true if the version is to be included in the path
Returns:
the path; never null

getCoordinates

public String getCoordinates()

createFromCoordinates

public static MavenId createFromCoordinates(String coordinates)

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

compareTo

public int compareTo(MavenId that)

Specified by:
compareTo in interface Comparable<MavenId>

toString

public String toString()

Overrides:
toString in class Object

clone

public MavenId clone()

Overrides:
clone in class Object


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.