org.apache.ivy.core.module.descriptor
Class DefaultModuleDescriptor

java.lang.Object
  extended by org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor
All Implemented Interfaces:
ModuleDescriptor, ExtendableItem

public class DefaultModuleDescriptor
extends java.lang.Object
implements ModuleDescriptor

Author:
X.Hanin

Field Summary
 
Fields inherited from interface org.apache.ivy.core.module.descriptor.ModuleDescriptor
CALLER_ALL_CONFIGURATION, DEFAULT_CONFIGURATION
 
Constructor Summary
DefaultModuleDescriptor(ModuleDescriptorParser parser, Resource res)
          IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate with instances created by this constructor !
DefaultModuleDescriptor(ModuleRevisionId id, java.lang.String status, java.util.Date pubDate)
           
DefaultModuleDescriptor(ModuleRevisionId id, java.lang.String status, java.util.Date pubDate, boolean isDefault)
           
 
Method Summary
 void addArtifact(java.lang.String conf, Artifact artifact)
          Artifact configurations are not used since added artifact may not be entirely completed, so its configurations data may not be accurate
 void addConfiguration(Configuration conf)
           
 void addConflictManager(ModuleId moduleId, PatternMatcher matcher, ConflictManager manager)
          regular expressions as explained in Pattern class may be used in ModuleId organisation and name
 void addDependency(DependencyDescriptor dependency)
           
 void addExcludeRule(ExcludeRule rule)
           
 void addLicense(License license)
           
 boolean canExclude()
          Returns true if this descriptor contains any exclusion rule
 void check()
          Throws an exception if the module descriptor is inconsistent For the moment, only extended configurations existence is checked
 boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md)
          Returns true if the module described by this descriptor dependes directly upon the given module descriptor
 boolean doesExclude(java.lang.String[] moduleConfigurations, ArtifactId artifactId)
          only works when namespace is properly set.
 Artifact[] getAllArtifacts()
           
 ExcludeRule[] getAllExcludeRules()
          Returns an array of all the exclude rules this module descriptor currently holds.
 Artifact[] getArtifacts(java.lang.String conf)
           
 java.lang.String getAttribute(java.lang.String attName)
          Gets the value of an attribute Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.
 java.util.Map getAttributes()
          Returns a Map of all attributes of this extendable item, including standard and extra ones.
 Configuration getConfiguration(java.lang.String confName)
          Returns the configuration object with the given name in the current module descriptor, null if not found.
 Configuration[] getConfigurations()
          Returns all the configurations declared by this module as an array.
 java.lang.String[] getConfigurationsNames()
           
 ConflictManager getConflictManager(ModuleId moduleId)
          Returns the conflict manager to use for the given ModuleId
 DependencyDescriptor[] getDependencies()
           
 ExcludeRule[] getExcludeRules(java.lang.String[] moduleConfigurations)
           
 java.lang.String getExtraAttribute(java.lang.String attName)
          Gets the value of an extra attribute Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)
 java.util.Map getExtraAttributes()
          Returns a Map of all extra attributes of this extendable item.
 java.lang.String getHomePage()
           
 long getLastModified()
           
 License[] getLicenses()
          Returns the licenses of the module described by this descriptor
 ModuleRevisionId getModuleRevisionId()
           
 Namespace getNamespace()
           
 ModuleDescriptorParser getParser()
          The ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.
 java.util.Date getPublicationDate()
          may be null if unknown in the descriptor itself
 java.lang.String[] getPublicConfigurationsNames()
           
 ModuleRevisionId getResolvedModuleRevisionId()
          The module revision id returned here is the resolved one, i.e. it is never a latest one.
 java.util.Date getResolvedPublicationDate()
          the publication date of the module revision should be the date at which it has been published, i.e. in general the date of any of its published artifacts, since all published artifact of a module should follow the same publishing cycle.
 Resource getResource()
          The resource being the source of this module descriptor, null if no resource corresponds to this module descriptor
 java.lang.String getStandardAttribute(java.lang.String attName)
          Gets the value of a standard attribute Can be used only to access the value of a standard attribute (like organisation, revision), not an extra one
 java.util.Map getStandardAttributes()
          Returns a Map of all standard attributes of this extendable item.
 java.lang.String getStatus()
           
 boolean isDefault()
          Returns true if this descriptor is a default one, i.e.
 boolean isMappingOverride()
           
 boolean isNamespaceUseful()
           
