001    /* Copyright 2000, 2001, Compaq Computer Corporation */
002    
003    package javafe.filespace;
004    
005    
006    import java.util.Enumeration;
007    import javafe.genericfile.*;
008    
009    
010    /**
011     * This module defines a very simple query interface for use in
012     * locating Java files according to a classpath.
013     */
014    
015    public abstract class Query {
016    
017        /***************************************************
018         *                                                 *
019         * Locating files:                                 *
020         *                                                 *
021         **************************************************/
022    
023        /**
024         * Return true iff the package P in the Java filespace is
025         * "accessible".<p>
026         *
027         * Warning: the definition of accessible is host system dependent
028         * and may in fact be defined as always true.<p>
029         */
030        //@ requires P != null;
031        //@ requires \nonnullelements(P);
032        public boolean accessable(String[] P) {
033            return true;
034        }
035    
036    
037        /**
038         * Attempt to locate the file typename+"."+extension in the package
039         * P in the Java filespace.<p>
040         *
041         * If such a file is found, then a (non-null) GenericFile
042         * representing it is returned.  Otherwise, null is returned.<p>
043         */
044        //@ requires P != null;
045        //@ requires typename != null;
046        //@ requires extension != null;
047        //@ requires \nonnullelements(P);
048        public abstract GenericFile findFile(String[] P, String typename,
049                                            String extension);
050    
051        //@ requires P != null;
052        //@ requires filename != null;
053        public abstract GenericFile findFile(String[] P, String filename);
054    
055        /** Locates a file with given package, typename, and one of the given
056          * extensions; the first directory on the search path containing a 
057          * candidate file is used - within that directory, extensions near the
058          * beginning of the extensions Vector take precedence.
059          */
060        //@ requires P != null;
061        //@ requires typename != null;
062        //@ requires extensions != null;
063        public abstract GenericFile findFile(String[] P, String typename,
064                                            String[] extensions);
065    
066    
067        /** Returns an Enumeration containing GenericFile objects representing
068            all the files in the given package P.
069        */
070        //@ requires P != null;
071        public abstract Enumeration findFiles(String[] P);
072    
073        /***************************************************
074         *                                                 *
075         * Checking class/interface existence:             *
076         *                                                 *
077         **************************************************/
078    
079        /**
080         * Return true iff the fully-qualified outside type P.T exists in
081         * our Java file space.
082         */
083        //@ requires P != null;
084        //@ requires \nonnullelements(P);
085        public boolean exists(String[] P, String T) {
086            return (findFile(P, T, "java") != null)
087                || (findFile(P, T, "class") != null);
088        }
089    }