Package com.google.common.jimfs
Class AttributeService
- java.lang.Object
-
- com.google.common.jimfs.AttributeService
-
final class AttributeService extends java.lang.Object
Service providing all attribute related operations for a file store. One piece of the file store implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AttributeService.SimpleFileAttribute<T>
Simple implementation ofFileAttribute
.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ALL_ATTRIBUTES
private static com.google.common.base.Splitter
ATTRIBUTE_SPLITTER
private com.google.common.collect.ImmutableList<java.nio.file.attribute.FileAttribute<?>>
defaultValues
private com.google.common.collect.ImmutableMap<java.lang.Class<?>,AttributeProvider>
providersByAttributesType
private com.google.common.collect.ImmutableMap<java.lang.String,AttributeProvider>
providersByName
private com.google.common.collect.ImmutableMap<java.lang.Class<?>,AttributeProvider>
providersByViewType
-
Constructor Summary
Constructors Constructor Description AttributeService(Configuration configuration)
Creates a new attribute service using the given configuration.AttributeService(java.lang.Iterable<? extends AttributeProvider> providers, java.util.Map<java.lang.String,?> userProvidedDefaults)
Creates a new attribute service using the given providers and user provided default attribute values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
addMissingProviders(java.util.Map<java.lang.String,AttributeProvider> providers)
private static void
addStandardProvider(java.util.Map<java.lang.String,AttributeProvider> result, java.lang.String view)
void
copyAttributes(File file, File copy, AttributeCopyOption copyOption)
Copies the attributes of the given file to the given copy file.private com.google.common.collect.ImmutableMap<java.lang.String,java.nio.file.attribute.FileAttributeView>
createInheritedViews(FileLookup lookup, AttributeProvider provider)
private void
createInheritedViews(FileLookup lookup, AttributeProvider provider, java.util.Map<java.lang.String,java.nio.file.attribute.FileAttributeView> inheritedViews)
java.lang.Object
getAttribute(File file, java.lang.String attribute)
Gets the value of the given attribute for the given file.java.lang.Object
getAttribute(File file, java.lang.String view, java.lang.String attribute)
Gets the value of the given attribute for the given view and file.private @Nullable java.lang.Object
getAttributeInternal(File file, java.lang.String view, java.lang.String attribute)
private static com.google.common.collect.ImmutableList<java.lang.String>
getAttributeNames(java.lang.String attributes)
private java.nio.file.attribute.FileAttributeView
getFileAttributeView(FileLookup lookup, java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> viewType, java.util.Map<java.lang.String,java.nio.file.attribute.FileAttributeView> inheritedViews)
<V extends java.nio.file.attribute.FileAttributeView>
@Nullable VgetFileAttributeView(FileLookup lookup, java.lang.Class<V> type)
Returns an attribute view of the given type for the given file lookup callback, ornull
if the view type is not supported.private static java.lang.Iterable<AttributeProvider>
getProviders(Configuration configuration)
private static java.lang.String
getSingleAttribute(java.lang.String attribute)
private static java.lang.String
getViewName(java.lang.String attribute)
private static void
readAll(File file, AttributeProvider provider, java.util.Map<java.lang.String,java.lang.Object> map)
<A extends java.nio.file.attribute.BasicFileAttributes>
AreadAttributes(File file, java.lang.Class<A> type)
Returns attributes of the given file as an object of the given type.com.google.common.collect.ImmutableMap<java.lang.String,java.lang.Object>
readAttributes(File file, java.lang.String attributes)
ImplementsFiles.readAttributes(Path, String, LinkOption...)
.void
setAttribute(File file, java.lang.String attribute, java.lang.Object value, boolean create)
Sets the value of the given attribute to the given value for the given file.private void
setAttributeInternal(File file, java.lang.String view, java.lang.String attribute, java.lang.Object value, boolean create)
void
setInitialAttributes(File file, java.nio.file.attribute.FileAttribute<?>... attrs)
Sets all initial attributes for the given file, including the given attributes if possible.com.google.common.collect.ImmutableSet<java.lang.String>
supportedFileAttributeViews()
ImplementsFileSystem.supportedFileAttributeViews()
.boolean
supportsFileAttributeView(java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> type)
ImplementsFileStore.supportsFileAttributeView(Class)
.
-
-
-
Field Detail
-
ALL_ATTRIBUTES
private static final java.lang.String ALL_ATTRIBUTES
- See Also:
- Constant Field Values
-
providersByName
private final com.google.common.collect.ImmutableMap<java.lang.String,AttributeProvider> providersByName
-
providersByViewType
private final com.google.common.collect.ImmutableMap<java.lang.Class<?>,AttributeProvider> providersByViewType
-
providersByAttributesType
private final com.google.common.collect.ImmutableMap<java.lang.Class<?>,AttributeProvider> providersByAttributesType
-
defaultValues
private final com.google.common.collect.ImmutableList<java.nio.file.attribute.FileAttribute<?>> defaultValues
-
ATTRIBUTE_SPLITTER
private static final com.google.common.base.Splitter ATTRIBUTE_SPLITTER
-
-
Constructor Detail
-
AttributeService
public AttributeService(Configuration configuration)
Creates a new attribute service using the given configuration.
-
AttributeService
public AttributeService(java.lang.Iterable<? extends AttributeProvider> providers, java.util.Map<java.lang.String,?> userProvidedDefaults)
Creates a new attribute service using the given providers and user provided default attribute values.
-
-
Method Detail
-
getProviders
private static java.lang.Iterable<AttributeProvider> getProviders(Configuration configuration)
-
addMissingProviders
private static void addMissingProviders(java.util.Map<java.lang.String,AttributeProvider> providers)
-
addStandardProvider
private static void addStandardProvider(java.util.Map<java.lang.String,AttributeProvider> result, java.lang.String view)
-
supportedFileAttributeViews
public com.google.common.collect.ImmutableSet<java.lang.String> supportedFileAttributeViews()
ImplementsFileSystem.supportedFileAttributeViews()
.
-
supportsFileAttributeView
public boolean supportsFileAttributeView(java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> type)
ImplementsFileStore.supportsFileAttributeView(Class)
.
-
setInitialAttributes
public void setInitialAttributes(File file, java.nio.file.attribute.FileAttribute<?>... attrs)
Sets all initial attributes for the given file, including the given attributes if possible.
-
copyAttributes
public void copyAttributes(File file, File copy, AttributeCopyOption copyOption)
Copies the attributes of the given file to the given copy file.
-
getAttribute
public java.lang.Object getAttribute(File file, java.lang.String attribute)
Gets the value of the given attribute for the given file.attribute
must be of the form "view:attribute" or "attribute".
-
getAttribute
public java.lang.Object getAttribute(File file, java.lang.String view, java.lang.String attribute)
Gets the value of the given attribute for the given view and file. Neither view nor attribute may have a ':' character.
-
getAttributeInternal
private @Nullable java.lang.Object getAttributeInternal(File file, java.lang.String view, java.lang.String attribute)
-
setAttribute
public void setAttribute(File file, java.lang.String attribute, java.lang.Object value, boolean create)
Sets the value of the given attribute to the given value for the given file.
-
setAttributeInternal
private void setAttributeInternal(File file, java.lang.String view, java.lang.String attribute, java.lang.Object value, boolean create)
-
getFileAttributeView
public <V extends java.nio.file.attribute.FileAttributeView> @Nullable V getFileAttributeView(FileLookup lookup, java.lang.Class<V> type)
Returns an attribute view of the given type for the given file lookup callback, ornull
if the view type is not supported.
-
getFileAttributeView
private java.nio.file.attribute.FileAttributeView getFileAttributeView(FileLookup lookup, java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> viewType, java.util.Map<java.lang.String,java.nio.file.attribute.FileAttributeView> inheritedViews)
-
createInheritedViews
private com.google.common.collect.ImmutableMap<java.lang.String,java.nio.file.attribute.FileAttributeView> createInheritedViews(FileLookup lookup, AttributeProvider provider)
-
createInheritedViews
private void createInheritedViews(FileLookup lookup, AttributeProvider provider, java.util.Map<java.lang.String,java.nio.file.attribute.FileAttributeView> inheritedViews)
-
readAttributes
public com.google.common.collect.ImmutableMap<java.lang.String,java.lang.Object> readAttributes(File file, java.lang.String attributes)
ImplementsFiles.readAttributes(Path, String, LinkOption...)
.
-
readAttributes
public <A extends java.nio.file.attribute.BasicFileAttributes> A readAttributes(File file, java.lang.Class<A> type)
Returns attributes of the given file as an object of the given type.- Throws:
java.lang.UnsupportedOperationException
- if the given attributes type is not supported
-
readAll
private static void readAll(File file, AttributeProvider provider, java.util.Map<java.lang.String,java.lang.Object> map)
-
getViewName
private static java.lang.String getViewName(java.lang.String attribute)
-
getAttributeNames
private static com.google.common.collect.ImmutableList<java.lang.String> getAttributeNames(java.lang.String attributes)
-
getSingleAttribute
private static java.lang.String getSingleAttribute(java.lang.String attribute)
-
-