com.borland.jbuilder.paths
Class PathSet

java.lang.Object
  |
  +--com.borland.jbuilder.paths.PathSet
Direct Known Subclasses:
AppServer, JDKPathSet

public class PathSet
extends java.lang.Object

A PathSet represents a collection of Java paths and is typically used to define a library for use by a JBuilder project. In addition to the definition of class, source, and documentation paths, a library may also list a number of additional libraries that it needs path entries from to function correctly.

Each path has a total of three accessor methods, combining the typical getter and setter with a "full" getter that incorporates all of the path entries from other libraries required by this library.

Two specialized subclasses of PathSet, JDKPathSet and ProjectPathSet, provide additional characteristics for defining JDKs and projects, respectively.


Field Summary
protected  PathSetCollection collection
           
static PathSet[] EMPTY_ARRAY
           
protected  boolean hasChanged
          This value tracks if changes have been made to this PathSet since it was last loaded or saved
protected  long lastFullUpdate
          This value indicates the last change that has been incorporated into the "full path" caches and resolved libraries
protected  long lastModified
          This value indicates the last change that has been made to this PathSet
protected  java.lang.String[] requiredNames
           
 
Constructor Summary
PathSet(java.lang.String name)
          Creates a new library PathSet.
 
Method Summary
 int addEntries(Url url)
          Recursively scans the specified directory for valid doc, source, and class paths.
protected  void addUniquePath(java.util.List list, Url url)
          Adds a path to a list of paths if and only if it is not already a member of the list.
protected  Url[] addUniquePath(Url[] oldPath, Url url)
          Adds a path to an array of paths if and only if it is not already a member of the array.
protected  void addUniquePaths(java.util.List list, Url[] urls)
          Adds several paths to a list, skipping paths that are already members of the list.
protected  void addUniquePathsIfEnabled(java.util.List list, Url[] urls)
          Adds several paths to a list, skipping paths that are already members of the list or are disabled in this SKU
protected  void buildFullPaths(java.util.List priorPathSets, java.util.List classPathList, java.util.List sourcePathList, java.util.List docPathList)
          Adds missing elements from the local path set to the full path list, then invokes buildFullPaths(List, List, List) on each required path set in turn.
 void delete()
          Removes this PathSet from disk and from its collection
 Url[] getClassPath()
          Returns the PathSet's current set of class path entries.
 PathSetCollection getCollection()
          Returns the PathSet's collection
 Url[] getDocPath()
          Returns the PathSet's current set of documentation path entries.
 Url[] getFullClassPath()
          Retreives the combined class path of this path set and all required path sets.
 Url[] getFullDocPath()
          Retreives the combined doc path of this path set and all required path sets.
 Url[] getFullSourcePath()
          Retreives the combined source path of this path set and all required path sets.
 long getLastModified()
          Reports the time that the last change was made directly to this PathSet.
 java.lang.String getName()
          Returns the current name for a PathSet.
protected static java.lang.String getNames(java.util.ArrayList pathSetList)
           
protected static java.lang.String getNames(PathSet[] pathSets)
           
 PathSet[] getRequired()
          Get the required path sets, after resolving the required names.
 java.lang.String[] getRequiredNames()
          Get the names of required path sets.
protected  PathSetResolver getResolver()
          Returns the PathSet's resolver
 Url[] getSourcePath()
          Returns the PathSet's current set of source path entries.
 Url getUrl()
          Returns the PathSet's storage Url
 boolean isEmpty()
          Is this PathSet empty? By definition it is empty if all the simple paths are empty.
 boolean isEnabled()
          Is this PathSet enabled? By definition it is enabled if all the entries on the class path are enabled
 boolean isReadOnly()
          Tests if this PathSet is read-only.
static PathSet load(Url url, PathSetCollection collection)
          Load a PathSet from disk.
protected  java.lang.String[] parseLibraries(java.lang.String required)
           
protected  void resolveRequired()
           
 void save()
          Saves this PathSet to disk.
 void setClassPath(Url[] classPath)
          Changes the PathSet's current set of class path entries.
 void setCollection(PathSetCollection collection)
          Sets the PathSet's collection
 void setDocPath(Url[] docPath)
          Changes the PathSet's current set of documentation path entries.
 void setName(java.lang.String name)
          Changes this PathSet's name.
 void setRequired(PathSet[] required)
          Deprecated. use setRequired(String[] required) instead
 void setRequired(java.lang.String required)
          Set the required path sets.
 void setRequired(java.lang.String[] required)
          Set the required path sets.
 void setSourcePath(Url[] sourcePath)
          Changes the PathSet's current set of source path entries.
 void setUrl(Url storagePath)
          Sets the PathSet's storage Url
protected  void updateFullPaths()
          Updates the cached representation of a set of 'full paths' by constructing temporary lists, populating them using buildFullPaths(List, List, List) and then converting them into the requisite cached arrays.
protected  void updateLastModified()
          Records a new last modified date for this path set and updates the global last updated time so that other path sets can rebuild their "full path" cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final PathSet[] EMPTY_ARRAY

collection

protected PathSetCollection collection

requiredNames

protected java.lang.String[] requiredNames

lastModified

protected long lastModified
This value indicates the last change that has been made to this PathSet

lastFullUpdate

protected long lastFullUpdate
This value indicates the last change that has been incorporated into the "full path" caches and resolved libraries

hasChanged

protected boolean hasChanged
This value tracks if changes have been made to this PathSet since it was last loaded or saved
Constructor Detail

PathSet

public PathSet(java.lang.String name)
Creates a new library PathSet.
Parameters:
name - The initial name for the PathSet. This value may not be null.
Method Detail

getName

