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, nosafe)
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.
 
extend(fileName, nosafe)
This method extends an existing DataMap by adding additional mapped fields.
 
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, nosafe)
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
{Boolean} nosafe
A flag to inhibit making the map "safe" - e.g. escaping complex attribute references and pre-compiling the map - use for Evt2EvtData, which is not used as a normal DataMap
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.

extend(fileName, nosafe)
This method extends an existing DataMap by adding additional mapped fields. The source file must be in the standard CSV format of the original DataMap file. Note also that if identical keys are specified in the new input map, they will replace existing entries.
Parameters:
{String} fileName
The name of the file that contains the DataMap extension definition.
{Boolean} nosafe
A flag to inhibit making the map "safe" - e.g. escaping complex attribute references and pre-compiling the map - use for Evt2EvtData, which is not used as a normal DataMap

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.

©2011
Documentation generated by JsDoc Toolkit 2.0.2 on Thu Apr 19 2012 01:41:43 GMT-0400 (EDT)