Groovy Documentation

java.gate.yam.depend
Class Dependencies

java.lang.Object
  java.gate.yam.depend.Dependencies
All Implemented Interfaces:
Serializable

class Dependencies

Dependencies keeps track of the link and inclusion dependencies between YamFiles and other Files.

author:
Angus Roberts


Field Summary
private Map includedBy

A Map of a File path to a Set of all file paths that include it.

private Map includes

A Map of a File path to a Set of all file paths that it includes.

private Map linkedBy

A Map of a File path to a Set of all file paths that link to it.

private Map linksTo

A Map of a File path to a Set of all file paths that it links to.

private static Logger log

Logger

private static long serialVersionUID

UID for stable serialisation

private static File serializationDirectory

The directory to which Dependencies are serialized

private static String serializationFilePrefix

The prefix used for serialized dependency files.

private static String serializationFileSuffix

The suffix used for serialized dependency files.

private static Map wikiDependencies

A Map of wiki area identifiers to Dependencies instances.

 
Constructor Summary
Dependencies()

 
Method Summary
static void clear()

Clear out the current Dependencies.

Set created(File createdFile)

A non-YamFile File has been "created" as far as the wiki is concerned if it has been uploaded.

Set created(YamFile createdYam)

Given a created YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the created YamFile.

Set deleted(File deletedFile)

Given a deleted File, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the deleted File.

Set deleted(YamFile deletedYam)

Given a deleted YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the deleted YamFile.

boolean equals(Object obj)

Are two Dependencies equal?

static boolean exists(String wikiID)

Do we have the Dependencies for a wiki, either loaded or serialized?

static Dependencies get(String wikiID)

Get the Dependencies instance for a wiki area.

static Dependencies get(Long wikiID)

Get Dependencies from a Long id.

int hashCode()

Returns the hash code value for this Dependencies.

String includedByAsString()

Create a String representation of the "includedBy" relationships in this Dependencies.

private void includes(String includingYamPath, List includedPaths)

Update the Dependencies with the fact that a YamFile includes a list of files.

String includesAsString()

Create a String representation of the "includes" relationships in this Dependencies.

boolean isEmpty()

Does this Dependencies contain any information about links or includes?

String linkedByAsString()

Create a String representation of the "linkedBy" relationships in this Dependencies.

private void linksTo(String linkingYamPath, List linkedPaths)

Update the Dependencies with the fact that a YamFile links to a list of files.

String linksToAsString()

Create a String representation of the "linksTo" relationships in this Dependencies.

private void logEventMethodException(String method, String paramString)

Log an Exception caught by one of the event methods

private String mapToString(Map map)

Create a String representation of a links or includes Map.

Set modified(YamFile modifiedYam)

Given a modified YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the modified YamFile.

static void remove(String wikiID)

Remove the Dependencies for a wiki area.

private void removeIncludes(String includingYamPath)

Remove all information about includes from a given YamFile path.

private void removeLinks(String linkingYamPath)

Remove all information about links from a given YamFile path.

private void renameIncludes(String oldName, String newName)

Rename all keys and values in the includes record of this Dependencies, from an old File name to a new File name.

private void renameLinks(String oldName, String newName)

Rename all keys and values in the link record of this Dependencies, from an old File name to a new File name.

Set renamed(File oldFile, File newFile)

Given the old name and new name of a renamed File, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the renamed File.

Set renamed(YamFile oldYam, YamFile newYam)

Given the old name and new name of a renamed YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the renamed YamFile.

static void serialize()

Serialize all Dependencies for every wiki to the serialization directory

static void serialize(String wikiID)

Serialize the Dependencies for a wiki to the serialization directory serialized

static void setSerializationDirectory(File directory)

Set the directory to which Dependencies are serialized.

static void setSerializationFilePrefix(String prefix)

Set the prefix for serialized dependency file names.

static void setSerializationFileSuffix(String suffix)

Set the suffix for serialized dependency file names.

String toSortedString()

Sorted string representation

String toString()

String representation

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Field Detail

includedBy

