public final class LibraryManager extends Object
| Modifier and Type | Field and Description |
|---|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLibrary(Library library)
Deprecated.
Use
LibraryManager.createLibrary(java.lang.String, java.lang.String, java.util.Map<java.lang.String, java.util.List<java.net.URL>>) 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 |
createLibrary(String type,
String name,
String displayName,
String description,
Map<String,List<URL>> contents)
Creates a new library definition and adds it to the list.
|
Library |
createLibrary(String type,
String name,
String displayName,
String description,
Map<String,List<URL>> contents,
Map<String,String> properties)
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.
|
Library |
createURILibrary(String type,
String name,
String displayName,
String description,
Map<String,List<URI>> contents)
Creates a new library definition and adds it to the list.
|
Library |
createURILibrary(String type,
String name,
String displayName,
String description,
Map<String,List<URI>> contents,
Map<String,String> properties)
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() |
public static final String PROP_LIBRARIES
public static final String PROP_OPEN_LIBRARY_MANAGERS
public String getDisplayName()
LibraryStorageArea.getDisplayName()public URL getLocation()
LibraryManager.getDefault()LibraryStorageArea.getLocation(),
LibraryManager.forLocation(java.net.URL)public Library getLibrary(String name)
name - of the library, must not be nullpublic Library[] getLibraries()
null)@Deprecated public void addLibrary(Library library) throws IOException, IllegalArgumentException
LibraryManager.createLibrary(java.lang.String, java.lang.String, java.util.Map<java.lang.String, java.util.List<java.net.URL>>) instead, as this properly supports local managers.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));library - to be installed, the library has to be created
with registered LibraryTypeProvider.IOException - when the library cannot be storedIllegalArgumentException - if the library is not recognized by any
LibraryTypeProvider or the library
of the same name already exists, or if this manager is not LibraryManager.getDefault().public Library createLibrary(String type, String name, Map<String,List<URL>> contents) throws IOException
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 contentIOException - if the new definition could not be storedIllegalArgumentException - 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 managerArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map<java.lang.String, java.util.List<java.net.URI>>)public Library createLibrary(@NonNull String type, @NonNull String name, @NullAllowed String displayName, @NullAllowed String description, @NonNull Map<String,List<URL>> contents) throws IOException
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)displayName - the display name of the library. If null the identifying name is useddescription - the library descriptioncontents - the initial contents of the library's volumes, as a map from volume type to volume contentIOException - if the new definition could not be storedIllegalArgumentException - 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 managerArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map<java.lang.String, java.util.List<java.net.URI>>)public Library createLibrary(@NonNull String type, @NonNull String name, @NullAllowed String displayName, @NullAllowed String description, @NonNull Map<String,List<URL>> contents, @NonNull Map<String,String> properties) throws IOException
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)displayName - the display name of the library. If null the identifying name is useddescription - the library descriptioncontents - the initial contents of the library's volumes, as a map from volume type to volume contentproperties - the optional properties associated with the library.IOException - if the new definition could not be storedIllegalArgumentException - 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 managerArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map<java.lang.String, java.util.List<java.net.URI>>)public Library createURILibrary(String type, String name, Map<String,List<URI>> contents) throws IOException
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 contentIOException - if the new definition could not be storedIllegalArgumentException - 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 managerArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map<java.lang.String, java.util.List<java.net.URI>>)public Library createURILibrary(@NonNull String type, @NonNull String name, @NullAllowed String displayName, @NullAllowed String description, @NonNull Map<String,List<URI>> contents) throws IOException
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)displayName - the display name of the library. If null the identifying name is useddescription - the library descriptioncontents - the initial contents of the library's volumes, as a map from volume type to volume contentIOException - if the new definition could not be storedIllegalArgumentException - 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 managerArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map<java.lang.String, java.util.List<java.net.URI>>)public Library createURILibrary(@NonNull String type, @NonNull String name, @NullAllowed String displayName, @NullAllowed String description, @NonNull Map<String,List<URI>> contents, @NonNull Map<String,String> properties) throws IOException
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)displayName - the display name of the library. If null the identifying name is useddescription - the library descriptioncontents - the initial contents of the library's volumes, as a map from volume type to volume contentproperties - the optional properties associated with the library.IOException - if the new definition could not be storedIllegalArgumentException - 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 managerArealLibraryProvider.createLibrary(java.lang.String, java.lang.String, A, java.util.Map<java.lang.String, java.util.List<java.net.URI>>)public void removeLibrary(Library library) throws IOException, IllegalArgumentException
library - to be removed.IOException - when library cannot be deleted.IllegalArgumentException - when library is not installed in a writable
LibraryProviderpublic void addPropertyChangeListener(PropertyChangeListener listener)
listener - to be notifiedpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener - public static LibraryManager getDefault()
public static LibraryManager forLocation(URL location) throws IllegalArgumentException
location - any storage location supported by an installed providerLibraryManager.getLocation() matches the supplied locationIllegalArgumentException - if no installed provider is able to manage locations of this kindArealLibraryProvider.loadArea(java.net.URL),
ArealLibraryProvider.getLibraries(A)public static Collection<LibraryManager> getOpenManagers()
LibraryManager.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.LibraryManager.getDefault()ArealLibraryProvider.getOpenAreas()public static void addOpenManagersPropertyChangeListener(PropertyChangeListener listener)
LibraryManager.PROP_OPEN_LIBRARY_MANAGERS.listener - to be notifiedpublic static void removeOpenManagersPropertyChangeListener(PropertyChangeListener listener)
listener -