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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_xml_pretty.clas.abap
class zcl_abapgit_xml_pretty {
static STATIC_SUPER = undefined;
static INTERNAL_TYPE = 'CLAS';
static INTERNAL_NAME = 'ZCL_ABAPGIT_XML_PRETTY';
static IMPLEMENTED_INTERFACES = [];
static ATTRIBUTES = {};
static METHODS = {"RAISE_ERROR": {"visibility": "I", "parameters": {"II_PARSER": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_IXML_PARSER", RTTIName: "\\INTERFACE=IF_IXML_PARSER"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}}},
"PRINT": {"visibility": "U", "parameters": {"RV_XML": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "R", "type_name": "StringType"}, "IV_XML": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}, "IV_IGNORE_ERRORS": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}, "IV_UNPRETTY": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}}}};
constructor() {
this.me = new abap.types.ABAPObject();
this.me.set(this);
this.INTERNAL_ID = abap.internalIdCounter++;
this.FRIENDS_ACCESS_INSTANCE = {
};
}
async constructor_(INPUT) {
if (super.constructor_) { await super.constructor_(INPUT); }
return this;
}
async print(INPUT) {
return zcl_abapgit_xml_pretty.print(INPUT);
}
static async print(INPUT) {
let rv_xml = new abap.types.String({qualifiedName: "STRING"});
let iv_xml = INPUT?.iv_xml;
if (iv_xml?.getQualifiedName === undefined || iv_xml.getQualifiedName() !== "STRING") { iv_xml = undefined; }
if (iv_xml === undefined) { iv_xml = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_xml); }
let iv_ignore_errors = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
if (INPUT && INPUT.iv_ignore_errors) {iv_ignore_errors.set(INPUT.iv_ignore_errors);}
if (INPUT === undefined || INPUT.iv_ignore_errors === undefined) {iv_ignore_errors = abap.builtin.abap_true;}
let iv_unpretty = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
if (INPUT && INPUT.iv_unpretty) {iv_unpretty.set(INPUT.iv_unpretty);}
if (INPUT === undefined || INPUT.iv_unpretty === undefined) {iv_unpretty = abap.builtin.abap_false;}
let li_ixml = new abap.types.ABAPObject({qualifiedName: "IF_IXML", RTTIName: "\\INTERFACE=IF_IXML"});
let li_xml_doc = new abap.types.ABAPObject({qualifiedName: "IF_IXML_DOCUMENT", RTTIName: "\\INTERFACE=IF_IXML_DOCUMENT"});
let li_stream_factory = new abap.types.ABAPObject({qualifiedName: "IF_IXML_STREAM_FACTORY", RTTIName: "\\INTERFACE=IF_IXML_STREAM_FACTORY"});
let li_istream = new abap.types.ABAPObject({qualifiedName: "IF_IXML_ISTREAM", RTTIName: "\\INTERFACE=IF_IXML_ISTREAM"});
let li_parser = new abap.types.ABAPObject({qualifiedName: "IF_IXML_PARSER", RTTIName: "\\INTERFACE=IF_IXML_PARSER"});
let lv_xstring = new abap.types.XString({qualifiedName: "XSTRING"});
let li_encoding = new abap.types.ABAPObject({qualifiedName: "IF_IXML_ENCODING", RTTIName: "\\INTERFACE=IF_IXML_ENCODING"});
let li_ostream = new abap.types.ABAPObject({qualifiedName: "IF_IXML_OSTREAM", RTTIName: "\\INTERFACE=IF_IXML_OSTREAM"});
let li_renderer = new abap.types.ABAPObject({qualifiedName: "IF_IXML_RENDERER", RTTIName: "\\INTERFACE=IF_IXML_RENDERER"});
abap.statements.assert(abap.compare.initial(iv_xml) === false);
li_ixml.set((await abap.Classes['CL_IXML'].create()));
li_xml_doc.set((await li_ixml.get().if_ixml$create_document()));
li_stream_factory.set((await li_ixml.get().if_ixml$create_stream_factory()));
li_istream.set((await li_stream_factory.get().if_ixml_stream_factory$create_istream_xstring({string: (await abap.Classes['ZCL_ABAPGIT_CONVERT'].string_to_xstring_utf8({iv_string: iv_xml}))})));
li_parser.set((await li_ixml.get().if_ixml$create_parser({stream_factory: li_stream_factory, istream: li_istream, document: li_xml_doc})));
await li_parser.get().if_ixml_parser$set_normalizing({normal: abap.builtin.abap_true});
if (abap.compare.ne((await li_parser.get().if_ixml_parser$parse()), abap.IntegerFactory.get(0))) {
if (abap.compare.eq(iv_ignore_errors, abap.builtin.abap_true)) {
rv_xml.set(iv_xml);
return rv_xml;
} else {
await this.raise_error({ii_parser: li_parser});
}
}
li_ostream.set((await li_stream_factory.get().if_ixml_stream_factory$create_ostream_xstring({string: lv_xstring})));
li_encoding.set((await li_ixml.get().if_ixml$create_encoding({character_set: abap.CharacterFactory.get(5, 'utf-8'), byte_order: abap.Classes['IF_IXML_ENCODING'].if_ixml_encoding$co_big_endian})));
await li_xml_doc.get().if_ixml_document$set_encoding({encoding: li_encoding});
li_renderer.set((await li_ixml.get().if_ixml$create_renderer({ostream: li_ostream, document: li_xml_doc})));
await li_renderer.get().if_ixml_renderer$set_normalizing({normal: abap.builtin.boolc(abap.compare.eq(iv_unpretty, abap.builtin.abap_false))});
await li_renderer.get().if_ixml_renderer$render();
rv_xml.set((await abap.Classes['ZCL_ABAPGIT_CONVERT'].xstring_to_string_utf8_bom({iv_xstring: lv_xstring})));
abap.statements.replace({target: rv_xml, all: false, with: abap.CharacterFactory.get(6, 'utf-16'), of: abap.CharacterFactory.get(5, 'utf-8')});
return rv_xml;
}
async raise_error(INPUT) {
return zcl_abapgit_xml_pretty.raise_error(INPUT);
}
static async raise_error(INPUT) {
let ii_parser = INPUT?.ii_parser;
if (ii_parser?.getQualifiedName === undefined || ii_parser.getQualifiedName() !== "IF_IXML_PARSER") { ii_parser = undefined; }
if (ii_parser === undefined) { ii_parser = new abap.types.ABAPObject({qualifiedName: "IF_IXML_PARSER", RTTIName: "\\INTERFACE=IF_IXML_PARSER"}).set(INPUT.ii_parser); }
let lv_num_errors = new abap.types.Integer({qualifiedName: "I"});
let li_error = new abap.types.ABAPObject({qualifiedName: "IF_IXML_PARSE_ERROR", RTTIName: "\\INTERFACE=IF_IXML_PARSE_ERROR"});
let lv_reason = new abap.types.String({qualifiedName: "STRING"});
lv_num_errors.set((await ii_parser.get().if_ixml_parser$num_errors()));
const indexBackup1 = abap.builtin.sy.get().index.get();
const unique1355 = lv_num_errors.get();
for (let unique1356 = 0; unique1356 < unique1355; unique1356++) {
abap.builtin.sy.get().index.set(unique1356 + 1);
li_error.set((await ii_parser.get().if_ixml_parser$get_error({index: abap.builtin.sy.get().index, min_severity: abap.Classes['IF_IXML_PARSE_ERROR'].if_ixml_parse_error$co_info})));
if (abap.compare.initial(li_error) === false) {
lv_reason.set((await li_error.get().if_ixml_parse_error$get_reason()));
}
if (abap.compare.initial(lv_reason) === false) {
break;
}
}
abap.builtin.sy.get().index.set(indexBackup1);
if (abap.compare.initial(lv_reason) === false) {
await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: lv_reason});
} else {
await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(17, 'error parsing xml')});
}
}
}
abap.Classes['ZCL_ABAPGIT_XML_PRETTY'] = zcl_abapgit_xml_pretty;
export {zcl_abapgit_xml_pretty}; |