Help
Class HelpFileParser

java.lang.Object
  |
  +--Help.HelpFileParser

public class HelpFileParser
extends Object

This class provides the parser for reading a help file. After the file is parser, we write another file that contains the structure of menu we have just found.

Version:
1.0
Author:
Sebastien Baehni
See Also:
MyMenu

Constructor Summary
HelpFileParser(String fileName)
          The main constructor.
 
Method Summary
protected  MyMenu[] createAllMenus()
          This method creates all the menu from a file.
protected  MyMenu createSubTitleMenu(long startPosition, long stopPosition)
          This method create a submenu structure.
protected  MyMenu[] createSubTitlesMenu(Long[] position, long lastValue)
          This method creates all the submenu of a main menu.
protected  MyMenu createTitleMenu(long startPosition, long stopPosition)
          This method creates the main menu structure with no sub menu.
protected  MyMenu createTitleMenu(long startPosition, long stopPosition, MyMenu[] mySubMenu)
          This method creates the main menu structure.
protected  Vector findAllParagraphs()
          This method find all the paragraphs (titles and subtitles)in a file.
protected  void findSubTitles(Vector titleVector)
          This method find all the subtitles between two titles.
protected  Long[] findTitleAndHisSubTitles(long startPosition)
          This method finds a title and all his subtitles.
static void main(String[] args)
          The main method that read the file, creates all the menu, write them in a file, read the written file (to be sure that the operation is succesful) and put in the console some parameters of the file.
protected  MyMenu[] readStructure(String fileName)
          This method read an array of menu from a file.
protected  void writeStructure(String fileName, MyMenu[] menu)
          This method write an array of menu in a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HelpFileParser

public HelpFileParser(String fileName)
The main constructor. It creates a new random access file.
Parameters:
fileName - The name of the file we want to parse.
Method Detail

findTitleAndHisSubTitles

protected Long[] findTitleAndHisSubTitles(long startPosition)
This method finds a title and all his subtitles.
Parameters:
startPosition - The position of the file pointer.
Returns:
An array of long that contains all the position of the differents title. The title is in first position.

findSubTitles

protected void findSubTitles(Vector titleVector)
This method find all the subtitles between two titles.
Parameters:
titleVector - The vector in which the position of the title and the subtitles are.

findAllParagraphs

protected Vector findAllParagraphs()
This method find all the paragraphs (titles and subtitles)in a file.
Returns:
A vector that contains multiple array of long in which they are the position of the titles and subtitle. an element of the vector represents a paragraph.

createSubTitleMenu

protected MyMenu createSubTitleMenu(long startPosition,
                                    long stopPosition)
This method create a submenu structure. This is a menu with a name (the title name), a text and no sub menu.
Parameters:
startPosition - The start position of the file pointer.
stopPosition - The stop position of the file pointer.
See Also:
MyMenu

createSubTitlesMenu

protected MyMenu[] createSubTitlesMenu(Long[] position,
                                       long lastValue)
This method creates all the submenu of a main menu.
Parameters:
position - The array containing the all the different position of submenu in a main menu.
lastValue - The last position of the subtitles in a file.
Returns:
An array of sub menu.
See Also:
MyMenu

createTitleMenu

protected MyMenu createTitleMenu(long startPosition,
                                 long stopPosition,
                                 MyMenu[] mySubMenu)
This method creates the main menu structure.
Parameters:
startPosition - The start position of the file pointer.
stopPosition - The stop position of the file pointer.
mySubMenu - The structure of submenu of the main menu.
Returns:
The main menu structure.
See Also:
MyMenu

createTitleMenu

protected MyMenu createTitleMenu(long startPosition,
                                 long stopPosition)
This method creates the main menu structure with no sub menu.
Parameters:
startPosition - The start position of the file pointer.
stopPosition - The stop position of the file pointer.
Returns:
The main menu structure.
See Also:
MyMenu

createAllMenus

protected MyMenu[] createAllMenus()
This method creates all the menu from a file.
Returns:
An array of main menus.
See Also:
MyMenu

writeStructure

protected void writeStructure(String fileName,
                              MyMenu[] menu)
This method write an array of menu in a file.
Parameters:
fileName - The name of the file we want to write the structure into.
menu - The structure containing all the menu.
See Also:
MyMenu

readStructure

protected MyMenu[] readStructure(String fileName)
This method read an array of menu from a file.
Parameters:
fileName - The name of the file we want to read the structure.
Returns:
The array of menu. Null if the array has not been found.
See Also:
MyMenu

main

public static void main(String[] args)
The main method that read the file, creates all the menu, write them in a file, read the written file (to be sure that the operation is succesful) and put in the console some parameters of the file.
Parameters:
args - The argument of the command line.