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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 3x 1x 1x 1x 1x 1x | const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_utils.clas.abap
class zcl_abapgit_utils {
static STATIC_SUPER = undefined;
static INTERNAL_TYPE = 'CLAS';
static INTERNAL_NAME = 'ZCL_ABAPGIT_UTILS';
static IMPLEMENTED_INTERFACES = [];
static ATTRIBUTES = {};
static METHODS = {"IS_BINARY": {"visibility": "U", "parameters": {"RV_IS_BINARY": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " ", "parm_kind": "R", "type_name": "CharacterType"}, "IV_DATA": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "XStringType"}}},
"IS_VALID_EMAIL": {"visibility": "U", "parameters": {"RV_VALID": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " ", "parm_kind": "R", "type_name": "CharacterType"}, "IV_EMAIL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}},
"CHECK_EOL": {"visibility": "U", "parameters": {"IV_DATA": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}}};
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 check_eol(INPUT) {
return zcl_abapgit_utils.check_eol(INPUT);
}
static async check_eol(INPUT) {
let iv_data = INPUT?.iv_data;
if (iv_data?.getQualifiedName === undefined || iv_data.getQualifiedName() !== "STRING") { iv_data = undefined; }
if (iv_data === undefined) { iv_data = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_data); }
if (abap.compare.initial(iv_data) === false && abap.compare.cs(iv_data, abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline) && abap.compare.ns(iv_data, abap.Classes['CL_ABAP_CHAR_UTILITIES'].cr_lf)) {
await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(52, 'Incorrect source format: Requires CRLF instead of LF')});
}
}
async is_binary(INPUT) {
return zcl_abapgit_utils.is_binary(INPUT);
}
static async is_binary(INPUT) {
let rv_is_binary = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
let iv_data = INPUT?.iv_data;
if (iv_data?.getQualifiedName === undefined || iv_data.getQualifiedName() !== "XSTRING") { iv_data = undefined; }
if (iv_data === undefined) { iv_data = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.iv_data); }
let lc_binary_threshold = new abap.types.Integer({qualifiedName: "I"});
lc_binary_threshold.set(10);
let lc_bytes_to_check = new abap.types.Integer({qualifiedName: "I"});
lc_bytes_to_check.set(1000);
let lv_string_data = new abap.types.String({qualifiedName: "STRING"});
let lv_printable_chars_count = new abap.types.Integer({qualifiedName: "I"});
let lv_percentage = new abap.types.Integer({qualifiedName: "I"});
let lv_data = new abap.types.XString({qualifiedName: "XSTRING"});
let lv_xlen = new abap.types.Integer({qualifiedName: "I"});
lv_xlen.set(abap.builtin.xstrlen({val: iv_data}));
if (abap.compare.eq(lv_xlen, abap.IntegerFactory.get(0))) {
return rv_is_binary;
}
lv_xlen.set(abap.builtin.nmin({val1: lv_xlen, val2: lc_bytes_to_check}));
lv_data.set(iv_data.getOffset({length: lv_xlen}));
try {
lv_string_data.set((await abap.Classes['ZCL_ABAPGIT_CONVERT'].xstring_to_string_utf8({iv_data: lv_data})));
} catch (e) {
if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
rv_is_binary.set(abap.builtin.abap_true);
return rv_is_binary;
} else {
throw e;
}
}
abap.statements.replace({target: lv_string_data, all: true, with: abap.builtin.space, of: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline});
abap.statements.replace({target: lv_string_data, all: true, with: abap.builtin.space, of: abap.Classes['CL_ABAP_CHAR_UTILITIES'].cr_lf});
abap.statements.find(lv_string_data, {regex: abap.CharacterFactory.get(12, '[^[:print:]]'), first: false, count: lv_printable_chars_count});
lv_percentage.set(abap.operators.divide(abap.operators.multiply(lv_printable_chars_count,abap.IntegerFactory.get(100)),abap.builtin.strlen({val: lv_string_data})));
rv_is_binary.set(abap.builtin.boolc(abap.compare.gt(lv_percentage, lc_binary_threshold)));
return rv_is_binary;
}
async is_valid_email(INPUT) {
return zcl_abapgit_utils.is_valid_email(INPUT);
}
static async is_valid_email(INPUT) {
let rv_valid = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
let iv_email = INPUT?.iv_email;
if (iv_email?.getQualifiedName === undefined || iv_email.getQualifiedName() !== "STRING") { iv_email = undefined; }
if (iv_email === undefined) { iv_email = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_email); }
let lc_email_regex = new abap.types.String({qualifiedName: "STRING"});
lc_email_regex.set('[\\w!#$%&*+/=?`{|}~^-]+(?:\\.[\\w!#$%&*+/=?`{|}~^-]+)*@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,6}');
if (abap.compare.initial(iv_email)) {
rv_valid.set(abap.builtin.abap_true);
} else {
abap.statements.find(iv_email, {regex: lc_email_regex});
rv_valid.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))));
}
return rv_valid;
}
}
abap.Classes['ZCL_ABAPGIT_UTILS'] = zcl_abapgit_utils;
export {zcl_abapgit_utils}; |