org.jorion.balboa.lookup
Class Lookup

java.lang.Object
  extended by org.jorion.balboa.lookup.Lookup

public class Lookup
extends java.lang.Object

Start class for the lookup feature.

Author:
Bernard Jorion, www.jorion.org

Constructor Summary
Lookup(Config cfg)
          Default constructor.
 
Method Summary
 void addListener(IListener listener)
          Register a new listener.
protected  void callListener(java.io.File jar, java.util.List<java.lang.String> entries)
          Call the listeners to signal a file was parsed.
protected static boolean compareEndsWith(java.lang.String expectedName, java.lang.String entryName, boolean ignoreCase)
          Standard case: compare end of strings.
protected static boolean comparePartial(java.lang.String expectedName, java.lang.String entryName, boolean ignoreCase)
          Litteral comparison.
protected static boolean compareWildcards(java.lang.String expectedName, java.lang.String entryName, boolean ignoreCase)
          Comparison with wild cards.
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllJars()
           
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getFoundJars()
           
protected  void parseDir(java.io.File dir)
          Parse the given directory.
protected  java.util.List<java.lang.String> parseJar(java.io.File jar)
          Parse the given jar looking for the given filename.
 void start()
          Retrieve all the jars of the source directory and parse them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lookup

public Lookup(Config cfg)
Default constructor.

Parameters:
cfg - The configuration object.
Method Detail

addListener

public void addListener(IListener listener)
Register a new listener.

Parameters:
listener - The listener to register.

callListener

protected void callListener(java.io.File jar,
                            java.util.List<java.lang.String> entries)
Call the listeners to signal a file was parsed.

Parameters:
jar - The jar parsed.
entries - The list of entries in this jar corresponding to the search criteria.

getAllJars

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllJars()
Returns:
A map with all the jars parsed.

getFoundJars

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getFoundJars()
Returns:
A map with all the jars that contain the required class.

start

public void start()
           throws java.io.IOException
Retrieve all the jars of the source directory and parse them.

Throws:
java.io.IOException - If an I/O error occurred.

parseDir

protected void parseDir(java.io.File dir)
                 throws java.io.IOException
Parse the given directory.

Parameters:
dir - The directory to parse.
Throws:
java.io.IOException - If an I/O error occurred.

parseJar

protected java.util.List<java.lang.String> parseJar(java.io.File jar)
                                             throws java.io.IOException
Parse the given jar looking for the given filename.

Parameters:
jar - The jar to parse.
Returns:
The list of the jar entrynames corresponding to the given filename.
Throws:
java.io.IOException - If an I/O error occurred.

compareEndsWith

protected static boolean compareEndsWith(java.lang.String expectedName,
                                         java.lang.String entryName,
                                         boolean ignoreCase)
Standard case: compare end of strings. Slashes in expectedName and in entryName will be replaced by dots.

Parameters:
expectedName - The expected name.
entryName - The jar entry name.
ignoreCase - True if the entryName must be converted to lower case.
Returns:
True if entryName ends with expectedName.

comparePartial

protected static boolean comparePartial(java.lang.String expectedName,
                                        java.lang.String entryName,
                                        boolean ignoreCase)
Litteral comparison. Slashes in expectedName and in entryName will be replaced by dots.

Parameters:
expectedName - The expected name.
entryName - The jar entry name.
ignoreCase - True if the entryName must be converted to lower case.
Returns:
True if entryName contains expectedName.

compareWildcards

protected static boolean compareWildcards(java.lang.String expectedName,
                                          java.lang.String entryName,
                                          boolean ignoreCase)
Comparison with wild cards. Slashes in expectedName and in entryName will be replaced by dots.

Parameters:
expectedName - The expected name.
entryName - The jar entry name.
ignoreCase - True if the entryName must be converted to lower case.
Returns:
True if entryName contains expectedName, using wildcards.