org.netbeans.modules.project.libraries/1 1.29.1

org.netbeans.api.project.libraries
Class LibraryManager

java.lang.Object
  extended by org.netbeans.api.project.libraries.LibraryManager

public final class LibraryManager
extends Object

LibraryManager provides registry of the installed libraries. LibraryManager can be used to list all installed libraries or to query library by its system name.


Field Summary
static String PROP_LIBRARIES
          Property fired when the set of libraries changes.
static String PROP_OPEN_LIBRARY_MANAGERS
          Property fired when list of open library managers changes.
 
Method Summary
 void addLibrary(Library library)
          Deprecated. Use createLibrary(java.lang.String, java.lang.String, java.util.Map>) instead, as this properly supports local managers.
static void addOpenManagersPropertyChangeListener(PropertyChangeListener listener)
          Adds PropertyChangeListener on list of open library managers.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds PropertyChangeListener.
 Library createLibrary(String type, String name, Map<String,List<URL>> contents)
          Creates a new library definition and adds it to the list.
 Library createURILibrary(String type, String name, Map<String,List<URI>> contents)
          Creates a new library definition and adds it to the list.
static LibraryManager forLocation(URL location)
          Gets a library manager which loads library definitions from a particular location.
static LibraryManager getDefault()
          Get the default instance of the library manager.
 String getDisplayName()
          Gets a human-readable description of this manager.
 Library[] getLibraries()
          Lists all libraries defined in this manager.
 Library getLibrary(String name)
          Returns library by its name.
 URL getLocation()
          Gets the location associated with this manager.
static Collection<LibraryManager> getOpenManagers()
          Gets an unspecified collection of managers which are somehow to be represented as open.
 void removeLibrary(Library library)
          Removes installed library
static void removeOpenManagersPropertyChangeListener(PropertyChangeListener listener)
          Removes PropertyChangeListener
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes PropertyChangeListener
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_LIBRARIES

public static final String PROP_LIBRARIES
Property fired when the set of libraries changes.

See Also:
Constant Field Values

PROP_OPEN_LIBRARY_MANAGERS

public static final String PROP_OPEN_LIBRARY_MANAGERS
Property fired when list of open library managers changes.

See Also:
Constant Field Values
Method Detail

getDisplayName

public String getDisplayName()
Gets a human-readable description of this manager. This may be used to visually differentiate the global manager from various local managers.

Returns:
a localized display name
Since:
org.netbeans.modules.project.libraries/1 1.15
See Also:
LibraryStorageArea.getDisplayName()

getLocation

public URL getLocation()
Gets the location associated with this manager.

Returns:
a location where library definitions are kept, or null in the case of getDefault()
Since:
org.netbeans.modules.project.libraries/1 1.15
See Also:
LibraryStorageArea.getLocation(), forLocation(java.net.URL)

getLibrary

public Library getLibrary(String name)
Returns library by its name.

Parameters:
name - of the library, must not be null
Returns:
library or null if the library is not found

getLibraries

public Library[] getLibraries()
Lists all libraries defined in this manager.

Returns:
library definitions (never null)

addLibrary

@Deprecated
public void addLibrary(Library library)
                throws IOException,
                       IllegalArgumentException
Deprecated. Use createLibrary(java.lang.String, java.lang.String, java.util.Map>) instead, as this properly supports local managers.

Installs a new library into the library manager.

A typical usage would be:

LibraryManager libraryManager = LibraryManager.getDefault(); LibraryImplementation libImpl = LibrariesSupport.getLibraryTypeProvider("j2se").createLibrary(); libImpl.setName("FooLibTest"); libImpl.setContent ("classpath",listOfResources); libraryManager.addLibrary(LibraryFactory.createLibrary(libImpl));

Parameters:
library - to be installed, the library has to be created with registered LibraryTypeProvider.
Throws:
IOException - when the library cannot be stored
IllegalArgumentException - if the library is not recognized by any LibraryTypeProvider or the library of the same name already exists, or if this manager is not getDefault().
Since:
org.netbeans.modules.project.libraries/1 1.14

