diff options
author | 2020-09-21 10:39:15 +0200 | |
---|---|---|
committer | 2020-09-21 10:34:45 +0000 | |
commit | 31ff2bb854c096cb6c178b2e80c538db73cb2c34 (patch) | |
tree | 271e863137ed7abcc3900a2971817a203e1d63f8 /cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/ParserFactory.ts | |
parent | fbbc9bceb83de1ade5b4b6a666546aba24a14e2f (diff) |
Support parsing of XML files within Velocity and Jinja Template.
Issue-ID: CCSDK-2769
Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: Ib79af3f7621d14176700d80e987c0cdf5a8a11a6
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/ParserFactory.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/ParserFactory.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/ParserFactory.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/ParserFactory.ts new file mode 100644 index 000000000..6cc62758e --- /dev/null +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/ParserFactory.ts @@ -0,0 +1,32 @@ + +import { XmlParser } from './XmlParser'; +import { Parser } from './Parser'; +import { VtlParser } from './VtlParser'; +import { FileExtension } from '../TemplateType'; +import { JinjaXMLParser } from './JinjaXML'; + +export class ParserFactory { + + getParser(fileContent: string, fileExtension: string): Parser { + let parser: Parser; + console.log('file extension =' + fileExtension); + if (fileExtension === FileExtension.Velocity) { + if (this.isXML(fileContent)) { + parser = new XmlParser(); + } else { + parser = new VtlParser(); + } + } else if (fileExtension === FileExtension.Jinja) { + if (this.isXML(fileContent)) { + parser = new JinjaXMLParser(); + } + } else if (fileExtension === FileExtension.XML) { + parser = new XmlParser(); + } + return parser; + } + + private isXML(fileContent: string): boolean { + return fileContent.includes('<?xml version="1.0" encoding="UTF-8"?>'); + } +} |