Skip to end of metadata
Go to start of metadata

Package common

This package provides access to the common methods provided in the hbutils repository supplied with every HostBridge product installation.

Package Summary

Package NameDescription
commonInterface to common methods.  The common object is created via the "require" syntax, ie: var common = require('common', 'hbutils');

Object Summary

Object nameDescription
buildJob(template, parameters)Builds a batch job card deck from a provided template and passed parameters
chunkString(string, length) Breaks up the supplied string into chunks of the supplied length
copybook.get(name)Gets the value of a field defined in a copybook
copybook.getAttr(name)Gets the attributes of a field defined in a copybook 
copybook.initialize(initCharacter)Initializes a copybook object using the provided character
copybook.set(name, value)Sets the value of a field defined in a copybook
copybook.toJSObj(excludes)Creates a JavaScript object from a copybook object
copybook.toString()Converts copybook buffer to a string
copybook.toXML()Convert copybook to XML (under construction or beta)
copyObject(object)Creates a deep copy of an object 
decode(string)Decodes an encoded string
encode(string)Makes a string safe for XML and/or HTTP processing.
gcmd.get(name)Allows access to any parameter in the Global Command string
hbGetProto(fieldObject)Implements screen objects by passing in a field object and returning the field value
hbRunProto(hbRunObject)Extend hb.run object with additional methods and properties (like if you are on the BMS map)
headers.js()Set return headers for HTTP on a response containing JavaScript 
headers.json()Set return headers for HTTP on a response containing JSON
headers.soap()Set return headers for HTTP on a response containing a SOAP envelope
headers.xDomain()Set return headers for HTTP on a response containing xDomain
headers.xml(encoding)Set return headers for HTTP on a response containing an XML document
insertAt(string, at, insertedString)Insert a string within another string
isArray(candidateArray)Determines if the passed parameter is an array
jsToXML(jsObject, root) Create XML from javaScript object
MailMessage(cssmtp)Create and send a mail message 

padLeft(padString, length, padChar, truncate)

To pad a given string on the left up to a maximum length with a given pad character
padRight(padString, length, padChar, truncate)To pad a given string on the right up to a maximum length with a given pad character
parseQueryString(string)Turns passed query string into name value pairs
repeat(string, iterations)Repeat a string
replaceNonDisplay(string, repCharacter) Replace non-displayable characters in a string
submitJob(cardDeck, node)Submits a z/OS batch job
tableLookup(fileName, [repository, [keySep, [lineSep]]])Table lookup from a file on a repository
toFixedFloor(number,decimalPlaces)Takes a number, truncates it to the provided number of decimal places, and returns a string
toJSONString(object)Creates a string that is a JSON object from any js. object (used liveDemo.hbx as test)
uuid(len,[radix])Create a unique identifier
uuidCompact()Create a unique identifier that is more compact but less performant than uuid
uuidFast()Create a unique identifier that is more perfomant but slightly bulkier than uuid
xmlFragment(parent, child)Create an XML document and add children to it
XMLHttpRequest() Implements most functionality of standard XML HTTP requests via various methods


common()

Description: common Interface

Object/Method Detail

buildJob(template, parameters)

Description: Builds a batch job card deck from a provided template and passed parameters.

Version Added: 6.91

Parameters:

{object} template - The skeleton of a batch job to be submitted.

{array} parameters -  a list of parameters to be incorporated into the batch job.

Returns: Card deck representing a batch job

chunkString(string, length)

Description: Breaks up the supplied string into chunks of the supplied length.

Version Added: 6.91

Parameters:

{string} string - The string that is to be broken up.

{number} length - The desired length of the outputted chunks.

Returns: An array containing the created chunks.

copybook.get(name)

Description: Gets the value of a field defined in a copybook.

Version Added: 6.91

Parameters: 

{string} name - The name of the field in the copybook to get the value of.

Returns:  The data associated with the field.

copybook.getAttr(name)

Description: Gets the data attributes of a field defined in a copybook.

Version Added: 6.91

Parameters:  

{string} name - The name of the field in the copybook to get the data attributes of.

Returns:  The data attributes for the requested field.

copybook.initialize(initCharacter)

Description: Initializes a copybook object using the provided character.

Version Added: 6.91

Parameters:

{string} initCharacter -  The character to be propagated across all of the copybook buffer

Returns:  None

copybook.set(name, value)

Description: Sets the value of a field defined in a copybook.

Version Added: 6.91

Parameters:

{string} name - The name of the field in the copybook to set the value of.

{varying} value - The value of the field in the copybook to set the value to; type can vary depending on the attributes of the field.

