@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, readSymbolicLink
public 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 FileSystemProvider
public CloudStorageFileSystem getFileSystem(URI uri)
gs://bucket
.getFileSystem
in class FileSystemProvider
public CloudStorageFileSystem newFileSystem(URI uri, Map<String,?> env)
gs://bucket
.
The URI can include a path component (that will be ignored).newFileSystem
in class FileSystemProvider
uri
- bucket and current working directory, e.g. gs://bucket
env
- 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 uri
IllegalArgumentException
- if uri
specifies a port, user, query, or fragment, or
if scheme is not public CloudStoragePath getPath(URI uri)
getPath
in class FileSystemProvider
public CloudStoragePath getPath(String uriInStringForm)
public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
newByteChannel
in class FileSystemProvider
IOException
public InputStream newInputStream(Path path, OpenOption... options) throws IOException
newInputStream
in class FileSystemProvider
IOException
public boolean deleteIfExists(Path path) throws IOException
deleteIfExists
in class FileSystemProvider
IOException
public void delete(Path path) throws IOException
delete
in class FileSystemProvider
IOException
public void move(Path source, Path target, CopyOption... options) throws IOException
move
in class FileSystemProvider
IOException
public void copy(Path source, Path target, CopyOption... options) throws IOException
copy
in class FileSystemProvider
IOException
public boolean isSameFile(Path path, Path path2)
isSameFile
in class FileSystemProvider
public boolean isHidden(Path path)
false
, because Google Cloud Storage doesn't support hidden files.isHidden
in class FileSystemProvider
public void checkAccess(Path path, AccessMode... modes) throws IOException
checkAccess
in class FileSystemProvider
IOException
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
readAttributes
in class FileSystemProvider
IOException
public Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options)
readAttributes
in class FileSystemProvider
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
getFileAttributeView
in class FileSystemProvider
public void createDirectory(Path dir, FileAttribute<?>... attrs)
createDirectory
in class FileSystemProvider
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter)
newDirectoryStream
in class FileSystemProvider
public void setAttribute(Path path, String attribute, Object value, LinkOption... options)
UnsupportedOperationException
because Cloud Storage objects are immutable.setAttribute
in class FileSystemProvider
public FileStore getFileStore(Path path)
UnsupportedOperationException
because this feature hasn't been implemented yet.getFileStore
in class FileSystemProvider
Copyright © 2017 Google. All rights reserved.