jpl.mipl.mars.viewer.finder
Class AbstractMarsImageFileFinder

java.lang.Object
  extended by jpl.mipl.mars.viewer.finder.AbstractMarsImageFileFinder
All Implemented Interfaces:
MarsImageFileFinder, MissionSpecFileInfo
Direct Known Subclasses:
MerImageFileFinder, PhxImageFileFinder

public abstract class AbstractMarsImageFileFinder
extends Object
implements MarsImageFileFinder

Purpose: Abstract class used to find RDR's related to a particular EDR. Subclasses implement different heirarchical organizations of the file system.

   Copyright 2003, California Institute of Technology.
   ALL RIGHTS RESERVED.
   U.S. Government Sponsorship acknowledge. 2003.
   
 ============================================================================
 Modification History :
 ----------------------

 Date              Who         What
 ----------------------------------------------------------------------------
 08/23/2003        Nick        Initial Release
 12/01/2003        Nick        Added getType() method.
 11/21/2005        Nick        Removed propChange(), filterProducts           
 ============================================================================
 

Version:
$Id: AbstractMarsImageFileFinder.java,v 1.8 2007/09/27 23:35:03 ntt Exp $
Author:
Nicholas Toole (Nicholas.T.Toole@jpl.nasa.gov)

Field Summary
protected  Comparator _comparator
           
protected  GroupIdentifier _groupIdentifier
           
protected  List _solRange
           
protected  File _treeRoot
           
protected  String _treeRootStr
          Reference to the root of the directory structure
protected static String SOL_NOT_APPLICABLE
           
 
Fields inherited from interface jpl.mipl.mars.viewer.finder.MarsImageFileFinder
SLASH
 
Constructor Summary
AbstractMarsImageFileFinder(String newRoot)
          Constructor.
 
Method Summary
 boolean equals(Object other)
          Returns true if this object and other is of same class type and have the same root.
abstract  String extractEyeType(String imgPath, short type)
          Returns the camera eye type as denoted by the file organization and the imgPath parameter.
 String extractFilename(String path)
          Returns the basename of a filepath, ie returns filename from filepath
abstract  String extractImageType(String imgPath, short type)
          Returns the image type as denoted by the file organization and the imgPath parameter.
abstract  List extractImageTypes(List imgPaths, short type)
          Returns the image types as denoted by the file organization and the imgPath parameters.
abstract  String extractInstrument(String imgPath, short type)
          Returns the instrument type as denoted by the file organization and the imgPath parameter.
 String formatSol(int sol)
          Formats the SOL as a string based on the directory structure
 String[] getCameraEyeTypes()
          Returns a String array of camera eye types.
