/*****************************************************************************/
/* File name: RegularFileSystem.java                                         */
/* Purpose: to represent a regular filesystem i.e. the filesystem that       */
/*          Java already knows about                                         */
/*                                                                           */
/* Last modified: 19.08.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*                                                                           */
/* This program is distributed in the hope that it will be useful, but       */
/* WITHOUT ANY WARRANTY; without even the implied warranty of                */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General */
/* Public License for more details.                                          */
/*                                                                           */
/* This software is distributed under the terms                              */
/* of the GNU General Public License as published                            */
/* by the Free Software Foundation; either version 2, or (at your option)    */
/* any later version.                                                        */
/* See file COPYING for your rights (GNU GPL)                                */
/*****************************************************************************/

package io;


import java.io.*;
import java.lang.reflect.*;


public
class

RegularFileSystem
                   implements FileSystemable,
                              Serializable
{

  private final static java.lang.String RCSID =
"$Header: /d/NFS/io/RCS/RegularFileSystem.java,v 1.3 1999/08/20 01:47:45 vklimov Exp $";


  protected java.lang.String path = null;
  protected Class   fileableClass = null;


  public

  RegularFileSystem( java.lang.String path ) throws NullPointerException
/*****************************************************************************/
/* Function name: RegularFileSystem                                          */
/* File name: RegularFileSystem.java                                         */
/* Purpose: constructor for the RegularFileSystem class                      */
/* Parameters: path                                                          */
/* Throws: NullPointerException                                              */
/* Returns:                                                                  */
/* Last modified: 20.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
                                                    /* RegularFileSystem */
/*---------------------------------------------------------------------------*/

      if (path == null)
        throw new NullPointerException();              /* throw ! */
      else
        {
          this.path = path;
          fileableClass = java.io.File.class;
        }
    /*end of if on null argument to the constructor*/

    }
/*end of RegularFileSystem*/


  public
  Class

  getFileClass()
/*****************************************************************************/
/* Function name: getFileClass                                               */
/* File name: RegularFileSystem.java                                         */
/* Purpose: to return a Class object to be used as an equivalent             */
/*          of the java.io.File class                                        */
/* Parameters:                                                               */
/* Returns: the Class object or null if the filesystem is not known or       */
/*          does not exist or in case of some other error                    */
/* Last modified: 19.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
                                                        /* getFileClass */
/*---------------------------------------------------------------------------*/

      return fileableClass;

    }
/*end of getFileClass*/


  public
  Filable

  getFilableInstance( java.lang.String path )
/*****************************************************************************/
/* Function name: getFilableInstance                                         */
/* File name: RegularFileSystem.java                                         */
/* Purpose: to return an instance of Filable object to be used               */
/*          as an equivalent of the java.io.File class                       */
/* Parameters: path                                                          */
/* Returns: the Filable object or null if the filesystem is not known or     */
/*          does not exist or in case of some other error                    */
/* Last modified: 19.08.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      Filable result = null;
                                                  /* getFilableInstance */
/*---------------------------------------------------------------------------*/

      try
        {
          result = (Filable) new RegularFile( path );
        }
      catch( NullPointerException e )
        {
          System.out.println( "RegularFileSystem, " +
                              "getFilableInstance: " +
                              "NullPointerException!\n" +
                              e.getMessage()               );
          e.printStackTrace( System.out );
        }
    /*end of try-catch*/

      return result;

    }
/*end of getFilableInstance*/


  public
  java.lang.String

  toString()
/*****************************************************************************/
/* Function name: toString                                                   */
/* File name: RegularFileSystem.java                                         */
/* Purpose: to represent this object as a string                             */
/* Parameters:                                                               */
/* Returns: the string representing this object                              */
/* Last modified: 19.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      java.lang.String result = "";
                                                        /* getFileClass */
/*---------------------------------------------------------------------------*/

      result += ( (path == null) ?
                         "path is null" :
                         "path is " + path
                );
      result += ( (fileableClass == null) ?
                  "fileableClass is null" :
                  "fileableClass is " +
                  fileableClass.getName()
                );

      return result;

    }
/*end of getFileClass*/


} /*end of RegularFileSystem */

/*****************************************************************************/
/* End of file: RegularFileSystem.java                                       */
/*****************************************************************************/
