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 classSimple implementation ofFileAttribute. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final com.google.common.base.Splitterprivate 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 voidaddMissingProviders(Map<String, AttributeProvider> providers) private static voidaddStandardProvider(Map<String, AttributeProvider> result, String view) voidcopyAttributes(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 voidcreateInheritedViews(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 ObjectgetAttributeInternal(File file, String view, String attribute) private static com.google.common.collect.ImmutableList<String> getAttributeNames(String attributes) private FileAttributeViewgetFileAttributeView(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, ornullif the view type is not supported.private static Iterable<AttributeProvider> getProviders(Configuration configuration) private static StringgetSingleAttribute(String attribute) private static StringgetViewName(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) voidsetAttribute(File file, String attribute, Object value, boolean create) Sets the value of the given attribute to the given value for the given file.private voidsetAttributeInternal(File file, String view, String attribute, Object value, boolean create) voidsetInitialAttributes(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().booleansupportsFileAttributeView(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
-
getAttribute
-
getAttributeInternal
-
setAttribute
-
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, ornullif 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
-