GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — BaseGraphCodec | @maxgraph/core

  • BaseGraphCodec

Class BaseGraphCodec

Codec for BaseGraphs.

Transient Fields:

  • eventListeners
  • view
  • container
  • cellRenderer
  • selectionModel
  • plugins

Hierarchy (View Summary)

  • ObjectCodec
    • BaseGraphCodec
  • Defined in serialization/codec/BaseGraphCodec.ts:35
Index

Constructors

constructor

Properties

exclude idrefs mapping reverse template allowEval

Methods

addObjectValue afterDecode afterEncode beforeDecode beforeEncode cloneTemplate convertAttributeFromXml convertAttributeToXml decode decodeAttribute decodeAttributes decodeChild decodeChildren decodeNode encode encodeObject encodeValue getAttributeName getFieldName getFieldTemplate getName isBooleanAttribute isExcluded isIgnoredAttribute isNumericAttribute isReference processInclude setName writeAttribute writeComplexAttribute writePrimitiveAttribute

Constructors

constructor

  • new BaseGraphCodec(): BaseGraphCodec

    Returns BaseGraphCodec

    Overrides ObjectCodec.constructor

    • Defined in serialization/codec/BaseGraphCodec.ts:36

Properties

exclude

exclude: string[]

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

Inherited from ObjectCodec.exclude

  • Defined in serialization/ObjectCodec.ts:246

idrefs

idrefs: string[]

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

Inherited from ObjectCodec.idrefs

  • Defined in serialization/ObjectCodec.ts:253

mapping

mapping: { [key: string]: string }

Maps from field names to XML attribute names.

Inherited from ObjectCodec.mapping

  • Defined in serialization/ObjectCodec.ts:258

reverse

reverse: { [key: string]: string }

Maps from XML attribute names to fieldnames.

Inherited from ObjectCodec.reverse

  • Defined in serialization/ObjectCodec.ts:263

template

template: any

Holds the template object associated with this codec.

Inherited from ObjectCodec.template

  • Defined in serialization/ObjectCodec.ts:241

StaticallowEval

allowEval: boolean = false

Static global switch that specifies if expressions in arrays are allowed.

WARNING: Enabling this switch carries a possible security risk.

Default

false

Inherited from ObjectCodec.allowEval

  • Defined in serialization/ObjectCodec.ts:236

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 field name as a key. If the field name 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

    Inherited from ObjectCodec.addObjectValue

    • Defined in serialization/ObjectCodec.ts:865

