 /*______________________________________________________________________________
                                                       WWS Coding Team

    FileDirectoryStrategy.java
      7/31/98

      A File and Directory Traversal strategy.
      
      Developed by:     David Wagstaff
                        Jeff Sabin

      Disclaimer:

            This program is an unpublished copyrighted work which is proprietary
            to Novell, Inc. and contains confidential information that is not
            to be reproduced or disclosed to any other person or entity without
            prior written consent from Novell, Inc. in each and every instance.

            WARNING:  Unauthorized reproduction of this program as well as
            unauthorized preparation of derivative works based upon the
            program or distribution of copies by sale, rental, lease or
            lending are violations of federal copyright laws and state trade
            secret laws, punishable by civil and criminal penalties.

______________________________________________________________________________*/

import java.io.File;

/**
  *
  * A File and Directory Traversal strategy.
  * 
  * @version 1.0 7/31/98
  * @author Jeff Sabin/David Wagstaff
  *
  */
class FileDirectoryStrategy implements Strategy
	{
	public void FileDirectoryStrategy() {}
							
	public boolean hasMoreChildren(Object o)
		{
		if (o instanceof Dir)
			return ((Dir)o).filesLeft > 0;
		return false;
		}

	public Object nextChild(Object o)
		{
		if (o instanceof Dir)
			{
			Dir d=(Dir)o;
			File f=new File(d,d.fileList[--d.filesLeft]);
			if (f.isFile())                              
 				return f;                                 
 			if (f.isDirectory())                          
 				return new Dir(d,d.fileList[d.filesLeft]);
 			} 
 		//not directory, not file, what is it?        
 		return null;
		}
	} 