createLibrary

public Library createLibrary(String type,
                             String name,
                             Map<String,List<URL>> contents)
                      throws IOException
Creates a new library definition and adds it to the list.

Parameters:
type - the type of library, as in LibraryTypeProvider.getLibraryType() or LibraryImplementation.getType()
name - the identifying name of the new library (must not duplicate a name already in use by a library in this manager)
contents - the initial contents of the library's volumes, as a map from volume type to volume content
Returns:
a newly created library
Throws:
IOException - if the new definition could not be stored
IllegalArgumentException - if the library type or one of the content volume types is not supported, or if a library of the same name already exists in this manager
Since:
org.netbeans.modules.project.libraries/1 1.15
See Also:
ArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map>)

createURILibrary

public Library createURILibrary(String type,
                                String name,
                                Map<String,List<URI>> contents)
                         throws IOException
Creates a new library definition and adds it to the list.

Parameters:
type - the type of library, as in LibraryTypeProvider.getLibraryType() or LibraryImplementation.getType()
name - the identifying name of the new library (must not duplicate a name already in use by a library in this manager)
contents - the initial contents of the library's volumes, as a map from volume type to volume content
Returns:
a newly created library
Throws:
IOException - if the new definition could not be stored
IllegalArgumentException - if the library type or one of the content volume types is not supported, or if a library of the same name already exists in this manager
Since:
org.netbeans.modules.project.libraries/1 1.18
See Also:
ArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map>)

removeLibrary

public void removeLibrary(Library library)
                   throws IOException,
                          IllegalArgumentException
Removes installed library

Parameters:
library - to be removed.
Throws:
IOException - when library cannot be deleted.
IllegalArgumentException - when library is not installed in a writable LibraryProvider
Since:
org.netbeans.modules.project.libraries/1 1.14

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds PropertyChangeListener. The listener is notified when library is added or removed.

Parameters:
listener - to be notified

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes PropertyChangeListener

Parameters:
listener -

getDefault

public static LibraryManager getDefault()
Get the default instance of the library manager.

Returns:
the singleton instance

forLocation

public static LibraryManager forLocation(URL location)
                                  throws IllegalArgumentException
Gets a library manager which loads library definitions from a particular location. There is no guarantee that the return value is the same object from call to call with the same location.

Parameters:
location - any storage location supported by an installed provider
Returns:
a library manager whose getLocation() matches the supplied location
Throws:
IllegalArgumentException - if no installed provider is able to manage locations of this kind
Since:
org.netbeans.modules.project.libraries/1 1.15
See Also:
ArealLibraryProvider.loadArea(java.net.URL), ArealLibraryProvider.getLibraries(A)

getOpenManagers

public static Collection<LibraryManager> getOpenManagers()
Gets an unspecified collection of managers which are somehow to be represented as open. For example, library storages referred to from open projects might be returned. You can listen on changes in list of open managers via addOpenManagersPropertyChangeListener(java.beans.PropertyChangeListener). There is no guarantee that the non-default managers are the same objects from call to call even if the locations remain the same.

Returns:
a set of managers, always including at least getDefault()
Since:
org.netbeans.modules.project.libraries/1 1.15
See Also:
ArealLibraryProvider.getOpenAreas()

addOpenManagersPropertyChangeListener

public static void addOpenManagersPropertyChangeListener(PropertyChangeListener listener)
Adds PropertyChangeListener on list of open library managers. The listener is notified when list of open library managers changes via PROP_OPEN_LIBRARY_MANAGERS.

Parameters:
listener - to be notified

removeOpenManagersPropertyChangeListener

public static void removeOpenManagersPropertyChangeListener(PropertyChangeListener listener)
Removes PropertyChangeListener

Parameters:
listener -

toString

public String toString()
Overrides:
toString in class Object

org.netbeans.modules.project.libraries/1 1.29.1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.