java.module
Class ModuleDefinition

java.lang.Object
  extended by java.module.ModuleDefinition

public abstract class ModuleDefinition
extends Object

This class represents the reified module definition in the module system.

Since:
1.7.0
Author:
Dave Bristor, Andreas Sterbenz, Stanley M. Ho
See Also:
ClassLoader, Repository, Version

Constructor Summary
protected ModuleDefinition()
          Constructor used by subclasses.
 
Method Summary
abstract  boolean allowShadowing()
          Returns whether this module was marked to allow shadowing.
 boolean equals(Object obj)
          Compares the specified object with this ModuleDefinition for equality.
 String getAttribute(String name)
          Returns the value corresponding to the specified attribute name that is associated with the module definition in the default locale.
abstract  String getAttribute(String name, Locale locale)
          Returns the value corresponding to the specified attribute name that is associated with the module definition in the specific locale.
abstract  Set<String> getAttributeNames()
          Returns an unmodifiable set of the names of the attributes associated with the module definition.
abstract  Set<String> getExportedClasses()
          Returns an unmodifiable set of the names of the classes that are exported by this module definition.
abstract  Set<String> getExportedResources()
          Returns an unmodifiable set of the path of the resources exported by this module definition.
abstract  List<ImportDependency> getImportDependencies()
          Returns an unmodifiable list of import dependency.
abstract  String getImportPolicyClassName()
          Returns the name of the import policy class of the module definiton.
abstract  String getMainClassName()
          Returns the name of the main class of the module definiton.
abstract  Set<String> getMemberClasses()
          Returns an unmodifiable set of the names of the classes that a member of this module definition.
abstract  ModuleDefinitionContent getModuleDefinitionContent()
          Returns a ModuleDefinitionContent instance which represents the content of this module definition.
 Module getModuleInstance()
          Returns a Module instance for the specified ModuleDefinition in the ModuleSystem.
abstract  String getName()
          Returns the name of the module definition.
abstract  Repository getRepository()
          Returns repository that is associated with the module definition.
abstract  VersionConstraint getResourceModuleConstraint()
          Returns the version constraint that the resource module must satisfy for it to be used by this module definition.
abstract  VersionConstraint getResourceTargetConstraint()
          Returns the version constraint that the target module must satisfy for it to use this module definition as resource module.
abstract  Version getVersion()
          Returns the version of the module definition.
 int hashCode()
          Returns a hash code for this ModuleDefinition.
 boolean isClassExported(String name)
          Check if the specified class is exported by this module definition.
 boolean isResourceExported(String path)
          Check if the specified resource is exported by this module definition.
 String toString()
          Returns a String object representing this ModuleDefinition.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModuleDefinition

protected ModuleDefinition()
Constructor used by subclasses.

Method Detail

getName

public abstract String getName()
Returns the name of the module definition.

Returns:
the name of the module definition.

getVersion

public abstract Version getVersion()
Returns the version of the module definition.

Returns:
the Version object.

getAttributeNames

public abstract Set<String> getAttributeNames()
Returns an unmodifiable set of the names of the attributes associated with the module definition.

Returns:
an unmodifiable set of the names of the attributes.

getAttribute

public final String getAttribute(String name)
Returns the value corresponding to the specified attribute name that is associated with the module definition in the default locale. If the module definition has attributes with duplicate names, the value of the attribute in the last occurrence is returned.

Parameters:
name - the name of the attribute.
Returns:
the value of the attribute in the default locale. Returns null if the specified attribute name is not found.

getAttribute

public abstract String getAttribute(String name,
                                    Locale locale)
Returns the value corresponding to the specified attribute name that is associated with the module definition in the specific locale. If the module definition has attributes with duplicate names, the value of the attribute in the last occurrence is returned.

Parameters:
name - the name of the attribute.
locale - the locale of the attribute.
Returns:
the value of the attribute in a specific locale. Returns null if the attribute name is not found.

