@Singleton @ThreadSafe @AutoService(value=java.nio.file.spi.FileSystemProvider.class) public final class CloudStorageFileSystemProvider extends FileSystemProvider
FileSystemProvider implementation.
Note: This class should never be used directly. This class is instantiated by the
service loader and called through a standardized API, e.g. Files. However
the javadocs in this class serve as useful documentation for the behavior of the Google Cloud
Storage NIO library.
| Constructor and Description |
|---|
CloudStorageFileSystemProvider()
Default constructor which should only be called by Java SPI.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkAccess(Path path,
AccessMode... modes) |
void |
copy(Path source,
Path target,
CopyOption... options) |
void |
createDirectory(Path dir,
FileAttribute<?>... attrs)
Does nothing since Google Cloud Storage uses fake directories.
|
void |
delete(Path path) |
boolean |
deleteIfExists(Path path) |
boolean |
equals(Object other) |
<V extends FileAttributeView> |
getFileAttributeView(Path path,
Class<V> type,
LinkOption... options) |
FileStore |
getFileStore(Path path)
Throws
UnsupportedOperationException because this feature hasn't been implemented yet. |
CloudStorageFileSystem |
getFileSystem(URI uri)
Returns Cloud Storage file system, provided a URI with no path, e.g.
|
CloudStoragePath |
getPath(String uriInStringForm)
Convenience method: replaces spaces with "%20", builds a URI, and calls getPath(uri).
|
CloudStoragePath |
getPath(URI uri) |
String |
getScheme() |
int |
hashCode() |
boolean |
isHidden(Path path)
Always returns
false, because Google Cloud Storage doesn't support hidden files. |
boolean |
isSameFile(Path path,
Path path2) |
void |
move(Path source,
Path target,
CopyOption... options) |
SeekableByteChannel |
newByteChannel(Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs) |
DirectoryStream<Path> |
newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter) |
CloudStorageFileSystem |
newFileSystem(URI uri,
Map<String,?> env)
Returns Cloud Storage file system, provided a URI, e.g.
|
InputStream |
newInputStream(Path path,
OpenOption... options) |
<A extends BasicFileAttributes> |
readAttributes(Path path,
Class<A> type,
LinkOption... options) |
Map<String,Object> |
readAttributes(Path path,
String attributes,
LinkOption... options) |
void |
setAttribute(Path path,
String attribute,
Object value,
LinkOption... options)
Throws
UnsupportedOperationException because Cloud Storage objects are immutable. |
static void |
setDefaultCloudStorageConfiguration(CloudStorageConfiguration newDefault)
Changes the default configuration for every filesystem object created
from here on, including via SPI.
|
static void |
setStorageOptions(StorageOptions newStorageOptions)
Sets options that are only used by the constructor.
|
String |
toString() |
createLink, createSymbolicLink, installedProviders, newAsynchronousFileChannel, newFileChannel, newFileSystem, newOutputStream, readSymbolicLinkpublic CloudStorageFileSystemProvider()
public static void setStorageOptions(@Nullable StorageOptions newStorageOptions)
public static void setDefaultCloudStorageConfiguration(@Nullable CloudStorageConfiguration newDefault)
If options are specified later then they override the defaults. Methods that take a whole CloudStorageConfiguration (eg. CloudStorageFileSystem.forBucket) will completely override the defaults. Methods that take individual options (eg. CloudStorageFileSystemProvier.newFileSystem) will override only these options; the rest will be taken from the defaults specified here.
This is meant to be done only once, at the beginning of some main program, in order to force all libraries to use some settings we like.
Libraries should never call this. If you're a library then, instead, create your own filesystem object with the right configuration and pass it along.
newDefault - new default CloudStorageConfigurationpublic String getScheme()
getScheme in class FileSystemProviderpublic CloudStorageFileSystem getFileSystem(URI uri)
gs://bucket.getFileSystem in class FileSystemProviderpublic CloudStorageFileSystem newFileSystem(URI uri, Map<String,?> env)
gs://bucket.
The URI can include a path component (that will be ignored).newFileSystem in class FileSystemProvideruri - bucket and current working directory, e.g. gs://bucketenv - map of configuration options, whose keys correspond to the method names of
CloudStorageConfiguration.Builder. However you are not allowed to set the working
directory, as that should be provided in the uriIllegalArgumentException - if uri specifies a port, user, query, or fragment, or
if scheme is not public CloudStoragePath getPath(URI uri)
getPath in class FileSystemProviderpublic CloudStoragePath getPath(String uriInStringForm)
public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newByteChannel in class FileSystemProviderIOExceptionpublic InputStream newInputStream(Path path, OpenOption... options) throws IOException
newInputStream in class FileSystemProviderIOExceptionpublic boolean deleteIfExists(Path path) throws IOException
deleteIfExists in class FileSystemProviderIOExceptionpublic void delete(Path path) throws IOException
delete in class FileSystemProviderIOExceptionpublic void move(Path source, Path target, CopyOption... options) throws IOException
move in class FileSystemProviderIOExceptionpublic void copy(Path source, Path target, CopyOption... options) throws IOException
copy in class FileSystemProviderIOExceptionpublic boolean isSameFile(Path path, Path path2)
isSameFile in class FileSystemProviderpublic boolean isHidden(Path path)
false, because Google Cloud Storage doesn't support hidden files.isHidden in class FileSystemProviderpublic void checkAccess(Path path, AccessMode... modes) throws IOException
checkAccess in class FileSystemProviderIOExceptionpublic <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
readAttributes in class FileSystemProviderIOExceptionpublic Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options)
readAttributes in class FileSystemProviderpublic <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
getFileAttributeView in class FileSystemProviderpublic void createDirectory(Path dir, FileAttribute<?>... attrs)
createDirectory in class FileSystemProviderpublic DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
newDirectoryStream in class FileSystemProviderpublic void setAttribute(Path path, String attribute, Object value, LinkOption... options)
UnsupportedOperationException because Cloud Storage objects are immutable.setAttribute in class FileSystemProviderpublic FileStore getFileStore(Path path)
UnsupportedOperationException because this feature hasn't been implemented yet.getFileStore in class FileSystemProviderCopyright © 2017 Google. All rights reserved.