afterDecode

  • afterDecode(dec: Codec, node: Element | null, 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

      Codec that controls the encoding process.

    • node: Element | null

      XML node to be decoded.

    • Optionalobj: any

      Object that represents the default decoding.

    Returns any

    Inherited from ObjectCodec.afterDecode

    • Defined in serialization/ObjectCodec.ts:930

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

    Inherited from ObjectCodec.afterEncode

    • Defined in serialization/ObjectCodec.ts:632

beforeDecode

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

    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 Element | null

    Inherited from ObjectCodec.beforeDecode

    • Defined in serialization/ObjectCodec.ts:916

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.

    • Optionalnode: Element

      XML node to encode the object into.

    Returns any

    Inherited from ObjectCodec.beforeEncode

    • Defined in serialization/ObjectCodec.ts:617

cloneTemplate

  • cloneTemplate(): any

    Returns a new instance of the template for this codec.

    Returns any

    Inherited from ObjectCodec.cloneTemplate

    • Defined in serialization/ObjectCodec.ts:284

convertAttributeFromXml

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

    Converts booleans and numeric values to the respective types. Values are numeric if isNumericAttribute returns true.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • attr: any

      XML attribute to be converted.

    • obj: any

      Objec to convert the attribute for.

    Returns any

    Inherited from ObjectCodec.convertAttributeFromXml

    • Defined in serialization/ObjectCodec.ts:576

convertAttributeToXml

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

    Converts true to "1" and false to "0" is isBooleanAttribute returns true. All other values are not converted.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Objec to convert the attribute for.

    • name: string | null

      Name of the attribute to be converted.

    • value: any

      Value to be converted.

    • node: Element

    Returns any

    Inherited from ObjectCodec.convertAttributeToXml

    • Defined in serialization/ObjectCodec.ts:540

decode

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

    Parses the given node into the object or returns a new object representing the given node.

    Dec is a reference to the calling decoder. It is used to decode complex objects and resolve references.

    If a node has an id attribute then the object cache is checked for the object. If the object is not yet in the cache then it is constructed using the constructor of template and cached in Codec.objects.

    This implementation decodes all attributes and childs of a node according to the following rules:

    • If the variable name is in exclude or if the attribute name is "id" or "as" then it is ignored.
    • If the variable name is in idrefs then Codec.getObject is used to replace the reference with an object.
    • The variable name is mapped using a reverse mapping.
    • If the value has a child node, then the codec is used to create a child object with the variable name taken from the "as" attribute.
    • If the object is an array and the variable name is empty then the value or child object is appended to the array.
    • If an add child has no value or the object is not an array then the child text content is evaluated using eval.

    For add nodes where the object is not an array and the variable name is defined, the default mechanism is used, allowing to override/add methods as follows:

    <Object>
    <add as="hello"><![CDATA[
    function(arg1) {
    mxUtils.alert('Hello '+arg1);
    }
    ]]></add>
    </Object>

    If no object exists for an ID in idrefs a warning is issued using GlobalConfig.logger.

    Returns the resulting object that represents the given XML node or the object given to the method as the into parameter.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • node: Element

      XML node to be decoded.

    • Optionalinto: any

      Optional object to encode the node into.

    Returns any

    Inherited from ObjectCodec.decode

    • Defined in serialization/ObjectCodec.ts:686

decodeAttribute

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

    Reads the given attribute into the specified object.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • attr: any

      XML attribute to be decoded.

    • Optionalobj: any

      Objec to encode the attribute into.

    Returns void

    Inherited from ObjectCodec.decodeAttribute

    • Defined in serialization/ObjectCodec.ts:753

decodeAttributes

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

    Decodes all attributes of the given node using decodeAttribute.

    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 void

    Inherited from ObjectCodec.decodeAttributes

    • Defined in serialization/ObjectCodec.ts:724

decodeChild

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

    Reads the specified child into the given object.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • child: Element

      XML child element to be decoded.

    • obj: any

      Objec to encode the node into.

    Returns void

    Inherited from ObjectCodec.decodeChild

    • Defined in serialization/ObjectCodec.ts:811

decodeChildren

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

    Decodes all children of the given node using decodeChild.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • node: Element

      XML node to be decoded.

    • Optionalobj: any

      Objec to encode the node into.

    Returns void

    Inherited from ObjectCodec.decodeChildren

    • Defined in serialization/ObjectCodec.ts:790

decodeNode

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

    Calls decodeAttributes and decodeChildren for the given node.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • node: Element | null

      XML node to be decoded.

    • obj: any

      Object to encode the node into.

    Returns void

    Inherited from ObjectCodec.decodeNode

    • Defined in serialization/ObjectCodec.ts:710

encode

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

    Encodes the specified object and returns a node representing then given object. Calls beforeEncode after creating the node and afterEncode with the resulting node after processing.

    Enc is a reference to the calling encoder. It is used to encode complex objects and create references.

    This implementation encodes all variables of an object according to the following rules:

    • If the variable name is in exclude then it is ignored.
    • If the variable name is in idrefs then Codec.getId is used to replace the object with its ID.
    • The variable name is mapped using mapping.
    • If obj is an array and the variable name is numeric (ie. an index) then it is not encoded.
    • If the value is an object, then the codec is used to create a child node with the variable name encoded into the "as" attribute.
    • Else, if encodeDefaults is true or the value differs from the template value, then ...
    • ... if obj is not an array, then the value is mapped to an attribute.
    • ... else if obj is an array, the value is mapped to an add child with a value attribute or a text child node, if the value is a function.

    If no ID exists for a variable in idrefs or if an object cannot be encoded, a warning is issued using GlobalConfig.logger.

    Returns the resulting XML node that represents the given object.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Object to be encoded.

    Returns Element | null

    Inherited from ObjectCodec.encode

    • Defined in serialization/ObjectCodec.ts:391

encodeObject

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

    Encodes the value of each member in then given obj into the given node using encodeValue.

    Parameters

    • enc: Codec

      Codec that controls the encoding process.

    • obj: any

      Object to be encoded.

    • node: Element

      XML node that contains the encoded object.

    Returns void

    Inherited from ObjectCodec.encodeObject

    • Defined in serialization/ObjectCodec.ts:408

encodeValue

  • encodeValue(
        enc: Codec,
        obj: any,
        name: string | null,
        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: string | null

      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

    Inherited from ObjectCodec.encodeValue

    • Defined in serialization/ObjectCodec.ts:436

getAttributeName

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

    Returns the attribute name for the given field name. Looks up the value in the mapping or returns the input if there is no mapping for the given name.

    Parameters

    • fieldname: string | null

    Returns string | null

    Inherited from ObjectCodec.getAttributeName

    • Defined in serialization/ObjectCodec.ts:312

getFieldName

  • getFieldName(attributename: string): string

    Returns the field name for the given attribute name. Looks up the value in the reverse mapping or returns the input if there is no reverse mapping for the given name.

    Parameters

    • attributename: string

    Returns string

    Inherited from ObjectCodec.getFieldName

    • Defined in serialization/ObjectCodec.ts:294

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

    Inherited from ObjectCodec.getFieldTemplate

    • Defined in serialization/ObjectCodec.ts:846

getName

  • getName(): string

    Returns the name used for the node names 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 from what this returns.

    The default implementation returns the classname of the template class if no name is set.

    Returns string

    Inherited from ObjectCodec.getName

    • Defined in serialization/ObjectCodec.ts:273

isBooleanAttribute

  • isBooleanAttribute(
        enc: Codec,
        obj: any,
        name: string | null,
        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

      Object to convert the attribute for.

    • name: string | null

      Name of the attribute to be converted.

    • value: any

      Value of the attribute to be converted.

    Returns boolean

    Inherited from ObjectCodec.isBooleanAttribute

    • Defined in serialization/ObjectCodec.ts:564

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 field name is in exclude or if the field name 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.

    • Optionalwrite: 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

    Inherited from ObjectCodec.isExcluded

    • Defined in serialization/ObjectCodec.ts:334

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.

    • Optionalobj: any

      Objec to encode the attribute into.

    Returns boolean

    Inherited from ObjectCodec.isIgnoredAttribute

    • Defined in serialization/ObjectCodec.ts:742

isNumericAttribute

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

    Returns true if the given XML attribute is or should be a numeric value.

    Parameters

    • dec: Codec

      Codec that controls the decoding process.

    • attr: any

      XML attribute to be converted.

    • obj: any

      Object to convert the attribute for.

    Returns boolean

    Inherited from ObjectCodec.isNumericAttribute

    • Defined in serialization/ObjectCodec.ts:597

isReference

  • isReference(obj: any, attr: string | null, value: any, write?: boolean): boolean

    Returns true if the given field name is to be treated as a textual reference (ID). This implementation returns true if the given field name is in idrefs.

    Parameters

    • obj: any

      Object instance that contains the field.

    • attr: string | null

      Field name of the field.

    • value: any

      Value of the field.

    • Optionalwrite: 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

    Inherited from ObjectCodec.isReference

    • Defined in serialization/ObjectCodec.ts:349

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.

    • Optionalinto: any

      Optional object to pass-thru to the codec.

    Returns boolean

    Inherited from ObjectCodec.processInclude

    • Defined in serialization/ObjectCodec.ts:884

setName

  • setName(name: string): void

    Parameters

    • name: string

    Returns void

    Inherited from ObjectCodec.setName

    • Defined in serialization/ObjectCodec.ts:277

writeAttribute

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

    Writes the given value into node using writePrimitiveAttribute or writeComplexAttribute depending on the type of the value.

    Parameters

    • enc: Codec
    • obj: any
    • name: string | null
    • value: any
    • node: Element

    Returns void

    Inherited from ObjectCodec.writeAttribute

    • Defined in serialization/ObjectCodec.ts:467

writeComplexAttribute

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

    Writes the given value as a child node of the given node.

    Parameters

    • enc: Codec
    • obj: any
    • name: string | null
    • value: any
    • node: Element

    Returns void

    Inherited from ObjectCodec.writeComplexAttribute

    • Defined in serialization/ObjectCodec.ts:511

writePrimitiveAttribute

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

    Writes the given value as an attribute of the given node.

    Parameters

    • enc: Codec
    • obj: any
    • name: string | null
    • value: any
    • node: Element

    Returns void

    Inherited from ObjectCodec.writePrimitiveAttribute

    • Defined in serialization/ObjectCodec.ts:484

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Constructors
constructor
Properties
excludeidrefsmappingreversetemplateallowEval
Methods
addObjectValueafterDecodeafterEncodebeforeDecodebeforeEncodecloneTemplateconvertAttributeFromXmlconvertAttributeToXmldecodedecodeAttributedecodeAttributesdecodeChilddecodeChildrendecodeNodeencodeencodeObjectencodeValuegetAttributeNamegetFieldNamegetFieldTemplategetNameisBooleanAttributeisExcludedisIgnoredAttributeisNumericAttributeisReferenceprocessIncludesetNamewriteAttributewriteComplexAttributewritePrimitiveAttribute
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.