net.dpml.library.impl
Class DefaultResource

java.lang.Object
  extended bynet.dpml.library.impl.DefaultDictionary
      extended bynet.dpml.library.impl.DefaultResource
All Implemented Interfaces:
Comparable, Dictionary, Resolver, Resource
Direct Known Subclasses:
DefaultModule

public class DefaultResource
extends DefaultDictionary
implements Resource, Resolver, Comparable

Implementation of a resource.

Version:
1.1.0
Author:
Digital Product Meta Library

Field Summary
static String ANONYMOUS
          Constant ANONYMOUS version symbol.
static String BOOTSTRAP
          Constant BOOTSTRAP symbol.
static String RELEASE
          Constant RELEASE symbol.
static String SNAPSHOT
          Constant SNAPSHOT symbol.
static String TIMESTAMP
          Timestamp.
 
Fields inherited from interface net.dpml.library.Resource
DECIMAL_VERSIONING_KEY
 
Method Summary
 int compareTo(Object other)
          Compare this object with another.
 Resource[] getAggregatedProviders(Scope scope, boolean expand, boolean sort)
          Return an array of resource that are providers to this resource.
 Artifact getArtifact(String id)
          Construct an artifact for the supplied type.
 File getBaseDir()
          Return the basedir for this resource.
 ResourceDirective.Classifier getClassifier()
          Return the resource classifier.
 Resource[] getClasspathProviders(Category category)
          Return an array of runtime providers filtered relative to a supplied classloading category.
 Resource[] getClasspathProviders(Scope scope)
          Return a sorted and filtered array of providers.
 Resource[] getConsumers(boolean expand, boolean sort)
          Return an array of resources that are consumers of this resource.
 Data[] getData()
          Return a data directives.
 Version getDecimalVersion()
          Return the decimal version.
 Filter[] getFilters()
          Return an array of filters associated with the resource.
 Info getInfo()
          Return the info block.
 String getLayoutPath(String id)
          Return a filename using the layout strategy employed by the cache.
 Library getLibrary()
          Return the singleton library.
 Artifact getLinkArtifact(String id)
          Construct an link artifact for the supplied type.
 String getName()
          Return the name of the resource.
 Module getParent()
          Return the enclosing parent module.
 Resource[] getProviders(Scope scope, boolean expand, boolean sort)
          Return an array of resource that are providers to this resource.
 ResourceDirective getResourceDirective()
          Return the underlying resource defintion.
 String getResourcePath()
          Return the fully qualified path to the resource.
 String getStatutoryVersion()
          Return the declard resource version.
static String getTimestamp()
          Return the UTC YYMMDD.HHMMSSS signature of a date.
static String getTimestamp(Date date)
          Return the UTC YYMMDD.HHMMSSS signature of a date.
 Type getType(String id)
          Return a resource type relative to a supplied type id.
 Type[] getTypes()
          Return the expanded array of types associated with the resource.
 String getVersion()
          Return the resource version.
 boolean isa(String type)
          Test if this resource is associated with a type of the supplied name.
 String toString()
          Return a string representation of the resource in the form 'resource:[path]'.
 URI toURI(String ref)
          Utility function supporting resolution of uris containing 'resource' or 'alias' schemes.
 
Methods inherited from class net.dpml.library.impl.DefaultDictionary
getBooleanProperty, getIntegerProperty, getLocalPropertyNames, getProperty, getProperty, getPropertyNames, resolve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.dpml.library.Dictionary
getBooleanProperty, getIntegerProperty, getLocalPropertyNames, getProperty, getProperty, getPropertyNames, resolve
 
Methods inherited from interface net.dpml.util.Resolver
getProperty, getProperty, resolve
 

Field Detail

TIMESTAMP

public static final String TIMESTAMP
Timestamp.


SNAPSHOT

public static final String SNAPSHOT
Constant SNAPSHOT symbol.

See Also:
Constant Field Values

BOOTSTRAP

public static final String BOOTSTRAP
Constant BOOTSTRAP symbol.

See Also:
Constant Field Values

RELEASE

public static final String RELEASE
Constant RELEASE symbol.

See Also:
Constant Field Values

ANONYMOUS

public static final String ANONYMOUS
Constant ANONYMOUS version symbol.

See Also:
Constant Field Values
Method Detail

getData

public Data[] getData()
Return a data directives.

Specified by:
getData in interface Resource
Returns:
the associated production data

getLibrary

public Library getLibrary()
Return the singleton library.

Specified by:
getLibrary in interface Resource
Returns:
the library

getName

public String getName()
Return the name of the resource.

Specified by:
getName in interface Resource
Returns:
the resource name

getVersion

public String getVersion()
Return the resource version.

Specified by:
getVersion in interface Resource
Returns:
the version

getStatutoryVersion

public String getStatutoryVersion()
Return the declard resource version.

Specified by:
getStatutoryVersion in interface Resource
Returns:
the statutory version

getDecimalVersion

public Version getDecimalVersion()
Return the decimal version.

Specified by:
getDecimalVersion in interface Resource
Returns:
the version

getResourcePath

public String getResourcePath()
Return the fully qualified path to the resource.

Specified by:
getResourcePath in interface Resource
Returns:
the path

getBaseDir

public File getBaseDir()
Return the basedir for this resource.

Specified by:
getBaseDir in interface Resource
Returns:
the base directory (possibly null)

getClassifier

public ResourceDirective.Classifier getClassifier()
Return the resource classifier.

Specified by:
getClassifier in interface Resource
Returns:
the classifier (LOCAL, EXTERNAL or ANONYMOUS)

