Class Index | File Index

Classes


Class DataMap

A DataMap specifies a conversion from a Record object into some other type of object. An external file is used to specify how the conversion is accomplished. This external file is in CSV format, with the first column being the name of the attribute in the target object. The second column is then the attribute in the Record object that will be plugged into the target object. The Record attribute references can be complex, for example they can specify array elements, nested attributes, and so forth.

In most cases, the conversion will be between a Record object and an Event object. The template will load the default maps automatically; you will only need to use this class if you are creating your own output objects or providing multiple conversions.
Defined in: utils.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
DataMap(fileName)
Creates a DataMap object by loading the map from a CSV file on disk.
Method Summary
Method Attributes Method Name and Description
 
DataMap objects are normally used to convert one object type into another, and the convert() routine typically uses an eval() to accomplish this.
 
Most DataMaps are simple translations between one flat object and another, but in some cases the source object may be a more complex object.
Class Detail
DataMap(fileName)
Creates a DataMap object by loading the map from a CSV file on disk.

Example:

// First, define the conversion in an external file (CSV format)
Rec2Evt.map:
Message,msg
InitUserName,iun
...
// Next, load the DataMap:
this.MAPS.Rec2Evt = new DataMap(this.CONFIG.collDir + "/Rec2Evt.map");
// And set your values in the Record object (typically in Record.parse())
rec.msg = rec.s_RXBufferString.substr(0,20);
rec.iun = rec.s_RXBufferString.substr(21,25);
// Finally, run the conversion:
rec.convert(this, instance.MAPS.Rec2Evt);
Parameters:
{String} fileName
The file to load the DataMap from
Method Detail
compile()
DataMap objects are normally used to convert one object type into another, and the convert() routine typically uses an eval() to accomplish this. In high-datarate code, however, the eval() method causes an unacceptable performance hit. To circumvent this, the compile() method will create a dynamic function which will be used to perform the conversion instead of the eval(). The normal template will use this for converting the input Record object into the output Event object.

makesafe()
Most DataMaps are simple translations between one flat object and another, but in some cases the source object may be a more complex object. The test here is if the RHS of your DataMap input file includes any complex object/attribute references, and/or references to "illegal" attribute names that should be quoted, e.g.: winevt.evt.myname My Attribute obj.Full Name If you have any of these, you should run the makesafe() method on your DataMap before attempting to use it.

©2008
Documentation generated by JsDoc Toolkit 2.0.2 on Thu Oct 07 2010 07:23:17 GMT-0400 (EDT)