Returns: None

copybook.toJSObj(excludes)

Description: Creates a JavaScript object from a copybook object.  

Version Added: 6.91

Parameters:

{array} excludes - An array of fields to exclude from the JavaScript object.

Returns: A JavaScript object representing the contents of the copybook.


If a group name is included in the 'excludes' array, it does not automatically exclude the fields defined to the group.

copybook.toString()

Description: Converts copybook buffer to a string.

Version Added: 6.91

Parameters: None

Returns:  A string containing all of the data from the copybook.

copybook.toXML()

Description: Convert copybook object to XML (under construction or beta)

Version Added: 6.91

Parameters:  None

Returns:  An XML document with the tags representing the field names in the copybook


This object is currently in beta testing.   

copyObject(object)

Description: Creates a deep copy of an object.

Version Added: 6.91

Parameters:

{object} object - The object to be cloned

Returns: The cloned object

decode(string)

Description: Decodes an encoded string.

Version Added: 6.91

Parameters:

{string} string - The string to be decoded.

Returns:  The decoded string.

encode(string)

Description: Makes a string safe for XML and/or HTTP processing.

Version Added: 6.91

Parameters: 

{string} string - The string to be encoded.

Returns:  The encoded string.

gcmd.get(name)

Description: Allows access to any directive in the Global Command string.

Version Added: 6.91

Parameters: 

{string} name - The name of the directive that you want the value of.

Returns:  The value of the directive. 

hbGetProto(fieldObject)

Description: Allows you to pass in a field object that has either the name of the field or the row, col, length of the text area or a getter function for the field.  The hb.get will return the field object with a new/modified property called 'value' containing the value of the field. 

Version Added: 6.91

Parameters:

{object} The field object for which you want the value of that field.

Returns: The same field object with a value property added to it. 

hbRunProto(directives, mapname)

Description: Extend hb.run object with additional methods and properties.

Version Added: 6.91

Parameters:

{string} directives - Any HostBridge directives that you wish to include in the run.

{string} mapname - The name of the map that you expect to be processed.

Returns:  None

This can be used to implement a call back function, or to include error messages when it is detected that you did not process the mapset that you expected, thus indicating a possible error in the transaction order or error condition. 

headers.js()

Description: Set return headers for HTTP on a response containing JavaScript.

Version Added: 6.91

Parameters: None

Returns:  None

headers.json()

Description: Set return headers for HTTP on a response containing JSON.

Version Added: 6.91

Parameters: None

Returns:  None

headers.soap()

Description: Set return headers for HTTP on a response containing a SOAP envelope.

Version Added: 6.91

Parameters: None

Returns:  None

headers.xDomain()

Description: Set return headers for HTTP on a response containing xDomain.

Version Added: 6.91

Parameters: None

Returns: None

headers.xml(encoding)

Description: Set return headers for HTTP on a response containing an XML document.

Version Added: 6.91

Parameters: 

{string} encoding - URL encoding (default is UTF-8)

Returns:  None

insertAt (string, at, insertedString)

Description: Insert a string within another string. 

Version Added: 6.91

Parameters:

{string} string - The original string within which another string is to be inserted.

{number} at - The position in the original string (zero based) where the other string is to be inserted.  

{string} insertedString - The string to be inserted within the original string.

Returns: The combined string.

isArray(candidateArray)

Description: Determines if the passed parameter is an array.

Version Added: 6.91

Parameters:

{array} candidateArray - the data that is being checked to see if it is an array

Returns: Boolean true/false indicator

jsToXML(jsObject, root)

Description: Create XML from JavaScript object. 

Version Added: 6.91

Parameters:

{object} jsObject - The JavaScript object to be converted.

{string} root - the name given to the XML root tag.

Returns: The created XML document.

MailMessage(cssmtp)

Description: Create and send a mail message (for details click here).

Version Added: 6.91

Parameters:

{string} cssmtp -  The CSSMTP write queue.

Returns: 

padLeft(padString, length, padChar, truncate)

Description: To pad a given string on the left up to a maximum length with a given pad character.

Version Added: 6.91

Parameters:

{string} padString - The string to be padded

{number} length - the final length of the padded string

{string} padChar - the character used to do the padding

{boolean} truncate - whether or not to truncate the string if padding caused it to exceed the final length

Returns:  The padded string

padRight(padString, length, padChar, truncate)

Description: To pad a given string on the left up to a maximum length with a given pad character.

Version Added: 6.91

Parameters:

{string} padString - The string to be padded

{number} length - the final length of the padded string

{string} padChar - the character used to do the padding

