private synchronized Properties buildProperties(boolean includesNonSerializable) { final Properties properties = new Properties(content); for (final Map.Entry<String, AttributeView> view : viewsNameIndex.entrySet()) { if (includesNonSerializable || view.getValue() instanceof ExtendedAttributeView && ((ExtendedAttributeView) view.getValue()).isSerializable()) { final ExtendedAttributeView extendedView = (ExtendedAttributeView) view.getValue(); for (final Map.Entry<String, Object> attr : extendedView.readAllAttributes().entrySet()) { properties.put(attr.getKey(), attr.getValue()); } } } return properties; } }
@Override public <V extends AttributeView> void addAttrView(final V view) { viewsNameIndex.put(view.name(), view); if (view instanceof ExtendedAttributeView) { final ExtendedAttributeView extendedView = (ExtendedAttributeView) view; for (Class<? extends BasicFileAttributeView> type : extendedView.viewTypes()) { viewsTypeIndex.put(type, view); } } else { viewsTypeIndex.put(view.getClass(), view); } }
@Override public void setAttribute(final Path path, final String attribute, final Object value, final LinkOption... options) throws UnsupportedOperationException, IllegalArgumentException, ClassCastException, IOException, SecurityException { checkNotNull("path", path); checkNotEmpty("attributes", attribute); final String[] s = split(attribute); if (s[0].length() == 0) { throw new IllegalArgumentException(attribute); } final ExtendedAttributeView view = getFileAttributeView(path, s[0], options); if (view == null) { throw new UnsupportedOperationException("View '" + s[0] + "' not available"); } view.setAttribute(attribute, value); }
@Override public Map<String, Object> readAttributes(final Path path, final String attributes, final LinkOption... options) throws UnsupportedOperationException, IllegalArgumentException, IOException, SecurityException { checkNotNull("path", path); checkNotEmpty("attributes", attributes); final String[] s = split(attributes); if (s[0].length() == 0) { throw new IllegalArgumentException(attributes); } final ExtendedAttributeView view = getFileAttributeView(path, s[0], options); if (view == null) { throw new UnsupportedOperationException("View '" + s[0] + "' not available"); } return view.readAttributes(s[1].split(",")); }
@Override public void setAttribute(final Path path, final String attribute, final Object value, final LinkOption... options) throws UnsupportedOperationException, IllegalArgumentException, ClassCastException, IOException, SecurityException { checkNotNull("path", path); checkNotEmpty("attributes", attribute); final String[] s = split(attribute); if (s[0].length() == 0) { throw new IllegalArgumentException(attribute); } final ExtendedAttributeView view = getFileAttributeView(path, s[0], options); if (view == null) { throw new UnsupportedOperationException("View '" + s[0] + "' not available"); } view.setAttribute(attribute, value); }
@Override public Map<String, Object> readAttributes(final Path path, final String attributes, final LinkOption... options) throws UnsupportedOperationException, IllegalArgumentException, IOException, SecurityException { checkNotNull("path", path); checkNotEmpty("attributes", attributes); final String[] s = split(attributes); if (s[0].length() == 0) { throw new IllegalArgumentException(attributes); } final ExtendedAttributeView view = getFileAttributeView(path, s[0], options); if (view == null) { throw new UnsupportedOperationException("View '" + s[0] + "' not available"); } return view.readAttributes(s[1].split(",")); }
view.setAttribute(s[1], value);
return view.readAttributes(s[1].split(","));
private synchronized Properties buildProperties(boolean includesNonSerializable) { final Properties properties = new Properties(content); for (final Map.Entry<String, AttributeView> view : viewsNameIndex.entrySet()) { if (includesNonSerializable || view.getValue() instanceof ExtendedAttributeView && ((ExtendedAttributeView) view.getValue()).isSerializable()) { final ExtendedAttributeView extendedView = (ExtendedAttributeView) view.getValue(); for (final Map.Entry<String, Object> attr : extendedView.readAllAttributes().entrySet()) { properties.put(attr.getKey(), attr.getValue()); } } } return properties; } }
@Override public <V extends AttributeView> void addAttrView(final V view) { viewsNameIndex.put(view.name(), view); if (view instanceof ExtendedAttributeView) { final ExtendedAttributeView extendedView = (ExtendedAttributeView) view; for (Class<? extends BasicFileAttributeView> type : extendedView.viewTypes()) { viewsTypeIndex.put(type, view); } } else { viewsTypeIndex.put(view.getClass(), view); } }