static DefaultModuleDescriptor newBasicInstance(ModuleRevisionId mrid, java.util.Date publicationDate)
           
static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid, boolean transitive, boolean changing)
           
static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid, java.lang.String[] confs, boolean transitive, boolean changing)
           
static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid)
           
static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid, DependencyArtifactDescriptor[] artifacts)
           
 void setDefault(boolean b)
           
 void setHomePage(java.lang.String homePage)
           
 void setLastModified(long lastModified)
           
 void setMappingOverride(boolean override)
           
 void setModuleRevisionId(ModuleRevisionId revId)
           
 void setNamespace(Namespace ns)
           
 void setPublicationDate(java.util.Date publicationDate)
           
 void setResolvedModuleRevisionId(ModuleRevisionId revId)
          This method update the resolved module revision id
 void setResolvedPublicationDate(java.util.Date publicationDate)
          This method update the resolved publication date
 void setStatus(java.lang.String status)
           
 void toIvyFile(java.io.File destFile)
          Writes this module descriptor as an ivy file.
 java.lang.String toString()
           
static ModuleDescriptor transformInstance(ModuleDescriptor md, Namespace ns)
          Transforms the given module descriptor of the given namespace and return a new module descriptor in the system namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultModuleDescriptor

public DefaultModuleDescriptor(ModuleRevisionId id,
                               java.lang.String status,
                               java.util.Date pubDate)

DefaultModuleDescriptor

public DefaultModuleDescriptor(ModuleRevisionId id,
                               java.lang.String status,
                               java.util.Date pubDate,
                               boolean isDefault)

DefaultModuleDescriptor

public DefaultModuleDescriptor(ModuleDescriptorParser parser,
                               Resource res)
IMPORTANT : at least call setModuleRevisionId and setResolvedPublicationDate with instances created by this constructor !

Method Detail

newDefaultInstance

public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid)

newCallerInstance

public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid,
                                                        java.lang.String[] confs,
                                                        boolean transitive,
                                                        boolean changing)

newCallerInstance

public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid,
                                                        boolean transitive,
                                                        boolean changing)

newDefaultInstance

public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid,
                                                         DependencyArtifactDescriptor[] artifacts)

newBasicInstance

public static DefaultModuleDescriptor newBasicInstance(ModuleRevisionId mrid,
                                                       java.util.Date publicationDate)

transformInstance

public static ModuleDescriptor transformInstance(ModuleDescriptor md,
                                                 Namespace ns)
Transforms the given module descriptor of the given namespace and return a new module descriptor in the system namespace. Note that dependency exclude rules are not converted in system namespace, because they aren't transformable (the name space hasn't the ability to convert regular expressions)

Parameters:
md -
ns -
Returns:

isDefault

public boolean isDefault()
Description copied from interface: ModuleDescriptor
Returns true if this descriptor is a default one, i.e. one generated for a module not actually having one.

Specified by:
isDefault in interface ModuleDescriptor
Returns:

setPublicationDate

public void setPublicationDate(java.util.Date publicationDate)

getPublicationDate

public java.util.Date getPublicationDate()
Description copied from interface: ModuleDescriptor
may be null if unknown in the descriptor itself

Specified by:
getPublicationDate in interface ModuleDescriptor
Returns:

setResolvedPublicationDate

public void setResolvedPublicationDate(java.util.Date publicationDate)
Description copied from interface: ModuleDescriptor
This method update the resolved publication date

Specified by:
setResolvedPublicationDate in interface ModuleDescriptor

getResolvedPublicationDate

public java.util.Date getResolvedPublicationDate()
Description copied from interface: ModuleDescriptor
the publication date of the module revision should be the date at which it has been published, i.e. in general the date of any of its published artifacts, since all published artifact of a module should follow the same publishing cycle.

Specified by:
getResolvedPublicationDate in interface ModuleDescriptor

setModuleRevisionId

