[ es ]
This is not a 100% Pure Java application, because one library, jLine , uses native code in MS Windows. However, in Linux or Unix it can be considered Pure Java . Then, the application itself is Pure Java , but not one of its dependencies.
Each DB2 command has different options because the grammar is specific for each command. Some commands are executed from the DB2 console ( CLP ), others from the system command line.
This application has the grammar of each command, so it can recognize the structure of a command that is currently typed, and then it can propose some possible options.
The grammar is defined in a set of configuration files, and when the application is loaded, it creates a graph that represents the grammar. This graph has one entering point (Starting Node) and one exiting point (Ending Node). The graph nodes are each of the words that compose a command, which made part of the grammar. The paths between nodes are the possibilities between the different parameters of a command.
When the application is executed, it reads the configuration file, and depending on this, reads the grammar files in order to build the graph. While the graph is being built, the application is ready to receive orders from the user, and to start to assist him to write commands.
Each time a user asks for help, the application takes what the user has written, and analyzes from the beginning of the phrase until the current position of the cursor. Then, this process converts the phrase in tokens that can be words, or some separator signs (such as parenthesis, or quotes, etc.) This is what is known as lexical analyzes.
After that, the application passes that list of tokens to the syntax analyzer and it compares that list, with the nodes in the graph. This process takes the first node from the graph (Starting node), and it sees if one of its paths matches the first token in the list. If they match, then the process takes the next element from the list, and changes its location in the graph, to the matched node. This process continues to analyze if the current node in the graph has a path that corresponds to the second token in the list. This process is done several times until one of the next cases happen:
The grammar defined in the application is not strictly the same used in DB2 . IBM can change the version, or add new commands and then, the application (Zemucan) becomes desynchronized for these changes. Because of that, the application has to be updated with the information included in the last versions.
This application is not strictly to use with DB2 . It can operate with any other program that is executed from the command line and that has a grammar with many options.
The interaction with the user terminal is done via jLine . This utility manages those types of events.
The application can be extended to work with other user interface, say a text interface like Charva , or say graphic interfaces.
In addition, the core can be used for other Java applications. As part of the development of this application, it is included some Extras that uses the core that reads the grammar and generates the graph.
[ es ]