public final class LibrariesSupport extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LibrariesSupport.ConversionMode
Policy for handling content items which cannot be converted into the desired format.
|
Modifier and Type | Method and Description |
---|---|
static URI |
convertFilePathToURI(String path)
Properly converts possibly relative file path to URI.
|
static List<URL> |
convertURIsToURLs(List<? extends URI> uris,
LibrariesSupport.ConversionMode conversionMode)
|
static String |
convertURIToFilePath(URI uri)
Properly converts possibly relative URI to file path.
|
static List<URI> |
convertURLsToURIs(List<URL> urls,
LibrariesSupport.ConversionMode conversionMode)
|
static LibraryImplementation |
createLibraryImplementation(String libraryType,
String[] volumeTypes)
Creates default LibraryImplementation
|
static LibraryImplementation3 |
createLibraryImplementation3(String libraryType,
String... volumeTypes)
Creates default
LibraryImplementation3 |
static URI |
getArchiveFile(URI uri)
Returns the URI of the archive file containing the file
referred to by a
jar -protocol URL. |
static URI |
getArchiveRoot(URI uri)
Returns a URI representing the root of an archive.
|
static String |
getDisplayName(LibraryImplementation impl)
Returns
LibraryImplementation display name. |
static LibraryImplementation |
getLibraryImplementation(Library library)
Returns the
LibraryImplementation for given Library . |
static LibraryStorageArea |
getLibraryStorageArea(LibraryManager manager)
Returns a
LibraryStorageArea for given LibraryManager . |
static LibraryTypeProvider |
getLibraryTypeProvider(String libraryType)
Returns registered
LibraryTypeProvider for given library type. |
static LibraryTypeProvider[] |
getLibraryTypeProviders()
Returns all registered
LibraryTypeProvider s. |
static String |
getLocalizedName(LibraryImplementation impl)
Returns a localized (user friendly) name of the
LibraryImplementation . |
static Map<String,String> |
getProperties(LibraryImplementation impl)
Returns
LibraryImplementation properties. |
static List<URI> |
getURIContent(LibraryImplementation impl,
String volumeType,
LibrariesSupport.ConversionMode conversionMode)
Returns
LibraryImplementation URI content. |
static FileObject |
resolveLibraryEntryFileObject(URL libraryLocation,
URI libraryEntry)
Helper method to resolve (possibly relative) library content URI to FileObject.
|
static URI |
resolveLibraryEntryURI(URL libraryLocation,
URI libraryEntry)
Helper method to resolve (possibly relative) library content URI.
|
static boolean |
setDisplayName(LibraryImplementation impl,
String name)
Sets
LibraryImplementation display name. |
static boolean |
setProperties(LibraryImplementation impl,
Map<String,String> props)
Sets
LibraryImplementation properties. |
static boolean |
setURIContent(LibraryImplementation impl,
String volumeType,
List<URI> path,
LibrariesSupport.ConversionMode conversionMode)
Sets
LibraryImplementation URI content. |
static boolean |
supportsDisplayName(LibraryImplementation impl)
Tests if given
LibraryImplementation supports display name. |
static boolean |
supportsProperties(LibraryImplementation impl)
Tests if given
LibraryImplementation supports properties. |
static boolean |
supportsURIContent(LibraryImplementation impl)
Tests if given
LibraryImplementation supports URI content. |
@NonNull public static LibraryImplementation3 createLibraryImplementation3(@NonNull String libraryType, @NonNull String... volumeTypes)
LibraryImplementation3
libraryType
- type of libraryvolumeTypes
- types of supported volumespublic static LibraryImplementation createLibraryImplementation(String libraryType, String[] volumeTypes)
libraryType
- type of libraryvolumeTypes
- types of supported volumespublic static LibraryTypeProvider getLibraryTypeProvider(String libraryType)
LibraryTypeProvider
for given library type. This method
is mostly used by LibraryProvider
implementators.libraryType
- the type of library for which the provider should be returned.LibraryTypeProvider
for given library type or null, if none is registered.public static LibraryTypeProvider[] getLibraryTypeProviders()
LibraryTypeProvider
s. This method
is mostly used by LibraryProvider
implementators.LibraryTypeProvider
, never returns null.public static URI convertFilePathToURI(@NonNull String path)
path
- file path to convert; can be relative; cannot be nullpublic static String convertURIToFilePath(URI uri)
uri
- URI convert; can be relative URI; cannot be null@NonNull public static List<URL> convertURIsToURLs(@NonNull List<? extends URI> uris, @NonNull LibrariesSupport.ConversionMode conversionMode)
uris
- the list of URI
s to be convertedconversionMode
- the Policy for handling content items which
cannot be converted into URL
s.URL
sIllegalArgumentException
- for unconvertable entry in
LibrariesSupport.ConversionMode.FAIL
@NonNull public static List<URI> convertURLsToURIs(@NonNull List<URL> urls, @NonNull LibrariesSupport.ConversionMode conversionMode)
urls
- the list of URL
s to be convertedconversionMode
- the Policy for handling content items which
cannot be converted into @{link URI}sURI
sIllegalArgumentException
- for unconvertable entry in
LibrariesSupport.ConversionMode.FAIL
public static FileObject resolveLibraryEntryFileObject(URL libraryLocation, URI libraryEntry)
libraryLocation
- library location file; can be null for global librarieslibraryEntry
- library entry to resolvepublic static URI resolveLibraryEntryURI(URL libraryLocation, URI libraryEntry)
libraryLocation
- library location filelibraryEntry
- relative library entry to resolvepublic static URI getArchiveFile(URI uri)
jar
-protocol URL.
Remember that any path within the archive is discarded
so you may need to check for non-root entries.uri
- a URI; can be relative URIjar
-protocol URI containing !/
public static URI getArchiveRoot(URI uri)
uri
- of a ZIP- (or JAR-) format archive file; can be relativejar
-protocol URI of the root of the archive@NonNull public static LibraryStorageArea getLibraryStorageArea(@NonNull LibraryManager manager)
LibraryStorageArea
for given LibraryManager
.manager
- the LibraryManager
to get a LibraryStorageArea
forLibraryStorageArea
@NonNull public static String getLocalizedName(@NonNull LibraryImplementation impl)
LibraryImplementation
.impl
- the library to get the localized name forpublic static boolean supportsDisplayName(@NonNull LibraryImplementation impl)
LibraryImplementation
supports display name.impl
- the LibraryImplementation
to be checkedLibraryImplementation
supports display name@CheckForNull public static String getDisplayName(@NonNull LibraryImplementation impl)
LibraryImplementation
display name.impl
- the LibraryImplementation
to return display name forpublic static boolean setDisplayName(@NonNull LibraryImplementation impl, @NullAllowed String name)
LibraryImplementation
display name.impl
- the LibraryImplementation
to set the display name toname
- the display nameLibraryImplementation
support display namepublic static boolean supportsProperties(@NonNull LibraryImplementation impl)
LibraryImplementation
supports properties.impl
- the LibraryImplementation
to be checkedLibraryImplementation
supports properties@NonNull public static Map<String,String> getProperties(@NonNull LibraryImplementation impl)
LibraryImplementation
properties.impl
- the LibraryImplementation
to return properties forpublic static boolean setProperties(@NonNull LibraryImplementation impl, @NonNull Map<String,String> props)
LibraryImplementation
properties.impl
- the LibraryImplementation
to set properties toprops
- the propertiesLibraryImplementation
support propertiespublic static boolean supportsURIContent(@NonNull LibraryImplementation impl)
LibraryImplementation
supports URI
content.impl
- the LibraryImplementation
to be checkedLibraryImplementation
supports URI
content@NonNull public static List<URI> getURIContent(@NonNull LibraryImplementation impl, @NonNull String volumeType, @NonNull LibrariesSupport.ConversionMode conversionMode)
LibraryImplementation
URI
content.impl
- the LibraryImplementation
to return URI
content forvolumeType
- the volumeTypeconversionMode
- conversion failure policy in case the library does not
support URI
content and the library URL
s are converted to URI
sURI
contentIllegalArgumentException
- when unsupported volumeType or for unconvertable entry in
LibrariesSupport.ConversionMode.FAIL
public static boolean setURIContent(@NonNull LibraryImplementation impl, @NonNull String volumeType, @NonNull List<URI> path, @NonNull LibrariesSupport.ConversionMode conversionMode)
LibraryImplementation
URI
content.impl
- the LibraryImplementation
to set the URI
content tovolumeType
- the volumeTypepath
- the URI
contentconversionMode
- conversion failure policy in case the library does not
support URI
content and the path URI
s are converted to URL
sLibraryImplementation
support URI
contentIllegalArgumentException
- when unsupported volumeType or for unconvertable entry in
LibrariesSupport.ConversionMode.FAIL
@NonNull public static LibraryImplementation getLibraryImplementation(@NonNull Library library)
LibraryImplementation
for given Library
.library
- the Library
to return SPI for.LibraryImplementation