FileDocCategorySizeDatePackage
ClassFileFinder.javaAPI DocJ2ME CLDC 1.14266Wed Feb 05 15:56:02 GMT 2003util

searchPathComponent

public class searchPathComponent extends Object

Fields Summary
public String
name
public boolean
isDirectory
public boolean
isZip
public ZipFile
zipfile
public searchPathComponent
next
Constructors Summary
searchPathComponent(String name)

    this.name = name;
    File thisFile = new File( name );
    if ( thisFile.exists() ){
        if ( thisFile.isDirectory() ){
        this.isDirectory = true;
        } else {
        // try to open it as a zip file.
        // if the open succeeds, it is a zip file.
        // else we are in error.
        try {
            this.zipfile = new ZipFile( thisFile );
            this.isZip   = true;
        }catch( java.io.IOException e ){
            return;
        }
        }
    }
    //
    // else it is none of the above.
    // this is an error.
    // we do not prevent putting erroneous components
    // on the path.
    //
    
Methods Summary
java.io.InputStreamfind(java.lang.String name)

    try {
        if ( isDirectory ){
        File thisFile = new File( this.name, name );
        if ( thisFile.exists() && thisFile.canRead() ){
            return new BufferedInputStream( new FileInputStream( thisFile ) );
        }
        } else if ( isZip ){
        ZipEntry ze = this.zipfile.getEntry( name );
        if ( ze != null )
            return new BufferedInputStream( this.zipfile.getInputStream( ze ) );
        }
    } catch ( IOException e ){
        return null;
    }
    return null;
    
public java.lang.StringtoString()

    return
        Localizer.getString(isDirectory?"classfilefinder.directory":isZip?"classfilefinder.zipfile":"classfilefinder.path_noop", this.name);