org.sonatype.aether.util.artifact
Class DefaultArtifact

java.lang.Object
  extended by org.sonatype.aether.util.artifact.AbstractArtifact
      extended by org.sonatype.aether.util.artifact.DefaultArtifact
All Implemented Interfaces:
Artifact

public final class DefaultArtifact
extends AbstractArtifact

A simple artifact. Note: Instances of this class are immutable and the exposed mutators return new objects rather than changing the current instance.

Author:
Benjamin Bentmann

Constructor Summary
DefaultArtifact(String coords)
          Creates a new artifact with the specified coordinates.
DefaultArtifact(String coords, Map<String,String> properties)
          Creates a new artifact with the specified coordinates and properties.
DefaultArtifact(String groupId, String artifactId, String extension, String version)
          Creates a new artifact with the specified coordinates and no classifier.
DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version)
          Creates a new artifact with the specified coordinates.
DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, ArtifactType type)
          Creates a new artifact with the specified coordinates.
DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, Map<String,String> properties, ArtifactType type)
          Creates a new artifact with the specified coordinates and properties.
DefaultArtifact(String groupId, String artifactId, String classifier, String extension, String version, Map<String,String> properties, File file)
          Creates a new artifact with the specified coordinates, properties and file.
 
Method Summary
 String getArtifactId()
           
 String getBaseVersion()
           
 String getClassifier()
           
 String getExtension()
           
 File getFile()
           
 String getGroupId()
           
 Map<String,String> getProperties()
           
 String getProperty(String key, String defaultValue)
           
 String getVersion()
           
 boolean isSnapshot()
           
 Artifact setFile(File file)
           
 Artifact setProperties(Map<String,String> properties)
           
 Artifact setVersion(String version)
           
 
Methods inherited from class org.sonatype.aether.util.artifact.AbstractArtifact
equals, hashCode, isSnapshot, newInstance, toBaseVersion, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultArtifact

public DefaultArtifact(String coords)
Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the artifact's extension defaults to jar and classifier to an empty string.

Parameters:
coords - The artifact coordinates in the format <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, must not be null.

DefaultArtifact

public DefaultArtifact(String coords,
                       Map<String,String> properties)
Creates a new artifact with the specified coordinates and properties. If not specified in the artifact coordinates, the artifact's extension defaults to jar and classifier to an empty string.

Parameters:
coords - The artifact coordinates in the format <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>, must not be null.
properties - The artifact properties, may be null.

DefaultArtifact

public DefaultArtifact(String groupId,
                       String artifactId,
                       String extension,
                       String version)
Creates a new artifact with the specified coordinates and no classifier. Passing null for any of the coordinates is equivalent to specifying an empty string.

Parameters:
groupId - The group identifier of the artifact, may be null.
artifactId - The artifact identifier of the artifact, may be null.
extension - The file extension of the artifact, may be null.
version - The version of the artifact, may be null.

DefaultArtifact

public DefaultArtifact(String groupId,
                       String artifactId,
                       String classifier,
                       String extension,
                       String version)
Creates a new artifact with the specified coordinates. Passing null for any of the coordinates is equivalent to specifying an empty string.

Parameters:
groupId - The group identifier of the artifact, may be null.
artifactId - The artifact identifier of the artifact, may be null.
classifier - The classifier of the artifact, may be null.
extension - The file extension of the artifact, may be null.
version - The version of the artifact, may be null.

DefaultArtifact

public DefaultArtifact(String groupId,
                       String artifactId,
                       String classifier,
                       String extension,
                       String version,
                       ArtifactType type)
Creates a new artifact with the specified coordinates. Passing null for any of the coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to determine the artifact's classifier and file extension if the corresponding arguments for this constructor are null.

Parameters:
groupId - The group identifier of the artifact, may be null.
artifactId - The artifact identifier of the artifact, may be null.
classifier - The classifier of the artifact, may be null.
extension - The file extension of the artifact, may be null.
version - The version of the artifact, may be null.
type - The artifact type from which to query classifier, file extension and properties, may be null.

DefaultArtifact

public DefaultArtifact(String groupId,
                       String artifactId,
                       String classifier,
                       String extension,
                       String version,
                       Map<String,String> properties,
                       ArtifactType type)
Creates a new artifact with the specified coordinates and properties. Passing null for any of the coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to determine the artifact's classifier and file extension if the corresponding arguments for this constructor are null. If the artifact type specifies properties, those will get merged with the properties passed directly into the constructor, with the latter properties taking precedence.

Parameters:
groupId - The group identifier of the artifact, may be null.
artifactId - The artifact identifier of the artifact, may be null.
classifier - The classifier of the artifact, may be null.
extension - The file extension of the artifact, may be null.
version - The version of the artifact, may be null.
properties - The properties of the artifact, may be null if none.
type - The artifact type from which to query classifier, file extension and properties, may be null.

DefaultArtifact

public DefaultArtifact(String groupId,
                       String artifactId,
                       String classifier,
                       String extension,
                       String version,
                       Map<String,String> properties,
                       File file)
Creates a new artifact with the specified coordinates, properties and file. Passing null for any of the coordinates is equivalent to specifying an empty string.

Parameters:
groupId - The group identifier of the artifact, may be null.
artifactId - The artifact identifier of the artifact, may be null.
classifier - The classifier of the artifact, may be null.
extension - The file extension of the artifact, may be null.
version - The version of the artifact, may be null.
properties - The properties of the artifact, may be null if none.
file - The resolved file of the artifact, may be null.
Method Detail

getGroupId

public String getGroupId()

getArtifactId

public String getArtifactId()

getBaseVersion

public String getBaseVersion()

getVersion

public String getVersion()

setVersion

public Artifact setVersion(String version)
Specified by:
setVersion in interface Artifact
Overrides:
setVersion in class AbstractArtifact

isSnapshot

public boolean isSnapshot()

getClassifier

public String getClassifier()

getExtension

public String getExtension()

getFile

public File getFile()

setFile

public Artifact setFile(File file)
Specified by:
setFile in interface Artifact
Overrides:
setFile in class AbstractArtifact

getProperty

public String getProperty(String key,
                          String defaultValue)

getProperties

public Map<String,String> getProperties()

setProperties

public Artifact setProperties(Map<String,String> properties)
Specified by:
setProperties in interface Artifact
Overrides:
setProperties in class AbstractArtifact


Copyright © 2010-2011 Sonatype, Inc.. All Rights Reserved.