The XPath Parser - Creation of an object model

These steps show how the object model is created for this xpath expression:

/Task[name = 'sample task' or @containingProject[name = 'a project']]

We obtains these list of operation and token after the parsing of the xpath expression:

compiler.getOpMap() = [1, 60, 29, 58, 50, 4, 4, 35, 40, 51, 6, 34, -2, 1, 30, 45, 2, 42, 5, 14, 29, 9, 40, 6, 6, 34, -2, 3, -1, 21, 3, 5, 29, 26, 39, 23, 6, 34, -2, 8, 30, 17, 5, 14, 29, 9, 40, 6, 6, 34, -2, 10, -1, 21, 3, 12, -1, -1, -1, -1, 0, 0, 0, 0]

Codes in red matches opCodes from the OpCodes class.

compiler.getTokenQueue() = [/, Task, [, name, =, sample task, or, @, containingProject, [, name, =, a project, ], ], null, null, null, null]

These arrays are be passed as parameters of the StartXPath constructor. The build(int position) method starts the conversion of the operation codes array to the object model.

The final Object Model

In the StartXPath.notifyPostBuild method. The predicate of each Table is converted to an ArrayList of Conditions that is kept in the Table.conditions field. The conditions of this ArrayList will be use to perfom the conversion to an SQL string.