All files / output cl_abap_conv_in_ce.clas.mjs

85.21% Statements 121/142
65.78% Branches 25/38
26.66% Functions 8/30
85.21% Lines 121/142

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 1421x 1x 302x 302x 302x 302x 302x 302x 302x 302x 1x 1x 1x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x     302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 38x 302x 189x 264x 75x 75x     302x 302x 302x 302x 302x     302x 75x 75x 75x 75x 75x 75x 75x 75x 75x           75x 75x 302x     302x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x 302x       302x 2x 2x 302x 2x 2x 2x 2x 302x 302x           302x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_abap_conv_in_ce.clas.abap
class cl_abap_conv_in_ce {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_ABAP_CONV_IN_CE';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"MV_INPUT": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_JS_ENCODING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_IGNORE_CERR": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"CREATE": {"visibility": "U", "parameters": {"RET": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_IN_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_IN_CE"});}, "is_optional": " "}, "ENCODING": {"type": () => {return new abap.types.Character(20, {"qualifiedName":"abap_encoding"});}, "is_optional": " "}, "INPUT": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "REPLACEMENT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"CHAR1","ddicName":"CHAR1","description":"CHAR1"});}, "is_optional": " "}, "IGNORE_CERR": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "ENDIAN": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"CHAR1","ddicName":"CHAR1","description":"CHAR1"});}, "is_optional": " "}}},
  "UCCPI": {"visibility": "U", "parameters": {"CHAR": {"type": () => {return new abap.types.Character(2, {"qualifiedName":"cl_abap_conv_in_ce=>ty_char2"});}, "is_optional": " "}, "UCCP": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}},
  "UCCP": {"visibility": "U", "parameters": {"CHAR": {"type": () => {return new abap.types.Character(2, {"qualifiedName":"cl_abap_conv_in_ce=>ty_char2"});}, "is_optional": " "}, "UCCP": {"type": () => {return new abap.types.Character();}, "is_optional": " "}}},
  "CONVERT": {"visibility": "U", "parameters": {"INPUT": {"type": () => {return new abap.types.Hex();}, "is_optional": " "}, "N": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}, "DATA": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "READ": {"visibility": "U", "parameters": {"N": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}, "DATA": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}}};
  #mv_input;
  #mv_js_encoding;
  #mv_ignore_cerr;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "convert": this.convert.bind(this),
      "read": this.read.bind(this),
    };
    this.#mv_input = new abap.types.XString({qualifiedName: "XSTRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_input"] = this.#mv_input;
    this.#mv_js_encoding = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_js_encoding"] = this.#mv_js_encoding;
    this.#mv_ignore_cerr = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    this.FRIENDS_ACCESS_INSTANCE["mv_ignore_cerr"] = this.#mv_ignore_cerr;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async create(INPUT) {
    return cl_abap_conv_in_ce.create(INPUT);
  }
  static async create(INPUT) {
    let ret = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_IN_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_IN_CE"});
    let encoding = new abap.types.Character(20, {"qualifiedName":"abap_encoding"});
    if (INPUT && INPUT.encoding) {encoding.set(INPUT.encoding);}
    if (INPUT === undefined || INPUT.encoding === undefined) {encoding = abap.CharacterFactory.get(5, 'UTF-8');}
    let input = new abap.types.XString({qualifiedName: "XSTRING"});
    if (INPUT && INPUT.input) {input.set(INPUT.input);}
    let replacement = new abap.types.Character(1, {"qualifiedName":"CHAR1","ddicName":"CHAR1","description":"CHAR1"});
    if (INPUT && INPUT.replacement) {replacement.set(INPUT.replacement);}
    if (INPUT === undefined || INPUT.replacement === undefined) {replacement = abap.CharacterFactory.get(1, '#');}
    let ignore_cerr = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    if (INPUT && INPUT.ignore_cerr) {ignore_cerr.set(INPUT.ignore_cerr);}
    if (INPUT === undefined || INPUT.ignore_cerr === undefined) {ignore_cerr = abap.builtin.abap_false;}
    let endian = new abap.types.Character(1, {"qualifiedName":"CHAR1","ddicName":"CHAR1","description":"CHAR1"});
    if (INPUT && INPUT.endian) {endian.set(INPUT.endian);}
    abap.statements.assert(abap.compare.eq(replacement, abap.CharacterFactory.get(1, '#')));
    abap.statements.assert(abap.compare.initial(endian));
    ret.set(await (new abap.Classes['CL_ABAP_CONV_IN_CE']()).constructor_());
    let unique1125 = encoding;
    if (abap.compare.eq(unique1125, abap.CharacterFactory.get(6, 'UTF-16'))) {
      ret.get().FRIENDS_ACCESS_INSTANCE["mv_js_encoding"].set(abap.CharacterFactory.get(8, 'utf-16le'));
    } else if (abap.compare.eq(unique1125, abap.CharacterFactory.get(5, 'UTF-8'))) {
      ret.get().FRIENDS_ACCESS_INSTANCE["mv_js_encoding"].set(abap.CharacterFactory.get(4, 'utf8'));
    } else if (abap.compare.eq(unique1125, abap.CharacterFactory.get(4, '4103'))) {
      ret.get().FRIENDS_ACCESS_INSTANCE["mv_js_encoding"].set(abap.CharacterFactory.get(8, 'utf-16le'));
    } else {
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
    }
    ret.get().FRIENDS_ACCESS_INSTANCE["mv_input"].set(input);
    ret.get().FRIENDS_ACCESS_INSTANCE["mv_ignore_cerr"].set(ignore_cerr);
    return ret;
  }
  async uccp(INPUT) {
    return cl_abap_conv_in_ce.uccp(INPUT);
  }
  static async uccp(INPUT) {
    let char = new abap.types.Character(2, {"qualifiedName":"cl_abap_conv_in_ce=>ty_char2"});
    let uccp = INPUT?.uccp;
    let int = new abap.types.Integer({qualifiedName: "I"});
    let hex = new abap.types.Hex({length: 2});
    hex.set(uccp);
    int.set(hex);
    try {
      char.set((await this.uccpi({uccp: int})));
    } catch (e) {
      if ((abap.Classes['CX_SY_CONVERSION_CODEPAGE'] && e instanceof abap.Classes['CX_SY_CONVERSION_CODEPAGE'])) {
      } else {
        throw e;
      }
    }
    return char;
  }
  async uccpi(INPUT) {
    return cl_abap_conv_in_ce.uccpi(INPUT);
  }
  static async uccpi(INPUT) {
    let char = new abap.types.Character(2, {"qualifiedName":"cl_abap_conv_in_ce=>ty_char2"});
    let uccp = INPUT?.uccp;
    if (uccp?.getQualifiedName === undefined || uccp.getQualifiedName() !== "I") { uccp = undefined; }
    if (uccp === undefined) { uccp = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.uccp); }
    let lv_hex = new abap.types.Hex({length: 2});
    let lo_in = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_IN_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_IN_CE"});
    lv_hex.set(uccp);
    abap.statements.concatenate({source: [lv_hex.getOffset({offset: 1, length: 1}), lv_hex.getOffset({length: 1})], target: lv_hex});
    lo_in.set((await this.create({encoding: abap.CharacterFactory.get(4, '4103')})));
    await lo_in.get().convert({input: lv_hex, data: char});
    return char;
  }
  async convert(INPUT) {
    let input = INPUT?.input;
    let n = new abap.types.Integer({qualifiedName: "I"});
    if (INPUT && INPUT.n) {n.set(INPUT.n);}
    let data = INPUT?.data || new abap.types.String({qualifiedName: "STRING"});
    let lv_error = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let encoding = new abap.types.String({qualifiedName: "STRING"});
    let ignore_cerr = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    abap.statements.assert(abap.compare.initial(this.#mv_js_encoding) === false);
    let buf = Buffer.from(input.get(), "hex");
    encoding.set(this.#mv_js_encoding);
    ignore_cerr.set(this.#mv_ignore_cerr);
    const decoder = TextDecoder || await import("util").TextDecoder;
    const td = new decoder(encoding.get(), {fatal: ignore_cerr.get() !== "X", ignoreBOM: true});
    try {
        data.set(td.decode(buf));
    } catch (e) {
      lv_error.set(abap.builtin.abap_true);
    }
    if (abap.compare.eq(lv_error, abap.builtin.abap_true)) {
      const unique1126 = await (new abap.Classes['CX_SY_CONVERSION_CODEPAGE']()).constructor_();
      unique1126.EXTRA_CX = {"INTERNAL_FILENAME": "cl_abap_conv_in_ce.clas.abap","INTERNAL_LINE": 124};
      throw unique1126;
    }
  }
  async read(INPUT) {
    let n = new abap.types.Integer({qualifiedName: "I"});
    if (INPUT && INPUT.n) {n.set(INPUT.n);}
    let data = INPUT?.data || new abap.types.String({qualifiedName: "STRING"});
    await this.convert({input: this.#mv_input, n: n, data: data});
  }
}
abap.Classes['CL_ABAP_CONV_IN_CE'] = cl_abap_conv_in_ce;
cl_abap_conv_in_ce.ty_char2 = new abap.types.Character(2, {"qualifiedName":"cl_abap_conv_in_ce=>ty_char2"});
export {cl_abap_conv_in_ce};