jdk/src/share/classes/java/nio/file/attribute/AttributeView.java
changeset 2057 3acf8e5e2ca0
child 2072 80dfe4469bbd
equal deleted inserted replaced
2056:115e09b7a004 2057:3acf8e5e2ca0
       
     1 /*
       
     2  * Copyright 2007-2009 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 package java.nio.file.attribute;
       
    27 
       
    28 import java.util.*;
       
    29 import java.io.IOException;
       
    30 
       
    31 /**
       
    32  * An object that provides a read-only or updatable <em>view</em> of non-opaque
       
    33  * values associated with an object in a filesystem. This interface is extended
       
    34  * or implemented by specific attribute views that define the attributes
       
    35  * supported by the view. A specific attribute view will typically define
       
    36  * type-safe methods to read or update the attributes that it supports. It also
       
    37  * provides <em>dynamic access</em> where the {@link #readAttributes
       
    38  * readAttributes}, {@link #getAttribute getAttribute} and {@link #setAttribute
       
    39  * setAttributs} methods are used to access the attributes by names defined
       
    40  * by the attribute view. Implementations must ensure that the attribute names
       
    41  * do not contain the colon (':') or comma (',') characters.
       
    42  *
       
    43  * @since 1.7
       
    44  */
       
    45 
       
    46 public interface AttributeView {
       
    47     /**
       
    48      * Returns the name of the attribute view.
       
    49      */
       
    50     String name();
       
    51 
       
    52     /**
       
    53      * Reads the value of an attribute.
       
    54      *
       
    55      * @param   attribute
       
    56      *          The attribute name (case sensitive)
       
    57      *
       
    58      * @return  The value of the attribute, or {@code null} if the attribute is
       
    59      *          not supported
       
    60      *
       
    61      * @throws  IOException
       
    62      *          If an I/O error occurs
       
    63      * @throws  SecurityException
       
    64      *          If a security manager is set and it denies access
       
    65      */
       
    66     Object getAttribute(String attribute) throws IOException;
       
    67 
       
    68     /**
       
    69      * Sets/updates the value of an attribute.
       
    70      *
       
    71      * @param   attribute
       
    72      *          The attribute name (case sensitive)
       
    73      * @param   value
       
    74      *          The attribute value
       
    75      *
       
    76      * @throws  UnsupportedOperationException
       
    77      *          If the attribute is not supported or this attribute view does
       
    78      *          not support updating the value of the attribute
       
    79      * @throws  IllegalArgumentException
       
    80      *          If the attribute value is of the correct type but has an
       
    81      *          inappropriate value
       
    82      * @throws  ClassCastException
       
    83      *          If the attribute value is not of the expected type or is a
       
    84      *          collection containing elements that are not of the expected
       
    85      *          type
       
    86      * @throws  IOException
       
    87      *          If an I/O error occurs
       
    88      * @throws  SecurityException
       
    89      *          If a security manager is set and it denies access
       
    90      */
       
    91     void setAttribute(String attribute, Object value) throws IOException;
       
    92 
       
    93     /**
       
    94      * Reads all, or a subset, of the attributes supported by this file attribute
       
    95      * view.
       
    96      *
       
    97      * <p> The {@code first} and {@code rest} parameters are the names of the
       
    98      * attributes to read. If any of the parameters has the value {@code "*"}
       
    99      * then all attributes are read. Attributes that are not supported are
       
   100      * ignored and will not be present in the returned map. It is implementation
       
   101      * specific if all attributes are read as an atomic operation with respect
       
   102      * to other file system operations.
       
   103      *
       
   104      * @param   first
       
   105      *          The name of an attribute to read (case sensitive)
       
   106      * @param   rest
       
   107      *          The names of others attributes to read (case sensitive)
       
   108      *
       
   109      * @return  An unmodifiable map of the attributes; may be empty. Its keys are
       
   110      *          the attribute names, its values are the attribute values
       
   111      *
       
   112      * @throws  IOException
       
   113      *          If an I/O error occurs
       
   114      * @throws  SecurityException
       
   115      *          If a security manager is set and it denies access
       
   116      */
       
   117     Map<String,?> readAttributes(String first, String... rest) throws IOException;
       
   118 }