private Map includedBy
A Map of a File path to a Set of all file paths that include it. Files are given by canonical paths. The key is "included by" its values. The key is the file that is included. This Map gives the inverse of the relation in the includes Map, and the contents of the two should be kept consistent. Both directions of the relation are recorded to make removal of old relations easier, and makes the calculation of transitive includes easier.


includes

private Map includes
A Map of a File path to a Set of all file paths that it includes. Files are given by canonical paths. The key "includes" its values. The key is the file that contains the include statement. This Map gives the inverse of the relation in the includedBy Map, and the contents of the two should be kept consistent.


linkedBy

private Map linkedBy
A Map of a File path to a Set of all file paths that link to it. Files are given by canonical paths. The key is "linked by" its values. The key is the file that is linked to. This Map gives the inverse of the relation in the linkedTo Map, and the contents of the two should be kept consistent. Both directions of the relation are recorded to make removal of old relations easier.


linksTo

private Map linksTo
A Map of a File path to a Set of all file paths that it links to. Files are given by canonical paths. The key "links to" its values. The key is the file that contains the link. This Map gives the inverse of the relation in the linkedBy Map, and the contents of the two should be kept consistent.


log

private static final Logger log
Logger


serialVersionUID

private static final long serialVersionUID
UID for stable serialisation


serializationDirectory

private static File serializationDirectory
The directory to which Dependencies are serialized


serializationFilePrefix

private static String serializationFilePrefix
The prefix used for serialized dependency files.


serializationFileSuffix

private static String serializationFileSuffix
The suffix used for serialized dependency files.


wikiDependencies

private static Map wikiDependencies
A Map of wiki area identifiers to Dependencies instances. Implemented with ConcurrenthashMap, and so is thread-safe. ConcurrenthashMap provides its own locking for updates. Construction uses the default concurrency factor (16), which should be ample for allowing multiple threads to update, without being so high as to impact on performance.


 
Constructor Detail

Dependencies

Dependencies()


 
Method Detail

clear

public static void clear()
Clear out the current Dependencies. Does not remove serialized Dependencies.


created

public Set created(File createdFile)

A non-YamFile File has been "created" as far as the wiki is concerned if it has been uploaded.

Given a created File, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the created File. If the created File has a canonical path that causes an IOException, then the files that need regenerating are not defined, and an empty Set is returned.

This method is synchronised internally.

param:
createdFile The File that has been created
return:
A Set of YamFiles that need regenerating as a result of the creation, empty if createdFile has an erroneous canonical path.


created

public Set created(YamFile createdYam)

Given a created YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the created YamFile. If the created YamFile has a canonical path that causes an Exception, then the files that need regenerating are not defined, and an empty Set is returned.

Updates this Dependencies' record of links and includes for YamFile, to take into account the creation.

This method is synchronised internally.

param:
createdYam The YamFile that has been created
return:
A Set of YamFiles that need regenerating as a result of the creation, empty if createdFile has an erroneous canonical path.


deleted

public Set deleted(File deletedFile)

Given a deleted File, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the deleted File. If the deleted File has a canonical path that causes an IOException, then the files that need regenerating are not defined, and an empty Set is returned.

This method is synchronised internally.

param:
deletedFile The File that has been deleted
return:
A Set of YamFiles that need regenerating as a result of the deletion, empty if deletedFile has an erroneous canonical path.


deleted

public Set deleted(YamFile deletedYam)

Given a deleted YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the deleted YamFile. If the deleted YamFile has a canonical path that causes an Exception, then the files that need regenerating are not defined, and an empty Set is returned.

Updates this Dependencies' record of links and includes for YamFile, to take into account the deletion.

This method is synchronised internally.

param:
deletedYam The YamFile that has been deleted
return:
A Set of YamFiles that need regenerating as a result of the deletion, empty if deletedFile has an erroneous canonical path.


equals

public boolean equals(Object obj)
Are two Dependencies equal? They are if they contain the same links and inclusions between the same YamFiles.
param:
obj the Object against which we test equality
return:
true if obj is equal to this Dependencies.


