FileDocCategorySizeDatePackage
ClassFileFinder.javaAPI DocphoneME MR2 API (J2ME)4763Wed May 02 17:59:48 BST 2007util

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);