src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java

Print this page




  41 
  42     private final FileAttributeView view;
  43     private final boolean isPosixView;
  44 
  45     FileOwnerAttributeViewImpl(PosixFileAttributeView view) {
  46         this.view = view;
  47         this.isPosixView = true;
  48     }
  49 
  50     FileOwnerAttributeViewImpl(AclFileAttributeView view) {
  51         this.view = view;
  52         this.isPosixView = false;
  53     }
  54 
  55     @Override
  56     public String name() {
  57         return "owner";
  58     }
  59 
  60     @Override
  61     public Object getAttribute(String attribute) throws IOException {
  62         if (attribute.equals(OWNER_NAME))
  63             return getOwner();
  64         return null;
  65     }
  66 
  67     @Override
  68     public void setAttribute(String attribute, Object value)
  69         throws IOException
  70     {
  71         if (attribute.equals(OWNER_NAME)) {
  72             setOwner((UserPrincipal)value);
  73             return;
  74         }
  75         throw new UnsupportedOperationException("'" + name() + ":" +
  76                 attribute + "' not supported");
  77     }
  78 
  79     @Override
  80     public Map<String,?> readAttributes(String[] attributes) throws IOException {
  81         Map<String,Object> result = new HashMap<String,Object>();
  82         for (String attribute: attributes) {
  83             if (attribute.equals("*") || attribute.equals(OWNER_NAME)) {
  84                 result.put(OWNER_NAME, getOwner());
  85             }
  86         }
  87         return result;
  88     }
  89 
  90     @Override
  91     public UserPrincipal getOwner() throws IOException {
  92         if (isPosixView) {
  93             return ((PosixFileAttributeView)view).readAttributes().owner();
  94         } else {
  95             return ((AclFileAttributeView)view).getOwner();
  96         }
  97     }
  98 
  99     @Override
 100     public void setOwner(UserPrincipal owner)
 101         throws IOException


  41 
  42     private final FileAttributeView view;
  43     private final boolean isPosixView;
  44 
  45     FileOwnerAttributeViewImpl(PosixFileAttributeView view) {
  46         this.view = view;
  47         this.isPosixView = true;
  48     }
  49 
  50     FileOwnerAttributeViewImpl(AclFileAttributeView view) {
  51         this.view = view;
  52         this.isPosixView = false;
  53     }
  54 
  55     @Override
  56     public String name() {
  57         return "owner";
  58     }
  59 
  60     @Override







  61     public void setAttribute(String attribute, Object value)
  62         throws IOException
  63     {
  64         if (attribute.equals(OWNER_NAME)) {
  65             setOwner((UserPrincipal)value);
  66             return;
  67         }
  68         throw new UnsupportedOperationException("'" + name() + ":" +
  69                 attribute + "' not supported");
  70     }
  71 
  72     @Override
  73     public Map<String,Object> readAttributes(String[] attributes) throws IOException {
  74         Map<String,Object> result = new HashMap<>();
  75         for (String attribute: attributes) {
  76             if (attribute.equals("*") || attribute.equals(OWNER_NAME)) {
  77                 result.put(OWNER_NAME, getOwner());
  78             }
  79         }
  80         return result;
  81     }
  82 
  83     @Override
  84     public UserPrincipal getOwner() throws IOException {
  85         if (isPosixView) {
  86             return ((PosixFileAttributeView)view).readAttributes().owner();
  87         } else {
  88             return ((AclFileAttributeView)view).getOwner();
  89         }
  90     }
  91 
  92     @Override
  93     public void setOwner(UserPrincipal owner)
  94         throws IOException