public abstract class AttributeProvider extends Object
Constructor and Description |
---|
AttributeProvider() |
Modifier and Type | Method and Description |
---|---|
com.google.common.collect.ImmutableSet<String> |
attributes(File file)
Returns the set of attributes supported by this view that are present in the given file.
|
Class<? extends BasicFileAttributes> |
attributesType()
Returns the type of file attributes object this provider supports, or null if it doesn't
support reading its attributes as an object.
|
protected static void |
checkNotCreate(String view,
String attribute,
boolean create)
Checks that the attribute is not being set by the user on file creation, throwing an
unsupported operation exception if it is.
|
protected static <T> T |
checkType(String view,
String attribute,
Object value,
Class<T> type)
Checks that the given value is of the given type, returning the value if so and throwing an
exception if not.
|
com.google.common.collect.ImmutableMap<String,?> |
defaultValues(Map<String,?> userDefaults)
Returns a map containing the default attribute values for this provider.
|
abstract com.google.common.collect.ImmutableSet<String> |
fixedAttributes()
Returns the set of attributes that are always available from this provider.
|
abstract Object |
get(File file,
String attribute)
Returns the value of the given attribute in the given file or null if the attribute is not
supported by this provider.
|
com.google.common.collect.ImmutableSet<String> |
inherits()
Returns the names of other providers that this provider inherits attributes from.
|
protected static IllegalArgumentException |
invalidType(String view,
String attribute,
Object value,
Class<?>... expectedTypes)
Throws an illegal argument exception indicating that the given value is not one of the
expected types for the given attribute.
|
abstract String |
name()
Returns the view name that's used to get attributes from this provider.
|
BasicFileAttributes |
readAttributes(File file)
Reads this provider's attributes from the given file as an attributes object.
|
abstract void |
set(File file,
String view,
String attribute,
Object value,
boolean create)
Sets the value of the given attribute in the given file object.
|
boolean |
supports(String attribute)
Returns whether or not this provider supports the given attribute directly.
|
protected static IllegalArgumentException |
unsettable(String view,
String attribute)
Throws an illegal argument exception indicating that the given attribute cannot be set.
|
abstract FileAttributeView |
view(FileLookup lookup,
com.google.common.collect.ImmutableMap<String,FileAttributeView> inheritedViews)
Returns a view of the file located by the given lookup callback.
|
abstract Class<? extends FileAttributeView> |
viewType()
Returns the type of the view interface that this provider supports.
|
public abstract String name()
public com.google.common.collect.ImmutableSet<String> inherits()
public abstract Class<? extends FileAttributeView> viewType()
public abstract FileAttributeView view(FileLookup lookup, com.google.common.collect.ImmutableMap<String,FileAttributeView> inheritedViews)
public com.google.common.collect.ImmutableMap<String,?> defaultValues(Map<String,?> userDefaults)
The given map should be in the same format and contains user-provided default values. If the user provided any default values for attributes handled by this provider, those values should be checked to ensure they are of the correct type. Additionally, if any changes to a user-provided attribute are necessary (for example, creating an immutable defensive copy), that should be done. The resulting values should be included in the result map along with default values for any attributes the user did not provide a value for.
public abstract com.google.common.collect.ImmutableSet<String> fixedAttributes()
public boolean supports(String attribute)
public com.google.common.collect.ImmutableSet<String> attributes(File file)
@Nullable public abstract Object get(File file, String attribute)
public abstract void set(File file, String view, String attribute, Object value, boolean create)
create
parameter indicates whether or not the value is being set upon creation of a new file via a
user-provided FileAttribute
.IllegalArgumentException
- if the given attribute is one supported by this provider but
it is not allowed to be set by the userUnsupportedOperationException
- if the given attribute is one supported by this provider
and is allowed to be set by the user, but not on file creation and create
is true@Nullable public Class<? extends BasicFileAttributes> attributesType()
public BasicFileAttributes readAttributes(File file)
UnsupportedOperationException
- if this provider does not support reading an attributes
objectprotected static IllegalArgumentException unsettable(String view, String attribute)
protected static void checkNotCreate(String view, String attribute, boolean create)
protected static <T> T checkType(String view, String attribute, Object value, Class<T> type)
protected static IllegalArgumentException invalidType(String view, String attribute, Object value, Class<?>... expectedTypes)
Copyright © 2013–2017 Google Inc.. All rights reserved.