//*******************************************************************
//
//   Protections.java          In Text          Definitions only
//
//   Authors:  Lewis and Loftus
//
//   Classes:  Protections
//
//   Interfaces:  File_Protection
//                Extended_File_Protection
//
//*******************************************************************


//-------------------------------------------------------------------
//
//  Interface File_Protection defines several constants used to
//  determine the access permissions on files.
//
//-------------------------------------------------------------------

interface File_Protection {

   //  Indicates that the file can be executed.
   int EXECUTE = 2;

   //  Indicates that the file can be read from.
   int READ = 4;

   //  Indicates that the file can be written to.
   int WRITE = 6;

} // interface File_Protection

//-------------------------------------------------------------------
//
//  Class Protections defines some utility routines to determine
//  protections.
//
//  Methods:
//
//     public boolean is_readable (int protection)
//     public boolean is_writable (int protection)
//     public boolean is_executable (int protection)
//
//-------------------------------------------------------------------

class Protections implements File_Protection {

   //===========================================================
   //  Returns true if the file can be read from.
   //===========================================================
   public boolean is_readable (int protection) {
      return (protection == READ);
   } // method is_readable

   //===========================================================
   //  Returns true if the file can be written to.
   //===========================================================
   public boolean is_writable (int protection) {
      return (protection == WRITE);
   } // method is_writable

   //===========================================================
   //  Returns true if the file can be executed.
   //===========================================================
   public boolean is_executable (int protection) {
      return (protection == EXECUTE);
   } // method is_executable

} // class Protections

//-------------------------------------------------------------------
//
//  Interface Extended_File_Protection demonstrates the ability to
//  derive one interface from another.
//
//-------------------------------------------------------------------

interface Extended_File_Protection extends File_Protection {

   //  Indicates that the file has an access control list.
   int ACL = 4;

   //  Indicates that the file can be deleted.
   int DELETE = 5;

   //  Indicates that the file can be copied.
   int COPY = 6;

}  // interface Extended_File_Protection


