org.apache.avalon.repository.util
Class RepositoryUtils

java.lang.Object
  extended byorg.apache.avalon.repository.util.RepositoryUtils

public class RepositoryUtils
extends Object

Various static utility methods used throughout repository related programing interfaces.

Version:
$Revision: 1.3 $
Author:
Alex Karasulu, Stephen McConnell

Field Summary
static String META
          meta extension tag for meta-data containing artifacts
 
Constructor Summary
RepositoryUtils()
           
 
Method Summary
static URL convertToURL(String host)
          Convert a path to a url.
static URL[] convertToURLs(String[] hosts)
          Convert a set of host path statements to formal urls.
static Attributes getAsAttributes(Properties properties)
          Transforms a Properties into a Attributes using a simple enumeration convention for property names which appends a numeric enumeration name component to the dotted property key.
static Attributes getAttributes(File cache, Artifact artifact)
          Gets the Attribues from the cache.
static Attributes getAttributes(String[] repositories, Artifact artifact)
          Gets the Attribues in a remote artifact.
static String[] getCleanPaths(String[] hosts)
          For a given set of host paths, returns an equivalent set ensuring that the path ends with the "/" character.
static String[] getDelimited(char a_delim, String a_substrate)
           
static String getEnumeratedBase(String key)
          Gets the key base of an enumerated property using the multivalued property key naming convention.
static Properties getProperties(File cache, Artifact artifact)
          Gets the Properties in the local cache.
static Properties getProperties(String[] repositories, Artifact artifact)
          Gets the Properties in a remote properties file.
static Properties getProperties(URL url)
          Gets the Properties in a remote properties file.
static boolean isEnumerated(String key)
          Detects whether or not a property key is of the multivalued enumeration kind.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META

public static final String META
meta extension tag for meta-data containing artifacts

See Also:
Constant Field Values
Constructor Detail

RepositoryUtils

public RepositoryUtils()
Method Detail

getAsAttributes

public static Attributes getAsAttributes(Properties properties)
Transforms a Properties into a Attributes using a simple enumeration convention for property names which appends a numeric enumeration name component to the dotted property key. Note that changes to the Attributes object do not have any effect on the Properties object and vice versa. All values are copied.

Parameters:
properties - the properties to be transformed
Returns:
the Attributes representing the properties

getAttributes

public static Attributes getAttributes(String[] repositories,
                                       Artifact artifact)
                                throws RepositoryException
Gets the Attribues in a remote artifact.

Parameters:
repositories - the reprositories to search against
artifact - the artifact to load meta data from
Returns:
the meta data as attributes
Throws:
RepositoryException - if there is execution failure

getAttributes

public static Attributes getAttributes(File cache,
                                       Artifact artifact)
                                throws RepositoryException
Gets the Attribues from the cache.

Parameters:
cache - the reprository cache
artifact - the artifact to load meta data from
Returns:
the meta data as attributes
Throws:
RepositoryException - if there is execution failure

getProperties

public static Properties getProperties(File cache,
                                       Artifact artifact)
                                throws RepositoryException
Gets the Properties in the local cache.

Parameters:
cache - the local cache
artifact - the artifact to load meta data from
Returns:
the loaded properties
Throws:
RepositoryException - if there is any problem loading the properties

getProperties

public static Properties getProperties(String[] repositories,
                                       Artifact artifact)
                                throws RepositoryException
Gets the Properties in a remote properties file.

Parameters:
repositories - the reprositories to search against
artifact - the artifact to load meta data from
Returns:
the loaded properties
Throws:
RepositoryException - if there is any problem loading the properties

getProperties

public static Properties getProperties(URL url)
                                throws IOException
Gets the Properties in a remote properties file.

Parameters:
url - the url to the properties file
Returns:
the loaded properties for the file
Throws:
IOException - indicating a IO error during property loading

isEnumerated

public static boolean isEnumerated(String key)
Detects whether or not a property key is of the multivalued enumeration kind. A multivalued key simply enumerates values by appending a '.' and a number after the dot: i.e. artifact.dependency.2 and artifact.alias.23 et. cetera.

Parameters:
key - the property name or key
Returns:
true if the property conforms to the enumerated property convention, false otherwise

getEnumeratedBase

public static String getEnumeratedBase(String key)
Gets the key base of an enumerated property using the multivalued property key naming convention.

Parameters:
key - the enumerated key whose last name component is a number
Returns:
the base name of the enumerated property

getDelimited

public static String[] getDelimited(char a_delim,
                                    String a_substrate)

convertToURLs

public static URL[] convertToURLs(String[] hosts)
Convert a set of host path statements to formal urls.

Parameters:
hosts - the set of host names
Returns:
the equivalent URL array

convertToURL

public static URL convertToURL(String host)
                        throws IllegalArgumentException
Convert a path to a url.

Parameters:
host - the host address
Returns:
the equivalent url
Throws:
IllegalArgumentException - if the path cannot be converted to a url

getCleanPaths

public static String[] getCleanPaths(String[] hosts)
For a given set of host paths, returns an equivalent set ensuring that the path ends with the "/" character.

Parameters:
hosts - the set of host path names
Returns:
the equivalent host path names


Copyright © Apache Software Foundation. All Rights Reserved.