public java.lang.String getName()
Returns the current name for a PathSet.
Returns:
The pathset's current name.

setName

public void setName(java.lang.String name)
Changes this PathSet's name.
Parameters:
name - A new name for the PathSet. This value may not be null.

updateLastModified

protected void updateLastModified()

Records a new last modified date for this path set and updates the global last updated time so that other path sets can rebuild their "full path" cache.

Any method that modifies the state of the PathSet should invoke this method as a side-effect.


getLastModified

public long getLastModified()
Reports the time that the last change was made directly to this PathSet. Note that the "full paths" of a PathSet may be changed indirectly by changes to other path sets. To find out when the full path may have been impacted use the static method PathSetManager.getLastModified().
Returns:
A millisecond timestamp.

setUrl

public void setUrl(Url storagePath)
Sets the PathSet's storage Url
Parameters:
storageUrl - A Url of a library file. This value may not be null

getUrl

public Url getUrl()
Returns the PathSet's storage Url
Returns:
An Url of a library file

isReadOnly

public boolean isReadOnly()
Tests if this PathSet is read-only.
Returns:
False if the PathSet can be written to disk, true if it cannot.

setCollection

public void setCollection(PathSetCollection collection)
Sets the PathSet's collection
Parameters:
collection - The PathSetCollection that this is part of.

getCollection

public PathSetCollection getCollection()
Returns the PathSet's collection
Returns:
A PathSetCollection which contains this PathSet

getResolver

protected PathSetResolver getResolver()
Returns the PathSet's resolver
Returns:
resolver The PathSetResolver used to look up libraries

getClassPath

public Url[] getClassPath()
Returns the PathSet's current set of class path entries.
Returns:
An array of class path entries.

getSourcePath

public Url[] getSourcePath()
Returns the PathSet's current set of source path entries.
Returns:
An array of source path entries.

getDocPath

public Url[] getDocPath()
Returns the PathSet's current set of documentation path entries.
Returns:
An array of documentation path entries.

setClassPath

public void setClassPath(Url[] classPath)
Changes the PathSet's current set of class path entries.
Parameters:
classPath - An array of class path entries.

setSourcePath

public void setSourcePath(Url[] sourcePath)
Changes the PathSet's current set of source path entries.
Parameters:
sourcePath - An array of source path entries.

setDocPath

public void setDocPath(Url[] docPath)
Changes the PathSet's current set of documentation path entries.
Parameters:
docPath - An array of documentation path entries.

resolveRequired

protected void resolveRequired()

getRequired

public PathSet[] getRequired()
Get the required path sets, after resolving the required names.

getRequiredNames

public java.lang.String[] getRequiredNames()
Get the names of required path sets.

setRequired

public void setRequired(java.lang.String[] required)
Set the required path sets.

setRequired

public void setRequired(java.lang.String required)
Set the required path sets.

setRequired

public void setRequired(PathSet[] required)
Deprecated. use setRequired(String[] required) instead

Set the required path sets.

isEmpty

public boolean isEmpty()
Is this PathSet empty? By definition it is empty if all the simple paths are empty.

isEnabled

public boolean isEnabled()
Is this PathSet enabled? By definition it is enabled if all the entries on the class path are enabled

addEntries

public int addEntries(Url url)
Recursively scans the specified directory for valid doc, source, and class paths. Each matching specimen is automatically added to the PathSet under construction.
Parameters:
url - The directory or JAR to scan.
Returns:
The number of ancestor directories to back up before continuing the search. A value of zero means don't back up at all, a value of one means to stop searching the current directory, two means to stop searching the parent directory, etc.

updateFullPaths

protected void updateFullPaths()
Updates the cached representation of a set of 'full paths' by constructing temporary lists, populating them using buildFullPaths(List, List, List) and then converting them into the requisite cached arrays.

buildFullPaths

protected void buildFullPaths(java.util.List priorPathSets,
                              java.util.List classPathList,
                              java.util.List sourcePathList,
                              java.util.List docPathList)
Adds missing elements from the local path set to the full path list, then invokes buildFullPaths(List, List, List) on each required path set in turn.

addUniquePath

protected void addUniquePath(java.util.List list,
                             Url url)
Adds a path to a list of paths if and only if it is not already a member of the list.

addUniquePath

protected Url[] addUniquePath(Url[] oldPath,
                              Url url)
Adds a path to an array of paths if and only if it is not already a member of the array.

addUniquePaths

protected void addUniquePaths(java.util.List list,
                              Url[] urls)
Adds several paths to a list, skipping paths that are already members of the list.

addUniquePathsIfEnabled

protected void addUniquePathsIfEnabled(java.util.List list,
                                       Url[] urls)
Adds several paths to a list, skipping paths that are already members of the list or are disabled in this SKU

getFullClassPath

public Url[] getFullClassPath()
Retreives the combined class path of this path set and all required path sets.

getFullSourcePath

public Url[] getFullSourcePath()
Retreives the combined source path of this path set and all required path sets.

getFullDocPath

public Url[] getFullDocPath()
Retreives the combined doc path of this path set and all required path sets.

getNames

protected static java.lang.String getNames(PathSet[] pathSets)

getNames

protected static java.lang.String getNames(java.util.ArrayList pathSetList)

parseLibraries

protected java.lang.String[] parseLibraries(java.lang.String required)

save

public void save()
Saves this PathSet to disk. No actual disk access is performed if no changes have been made since the last save or the initial load.

load

public static PathSet load(Url url,
                           PathSetCollection collection)
Load a PathSet from disk.
Parameters:
url - The storage location of the JDK or library definition
collection - The PathSetCollection that the PathSet belongs to

delete

public void delete()
Removes this PathSet from disk and from its collection