abstract  String getEdrThumbnail(String edrPath)
          Given a complete path to an EDR, returns the associated thumbnail path, if it exists.
 String getGroupId(String imagePath)
          Many file finders have images that form a set through some special relationship (i.e.
 Comparator getImageComparator()
          Returns file finders instance of a comparator for sorting files according to some set of rules.
 String getInitialSol()
          Returns a list of the SOL range of a given file finder.
 String[] getInstrumentTypes()
          Returns a String array of instrument names.
 String[] getRdrTypes()
          Returns a String array of RDR types.
 String getRoot()
          Returns string of the root of the file organization.
 File getRootFile()
          Returns File of the root of the file organization.
 List getSolRange()
          Returns a list of the SOL range of a given file finder.
abstract  String getSourceProductPath(String rdrPath)
          Returns the path of the source EDR for nominal RDR products, or the path of the linearized version of that EDR for linearized RDR products.
abstract  String getType()
          Returns string identifier of the image file finder type.
protected  void initSolRange()
           
abstract  boolean isThumbnail(String imgFile)
          Determines if image represented by imgFile is a thumbnail.
abstract  boolean isThumbnailType(String type)
          Determines if product type represented by type is a thumbnail.
abstract  boolean isTypeNominal(String type)
          Returns true if the type parameter is raw, false otherwise (e.g.
abstract  boolean isTypeSource(String type)
          Returns true if the type parameter is source.
abstract  EdrResult queryEdrs(EdrQuery request)
          Returns an EdrResult containing image files found according to file heirarchy.
abstract  RdrResult queryRdrs(RdrQuery request)
          Returns an RdrResult containing RDR paths found according to file heirarchy based on the request.
 List removeThumbnails(List inImages)
          Given a vector of image file names, uses isThumbnail method to determine if file should be included in the returned List.
 void setRoot(String newRoot)
          Sets the root of the file organization.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jpl.mipl.mars.viewer.finder.MissionSpecFileInfo
extractSclk, extractVersion, isProductNameFormatted, isStereoPair
 

Field Detail

SOL_NOT_APPLICABLE

protected static final String SOL_NOT_APPLICABLE
See Also:
Constant Field Values

_treeRootStr

protected String _treeRootStr
Reference to the root of the directory structure


_treeRoot

protected File _treeRoot

_solRange

protected List _solRange

_comparator

protected Comparator _comparator

_groupIdentifier

protected GroupIdentifier _groupIdentifier
Constructor Detail

AbstractMarsImageFileFinder

public AbstractMarsImageFileFinder(String newRoot)
                            throws FileFinderException
Constructor.

Parameters:
newRoot - Root of the file organization
Throws:
FileFinderException - If directory specified by newRoot parameter does not exist or cannot be read.
Method Detail

setRoot

public void setRoot(String newRoot)
             throws FileFinderException
Sets the root of the file organization.

Specified by:
setRoot in interface MarsImageFileFinder
Parameters:
newRoot - Path of the root.
Throws:
FileFinderException - If directory specified by newRoot parameter does not exist or cannot be read.

getType

public abstract String getType()
Returns string identifier of the image file finder type.

Specified by:
getType in interface MarsImageFileFinder
Returns:
Root of file organinzation.

getRoot

public String getRoot()
Returns string of the root of the file organization.

Specified by:
getRoot in interface MarsImageFileFinder
Returns:
Root of file organinzation.

getRootFile

public File getRootFile()
Returns File of the root of the file organization.

Specified by:
getRootFile in interface MarsImageFileFinder
Returns:
Root of file organinzation.

queryEdrs

public abstract EdrResult queryEdrs(EdrQuery request)
                             throws FileFinderException
Returns an EdrResult containing image files found according to file heirarchy.

Specified by:
queryEdrs in interface MarsImageFileFinder
Parameters:
EdrQuery - Request object with query parameters.
Returns:
EdrResult based on query.
Throws:
FileFinderException - if file finder error occurs

queryRdrs

public abstract RdrResult queryRdrs(RdrQuery request)
                             throws FileFinderException
Returns an RdrResult containing RDR paths found according to file heirarchy based on the request.

Specified by:
queryRdrs in interface MarsImageFileFinder
Parameters:
RdrQuery - Request object with query parameters.
Returns:
RdrResult based on query.
Throws:
FileFinderException - if file finder error occurs

extractFilename

public String extractFilename(String path)
Returns the basename of a filepath, ie returns filename from filepath

Specified by:
extractFilename in interface MissionSpecFileInfo
Parameters:
path - Filepath of the file whose name is to be extracted.
Returns:
Base name of the file represented by path

extractInstrument

public abstract String extractInstrument(String imgPath,
                                         short type)
Returns the instrument type as denoted by the file organization and the imgPath parameter.

Specified by:
extractInstrument in interface MissionSpecFileInfo
Parameters:
imgPath - Complete path of the edr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Instrument as determined by organization. Null if cannot be determined.

extractImageType

public abstract String extractImageType(String imgPath,
                                        short type)
Returns the image type as denoted by the file organization and the imgPath parameter.

Specified by:
extractImageType in interface MissionSpecFileInfo
Parameters:
imgPath - Complete path of the edr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Image type as determined by filename and org. Null if cannot be determined.

extractImageTypes

public abstract List extractImageTypes(List imgPaths,
                                       short type)
Returns the image types as denoted by the file organization and the imgPath parameters.

Specified by:
extractImageTypes in interface MissionSpecFileInfo
Parameters:
imgPaths - List of paths of the edr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Lisy of image types as determined by filename and org.

extractEyeType

public abstract String extractEyeType(String imgPath,
                                      short type)
Returns the camera eye type as denoted by the file organization and the imgPath parameter.

Specified by:
extractEyeType in interface MissionSpecFileInfo
Parameters:
imgPath - Complete path of the edr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Camera eye type as determined by organization.

isThumbnail

public abstract boolean isThumbnail(String imgFile)
Determines if image represented by imgFile is a thumbnail.

Specified by:
isThumbnail in interface MissionSpecFileInfo
Parameters:
imgFile - Filename of the image.
Returns:
True if file is a thumbnail, false otherwise.

isThumbnailType

public abstract boolean isThumbnailType(String type)
Determines if product type represented by type is a thumbnail.

Specified by:
isThumbnailType in interface MissionSpecFileInfo
Parameters:
type - Product type.
Returns:
True if file is a thumbnail, false otherwise.

getInstrumentTypes

public String[] getInstrumentTypes()
Returns a String array of instrument names. Returns a String[] of length 0.

Specified by:
getInstrumentTypes in interface MissionSpecFileInfo
Returns:
String array of instrument types, first element an empty string.

getRdrTypes

public String[] getRdrTypes()
Returns a String array of RDR types. Returns a String[] of length 0.

Specified by:
getRdrTypes in interface MissionSpecFileInfo
Returns:
String array of RDR types.

getCameraEyeTypes

public String[] getCameraEyeTypes()
Returns a String array of camera eye types. Returns a String[] of length 0.

Specified by:
getCameraEyeTypes in interface MissionSpecFileInfo
Returns:
String array of camera eye types.

removeThumbnails

public List removeThumbnails(List inImages)
Given a vector of image file names, uses isThumbnail method to determine if file should be included in the returned List. This method is not destructive to the input List.

Specified by:
removeThumbnails in interface MarsImageFileFinder
Parameters:
inImages - List of image pathnames
Returns:
List of non-thumbnail files

equals

public boolean equals(Object other)
Returns true if this object and other is of same class type and have the same root.

Specified by:
equals in interface MissionSpecFileInfo
Overrides:
equals in class Object
Parameters:
other - MarsImageFileFinder object to be compared to
Returns:
True if class and state are same, false otherwise

formatSol

public String formatSol(int sol)
Formats the SOL as a string based on the directory structure

Specified by:
formatSol in interface MarsImageFileFinder
Parameters:
Sol - day as integer
Returns:
string representation of the sol parameter

getSourceProductPath

public abstract String getSourceProductPath(String rdrPath)
                                     throws FileFinderException
Returns the path of the source EDR for nominal RDR products, or the path of the linearized version of that EDR for linearized RDR products. NOTE: Behavior of this method must be constrained such that a 'source image' will return the path of itself. For example, is the parameter is the linearized thumbnail source, this method will return that same path, and not the path of the nominal thumbnail nor the nomial fullsized.

Specified by:
getSourceProductPath in interface MarsImageFileFinder
Parameters:
rdrPath - Path of the RDR product.
Returns:
Path of the corresponding source EDR (nominal or linearized).
Throws:
FileFinderException

isTypeNominal

public abstract boolean isTypeNominal(String type)
Returns true if the type parameter is raw, false otherwise (e.g. type is linearized).

Specified by:
isTypeNominal in interface MissionSpecFileInfo
Parameters:
Product - type of the image
Returns:
True is type is raw, false otherwise.

isTypeSource

public abstract boolean isTypeSource(String type)
Returns true if the type parameter is source.

Specified by:
isTypeSource in interface MissionSpecFileInfo
Parameters:
Product - type of the image
Returns:
True is type is source.

initSolRange

protected void initSolRange()

getSolRange

public List getSolRange()
Returns a list of the SOL range of a given file finder. By default, returns list containing "N/A"

Specified by:
getSolRange in interface MarsImageFileFinder
Returns:
Solar day range

getInitialSol

public String getInitialSol()
Returns a list of the SOL range of a given file finder. By default, returns list containing "N/A"

Specified by:
getInitialSol in interface MarsImageFileFinder
Returns:
Solar day range

getEdrThumbnail

public abstract String getEdrThumbnail(String edrPath)
Given a complete path to an EDR, returns the associated thumbnail path, if it exists. If so, the thumbnail's path is returned, else, null is returned.

Specified by:
getEdrThumbnail in interface MarsImageFileFinder
Parameters:
edrPath - Absolute path of EDR file
Returns:
Associated thumbnail path, if it exists, else null

getImageComparator

public Comparator getImageComparator()
Returns file finders instance of a comparator for sorting files according to some set of rules.

Specified by:
getImageComparator in interface MissionSpecFileInfo
Returns:
File finder's image comparator.

getGroupId

public String getGroupId(String imagePath)
Many file finders have images that form a set through some special relationship (i.e. same SCLK, etc). This method will return an identifier for that set as a group id, shared by all images in that set.

Specified by:
getGroupId in interface MissionSpecFileInfo
Parameters:
Path - to an image file
Returns:
Group id of that image as defined by the file finder.