de.hunsicker.jalopy.language
Class ClassRepository

java.lang.Object
  |
  +--de.hunsicker.jalopy.language.ClassRepository

public class ClassRepository
extends java.lang.Object

Stores type names for Java packages. This information is needed in order to be able to switch between single-type-import declarations and type-import-on-demand declarations.

This class is thread-safe.

Version:
$Revision: 1.3.2.2 $
Author:
Marco Hunsicker

Method Summary
static ClassRepositoryEntry createEntry(ClassRepositoryEntry.Info info)
          Creates a repository entry for the given repository info.
 ClassRepositoryEntry.Info get(java.io.File location)
          Returns the repository info for the given location.
 java.lang.String[] getContent()
          Returns the current contents of the repository.
 ClassRepositoryEntry.Info[] getInfo()
          Returns the repository info (info about all registered entries).
static ClassRepository getInstance()
          Returns the sole instance of this class.
 int getSize()
          Returns the current size of the repository.
 boolean isEmpty()
          Indicates whether the repository is currently empty.
 void load(java.io.File location)
          Loads the contents of the given location into memory.
 void loadAll(java.util.List locations)
          Loads the contents of the given locations into memory.
 ClassRepositoryEntry.Info loadInfo(java.io.File file)
          Loads the information from the given repository entry file.
 void unload(java.io.File location)
          Unloads the given file from memory.
 void unloadAll(java.util.List locations)
          Unloads the given locations from memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ClassRepository getInstance()
Returns the sole instance of this class.

Returns:
class instance.

getContent

public java.lang.String[] getContent()
Returns the current contents of the repository.

Returns:
active contents. The repository can be empty in which case an empty array will be returned. This method never returns null.

isEmpty

public boolean isEmpty()
Indicates whether the repository is currently empty.

Returns:
true if the repository is currently empty.

getInfo

public ClassRepositoryEntry.Info[] getInfo()
Returns the repository info (info about all registered entries).

Returns:
repository information.

getSize

public int getSize()
Returns the current size of the repository.

Returns:
the size of the repository.
Since:
1.0b7

createEntry

public static ClassRepositoryEntry createEntry(ClassRepositoryEntry.Info info)
                                        throws java.io.IOException
Creates a repository entry for the given repository info.

Parameters:
info - the information to create an entry upon.
Returns:
the generated repository entry. Returns null if the location info is no package root.
Throws:
java.io.IOException - if an I/O error occurred.
java.lang.IllegalArgumentException - if the location specified in the info object does not denote an existing file or directory.

get

public ClassRepositoryEntry.Info get(java.io.File location)
Returns the repository info for the given location.

Parameters:
location - location to return the repository info for.
Returns:
the corresponding repository info or null if no repository file for the given location exists (i.e. the given location was not registered yet).

load

public void load(java.io.File location)
          throws java.io.IOException
Loads the contents of the given location into memory.

If the given location is already registered, both persistent storage and memory will be updated. If the location denotes a Java archive (JAR) an update will only be performed if the archive actually changed.

Directories will always be updated as there is no easy way to detect changes in such a case. You should perform logic to avoid unnecessary loads in the Plug-in code.

If no entry exits for the location, a new entry will be generated and its contents loaded into memory.

Parameters:
location - location to add.
Throws:
java.io.IOException - if an I/O error occured.

loadAll

public void loadAll(java.util.List locations)
             throws java.io.IOException
Loads the contents of the given locations into memory.

Parameters:
locations - locations to add (of type <File>).
Throws:
java.io.IOException - if an I/O error occurred.

loadInfo

public ClassRepositoryEntry.Info loadInfo(java.io.File file)
                                   throws java.io.IOException
Loads the information from the given repository entry file.

Parameters:
file - the repository entry file.
Returns:
the entry info.
Throws:
java.io.IOException - if an I/O error occurred.

unload

public void unload(java.io.File location)
            throws java.io.IOException
Unloads the given file from memory. If the given location was not registered, the call we be safely ignored.

Parameters:
location - location to unload.
Throws:
java.io.IOException - if an I/O error occurred.
See Also:
ClassRepositoryEntry.Info.getLocation()

unloadAll

public void unloadAll(java.util.List locations)
               throws java.io.IOException
Unloads the given locations from memory. If one of the given locations was not registered, it will be ignored.

Parameters:
locations - locations to unload (of type <File>).
Throws:
java.io.IOException - if an I/O error occurred.
See Also:
ClassRepositoryEntry.Info.getLocation()


Copyright © 1997-2005 Jalopy. All Rights Reserved.