本文整理匯總了Java中java.nio.file.attribute.FileAttributeView類的典型用法代碼示例。如果您正苦於以下問題:Java FileAttributeView類的具體用法?Java FileAttributeView怎麽用?Java FileAttributeView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FileAttributeView類屬於java.nio.file.attribute包,在下文中一共展示了FileAttributeView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@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;
}
示例2: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@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;
}
示例3: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@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);
}
示例4: getSupportedFileAttributes
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
private Set<String> getSupportedFileAttributes(FileStore fs) {
Set<String> attrs = new HashSet<String>();
if (fs.supportsFileAttributeView(AclFileAttributeView.class)) {
attrs.add("acl");
}
if (fs.supportsFileAttributeView(BasicFileAttributeView.class)) {
attrs.add("basic");
}
if (fs.supportsFileAttributeView(FileOwnerAttributeView.class)) {
attrs.add("owner");
}
if (fs.supportsFileAttributeView(UserDefinedFileAttributeView.class)) {
attrs.add("user");
}
if (fs.supportsFileAttributeView(DosFileAttributeView.class)) {
attrs.add("dos");
}
if (fs.supportsFileAttributeView(PosixFileAttributeView.class)) {
attrs.add("posix");
}
if (fs.supportsFileAttributeView(FileAttributeView.class)) {
attrs.add("file");
}
return attrs;
}
示例5: supportsFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
public boolean supportsFileAttributeView(
Class<? extends FileAttributeView> type) {
String name = "notFound";
if(type == BasicFileAttributeView.class) {
name = "basic";
} else if(type == DosFileAttributeView.class) {
name = "dos";
} else if(type == PosixFileAttributeView.class) {
name = "posix";
} else if(type == FileOwnerAttributeView.class) {
name = "owner";
}
return attributeSets.containsKey(name);
}
示例6: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
Class<V> type, LinkOption... options) {
final EphemeralFsPath efsPath = cast(path);
synchronized(efsPath.fs.fsLock) {
return efsPath.fs.getFileAttributeView(
new EphemeralFsPathProvider() {
@Override
public EphemeralFsPath get() {
return translate(efsPath);
}
},
type,
closeChecker,
options);
}
}
示例7: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
public <V extends FileAttributeView> Optional<V> getFileAttributeView( EightyPath path, final Class<V> type, LinkOption... options ) {
if( !isViewSupported( type ) ) {
return Optional.empty();
}
if( !existsEx( path, options ) ) {
return Optional.of( getFileAttributeViewDummy( path, type ) );
}
EightyPath real = toRealPathEx( path, options );
EightyFileSystem eightyFileSystem = path._getFileSystem();
EightyFS efs = eightyFileSystem.get80();
V fav = getSymLinkSensitiveFileAttributeView( type, real, efs );
handleReadOnlyFileSystems( eightyFileSystem, fav );
return Optional.of( fav );
}
示例8: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Override
public <V extends FileAttributeView> V getFileAttributeView(
Path path, Class<V> type, LinkOption... options) {
checkOpen();
final JimfsPath checkedPath = checkPath(path);
final ImmutableSet<LinkOption> optionsSet = Options.getLinkOptions(options);
return view.getFileAttributeView(
new FileLookup() {
@Override
public File lookup() throws IOException {
checkOpen(); // per the spec, must check that the stream is open for each view operation
return view
.lookUpWithLock(checkedPath, optionsSet)
.requireExists(checkedPath)
.file();
}
},
type);
}
示例9: testView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Test
public void testView() throws IOException {
AclFileAttributeView view =
provider.view(
fileLookup(),
ImmutableMap.<String, FileAttributeView>of(
"owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
assertNotNull(view);
assertThat(view.name()).isEqualTo("acl");
assertThat(view.getAcl()).isEqualTo(defaultAcl);
view.setAcl(ImmutableList.<AclEntry>of());
view.setOwner(FOO);
assertThat(view.getAcl()).isEqualTo(ImmutableList.<AclEntry>of());
assertThat(view.getOwner()).isEqualTo(FOO);
assertThat(file.getAttribute("acl", "acl")).isEqualTo(ImmutableList.<AclEntry>of());
}
示例10: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Override
@Nullable
public <V extends FileAttributeView> V getFileAttributeView(
Path path,
Class<V> type,
LinkOption... options) {
return promote(path).getFileAttributeView(type, options);
}
示例11: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
Class<V> type,
LinkOption... options)
{
return Files.getFileAttributeView(unwrap(file), type, options);
}
示例12: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@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);
}
示例13: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
/**
* Can return a {@link CloudFileAttributesView}
* @param type {@link CloudFileAttributesView} or {@link BasicFileAttributeView}
*/
@Override
public <V extends FileAttributeView> V getFileAttributeView(BlobStoreContext blobStoreContext, Class<V> type, CloudPath cloudPath) {
if (CloudFileAttributesView.class.equals(type) || BasicFileAttributeView.class.equals(type)) {
return type.cast(new CloudFileAttributesView(blobStoreContext, cloudPath));
}
return null;
}
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:13,代碼來源:DefaultCloudFileSystemImplementation.java
示例14: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Override
@SuppressWarnings( "unchecked" )
public <V extends FileAttributeView> V getFileAttributeView( Path path, Class<V> type, LinkOption... options )
{
if( type.isAssignableFrom( BasicFileAttributeView.class ) )
{
P p = toCachePath( path );
return (V) p.getFileSystem().getFileSystemIO().getAttributeView( p.getResolvedPath() );
}
throw new UnsupportedOperationException();
}
示例15: getFileAttributeView
import java.nio.file.attribute.FileAttributeView; //導入依賴的package包/類
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
Class<V> type,
LinkOption... options)
{
throw new UnsupportedOperationException();
}