Skip to main content
UndefinedNameError: reference to undefined name 'Pentaho' (click for details)
    at (Template:Custom/Views/Header/HeaderMenuGlobalNav), /content/body/pre, line 28, column 64
    at template()
    at (Template:Custom/Views/Header), /content/body/pre[1], line 31, column 12
    at (Documentation/8.0/Developer_Center/JavaScript_API/platform/pentaho.lang.ISpecifiable), /content/body/div/div/div[2]/pre/code/table[2]/tbody/tr/td/table[2]/tbody/tr/td[2]/p
Pentaho Documentation



The ISpecifiable interface represents the class of objects that can be described by a specification.

A specification is a minimal representation of the information required to build a typed object and all of its "owned" contents.

It can be used to create a copy of a typed object.

In most cases, a specification is a plain JavaScript object (plain, i.e., think "it was built with an object literal"). However, it can also be a non-object value, when a typed object can be wholly expressed as a number, boolean, string or function value.

To be clear, depending on a specification's contents, it may or may qualify as a JSON object.

The pentaho.lang.ISpecifiable#toSpec method creates a specification of a specifiable object.


Given a specification, a specifiable class must provide a way to construct instances from it.

A specification object (or any of its "owned" contents) can be used destructively, partially or totally, to construct a specifiable object.

This supports the memory-effective, one-time cast-construction pattern, where the prototype of existing objects is changed, by using Object.setPrototypeOf.

This also means that, without further knowledge, a specification can only be used to create a single copy of an object.

"Newable" constructors

By convention, in classes that have a constructor function that should be used with the new operator — has a "newable" constructor — the specification object is the first, optional or required, constructor argument.

The following example illustrates this type of constructor function.

function Foo(spec) { = (spec && || "bar";
   this.qux = (spec && spec.qux) || "qux";

Foo.prototype.toSpec = function() {
    return {
        qux: this.qux

// Create a Foo instance
var foo1 = new Foo({bar: "a", qux: "b"});

// Obtain a specification of 

"Initialization" constructors

In classes whose constructor is an initialization function that should not, however, be called using new (not "newable"), a plain object's prototype should be set using Object.setPrototypeOf and the constructor called on the "morphed" object, afterwards. In these cases, it is also conventional for the constructor function to provide a static to method that performs the class "conversion".

The following example illustrates this type of constructor function.

function Foo() {
   if(! = "bar";
   if(!this.qux) this.qux = "qux";

Foo.prototype.toSpec = function() {
    return {
        qux: this.qux
}; = function(spec) {
    if(spec instanceof Foo) return spec;

    Object.setPrototypeOf(spec, Foo);;
    return spec;

// Convert to a Foo instance
var foo1 ={bar: "a", qux: "b"});

Source: doc-js/pentaho/lang/ISpecifiable.jsdoc, line 17


Name Description
toSpec(keyArgs) : *

Creates a specification of this object.

Methods Details

toSpec(keyArgs) : *

Creates a specification of this object.

Specific classes can support optional keyword arguments.

Source: doc-js/pentaho/lang/ISpecifiable.jsdoc, line 133

Name Default Value Summary
keyArgs : Object

The keyword arguments.

Name Description

A new specification of the object.