EncodingPatcher

Configuration file

sample_EncodingPatcher_Format_EDI.properties

Class name

com.ebd.hub.datawizard.parser.stream.EncodingPatcher

Description


This preparser is able to replace bytes or byte sequences with other bytes, byte sequences, or nothing. The main use of this preparser is the repair of damaged data. Statements for the replacements are stored in a properties file. One statement is equal to one line with the following structure: 0xHEXA1=0xHEXA2

Example


0xE9=0x20

Replaces every byte E9 with the byte 20.

0x0d0a=

Replaces the byte sequence 0D0A with nothing.

0x04=0x0D0A

Replaces the control character 04 with 0D0A (CR-LF).

The hex characters A to F can either be written in lowercase or uppercase. Every byte sequence must have an even number of hex characters. Every statement is on the same hierarchy level, independent of the order in the configuration file. The byte sequence on the left side of the = is replaced with the byte sequence on the right side of the =.

It is possible to chain up several EncodingPatchers with the ChainPreParser.

Example file


sample_EncodingPatcher_Format_EDI.properties
#! class = com.ebd.hub.datawizard.parser.stream.EncodingPatcher
# Properties File for formatting EDI and TradaComs
# Encoding: only ISO-8859_1 or ASCII. For UTF8 use with care.
# UNA:+.? '\r\n replace nothing
0x554E413A2B2E3F20270D0A = 0x554E413A2B2E3F20270D0A
# UNA:+.? '\n -> UNA:+.? '\r\n
0x554E413A2B2E3F20270A = 0x554E413A2B2E3F20270D0A
# UNA:+.? 'UN -> UNA:+.? '\r\nUN
0x554E413A2B2E3F2027554E = 0x554E413A2B2E3F20270D0A554E
# ?? replace nothing
0x3F3F = 0x3F3F
# ?' replace nothing
0x3F27 = 0x3F27
# '\r\n replace nothing
0x270D0A = 0x270D0A
# '\n -> '\r\n
0x270A = 0x270D0A
# ' -> '\r\n
0x27 = 0x270D0A
# \r\n -> remove it
0x0D0A =
# \n -> remove it
0x0A =