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