src/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java
Print this page
*** 57,82 ****
@Override
public final String name() {
return "user";
}
- private Object getAttribute(String attribute) throws IOException {
- int size;
- try {
- size = size(attribute);
- } catch (IOException e) {
- // not found or some other I/O error
- if (list().contains(attribute))
- throw e;
- return null;
- }
-
- byte[] buf = new byte[size];
- int n = read(attribute, ByteBuffer.wrap(buf));
- return (n == size) ? buf : Arrays.copyOf(buf, n);
- }
-
@Override
public final void setAttribute(String attribute, Object value)
throws IOException
{
ByteBuffer bb;
--- 57,66 ----
*** 92,117 ****
public final Map<String,Object> readAttributes(String[] attributes)
throws IOException
{
// names of attributes to return
List<String> names = new ArrayList<>();
-
for (String name: attributes) {
if (name.equals("*")) {
names = list();
break;
} else {
names.add(name);
}
}
// read each value and return in map
Map<String,Object> result = new HashMap<>();
for (String name: names) {
! Object value = getAttribute(name);
! if (value != null)
result.put(name, value);
}
-
return result;
}
}
--- 76,103 ----
public final Map<String,Object> readAttributes(String[] attributes)
throws IOException
{
// names of attributes to return
List<String> names = new ArrayList<>();
for (String name: attributes) {
if (name.equals("*")) {
names = list();
break;
} else {
+ if (name.length() == 0)
+ throw new IllegalArgumentException();
names.add(name);
}
}
// read each value and return in map
Map<String,Object> result = new HashMap<>();
for (String name: names) {
! int size = size(name);
! byte[] buf = new byte[size];
! int n = read(name, ByteBuffer.wrap(buf));
! byte[] value = (n == size) ? buf : Arrays.copyOf(buf, n);
result.put(name, value);
}
return result;
}
}