gate.yam.depend
Class Dependencies

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

public class Dependencies
extends Object
implements Serializable

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

Author:
Angus Roberts
See Also:
Serialized Form

Constructor Summary
Dependencies()
           
 
Method Summary
static void clear()
          Clear out the current Dependencies.
 Set<String> created(File createdFile)
          A non-YamFile File has been "created" as far as the wiki is concerned if it has been uploaded.
 Set<String> 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<String> 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<String> 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(Long wikiID)
          Get Dependencies from a Long id.
static Dependencies get(String wikiID)
          Get the Dependencies instance for a wiki area.
 int hashCode()
          Returns the hash code value for this Dependencies.
 String includedByAsString()
          Create a String representation of the "includedBy" relationships in this Dependencies.
 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.
 String linksToAsString()
          Create a String representation of the "linksTo" relationships in this Dependencies.
 Set<String> 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.
 Set<String> 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<String> 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
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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dependencies

public Dependencies()
Method Detail

clear

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


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.

Parameters:
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.

Parameters:
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.

Parameters:
suffix - The suffix for serialized dependency files. The dependency file name is made up of the configured prefix, the wiki ID, and this suffix.

get

public static Dependencies get(String wikiID)
                        throws gate.persist.PersistenceException
Get the Dependencies instance for a wiki area. Lazily loads if serialized. Creates a new Dependencies if none exists for a wiki area.

Parameters:
wikiID - The identifier for the wiki area
Returns:
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)
                        throws gate.persist.PersistenceException
Get Dependencies from a Long id.

Throws:
gate.persist.PersistenceException

exists

public static boolean exists(String wikiID)
Do we have the Dependencies for a wiki, either loaded or serialized?

Parameters:
wikiID - The ID of the wiki to be checked for Dependencies
Returns:
true if Dependencies exist for wikiID

remove

public static void remove(String wikiID)
                   throws gate.persist.PersistenceException
Remove the Dependencies for a wiki area. Removes from current Dependencies, and any serialization.

Parameters:
wikiID - The id of the wiki area for which Dependecies will be removed.
Throws:
gate.persist.PersistenceException - If a serialized Dependencies could not be deleted.

serialize

public static void serialize()
                      throws gate.persist.PersistenceException
Serialize all Dependencies for every wiki to the serialization directory

Throws:
gate.persist.PersistenceException - when serialization gives a filesystem error.

serialize

public static void serialize(String wikiID)
                      throws gate.persist.PersistenceException
Serialize the Dependencies for a wiki to the serialization directory

Parameters:
wikiID - The ID of the wiki for which the Dependencies will be serialized
Throws:
gate.persist.PersistenceException - when serialization gives a filesystem error

isEmpty

public boolean isEmpty()
Does this Dependencies contain any information about links or includes?

Returns:
true if this Dependencies contains no information about links, and no information about includes

equals

public boolean equals(Object obj)
Are two Dependencies equal? They are if they contain the same links and inclusions between the same YamFiles.

Overrides:
equals in class Object
Parameters:
obj - the Object against which we test equality
Returns:
true if obj is equal to this Dependencies.

hashCode

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

Overrides:
hashCode in class Object
Returns:
The has code for this Dependencies

toString

public String toString()
String representation

Overrides:
toString in class Object

toSortedString

public String toSortedString()
Sorted string representation


modified

public Set<String> 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

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

created

public Set<String> 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.

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

created

public Set<String> 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.

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

deleted

public Set<String> 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.

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

deleted

public Set<String> 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.

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

renamed

public Set<String> 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.

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

renamed

public Set<String> 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.

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

linksToAsString

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

Returns:
The String representation of "linksTo"

includesAsString

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

Returns:
The String representation of "includes"

linkedByAsString

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

Returns:
The String representation of "linkedBy"

includedByAsString

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

Returns:
The String representation of "includedBy"