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 | 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 2x 7x 1x 5x 1x 3x 3x 7x 7x 3x 3x 2x 1x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 3x 7x 7x 7x 7x 7x 7x 4x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 4x 4x 4x 7x 1x 1x | const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_ajson_utilities.clas.locals_imp.abap
class lcl_node_iterator {
static STATIC_SUPER = undefined;
static INTERNAL_TYPE = 'CLAS';
static INTERNAL_NAME = 'CLAS-ZCL_ABAPGIT_AJSON_UTILITIES-LCL_NODE_ITERATOR';
static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_AJSON_ITERATOR"];
static ATTRIBUTES = {"MI_JSON": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
"MV_NODE_TYPE": {"type": () => {return new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
"MV_BASE_PATH": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
"MR_CURSOR": {"type": () => {return new abap.types.DataReference(new abap.types.Structure({
"path": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-PATH"}),
"name": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-NAME"}),
"type": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"}),
"value": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-VALUE"}),
"index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-INDEX"}),
"order": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-ORDER"}),
"children": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-CHILDREN"})}, "zif_abapgit_ajson_types=>ty_node", undefined, {}, {}));}, "visibility": "I", "is_constant": " ", "is_class": " "},
"MV_TABIX": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
"MV_HAS_NEXT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
static METHODS = {"FIND_FIRST_NODE": {"visibility": "I", "parameters": {}},
"CONSTRUCTOR": {"visibility": "U", "parameters": {"II_JSON": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "IV_PATH": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}, "IV_NODE_TYPE": {"type": () => {return new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}}};
#mi_json;
#mv_node_type;
#mv_base_path;
#mr_cursor;
#mv_tabix;
#mv_has_next;
constructor() {
this.me = new abap.types.ABAPObject();
this.me.set(this);
this.INTERNAL_ID = abap.internalIdCounter++;
this.FRIENDS_ACCESS_INSTANCE = {
"find_first_node": this.#find_first_node.bind(this),
};
this.#mi_json = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});
this.FRIENDS_ACCESS_INSTANCE["mi_json"] = this.#mi_json;
this.#mv_node_type = new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"});
this.FRIENDS_ACCESS_INSTANCE["mv_node_type"] = this.#mv_node_type;
this.#mv_base_path = new abap.types.String({qualifiedName: "STRING"});
this.FRIENDS_ACCESS_INSTANCE["mv_base_path"] = this.#mv_base_path;
this.#mr_cursor = new abap.types.DataReference(new abap.types.Structure({
"path": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-PATH"}),
"name": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-NAME"}),
"type": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"}),
"value": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-VALUE"}),
"index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-INDEX"}),
"order": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-ORDER"}),
"children": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE-CHILDREN"})}, "zif_abapgit_ajson_types=>ty_node", undefined, {}, {}));
this.FRIENDS_ACCESS_INSTANCE["mr_cursor"] = this.#mr_cursor;
this.#mv_tabix = new abap.types.Integer({qualifiedName: "I"});
this.FRIENDS_ACCESS_INSTANCE["mv_tabix"] = this.#mv_tabix;
this.#mv_has_next = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
this.FRIENDS_ACCESS_INSTANCE["mv_has_next"] = this.#mv_has_next;
}
async constructor_(INPUT) {
let ii_json = INPUT?.ii_json;
if (ii_json?.getQualifiedName === undefined || ii_json.getQualifiedName() !== "ZIF_ABAPGIT_AJSON") { ii_json = undefined; }
if (ii_json === undefined) { ii_json = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"}).set(INPUT.ii_json); }
let iv_path = INPUT?.iv_path;
if (iv_path?.getQualifiedName === undefined || iv_path.getQualifiedName() !== "STRING") { iv_path = undefined; }
if (iv_path === undefined) { iv_path = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_path); }
let iv_node_type = INPUT?.iv_node_type;
if (iv_node_type?.getQualifiedName === undefined || iv_node_type.getQualifiedName() !== "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE") { iv_node_type = undefined; }
if (iv_node_type === undefined) { iv_node_type = new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"}).set(INPUT.iv_node_type); }
if (!(abap.compare.eq(iv_node_type, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().array) || abap.compare.eq(iv_node_type, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().object))) {
await abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'].raise({iv_msg: new abap.types.String().set(`Iterator can iterate arrays or objects only ("${abap.templateFormatting(iv_node_type)}" passed)`)});
}
this.#mv_base_path.set((await abap.Classes['ZCL_ABAPGIT_AJSON'].normalize_path({iv_path: iv_path})));
this.#mv_node_type.set(iv_node_type);
this.#mi_json.set(ii_json);
let lv_node_type = new abap.types.String({qualifiedName: "ZIF_ABAPGIT_AJSON_TYPES=>TY_NODE_TYPE"});
lv_node_type.set((await ii_json.get().zif_abapgit_ajson$get_node_type({iv_path: this.#mv_base_path})));
if (abap.compare.initial(lv_node_type)) {
await abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'].raise({iv_msg: new abap.types.String().set(`Path not found: ${abap.templateFormatting(iv_path)}`)});
} else if (abap.compare.eq(this.#mv_node_type, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().array) && abap.compare.ne(lv_node_type, this.#mv_node_type)) {
await abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'].raise({iv_msg: new abap.types.String().set(`Array expected at: ${abap.templateFormatting(iv_path)}`)});
} else if (abap.compare.eq(this.#mv_node_type, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().object) && abap.compare.ne(lv_node_type, this.#mv_node_type)) {
await abap.Classes['ZCX_ABAPGIT_AJSON_ERROR'].raise({iv_msg: new abap.types.String().set(`Object expected at: ${abap.templateFormatting(iv_path)}`)});
}
await this.#find_first_node();
return this;
}
async #find_first_node() {
let unique561 = this.#mv_node_type;
if (abap.compare.eq(unique561, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().array)) {
for await (const unique562 of abap.statements.loop(this.#mi_json.get().zif_abapgit_ajson$mt_json_tree,{usingKey: "array_index",where: async (I) => {return abap.compare.eq(I.path, this.#mv_base_path);},topEquals: {"path": this.#mv_base_path}})) {
this.#mr_cursor.assign(unique562);
this.#mv_has_next.set(abap.builtin.abap_true);
this.#mv_tabix.set(abap.builtin.sy.get().tabix);
break;
}
} else if (abap.compare.eq(unique561, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().object)) {
for await (const unique563 of abap.statements.loop(this.#mi_json.get().zif_abapgit_ajson$mt_json_tree,{where: async (I) => {return abap.compare.eq(I.path, this.#mv_base_path);},topEquals: {"path": this.#mv_base_path}})) {
this.#mr_cursor.assign(unique563);
this.#mv_has_next.set(abap.builtin.abap_true);
this.#mv_tabix.set(abap.builtin.sy.get().tabix);
break;
}
} else {
abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.IntegerFactory.get(0)));
}
}
async zif_abapgit_ajson_iterator$has_next() {
let rv_yes = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
rv_yes.set(this.#mv_has_next);
return rv_yes;
}
async zif_abapgit_ajson_iterator$next() {
let ri_item = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_AJSON", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_AJSON"});
if (abap.compare.eq(this.#mv_has_next, abap.builtin.abap_false)) {
return ri_item;
}
ri_item.set((await this.#mi_json.get().zif_abapgit_ajson$slice({iv_path: new abap.types.String().set(`${abap.templateFormatting(this.#mr_cursor.get().path)}${abap.templateFormatting(this.#mr_cursor.get().name)}`)})));
this.#mv_tabix.set(abap.operators.add(this.#mv_tabix,abap.IntegerFactory.get(1)));
let unique564 = this.#mv_node_type;
if (abap.compare.eq(unique564, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().array)) {
abap.statements.readTable(this.#mi_json.get().zif_abapgit_ajson$mt_json_tree,{index: this.#mv_tabix,
referenceInto: this.#mr_cursor});
} else if (abap.compare.eq(unique564, abap.Classes['ZIF_ABAPGIT_AJSON_TYPES'].zif_abapgit_ajson_types$node_type.get().object)) {
abap.statements.readTable(this.#mi_json.get().zif_abapgit_ajson$mt_json_tree,{index: this.#mv_tabix,
referenceInto: this.#mr_cursor});
} else {
abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.IntegerFactory.get(0)));
}
this.#mv_has_next.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0)) && abap.compare.eq(this.#mr_cursor.get().path, this.#mv_base_path)));
return ri_item;
}
}
abap.Classes['CLAS-ZCL_ABAPGIT_AJSON_UTILITIES-LCL_NODE_ITERATOR'] = lcl_node_iterator;
export {lcl_node_iterator}; |