exists

public static boolean exists(String wikiID)
Do we have the Dependencies for a wiki, either loaded or serialized?
param:
wikiID The ID of the wiki to be checked for Dependencies
return:
true if Dependencies exist for wikiID


get

public static Dependencies get(String wikiID)
Get the Dependencies instance for a wiki area. Lazily loads if serialized. Creates a new Dependencies if none exists for a wiki area.
param:
wikiID The identifier for the wiki area
return:
The Dependencies for the wiki area, a new Dependencies if one did not previously exist, null if given a null wiki identifier.
throws:
gate.persist.PersistenceException If a Dependencies serialization file cannot be deserialized


get

public static Dependencies get(Long wikiID)
Get Dependencies from a Long id.


hashCode

public int hashCode()
Returns the hash code value for this Dependencies.
return:
The has code for this Dependencies


includedByAsString

public String includedByAsString()
Create a String representation of the "includedBy" relationships in this Dependencies. Intended for checking internal state when testing.
return:
The String representation of "includedBy"


includes

private void includes(String includingYamPath, List includedPaths)

Update the Dependencies with the fact that a YamFile includes a list of files. This list is taken to be all the includes from the YamFile. Any previously recorded includes for this YamFile are removed.

Transitivity of includes is taken into account internally: the client does not need to provide the transitive closure of includes.

Note that this method is not synchronized: it must be synchonized by calling methods.

param:
includingYamPath The canonical path of the YamFile that includes other files
param:
includedPaths A List of other File canonical paths that are included in includingYam


includesAsString

public String includesAsString()
Create a String representation of the "includes" relationships in this Dependencies. Intended for checking internal state when testing.
return:
The String representation of "includes"


isEmpty

public boolean isEmpty()
Does this Dependencies contain any information about links or includes?
return:
true if this Dependencies contains no information about links, and no information about includes


linkedByAsString

public String linkedByAsString()
Create a String representation of the "linkedBy" relationships in this Dependencies. Intended for checking internal state when testing.
return:
The String representation of "linkedBy"


linksTo

private void linksTo(String linkingYamPath, List linkedPaths)

Update the Dependencies with the fact that a YamFile links to a list of files. This list is taken to be all the links and the only links from the YamFile. Any previously recorded links for this YamFile are removed.

Because the end of a link does not affect the actual content of a linking file, transitivity of links is not considered, and therefore neither is circular linking.

Note that this method is not synchronized: it must be synchonized by calling methods.

param:
linkingYamPath The path of the YamFile that links to other Files
param:
linkedPaths A List of other File canonical paths that are linked to by linkingYam


linksToAsString

public String linksToAsString()
Create a String representation of the "linksTo" relationships in this Dependencies. Intended for checking internal state when testing.
return:
The String representation of "linksTo"


logEventMethodException

private void logEventMethodException(String method, String paramString)
Log an Exception caught by one of the event methods
param:
method The name of the method
param:
paramString String representation of the method parameters


mapToString

private String mapToString(Map map)
Create a String representation of a links or includes Map.
param:
map The links or includes Map for which a String will be created
return:
The String representaiton of map.


modified

public Set modified(YamFile modifiedYam)

Given a modified YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the modified YamFile. If the modified YamFile has a canonical path that causes an Exception, then the files that need regenerating are not defined, and an empty Set is returned.

Updates this Dependencies' record of links and includes for YamFile, to take into account the modification.

This method is synchronised internally.

Note that there is no equivalent modified(File) method for modifying a File that is not a YamFile, as they cannot be modified via the wiki

param:
modifiedYam The YamFile that has been modified
return:
A Set of YamFiles that need regenerating as a result of the modification, empty if modifiedFile has an erroneous canonical path.


remove

public static void remove(String wikiID)
Remove the Dependencies for a wiki area. Removes from current Dependencies, and any serialization.
param:
wikiID The id of the wiki area for which Dependecies will be removed.
throws:
PersistenceException If a serialized Dependencies could not be deleted.


removeIncludes

