Class Index | File Index

Classes


Namespace mmir.parser


Defined in: parserModule.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
This module holds functions / classes for template parsing.
Method Summary
Method Attributes Method Name and Description
<static>  
mmir.parser.appendStringified(obj, propertyNames, stringBuffer, propertyNamePostfix, valueFunc)
Creates String-representations (JSON-like) for the specified properties and appends them to the StringBuffer.
<static>  
mmir.parser.restoreObject(storedObject, isTriggerPublish, fileFormatNo)
Creates the appropriate object from a JSON-like storedObject.
Namespace Detail
mmir.parser
This module holds functions / classes for template parsing.

This module contains definitions for constants used in the Template Parser and Renderer.

//access the parser module
// (it is a sub-module of mmir!)
var someConst = mmir.parser.element.INCLUDE_SCRIPT;
...
Method Detail
<static> {Array} mmir.parser.appendStringified(obj, propertyNames, stringBuffer, propertyNamePostfix, valueFunc)
Creates String-representations (JSON-like) for the specified properties and appends them to the StringBuffer.

This function iterates over the Array propertyNames: If a property with that name exists in obj, a JSON-like String-representation is generated and appended at the end of the array stringBuffer.
Multiple representations are separated by comma entry ',' in stringBuffer.
The last entry in stringBuffer is a comma entry ',' if at least one property entry was inserted in stringBuffer.

NOTE that the String-representation inserted into stringBuffer may not have a 1:1 correspondence with properties (only the last entry is guaranteed to be ',', if a property was inserted).
For pratical use, the returned (or modified) stringBuffer should be converted into a String e.g. by stringBuffer.join('').
Defined in: storageUtils.js.

var obj = {
	some: "properties",
	including: function(arg1,arg2){ return 'functions' }
};

var sb = mobileDS.parser.appendStringified(obj, ['some'], []);
var str = sb.join(',');
//str will be: "some:\"properties\","
Parameters:
{Object} obj
the object, that contains the properties for which String representations should be generated.
{Array} propertyNames
the names of the properties, for which String-representations should be generated.
{Array} stringBuffer
the buffer: String-representations will be appended as entries at the end of the buffer
{String} propertyNamePostfix Optional
OPTIONAL if present, this postfix will be appended to each property name, before processing it. This is a convenience method, e.g. if all properties in propertyNames should end with the same String / postfix.
{Function} valueFunc Optional
OPTIONAL by default, value representations are generated using the JSON.stringify function. If instead this argument is present, this function will be invoked for creating the string representation of the property-value. The function signature is valueFunc(propertyName : String, propertyValue : Object) : String. If the function returns void, then the corresponding property will not be added/stringified.
Returns:
{Array} the modified stringBuffer
Requires:
JSON.stringify

<static> {Object} mmir.parser.restoreObject(storedObject, isTriggerPublish, fileFormatNo)
Creates the appropriate object from a JSON-like storedObject.

NOTE that in difference to a real JSON object, the storedObject may contain function definitions.

The storedObject must have a String property classConstructor

If storedObject contains a function init, then this function will be invoked before returning the new newly created object.
Defined in: storageUtils.js.

Parameters:
{Object} storedObject
a JSON-like object with fields and functions (which will be transfered to the returned object).
{Boolean} isTriggerPublish Optional
OPTIONAL if true then the restore function call initPublish() on the restored object before returning. This should only be true for the root-object (e.g. the View-object or Partial-object; nested objects should NOT invoke restoreObject() with this argument set to true).
{Number} fileFormatNo Optional
OPTIONAL NOTE: if argument isTriggerPublish was used with value true, then this argument MUST be used too! If the number given does not match parser.STORAGE_FILE_FORMAT_NUMBER the file format is assumed to be out-dated and an Error will be thrown.
Throws:
Error if fileFormatNo does not match STORAGE_FILE_FORMAT_NUMBER.
Returns:
{Object} an new instance created with the constructor classConstructor and set with all properties (fields and functions) from storedObject.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Feb 26 2016 21:33:47 GMT+0100 (Mitteleuropäische Zeit)