java.nio.file.attribute.FileAttributeView Java Examples

The following examples show how to use java.nio.file.attribute.FileAttributeView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MCRFileSystemProvider.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    MCRPath mcrPath = MCRFileSystemUtils.checkPathAbsolute(path);
    if (type == null) {
        throw new NullPointerException();
    }
    //must support BasicFileAttributeView
    if (type == BasicFileAttributeView.class) {
        return (V) new BasicFileAttributeViewImpl(mcrPath);
    }
    if (type == MCRMD5AttributeView.class) {
        return (V) new MD5FileAttributeViewImpl(mcrPath);
    }
    return null;
}
 
Example #2
Source File: MCRFileSystemProvider.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    MCRPath mcrPath = MCRFileSystemUtils.checkPathAbsolute(path);
    if (type == null) {
        throw new NullPointerException();
    }
    //must support BasicFileAttributeView
    if (type == BasicFileAttributeView.class) {
        return (V) new BasicFileAttributeViewImpl(mcrPath);
    }
    if (type == MCRMD5AttributeView.class) {
        return (V) new MD5FileAttributeViewImpl(mcrPath);
    }
    return null;
}
 
Example #3
Source File: MCRDirectoryStream.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    if (path != null) {
        MCRPath file = checkRelativePath(path);
        if (file.getNameCount() != 1) {
            throw new InvalidPathException(path.toString(), "'path' must have one name component.");
        }
    }
    checkClosed();
    if (type == null) {
        throw new NullPointerException();
    }
    //must support BasicFileAttributeView
    if (type == BasicFileAttributeView.class) {
        return (V) new BasicFileAttributeViewImpl(this, path);
    }
    if (type == MCRMD5AttributeView.class) {
        return (V) new MD5FileAttributeViewImpl(this, path);
    }
    return null;
}
 
Example #4
Source File: BundleFileSystemProvider.java    From incubator-taverna-language with Apache License 2.0 6 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
		Class<V> type, LinkOption... options) {
	BundleFileSystem fs = (BundleFileSystem) path.getFileSystem();
	if (path.toAbsolutePath().equals(fs.getRootDirectory())) {
		// Bug in ZipFS, it will fall over as there is no entry for /
		//
		// Instead we'll just give a view of the source (e.g. the zipfile
		// itself).
		// Modifying its times is a bit futile since they are likely to be
		// overriden when closing, but this avoids a NullPointerException
		// in Files.setTimes().
		return Files.getFileAttributeView(fs.getSource(), type, options);
	}
	return origProvider(path).getFileAttributeView(fs.unwrap(path), type,
			options);
}
 
Example #5
Source File: MCRDirectoryStream.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    Path localRelativePath = toLocalPath(path);
    if (type == MCRMD5AttributeView.class) {
        BasicFileAttributeView baseView = baseStream.getFileAttributeView(localRelativePath,
            BasicFileAttributeView.class, options);
        return (V) new MD5FileAttributeViewImpl(baseView, (v) -> resolve(path));
    }
    return baseStream.getFileAttributeView(localRelativePath, type, options);
}
 
Example #6
Source File: FaultyFileSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #7
Source File: FaultyFileSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #8
Source File: FaultyFileSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #9
Source File: GfsFileStore.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Override
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
  return
    type.isAssignableFrom(GfsFileAttributeView.Basic.class)
      || type.isAssignableFrom(GfsFileAttributeView.Posix.class)
      || type.isAssignableFrom(GfsFileAttributeView.Git.class);
}
 
Example #10
Source File: FaultyFileSystem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #11
Source File: HadoopFileSystem.java    From jsr203-hadoop with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
<V extends FileAttributeView> V getView(HadoopPath path, Class<V> type) {
       if (type == null)
           throw new NullPointerException();
       if (type == BasicFileAttributeView.class)
           return (V)new HadoopBasicFileAttributeView(path, false);
       if (type == HadoopBasicFileAttributeView.class)
           return (V)new HadoopBasicFileAttributeView(path, true);
       if (type == FileOwnerAttributeView.class)
           return (V)new HadoopPosixFileAttributeView(path, false);
       if (type == PosixFileAttributeView.class)
           return (V)new HadoopPosixFileAttributeView(path, true);
       return null;
   }
 
Example #12
Source File: FaultyFileSystem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #13
Source File: FaultyFileSystem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #14
Source File: DelegatingFileSystemProviderTest.java    From tessera with Apache License 2.0 5 votes vote down vote up
@Test
public void getFileAttributeView() {
    final Path path = mock(Path.class);
    final Class<FileAttributeView> type = FileAttributeView.class;

    provider.getFileAttributeView(path, type);

    verify(delegate).getFileAttributeView(path, type);
}
 