public void setModuleRevisionId(ModuleRevisionId revId)

setResolvedModuleRevisionId

public void setResolvedModuleRevisionId(ModuleRevisionId revId)
Description copied from interface: ModuleDescriptor
This method update the resolved module revision id

Specified by:
setResolvedModuleRevisionId in interface ModuleDescriptor

setStatus

public void setStatus(java.lang.String status)

addDependency

public void addDependency(DependencyDescriptor dependency)

addConfiguration

public void addConfiguration(Configuration conf)

addArtifact

public void addArtifact(java.lang.String conf,
                        Artifact artifact)
Artifact configurations are not used since added artifact may not be entirely completed, so its configurations data may not be accurate

Parameters:
conf -
artifact -

getModuleRevisionId

public ModuleRevisionId getModuleRevisionId()
Specified by:
getModuleRevisionId in interface ModuleDescriptor

getResolvedModuleRevisionId

public ModuleRevisionId getResolvedModuleRevisionId()
Description copied from interface: ModuleDescriptor
The module revision id returned here is the resolved one, i.e. it is never a latest one. If the revision has not been resolved, a null revision should be returned by getRevision() of the returned ModuleRevisionId. This revision must be the same as the module descriptor resolved revision id unless no module descriptor is defined

Specified by:
getResolvedModuleRevisionId in interface ModuleDescriptor
Returns:

getStatus

public java.lang.String getStatus()
Specified by:
getStatus in interface ModuleDescriptor

getConfigurations

public Configuration[] getConfigurations()
Description copied from interface: ModuleDescriptor
Returns all the configurations declared by this module as an array. This array is never empty (a 'default' conf is assumed when none is declared in the ivy file)

Specified by:
getConfigurations in interface ModuleDescriptor
Returns:
all the configurations declared by this module as an array.

getConfigurationsNames

public java.lang.String[] getConfigurationsNames()
Specified by:
getConfigurationsNames in interface ModuleDescriptor

getPublicConfigurationsNames

public java.lang.String[] getPublicConfigurationsNames()
Specified by:
getPublicConfigurationsNames in interface ModuleDescriptor

getConfiguration

public Configuration getConfiguration(java.lang.String confName)
Returns the configuration object with the given name in the current module descriptor, null if not found.

Specified by:
getConfiguration in interface ModuleDescriptor
Returns:

getArtifacts

public Artifact[] getArtifacts(java.lang.String conf)
Specified by:
getArtifacts in interface ModuleDescriptor

getAllArtifacts

public Artifact[] getAllArtifacts()
Specified by:
getAllArtifacts in interface ModuleDescriptor

getDependencies

public DependencyDescriptor[] getDependencies()
Specified by:
getDependencies in interface ModuleDescriptor

dependsOn

public boolean dependsOn(VersionMatcher matcher,
                         ModuleDescriptor md)
Description copied from interface: ModuleDescriptor
Returns true if the module described by this descriptor dependes directly upon the given module descriptor

Specified by:
dependsOn in interface ModuleDescriptor
Returns:

toIvyFile

public void toIvyFile(java.io.File destFile)
               throws java.text.ParseException,
                      java.io.IOException
Description copied from interface: ModuleDescriptor
Writes this module descriptor as an ivy file. If this descriptor was obtained through the parsing of an ivy file, it should keep the layout of the file the most possible similar to the original one.

Specified by:
toIvyFile in interface ModuleDescriptor
Parameters:
destFile - the destination ivy file
Throws:
java.text.ParseException
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setDefault

public void setDefault(boolean b)

addConflictManager

public void addConflictManager(ModuleId moduleId,
                               PatternMatcher matcher,
                               ConflictManager manager)
regular expressions as explained in Pattern class may be used in ModuleId organisation and name

Parameters:
moduleId -
matcher -
resolverName -

getConflictManager

public ConflictManager getConflictManager(ModuleId moduleId)
Description copied from interface: ModuleDescriptor
Returns the conflict manager to use for the given ModuleId

Specified by:
getConflictManager in interface ModuleDescriptor
Returns:

addLicense

public void addLicense(License license)

getLicenses

