module:nmodule/export/rc/Transformer

module:nmodule/export/rc/Transformer

API Status: Development

Transform one object into another type.

Constructor

(abstract) new (require("nmodule/export/rc/Transformer"))()

Source:

Methods

getDefaultConfig(transformedObject) → {baja.Component|Promise.<(baja.Component|undefined)>|undefined}

Description:
  • When invoking a transform operation using the Export Dialog, options can
    be provided by the user to configure how the transform is performed.

    If this transformer should provide user-configurable options, override
    this function to provide them in the form of a Component. This
    Component will be shown to the user in a Property Sheet for
    configuration.

Source:
See:
Example

Provide a config option for 'prettyPrint' that uses a custom display name.

getDefaultConfig() {
  var comp = baja.$('baja:Component');
  comp.add({
    slot: 'prettyPrint',
    value: true,
    cx: { displayName: 'Pretty Print' }
  });
  return comp;
}
Parameters:
Name Type Description
transformedObject *

the transform object can be used to help
decide values on default config.

Returns:
Type
baja.Component | Promise.<(baja.Component|undefined)> | undefined

(abstract) getDisplayName() → {string}

Source:
Returns:

the display name of this transformer

Type
string

getExportContextObject(config) → {object|Promise.<object>}

Description:
  • When the user invokes the transform, the Component as edited by the
    user will need to be converted to a context object to be used in the
    transform() method. This function provides a hook to perform extra
    processing during that conversion.

    By default, will return a simple mapping of the Component's slot names
    to their values.

Source:
Parameters:
Name Type Description
config baja.Component | object

the config component as edited by the user

Returns:

the context object

Type
object | Promise.<object>

(abstract) getFileExtension() → {string}

Source:
Returns:

the default file extension to use when saving the data produced by this transformer

Type
string

(abstract) getIcon() → {string}

Source:
Returns:

the icon for this transformer

Type
string

(abstract) getMimeType() → {string}

Source:
Returns:

the mime type for the data produced by this transformer

Type
string

isSupplier() → {boolean}

Description:
  • By default, all Transformers supply data to an ExportDestinationType.

    If there is nothing to supply to a destination, then return false and
    this will instruct the UI to show no ExportDestinationTypes.

Source:
See:
Returns:
Type
boolean

(abstract) transform(object, cxopt) → {Promise.<*>|*}

Description:
  • Transform an object into another type of data.

Source:
Parameters:
Name Type Attributes Description
object *

the object to be transformed

cx object <optional>

transform context containing options as configured by the user

Returns:

to be resolved with the transformed data

Type
Promise.<*> | *