Example #15
Source File: FaultyFileSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #16
Source File: FaultyFileSystem.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #17
Source File: FaultyFileSystem.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #18
Source File: HadoopFileStore.java    From jsr203-hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public boolean supportsFileAttributeView(
    Class<? extends FileAttributeView> type) {
  if (type == BasicFileAttributeView.class) {
    return this.system.supportedFileAttributeViews().contains("basic");
  }
  if (type == PosixFileAttributeView.class) {
    return this.system.supportedFileAttributeViews().contains("posix");
  }
  // FIXME Implements all FileAttributeView checks
  return false;
}
 
Example #19
Source File: SFTPFileSystemProvider.java    From sftp-fs with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a file attribute view of a given type.
 * This method works in exactly the manner specified by the {@link Files#getFileAttributeView(Path, Class, LinkOption...)} method.
 * <p>
 * This provider supports {@link BasicFileAttributeView}, {@link FileOwnerAttributeView} and {@link PosixFileAttributeView}.
 * All other classes will result in a {@code null} return value.
 * <p>
 * Note: if the type is {@link BasicFileAttributeView} or a sub type, the last access time and creation time must be {@code null} when calling
 * {@link BasicFileAttributeView#setTimes(FileTime, FileTime, FileTime)}, otherwise an exception will be thrown.
 * When setting the owner or group for the path, the name must be the UID/GID of the owner/group.
 */
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    Objects.requireNonNull(type);
    if (type == BasicFileAttributeView.class) {
        return type.cast(new AttributeView("basic", toSFTPPath(path))); //$NON-NLS-1$
    }
    if (type == FileOwnerAttributeView.class) {
        return type.cast(new AttributeView("owner", toSFTPPath(path))); //$NON-NLS-1$
    }
    if (type == PosixFileAttributeView.class) {
        return type.cast(new AttributeView("posix", toSFTPPath(path))); //$NON-NLS-1$
    }
    return null;
}
 
Example #20
Source File: TestProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    Path delegate = theFileSystem.unwrap(file);
    return defaultProvider.getFileAttributeView(delegate, type, options);
}
 
Example #21
Source File: FaultyFileSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #22
Source File: JFileSystemProvider.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
                                                            Class<V> type,
                                                            LinkOption... options)
{
  // TODO Auto-generated method stub
  throw new UnsupportedOperationException();
}
 
Example #23
Source File: FileProviderBase.java    From baratine with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
                                                            Class<V> type,
                                                            LinkOption... options)
{
  throw new UnsupportedOperationException();
}
 
Example #24
Source File: FilesGetAttributeViewTest.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Test
public void getFileAttributeViewFromFile_shouldBeNotNull() throws IOException {
  initRepository();
  writeToCache("/file.txt");
  commitToMaster();
  initGitFileSystem();
  assertNotNull(Files.getFileAttributeView(gfs.getPath("/file.txt"), FileAttributeView.class));
}
 
Example #25
Source File: FaultyFileSystem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
 
Example #26
Source File: MCRDirectoryStream.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Class<V> type) {
    V fileAttributeView = baseStream.getFileAttributeView(type);
    if (fileAttributeView != null) {
        return fileAttributeView;
    }
    if (type == MCRMD5AttributeView.class) {
        BasicFileAttributeView baseView = baseStream.getFileAttributeView(BasicFileAttributeView.class);
        return (V) new MD5FileAttributeViewImpl(baseView, (v) -> dir);
    }
    return null;
}
 
Example #27
Source File: GfsFileStore.java    From ParallelGit with Apache License 2.0 5 votes vote down vote up
@Override
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
  return
    type.isAssignableFrom(GfsFileAttributeView.Basic.class)
      || type.isAssignableFrom(GfsFileAttributeView.Posix.class)
      || type.isAssignableFrom(GfsFileAttributeView.Git.class);
}
 
Example #28
Source File: GfsIO.java    From ParallelGit with Apache License 2.0 4 votes vote down vote up
@Nullable
public static <V extends FileAttributeView> V getFileAttributeView(GitPath path, Class<V> type) throws IOException, UnsupportedOperationException {
  Node node = findNode(path);
  return node != null ? GfsFileAttributeView.forNode(node, type) : null;
}
 
Example #29
Source File: JFileStore.java    From baratine with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type)
{
  return false;
}
 
Example #30
Source File: EncryptedFileSystemProvider.java    From encfs4j with Apache License 2.0 4 votes vote down vote up
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
		Class<V> type, LinkOption... options) {
	return Files.getFileAttributeView(EncryptedFileSystem.dismantle(file),
			type, options);
}