The default implementation 2
If you want to convert GXL into another graph exchange format or vice versa, it often can be useful to hold the whole document structure in memory in order to manipulate it. That's what the default implementation 2 does. All the user has to do is to parse the source document so that the right event stream is generated for the GXLConnector. The default implementation will then create the syntax tree. You can read the tree by calling the method getResultObject() in the GXLConverterAPI, which will return the root of the syntax tree. The child elements of each node can be read using the method getChildElements() (defined in the GXLStandardAPI). The attributes are returned by the method getAttributes() (as well defined in the GXLStandardAPI).
The methods getChildElements() and getAttributes() return a Vector including the wanted elements. It is important that the elements of the value part of the GXL graph model and attributes are returned in an array of length two. For example the attribute id with the value A1 would be saved in the array
| [0] "id" |
| [1] "A1" |
and the simple data type boolean with the value true would be saved in the array
| [0] "bool" |
| [1] "true" |
This is due to the fact that the abstract class hierarchy includes no classes representing these structures and therefore an alternative way of returning them had to be found. The arrays are very easy to handle and therefore external classes can iterate the returned child elements / attributes in an elegant way.
An important fact is that all attributes in the classes of the default implementation 2 are declared public, so that the user can manipulate them directly, if he wants. Furthermore, it is important that you get references to the original objects if you call the method getChildElements(). Thus it is possible to delete child elements by setting them null. If you for example want to delete a node belonging to a graph, you can call the method getChildElements() of the GXLGraphAPIImpl, iterate the returned vector and set the node construct null.
Furthermore interesting for the user can be that each class of the default implementation 2 has a toString() method. It returns a short string describing the GXL construct which it is representing. For example the toString() method of the calls GXLGraphAPIImpl returns the string "graph".
For the detailed implementation of the default implementation 2 have a look at the source code section.