jspurefix
Version:
pure node js fix engine
80 lines • 2.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContainedFieldSet = void 0;
const elastic_buffer_1 = require("../../buffer/elastic-buffer");
class ContainedFieldSet {
constructor(type, name, category, abbreviation, description) {
this.type = type;
this.name = name;
this.category = category;
this.abbreviation = abbreviation;
this.description = description;
this.groups = new Map();
this.components = new Map();
this.simple = new Map();
this.fields = [];
this.containedTag = {};
this.flattenedTag = [];
this.containedLength = {};
this.localTag = {};
this.localRequired = {};
this.tagToSimple = {};
this.tagToField = {};
this.localNameToField = new Map();
this.nameToLocalAttribute = new Map();
this.localAttribute = [];
this.containsRaw = false;
}
reset() {
this.groups.clear();
this.components.clear();
this.simple.clear();
this.empty(this.fields);
this.empty(this.flattenedTag);
this.empty(this.localAttribute);
this.localNameToField.clear();
}
empty(arr) {
while (arr.length > 0) {
arr.pop();
}
}
toString() {
const buffer = new elastic_buffer_1.ElasticBuffer(2 * 1024);
const fields = this.fields;
buffer.writeString(`Set: ${this.name}(${this.getPrefix()}) fields [${fields.length}]: `);
const set = fields.map((f) => f.toString());
const s = set.join(', ');
buffer.writeString(s);
return buffer.toString();
}
keys() {
const keys = Object.keys(this.containedTag);
const nums = new Array(keys.length);
for (let j = 0; j < keys.length; ++j) {
nums[j] = parseInt(keys[j], 10);
}
return nums;
}
getFieldName(tag) {
const s = this.tagToSimple[tag];
if (s == null) {
const gf = this.tagToField[tag];
if (gf !== null) {
return `${gf.name}`;
}
return `${tag}`;
}
return s.name;
}
getSet(path) {
if (!path)
return null;
return path.split('.').reduce((set, next) => {
var _a, _b;
return (_b = (_a = set.groups.get(next)) !== null && _a !== void 0 ? _a : set.components.get(next)) !== null && _b !== void 0 ? _b : null;
}, this);
}
}
exports.ContainedFieldSet = ContainedFieldSet;
//# sourceMappingURL=contained-field-set.js.map