Qwylt

java.lang.module
Class ModuleSystem

java.lang.Object
  extended by java.lang.module.ModuleSystem

public abstract class ModuleSystem
extends java.lang.Object

This class represents a module system provider.

Since:
Feb 19, 2009
Author:
Bryan Atsatt

Constructor Summary
protected ModuleSystem()
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object other)
          Test if the specified object is equal to this instance.
static ModuleSystem getModuleSystem(ModuleInfo.Term... required)
          Returns the named module system.
static ModuleSystem getModuleSystem(java.util.Set<ModuleInfo.Term> required)
          Returns the named module system.
abstract  java.util.Set<ModuleInfo.Term> getModuleSystemIDs()
          Return the set of identifiers for this module system.
static java.util.List<ModuleSystem> getModuleSystems()
          Returns a list of the available module systems.
abstract  java.lang.String getQueryFormatDescription()
          Returns a description of the query format supported by parseQuery(java.lang.String).
static ModuleSystem getRoot()
          Returns the root ModuleSystem.
 int hashCode()
          Returns the hash code for this instance.
 ModuleRepository newRepository(java.lang.String name, java.io.File rootDirectory)
          Returns a new ModuleRepository for this ModuleSystem at the specified location and with a standard search policy.
abstract  ModuleRepository newRepository(java.lang.String name, java.io.File rootDirectory, SearchPolicy searchPolicy)
          Returns a new ModuleRepository for this ModuleSystem at the specified location and with the specified search policy.
abstract  ModuleQuery parseQuery(java.lang.String query)
          Parses the string argument as a ModuleQuery from a format supported by this ModuleSystem.
protected  ModuleQuery parseQuery(java.lang.String query, char versionSeparator)
          A default query parser.
abstract  Version parseVersion(java.lang.String version)
          Parses the string argument as a version number from a format supported by this ModuleSystem.
abstract  Matcher<Version> parseVersionExpression(java.lang.String versionExpression)
          Parses the string argument as a version expression from a format supported by this ModuleSystem.
abstract  ResourceSpace resolve(ModuleInfo moduleInfo)
          Build a ResourceSpace from the ModuleInfo to provide access to all imported resources.
 java.lang.String toString()
          Returns a string representation of this instance.
 void verify(ModuleArchive archive)
          Check that the specified ModuleInfo is valid.
abstract  void verify(ModuleInfo moduleInfo)
          Verify the contents of the specified ModuleInfo.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModuleSystem

protected ModuleSystem()
Constructor.

Method Detail

getRoot

public static ModuleSystem getRoot()
Returns the root ModuleSystem.

Returns:
The root ModuleSystem.

getModuleSystem

public static ModuleSystem getModuleSystem(java.util.Set<ModuleInfo.Term> required)
Returns the named module system.

Parameters:
required - The required module system terms. Each term must either exactly match one provided by a candidate module system or the names must match; exact match is checked first.
Returns:
The module system or null if not found.

getModuleSystem

public static ModuleSystem getModuleSystem(ModuleInfo.Term... required)
Returns the named module system.

Parameters:
required - The required module system terms. Each term must either exactly match one provided by a candidate module system or the names must match; exact match is checked first.
Returns:
The module system or null if not found.

getModuleSystems

public static java.util.List<ModuleSystem> getModuleSystems()
Returns a list of the available module systems.

Returns:
The available module systems.

getModuleSystemIDs

public abstract java.util.Set<ModuleInfo.Term> getModuleSystemIDs()
Return the set of identifiers for this module system.

Returns:
The identifiers.

verify

public abstract void verify(ModuleInfo moduleInfo)
                     throws java.lang.Exception
Verify the contents of the specified ModuleInfo.

Parameters:
moduleInfo - The ModuleInfo to check.
Throws:
java.lang.Exception - If not valid. // TODO define custom type or message format.

resolve

public abstract ResourceSpace resolve(ModuleInfo moduleInfo)
                               throws ConnectionError
Build a ResourceSpace from the ModuleInfo to provide access to all imported resources.

Parameters:
moduleInfo - The ModuleInfo to resolve.
Returns:
A ResourceSpace that provides access to all imported resources.
Throws:
ConnectionError - If resolution fails.

verify

public void verify(ModuleArchive archive)
Check that the specified ModuleInfo is valid. At minimum, this will ensure that all dependencies are satisfied.

Parameters:
archive - The ModuleArchive to check.
Throws:
ConnectionError - If not valid.

getQueryFormatDescription

public abstract java.lang.String getQueryFormatDescription()
Returns a description of the query format supported by parseQuery(java.lang.String).

Returns:
The description.

parseQuery

public abstract ModuleQuery parseQuery(java.lang.String query)
Parses the string argument as a ModuleQuery from a format supported by this ModuleSystem.

Parameters:
query - The query in a format supported by this ModuleSystem.
Returns:
The ModuleQuery.
Throws:
java.lang.IllegalArgumentException - If query format is invalid for this ModuleSystem.

parseVersion

public abstract Version parseVersion(java.lang.String version)
Parses the string argument as a version number from a format supported by this ModuleSystem.

Parameters:
version - The version in a format supported by this ModuleSystem.
Returns:
The Version instance.
Throws:
java.lang.IllegalArgumentException - If version format is invalid for this ModuleSystem.

parseVersionExpression

public abstract Matcher<Version> parseVersionExpression(java.lang.String versionExpression)
Parses the string argument as a version expression from a format supported by this ModuleSystem.

Parameters:
versionExpression - The version expression string in a format supported by this ModuleSystem.
Returns:
The matcher instance.
Throws:
java.lang.IllegalArgumentException - If versionExpression format is invalid for this ModuleSystem.

newRepository

public ModuleRepository newRepository(java.lang.String name,
                                      java.io.File rootDirectory)
                               throws java.io.IOException
Returns a new ModuleRepository for this ModuleSystem at the specified location and with a standard search policy.

Parameters:
name - The repository name.
rootDirectory - The repository location.
Returns:
The repository.
Throws:
java.io.IOException - If an I/O error occurs.

newRepository

public abstract ModuleRepository newRepository(java.lang.String name,
                                               java.io.File rootDirectory,
                                               SearchPolicy searchPolicy)
                                        throws java.io.IOException
Returns a new ModuleRepository for this ModuleSystem at the specified location and with the specified search policy.

Parameters:
name - The repository name.
rootDirectory - The repository location.
searchPolicy - The search policy.
Returns:
The repository.
Throws:
java.io.IOException - If an I/O error occurs.

equals

public boolean equals(java.lang.Object other)
Test if the specified object is equal to this instance.

Overrides:
equals in class java.lang.Object
Parameters:
other - The object to compare to.
Returns:
true if other is equivalent to this instance; otherwise, returns false.

hashCode

public int hashCode()
Returns the hash code for this instance.

Overrides:
hashCode in class java.lang.Object
Returns:
The identity hash code for this instance.

toString

public java.lang.String toString()
Returns a string representation of this instance.

Overrides:
toString in class java.lang.Object
Returns:
The string.

parseQuery

protected ModuleQuery parseQuery(java.lang.String query,
                                 char versionSeparator)
A default query parser.

Parameters:
query - The query string.
versionSeparator - The character that separates name and version in an identifier.
Returns:
The query.

Qwylt

Send comments or questions to Bryan Atsatt