public License[] getLicenses()
Description copied from interface: ModuleDescriptor
Returns the licenses of the module described by this descriptor

Specified by:
getLicenses in interface ModuleDescriptor
Returns:

getHomePage

public java.lang.String getHomePage()
Specified by:
getHomePage in interface ModuleDescriptor

setHomePage

public void setHomePage(java.lang.String homePage)

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface ModuleDescriptor

setLastModified

public void setLastModified(long lastModified)

getNamespace

public Namespace getNamespace()

isNamespaceUseful

public boolean isNamespaceUseful()

setNamespace

public void setNamespace(Namespace ns)

check

public void check()
Throws an exception if the module descriptor is inconsistent For the moment, only extended configurations existence is checked


setMappingOverride

public void setMappingOverride(boolean override)

isMappingOverride

public boolean isMappingOverride()

getAttribute

public java.lang.String getAttribute(java.lang.String attName)
Description copied from interface: ExtendableItem
Gets the value of an attribute Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.

Specified by:
getAttribute in interface ExtendableItem
Parameters:
attName - the name of the attribute to get
Returns:
the value of the attribute, null if the attribute doesn't exist

getAttributes

public java.util.Map getAttributes()
Description copied from interface: ExtendableItem
Returns a Map of all attributes of this extendable item, including standard and extra ones. The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)

Specified by:
getAttributes in interface ExtendableItem
Returns:

getExtraAttribute

public java.lang.String getExtraAttribute(java.lang.String attName)
Description copied from interface: ExtendableItem
Gets the value of an extra attribute Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)

Specified by:
getExtraAttribute in interface ExtendableItem
Parameters:
attName - the name of the extra attribute to get
Returns:
the value of the attribute, null if the attribute doesn't exist

getExtraAttributes

public java.util.Map getExtraAttributes()
Description copied from interface: ExtendableItem
Returns a Map of all extra attributes of this extendable item. The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)

Specified by:
getExtraAttributes in interface ExtendableItem
Returns:

getStandardAttribute

public java.lang.String getStandardAttribute(java.lang.String attName)
Description copied from interface: ExtendableItem
Gets the value of a standard attribute Can be used only to access the value of a standard attribute (like organisation, revision), not an extra one

Specified by:
getStandardAttribute in interface ExtendableItem
Parameters:
attName - the name of the standard attribute to get
Returns:
the value of the attribute, null if the attribute doesn't exist

getStandardAttributes

public java.util.Map getStandardAttributes()
Description copied from interface: ExtendableItem
Returns a Map of all standard attributes of this extendable item. The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)

Specified by:
getStandardAttributes in interface ExtendableItem
Returns:

getParser

public ModuleDescriptorParser getParser()
Description copied from interface: ModuleDescriptor
The ModuleDescriptorParser used to parse this module descriptor, null is no parser was used.

Specified by:
getParser in interface ModuleDescriptor
Returns:

getResource

public Resource getResource()
Description copied from interface: ModuleDescriptor
The resource being the source of this module descriptor, null if no resource corresponds to this module descriptor

Specified by:
getResource in interface ModuleDescriptor
Returns:

addExcludeRule

public void addExcludeRule(ExcludeRule rule)

canExclude

public boolean canExclude()
Description copied from interface: ModuleDescriptor
Returns true if this descriptor contains any exclusion rule

Specified by:
canExclude in interface ModuleDescriptor
Returns:
true if this descriptor contains any exclusion rule

doesExclude

public boolean doesExclude(java.lang.String[] moduleConfigurations,
                           ArtifactId artifactId)
only works when namespace is properly set. The behaviour is not specified if namespace is not set

Specified by:
doesExclude in interface ModuleDescriptor
Returns:

getAllExcludeRules

public ExcludeRule[] getAllExcludeRules()
Description copied from interface: ModuleDescriptor
Returns an array of all the exclude rules this module descriptor currently holds. Module Descriptor exclude rules are used to exclude (usually transitive) dependencies for the whole module.

Specified by:
getAllExcludeRules in interface ModuleDescriptor
Returns:
an array of ExcludeRule this module descriptor holds

getExcludeRules

public ExcludeRule[] getExcludeRules(java.lang.String[] moduleConfigurations)