jmud-0.11/
jmud-0.11/bin/
jmud-0.11/doc/
jmud-0.11/rec/
jmud-0.11/rec/mun/
jmud-0.11/rec/mun/grecia/
jmud-0.11/rec/mun/gunnar/
jmud-0.11/rec/qua/
jmud-0.11/src/bool/
jmud-0.11/src/clone/
jmud-0.11/src/integer/
jmud-0.11/src/misc/
jmud-0.11/src/string/
jmud-0.11/src/util/bit/
jmud-0.11/src/util/color/
jmud-0.11/src/util/file/
jmud-0.11/src/util/jgp/adaptor/
jmud-0.11/src/util/jgp/algorithm/
jmud-0.11/src/util/jgp/container/
jmud-0.11/src/util/jgp/functor/
jmud-0.11/src/util/jgp/interfaces/
jmud-0.11/src/util/jgp/predicate/
jmud-0.11/src/util/log/
jmud-0.11/src/util/state/
jmud-0.11/trash/
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Vector;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.BufferedReader;
import java.io.FileReader;

import util.file.InvalidFileFormatException;
import misc.Separators;

class Help {
  
  private Vector theHelp = null;
  
  Help(String helpFileName)
    throws InvalidFileFormatException, FileNotFoundException, IOException {
      theHelp = new Vector();
      BufferedReader helpFile = null;
      
      helpFile = new BufferedReader(new FileReader(helpFileName));       
     
      for ( ; ; ) {
	if (!helpFile.ready())
	  throw new InvalidFileFormatException();
	String helpText = helpFile.readLine();

	if (helpText.startsWith(Separators.EOF))
	  break;

	if (!helpText.startsWith(Separators.BOR))
	  throw new InvalidFileFormatException();
	helpText = helpText.substring(1);
	for ( ; ; ) {
	  if (!helpFile.ready())
	    throw new InvalidFileFormatException();
	  String helpLine = helpFile.readLine();

	  if (helpLine.startsWith(Separators.BOR))
	    throw new InvalidFileFormatException();
	  if (helpLine.startsWith(Separators.EOR))
	    break;
	  
	  helpText += Separators.NL + helpLine;
	}
	theHelp.addElement(helpText);
      }

      helpFile.close();
  }
  
  String findHelpByKey(String keyWord)
    throws NoSuchElementException {
      String helpText = "";
      for (Enumeration help = theHelp.elements(); help.hasMoreElements(); ) {
	String currHelp = (String) help.nextElement();
	StringTokenizer helpIndex = new StringTokenizer(new StringTokenizer(currHelp, Separators.NL).nextToken());
	for ( ; ; ) {
	  if (helpIndex.hasMoreTokens()) {
	    if (helpIndex.nextToken().toLowerCase().startsWith(keyWord.toLowerCase())) {
	      helpText += ((helpText == "") ? currHelp : Separators.NL +
	      "----------------------------------------------------------------------" + 
	      Separators.NL + currHelp);
	      break;
	    }
	  }
	  else break;
	}
      }
      if (helpText == "")
	throw new NoSuchElementException();
      else return helpText;
  }
}