Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EditorPopupMenuCodec

Custom codec for configuring s. This class is created and registered dynamically at load time and used implicitly via and the . This codec only reads configuration data for existing popup menus, it does not encode or create menus. Note that this codec only passes the configuration node to the popup menu, which uses the config to dynamically create menus. See <EditorPopupMenu.createMenu>.

Hierarchy

Index

Constructors

constructor

Properties

exclude

exclude: string[]

Array containing the variable names that should be ignored by the codec.

idrefs

idrefs: string[]

Array containing the variable names that should be turned into or converted from references. See Codec.getId and Codec.getObject.

mapping

mapping: {}

Maps from from fieldnames to XML attribute names.

Type declaration

  • [key: string]: string

reverse

reverse: {}

Maps from from XML attribute names to fieldnames.

Type declaration

  • [key: string]: string

template

template: any

Holds the template object associated with this codec.

Static allowEval

allowEval: boolean = false

Static global switch that specifies if expressions in arrays are allowed. Default is false. NOTE: Enabling this carries a possible security risk.

static

Methods

addObjectValue

  • addObjectValue(obj: any, fieldname: string, value: any, template: any): void
  • Sets the decoded child node as a value of the given object. If the object is a map, then the value is added with the given fieldname as a key. If the fieldname is not empty, then setFieldValue is called or else, if the object is a collection, the value is added to the collection. For strongly typed languages it may be required to override this with the correct code to add an entry to an object.

    Parameters

    • obj: any
    • fieldname: string
    • value: any
    • template: any

    Returns void

afterDecode

  • afterDecode(dec: Codec, node: null | Element, obj?: any): any
  • Hook for subclassers to post-process the object after decoding. This implementation returns the given object without any changes. The return value of this method is returned to the decoder from decode.

    Parameters

    • dec: Codec
    • node: null | Element

      XML node to be decoded.

    • Optional obj: any

      Object that represents the default decoding.

    Returns any

afterEncode

  • afterEncode(enc: Codec, obj: any, node: Element): Element
  • Hook for subclassers to post-process the node for the given object after encoding and return the post-processed node. This implementation returns the input node. The return value of this method is returned to the encoder from encode.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Object to be encoded.

    • node: Element

      XML node that represents the default encoding.

    Returns Element

beforeDecode

  • beforeDecode(dec: Codec, node: Element, obj: any): null | Element
  • Hook for subclassers to pre-process the node for the specified object and return the node to be used for further processing by decode. The object is created based on the template in the calling method and is never null. This implementation returns the input node. The return value of this function is used in decode to perform the default decoding into the given object.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • node: Element

      XML node to be decoded.

    • obj: any

      Object to encode the node into.

    Returns null | Element

beforeEncode

  • beforeEncode(enc: Codec, obj: any, node?: Element): any
  • Hook for subclassers to pre-process the object before encoding. This returns the input object. The return value of this function is used in encode to perform the default encoding into the given node.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Object to be encoded.

    • Optional node: Element

      XML node to encode the object into.

    Returns any

cloneTemplate

  • cloneTemplate(): any

convertAttributeFromXml

  • convertAttributeFromXml(dec: Codec, attr: any, obj: any): any

convertAttributeToXml

  • convertAttributeToXml(enc: Codec, obj: any, name: null | string, value: any, node: Element): any

decode

  • decode(dec: Codec, node: Element, into: any): any

decodeAttribute

  • decodeAttribute(dec: Codec, attr: any, obj?: any): void

decodeAttributes

  • decodeAttributes(dec: Codec, node: Element, obj: any): void

decodeChild

  • decodeChild(dec: Codec, child: Element, obj: any): void

decodeChildren

  • decodeChildren(dec: Codec, node: Element, obj?: any): void

decodeNode

  • decodeNode(dec: Codec, node: null | Element, obj: any): void

encode

  • encode(enc: Codec, obj: Element): null | Element

encodeObject

  • encodeObject(enc: Codec, obj: any, node: Element): void