{boolean} truncate - whether or not to truncate the string if padding caused it to exceed the final length

Returns: The padded string

parseQueryString(string)

Description: Turns passed query string into name value pairs.

Version Added: 6.91

Parameters: 

{string} string - A string in URL query string format. 

Returns:  An array of name value pairs.

repeat(string, iterations)

Description: Repeat a string.

Version Added: 6.91

Parameters:

{string} string - The string you want to repeat.

{number} iterations - The number of times you want to repeat a string.

Returns: The newly constructed string. 

replaceNonDisplay(string, repCharacter) 

Description: Replace non-displayable characters in a string. 

Version Added: 6.91

Parameters: 

{string} string - The string to be operated on.

{string} repCharacter - The character you want to replace non-displayable characters with.

Returns:  The string with the non-displayable characters replaced.

submitJob(cardDeck, node) 

Description:  Submits a z/OS batch job

Version Added: 6.91

Parameters:

{array} cardDeck - An array of 80-column records containing z/OS batch JCL.

{string} node - The JES node under which the job is run. 

Returns: None

You must have an INTRDR class defined to your z/OS system for the job to be successfully submitted. 

tableLookup(fileName, [repository, [keySep, [lineSep]]])

Description: Table lookup from a file on a repository.

Version Added: 6.91

Parameters:

{string} fileName - The name of a plain text file in a repository to search.

{string} (optional) repository - The name of the repository where the file to interrogate resides (default is hbscript)

{string} (optional) keySep - The separator value between data items in a table row (default is the comma)

{string} (optional) lineSep - The separator value delineating the end of a table row (default is \x0d\x25)

Returns: 

For method lookup, the value of the table row with the supplied key.

For method index, the key of the table row with the supplied index.

For method size, the number of items in a table.

Example:


// Using the table CVDATable.txt which is supplied in your HostBridge hbutils repository:

var common = require('common', 'hbutils');
x = new common.tableLookup('CVDATable.txt','hbutils');
writeln(x.lookup('40'));
writeln(x.size());
writeln(x.index(39));

// The writeln output would be:

// NOTBRWBLE
// 967
// 40


toFixedFloor(number, decimalPlaces)

Description: Takes a number, truncates it to the provided number of decimal places, and returns a string. 

Version Added: 6.91

Parameters:

{number} number - The number to be converted to a string.

{number} decimalPlaces - The number of decimal places to insert into the returned string. 

Returns: The created string.

toJSONString(object)

Description: Creates a string that is a JSON object from any js. object.

Version Added: 6.91

Parameters:

{object} object -  The object to be converted.

Returns: The created JSON string.

uuid(len,[radix])

Description: Create a unique identifier.

Version Added: 6.91

Parameters:

{number} length - Length of the unique identifer

{number} radix - The number of allowable values for each character.

Returns: A UUID.

uuidCompact()

Description: Create a unique identifier that is more compact but less performant than uuid.

Version Added: 6.91

Parameters: None

Returns:  A UUID.

uuidFast()

Description: Create a unique identifier that is more perfomant but slightly bulkier than uuid. 


Version Added: 6.91

Parameters: None.

Returns:  A UUID.

xmlFragment(parent, child)

Description: Create an XML document and add children to it.

Version Added: 6.91

Parameters:

{string} parent -  The name given to the XML root (parent) tag.

{string} child - The XML fragment that will be converted to a child of the parent.

Returns:  The XML document.

XMLHttpRequest() 

Description: Implements most functionality of standard XML HTTP requests via various methods. 

Version Added: 6.91

Parameters: Depends on the method used.

Returns: Depends on the method used.

XMLHttpRequest Methods 

abort()

Description: Aborts the request process.

Parameters: None

Returns: None


getAllResponseHeaders()

Description: Creates a concatenated string of all response headers.

Parameters: None

Returns: A concatenated string of all response headers.


getRequestHeader(name)

Description: Gets the value of a given request header

Parameters: 

{string} name - The name of a request header.

Returns: The value of a request header.


open(method, url, async, user, password)

Description: Opens a web request to the host. 

Parameters: 

{string} method - The HTTP request method (ex. GET, POST)

{string} url - the HTTP request URL

{boolean} - async - async communication

{user} -  The userid associated with the open request

{password} - The password associated with the open request

Returns: None


send(data)

Description: Sends an HTTP response.

Parameters: 

{string} data -  The sent response.

Returns: None


setRequestHeader(name, value)

Description: Sets a given request header with the provided value.

Parameters: 

{string} name - The request header to give a value to.

{string} value - The value to associate with the request header.

Returns: None


  • No labels
Write a comment…