import {IDisposable} from "../../interfaces/Interfaces"; import {JSONDigester} from "../json-digester/JSONDigester"; import {Report} from "../../items/Report"; import {JRDigesterFactory} from "./JRDigesterFactory"; export class JSONSchemaLoader implements IDisposable { private _digester:JSONDigester; private _report:Report; constructor(digester:JSONDigester) { this._digester = digester; } load(json:{[key:string]: any}):Report { try { this._digester.push(this); this._digester.parse(json); } finally { this._digester.clear(); } return this._report; } dispose() { } setReport(report: Report):void { this._report = report; } static load(json:{[key:string]: any}):Report { const loader = new JSONSchemaLoader(JRDigesterFactory.createDigester()); return loader.load(json); } }