getImportDependencies

public abstract List<ImportDependency> getImportDependencies()
Returns an unmodifiable list of import dependency. The order of the import dependency in the list follows the declared import order in the module definition.

Returns:
an unmodifiable list of import dependency.

getMainClassName

public abstract String getMainClassName()
Returns the name of the main class of the module definiton.

Returns:
the class name if module definition has a main class. Otherwise, return null.

getImportPolicyClassName

public abstract String getImportPolicyClassName()
Returns the name of the import policy class of the module definiton.

Returns:
the class name if module definition has a import policy class. Otherwise, return null.

getRepository

public abstract Repository getRepository()
Returns repository that is associated with the module definition.

Returns:
the Repository object.

getMemberClasses

public abstract Set<String> getMemberClasses()
Returns an unmodifiable set of the names of the classes that a member of this module definition.

Returns:
The unmodifiable set of the names of the member classes.

getExportedClasses

public abstract Set<String> getExportedClasses()
Returns an unmodifiable set of the names of the classes that are exported by this module definition. This is a subset of the classes returned by getMemberClasses().

Returns:
The unmodifiable set of the names of the exported classes.

isClassExported

public boolean isClassExported(String name)
Check if the specified class is exported by this module definition.

Parameters:
name - the name of the class.
Returns:
true if the class is exported.

getExportedResources

public abstract Set<String> getExportedResources()
Returns an unmodifiable set of the path of the resources exported by this module definition.

Resources are specified as '/' separated paths, with no leading '/'.

Returns:
The unmodifiable set of the path of the exported resources.

isResourceExported

public final boolean isResourceExported(String path)
Check if the specified resource is exported by this module definition.

Parameters:
path - A '/' delimited path (e.g. x/y/Z.class")
Returns:
true if the resource in the path is exported.

getModuleInstance

public final Module getModuleInstance()
                               throws ModuleInitializationException
Returns a Module instance for the specified ModuleDefinition in the ModuleSystem. The module is initialized and ready to use. Equivalent to:
      getRepository().getModuleSystem().getModule(this);
 

Returns:
a Module instance of the ModuleDefinition.
Throws:
ModuleInitializationException - if the module instance cannot be initialized.
IllegalStateException - if the specified module definition has already been disabled.

getResourceModuleConstraint

public abstract VersionConstraint getResourceModuleConstraint()
Returns the version constraint that the resource module must satisfy for it to be used by this module definition.

Returns:
the version constraint that the resource module must satisfy.

getResourceTargetConstraint

public abstract VersionConstraint getResourceTargetConstraint()
Returns the version constraint that the target module must satisfy for it to use this module definition as resource module.

Returns:
the version constraint that the target module must satisfy.

allowShadowing

public abstract boolean allowShadowing()
Returns whether this module was marked to allow shadowing.

Returns:
whether this module was marked to allow shadowing.

getModuleDefinitionContent

public abstract ModuleDefinitionContent getModuleDefinitionContent()
Returns a ModuleDefinitionContent instance which represents the content of this module definition.

If a security manager is present, this method calls the security manager's checkPermission method with a ModuleSystemPermission("accessModuleDefinitionContent") permission to ensure it's ok to access the content of this module definition.

Returns:
the ModuleDefinitionContent instance.
Throws:
SecurityException - if a security manager exists and its checkPermission method denies access to the content of this module definition.

equals

public final boolean equals(Object obj)
Compares the specified object with this ModuleDefinition for equality. Returns true if and only if obj is the same object as this object.

Overrides:
equals in class Object
Parameters:
obj - the object to be compared for equality with this module definition.
Returns:
true if the specified object is equal to this module definition

hashCode

public final int hashCode()
Returns a hash code for this ModuleDefinition.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

toString

public String toString()
Returns a String object representing this ModuleDefinition.

Overrides:
toString in class Object
Returns:
a string representation of the ModuleDefinition object.