encodeValue

  • encodeValue(enc: Codec, obj: any, name: null | string, value: any, node: Element): void
  • Converts the given value according to the mappings and id-refs in this codec and uses writeAttribute to write the attribute into the given node.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Object whose property is going to be encoded.

    • name: null | string

      XML node that contains the encoded object.

    • value: any

      Value of the property to be encoded.

    • node: Element

      XML node that contains the encoded object.

    Returns void

getAttributeName

  • getAttributeName(fieldname: null | string): null | string

getFieldName

  • getFieldName(attributename: string): string

getFieldTemplate

  • getFieldTemplate(obj: any, fieldname: string, child: Element): any
  • Returns the template instance for the given field. This returns the value of the field, null if the value is an array or an empty collection if the value is a collection. The value is then used to populate the field for a new instance. For strongly typed languages it may be required to override this to return the correct collection instance based on the encoded child.

    Parameters

    • obj: any
    • fieldname: string
    • child: Element

    Returns any

getName

  • getName(): string
  • Returns the name used for the nodenames and lookup of the codec when classes are encoded and nodes are decoded. For classes to work with this the codec registry automatically adds an alias for the classname if that is different than what this returns. The default implementation returns the classname of the template class.

    Returns string

isBooleanAttribute

  • isBooleanAttribute(enc: Codec, obj: any, name: null | string, value: any): boolean
  • Returns true if the given object attribute is a boolean value.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Objec to convert the attribute for.

    • name: null | string

      Name of the attribute to be converted.

    • value: any

      Value of the attribute to be converted.

    Returns boolean

isExcluded

  • isExcluded(obj: any, attr: string, value: any, write?: boolean): boolean
  • Returns true if the given attribute is to be ignored by the codec. This implementation returns true if the given fieldname is in exclude or if the fieldname equals ObjectIdentity.FIELD_NAME.

    Parameters

    • obj: any

      Object instance that contains the field.

    • attr: string

      Fieldname of the field.

    • value: any

      Value of the field.

    • Optional write: boolean

      Boolean indicating if the field is being encoded or decoded. Write is true if the field is being encoded, else it is being decoded.

    Returns boolean

isIgnoredAttribute

  • isIgnoredAttribute(dec: Codec, attr: any, obj?: any): boolean
  • Returns true if the given attribute should be ignored. This implementation returns true if the attribute name is "as" or "id".

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • attr: any

      XML attribute to be decoded.

    • Optional obj: any

      Objec to encode the attribute into.

    Returns boolean

isNumericAttribute

  • isNumericAttribute(dec: Codec, attr: any, obj: any): boolean

isReference

  • isReference(obj: any, attr: string, value: any, write?: boolean): boolean
  • Returns true if the given fieldname is to be treated as a textual reference (ID). This implementation returns true if the given fieldname is in idrefs.

    Parameters

    • obj: any

      Object instance that contains the field.

    • attr: string

      Fieldname of the field.

    • value: any

      Value of the field.

    • Optional write: boolean

      Boolean indicating if the field is being encoded or decoded. Write is true if the field is being encoded, else it is being decoded.

    Returns boolean

processInclude

  • processInclude(dec: Codec, node: Element, into?: any): boolean
  • Returns true if the given node is an include directive and executes the include by decoding the XML document. Returns false if the given node is not an include directive.

    Parameters

    • dec: Codec

      Codec that controls the encoding/decoding process.

    • node: Element

      XML node to be checked.

    • Optional into: any

      Optional object to pass-thru to the codec.

    Returns boolean

writeAttribute

  • writeAttribute(enc: Codec, obj: any, name: null | string, value: any, node: Element): void

writeComplexAttribute

  • writeComplexAttribute(enc: Codec, obj: any, name: null | string, value: any, node: Element): void

writePrimitiveAttribute

  • writePrimitiveAttribute(enc: Codec, obj: any, name: null | string, value: any, node: Element): void

Generated using TypeDoc