< prev index next >

src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  56         }
  57         return s;
  58     }
  59 
  60     /**
  61      * Gets a DynamicFileAttributeView by name. Returns {@code null} if the
  62      * view is not available.
  63      */
  64     abstract DynamicFileAttributeView getFileAttributeView(Path file,
  65                                                            String name,
  66                                                            LinkOption... options);
  67 
  68     @Override
  69     public final void setAttribute(Path file,
  70                                    String attribute,
  71                                    Object value,
  72                                    LinkOption... options)
  73         throws IOException
  74     {
  75         String[] s = split(attribute);
  76         if (s[0].length() == 0)
  77             throw new IllegalArgumentException(attribute);
  78         DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
  79         if (view == null)
  80             throw new UnsupportedOperationException("View '" + s[0] + "' not available");
  81         view.setAttribute(s[1], value);
  82     }
  83 
  84     @Override
  85     public final Map<String,Object> readAttributes(Path file, String attributes, LinkOption... options)
  86         throws IOException
  87     {
  88         String[] s = split(attributes);
  89         if (s[0].length() == 0)
  90             throw new IllegalArgumentException(attributes);
  91         DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
  92         if (view == null)
  93             throw new UnsupportedOperationException("View '" + s[0] + "' not available");
  94         return view.readAttributes(s[1].split(","));
  95     }
  96 
  97     /**
  98      * Deletes a file. The {@code failIfNotExists} parameters determines if an
  99      * {@code IOException} is thrown when the file does not exist.
 100      */
 101     abstract boolean implDelete(Path file, boolean failIfNotExists) throws IOException;
 102 
 103     @Override
 104     public final void delete(Path file) throws IOException {
 105         implDelete(file, true);
 106     }
 107 
 108     @Override
 109     public final boolean deleteIfExists(Path file) throws IOException {




  56         }
  57         return s;
  58     }
  59 
  60     /**
  61      * Gets a DynamicFileAttributeView by name. Returns {@code null} if the
  62      * view is not available.
  63      */
  64     abstract DynamicFileAttributeView getFileAttributeView(Path file,
  65                                                            String name,
  66                                                            LinkOption... options);
  67 
  68     @Override
  69     public final void setAttribute(Path file,
  70                                    String attribute,
  71                                    Object value,
  72                                    LinkOption... options)
  73         throws IOException
  74     {
  75         String[] s = split(attribute);
  76         if (s[0].isEmpty())
  77             throw new IllegalArgumentException(attribute);
  78         DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
  79         if (view == null)
  80             throw new UnsupportedOperationException("View '" + s[0] + "' not available");
  81         view.setAttribute(s[1], value);
  82     }
  83 
  84     @Override
  85     public final Map<String,Object> readAttributes(Path file, String attributes, LinkOption... options)
  86         throws IOException
  87     {
  88         String[] s = split(attributes);
  89         if (s[0].isEmpty())
  90             throw new IllegalArgumentException(attributes);
  91         DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
  92         if (view == null)
  93             throw new UnsupportedOperationException("View '" + s[0] + "' not available");
  94         return view.readAttributes(s[1].split(","));
  95     }
  96 
  97     /**
  98      * Deletes a file. The {@code failIfNotExists} parameters determines if an
  99      * {@code IOException} is thrown when the file does not exist.
 100      */
 101     abstract boolean implDelete(Path file, boolean failIfNotExists) throws IOException;
 102 
 103     @Override
 104     public final void delete(Path file) throws IOException {
 105         implDelete(file, true);
 106     }
 107 
 108     @Override
 109     public final boolean deleteIfExists(Path file) throws IOException {


< prev index next >