private void removeIncludes(String includingYamPath)

Remove all information about includes from a given YamFile path. I.e. remove all includes from that YamFile to others in the includes Map, and remove all inverse "includedBy" Map relations. Doesn't remove includes to the YamFile.

Note that this method is not synchronized: it must be synchonized by calling methods.

param:
includingYamPath The canonical path of a YamFile for which all includes originating in that file will be removed


removeLinks

private void removeLinks(String linkingYamPath)

Remove all information about links from a given YamFile path. I.e. remove all links from that YamFile to others in the linksTo Map, and remove all inverse "linkedBy" Map relations. Doesn't remove links to the YamFile.

Note that this method is not synchronized: it must be synchonized by calling methods.

param:
linkingYamPath The canonical path of a YamFile for which all links originating in that file will be removed


renameIncludes

private void renameIncludes(String oldName, String newName)

Rename all keys and values in the includes record of this Dependencies, from an old File name to a new File name.

Note that this method is not synchronized: it must be synchonized by calling methods.

param:
oldName The old name of the File
param:
newName The new name of the File


renameLinks

private void renameLinks(String oldName, String newName)

Rename all keys and values in the link record of this Dependencies, from an old File name to a new File name.

Note that this method is not synchronized: it must be synchonized by calling methods.

param:
oldName The old name of the File
param:
newName The new name of the File


renamed

public Set renamed(File oldFile, File newFile)

Given the old name and new name of a renamed File, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the renamed File. If the old or new File has a canonical path that causes an IOException, then the files that need regenerating are not defined, and an empty Set is returned.

Updates this Dependencies' record of links and includes for the File, to take into account the renaming.

This method is synchronised internally.

param:
oldFile The File that has been renamed
param:
newFile The new File
return:
A Set of YamFiles that need regenerating as a result of the renaming, empty if renamedFile has an erroneous canonical path.


renamed

public Set renamed(YamFile oldYam, YamFile newYam)

Given the old name and new name of a renamed YamFile, returns a Set of the canonical paths of those YamFiles that need regenerating, because they depend on the renamed YamFile. If the old or new YamFile has a canonical path that causes an Exception, then the files that need regenerating are not defined, and an empty Set is returned.

Updates this Dependencies' record of links and includes for YamFile, to take into account the renaming.

This method is synchronised internally.

param:
oldYam The YamFile that has been renamed
param:
newYam The new YamFile
return:
A Set of YamFiles that need regenerating as a result of the renaming, empty if renamedYam has an erroneous canonical path.


serialize

public static void serialize()
Serialize all Dependencies for every wiki to the serialization directory
throws:
PersistenceException when serialization gives a filesystem error.


serialize

public static void serialize(String wikiID)
Serialize the Dependencies for a wiki to the serialization directory
param:
wikiID The ID of the wiki for which the Dependencies will be serialized
throws:
PersistenceException when serialization gives a filesystem error


setSerializationDirectory

public static void setSerializationDirectory(File directory)
Set the directory to which Dependencies are serialized. This is not synchonised. It is expected that serializationDirectory will be set once by the wiki on start up, and that neither users nor administrators will change it while the wiki is running.
param:
directory The directory to which Dependencies are serialized


setSerializationFilePrefix

public static void setSerializationFilePrefix(String prefix)
Set the prefix for serialized dependency file names. This is not synchonised. It is expected that it will be set once by the wiki on start up, and that neither users nor administrators will change it while the wiki is running.
param:
prefix The prefix for serialized dependency files. The dependency file name is made up of this prefix, the wiki ID, and the configured suffix.


setSerializationFileSuffix

public static void setSerializationFileSuffix(String suffix)
Set the suffix for serialized dependency file names. This is not synchonised. It is expected that it will be set once by the wiki on start up, and that neither users nor administrators will change it while the wiki is running.
param:
suffix The suffix for serialized dependency files. The dependency file name is made up of the configured prefix, the wiki ID, and this suffix.


toSortedString

public String toSortedString()
Sorted string representation


toString

public String toString()
String representation


 

Groovy Documentation