getInfo

public Info getInfo()
Return the info block.

Specified by:
getInfo in interface Resource
Returns:
the info block

getTypes

public Type[] getTypes()
Return the expanded array of types associated with the resource. The returned array is a function of the types declared by a resource expanded relative to any types implied by processor dependencies.

Specified by:
getTypes in interface Resource
Returns:
the type array

isa

public boolean isa(String type)
Test if this resource is associated with a type of the supplied name.

Specified by:
isa in interface Resource
Parameters:
type - the type id
Returns:
TRUE if this resource produces an artifact of the supplied type

getType

public Type getType(String id)
             throws IllegalArgumentException
Return a resource type relative to a supplied type id.

Specified by:
getType in interface Resource
Parameters:
id - the type name to retrieve
Returns:
the type instance
Throws:
IllegalArgumentException - if the id value does not match a type produced by the resource.

getLinkArtifact

public Artifact getLinkArtifact(String id)
Construct an link artifact for the supplied type.

Specified by:
getLinkArtifact in interface Resource
Parameters:
id - the resource type id
Returns:
the link artifact

getArtifact

public Artifact getArtifact(String id)
Construct an artifact for the supplied type.

Specified by:
getArtifact in interface Resource
Parameters:
id - the resource type identifier
Returns:
the artifact

getParent

public Module getParent()
Return the enclosing parent module.

Specified by:
getParent in interface Resource
Returns:
the enclosing module of null if this a top-level module.

getFilters

public Filter[] getFilters()
Return an array of filters associated with the resource.

Specified by:
getFilters in interface Resource
Returns:
the array of filters

toURI

public URI toURI(String ref)
          throws URISyntaxException
Utility function supporting resolution of uris containing 'resource' or 'alias' schemes. If the supplied uri schem is 'resource' or 'alias' the reference is resolved to a artifact type, group and name from which a resource is resolved and the uri returned. If the scheme is resource the usri of the resource is returned. If the scheme is 'alias' a linkn alias is returned. If the scheme is not 'resource' or 'alias' the argument will be evaluated as a normal transit artifact uri specification.

Specified by:
toURI in interface Resolver
Parameters:
ref - the uri argument
Returns:
the uri value
Throws:
URISyntaxException - if an error occurs during uri creation

getProviders

public Resource[] getProviders(Scope scope,
                               boolean expand,
                               boolean sort)
Return an array of resource that are providers to this resource.

Specified by:
getProviders in interface Resource
Parameters:
scope - the operational scope
expand - if true include transitive dependencies
sort - if true the array will sorted relative to dependencies
Returns:
the resource providers

getAggregatedProviders

public Resource[] getAggregatedProviders(Scope scope,
                                         boolean expand,
                                         boolean sort)
Return an array of resource that are providers to this resource. If the supplied scope is BUILD the returned resource array is equivalent getProviders( Scope.BUILD, .. ). If the scope is RUNTIME the returned resource array includes BUILD and RUNTIME resources. If the scope is TEST the returned array includes BUILD, RUNTIME and TEST resources.

Specified by:
getAggregatedProviders in interface Resource
Parameters:
scope - the scope of aggregation to be applied to the selection
expand - if TRUE include transitive dependencies
sort - if true the array will sorted relative to dependencies
Returns:
the resource providers

getClasspathProviders

public Resource[] getClasspathProviders(Scope scope)
Return a sorted and filtered array of providers. Resources not declaring the "jar" type as a produced type are excluded from selection. The resource array will include transitive dependencies. The method is suitable for the construction of build and test phase classloaders.

Specified by:
getClasspathProviders in interface Resource
Parameters:
scope - the aggregation scope
Returns:
the scoped resource chain

getClasspathProviders

public Resource[] getClasspathProviders(Category category)
Return an array of runtime providers filtered relative to a supplied classloading category. Resources not declaring the "jar" type as a produced type are excluded from selection. The resource array returned from this operation is a sorted transitive sequence excluding all resource references by any category higher than the supplied category. This method is typically used to construct information suitable for the gerneration of plugin metadata.

Specified by:
getClasspathProviders in interface Resource
Parameters:
category - the classloader category
Returns:
the category scoped resource chain

getConsumers

public Resource[] getConsumers(boolean expand,
                               boolean sort)
Return an array of resources that are consumers of this resource.

Specified by:
getConsumers in interface Resource
Parameters:
expand - if true the returned array includes consumers associated through transitive dependency relationships, otherwise the array is limited to direct consumers
sort - if true the array is sorted relative to depenency relationships
Returns:
the array of consumer projects

getResourceDirective

public ResourceDirective getResourceDirective()
Return the underlying resource defintion.

Returns:
the resource directive

getLayoutPath

public String getLayoutPath(String id)
Return a filename using the layout strategy employed by the cache.

Specified by:
getLayoutPath in interface Resource
Parameters:
id - the artifact type
Returns:
the filename

toString

public String toString()
Return a string representation of the resource in the form 'resource:[path]'.

Returns:
the string value

compareTo

public int compareTo(Object other)
Compare this object with another.

Specified by:
compareTo in interface Comparable
Parameters:
other - the other object
Returns:
the comparitive index

getTimestamp

public static String getTimestamp()
Return the UTC YYMMDD.HHMMSSS signature of a date.

Returns:
the UTC date-stamp signature

getTimestamp

public static String getTimestamp(Date date)
Return the UTC YYMMDD.HHMMSSS signature of a date.

Parameters:
date - the date
Returns:
the UTC date-stamp signature