Class: Converter

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

Signature:

class Converter<V>

QuickNav


Converter

Version:
  • 7.1.0
Since:
  • 0.6
Module:
  • ojvalidation-base

Module usage

See JET Module Loading for an overview of module usage within JET.

Javascript Import Format
define(['ojs/ojvalidation-base'], function(validationBase) {
 // Application should call API on validationBase.Converter 
})
Typescript Import Format
//This class is not exported from module and can not be accessed in runtime.
//However to enable typechecking and ducktyping, you can access it as an interface.
import {Converter} from "ojs/ojvalidation-base";

//To access this type in your code,
class MyClass implements Converter{
//or,
let myVariable: Converter;
Generic Parameters
ParameterDescription
VType of value to be converted. Parse will convert string to this type and format will format this type to string

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.

Constructor

(abstract) new Converter(options)

Constructs an immutable instance of Converter.
Parameters:
Name Type Argument Description
options Object <optional>
an object literal used to provide an optional information to initialize the converter.

Methods

format(value) → {string|null}

Formats the value using the options provided.
Parameters:
Name Type Description
value V the value to be formatted for display
Throws:
if formatting fails.
Type
Error
Returns:
the localized and formatted value suitable for display
Type
string | null

getHint(): string|null

Returns a hint that describes the converter format expected.
Returns:
a hint describing the format the value is expected to be in.
Type
string | null

getOptions(): object

Returns the options called with converter initialization.
Returns:
an object of options.
Type
Object

parse(value) → {(V|null)}

Parses a String value using the options provided.
Parameters:
Name Type Description
value string to parse
Throws:
if parsing fails
Type
Error
Returns:
the parsed value.
Type
(V|null)

resolvedOptions(): object

Returns an object literal with locale and formatting options computed during initialization of the object. If options was not provided at the time of initialization, the properties will be derived from the locale defaults.
Returns:
an object of resolved options.
Type
Object