使用规则表验证组级别数据

时间:2017-03-26 09:00:12

标签: java sql

我在文件中有数据结构规则。输入文件数据应遵循这些规则,如果不需要捕获。

规则如下:

DataRecord|GroupNum|GroupDefination|MinGroupOccurrence|MaxGroupOccurrence|RecordDefination|MinRecordOccurrence|MaxRecordOccurrence
AAA|1|M|1|2|M|1|2
BBB|1|M|1|2|O|0|1
CCC|1|M|1|2|M|1|1
DDD|2|O|0|3|M|1|2
EEE|2|O|0|3|M|1|1
FFF|2|O|0|3|O|0|1

O代表可选,M代表

在第1组中,有三条记录AAA,BBB和CCC。

1st - This group is mandatory so it will definitely should come in input file data.
2nd - This group can occur min 1 time and max 2 times.
Lets say..if this group occurs two times. The data would be like this

1st occurrence of Group 1
AAA 1st occurrence of AAA
AAA This can occur upto two times (2nd occurrence of AAA)
BBB Its optional so it may be here or may not be here. But in this example of   input data its occurred
CCC Its mandatory and can occur only one time

2nd occurrence of Group 1

AAA 1st occurrence of AAA, second time didnt come. Not a problem because its range is from 1 to 2 and its mandtaory. So it should be here atleast one time.
BBB

第二次出现CCC组没有来。但它应该来,因为它的强制数据记录。需要捕获

Here DataRecord is records
- GroupNum is Group number
- GroupDefination  is whether Group is mandatory or optional.
- MinGroupOccurrence and MaxGroupOccurrence is Min and Max number of occurrence of a group.
- RecordDefination tells whether record is mandatory or optional
- MinRecordOccurrence and MaxRecordOccurrence tells how many times a record can occur itself in a Group

简短的说法是,A组可以拥有一组记录,并且该组内的一条记录可以多次出现。 (在上面的确切模式表中解释)

我在文件中的输入数据将会像这样

AAA
AAA
BBB
CCC
AAA
BBB
DDD
EEE
FFF

如果您看到我上面给出的输入数据,根据数据定义表,第1组是强制性的,最多可以发生两次,并且在该组中记录CCC是强制性的。但是如果你在第二次出现输入数据时看到CCC没有来。所以此时输入数据不遵循数据定义表规则。我需要捕获错过的第二组第1组的CCC数据记录。

我的定义表非常大并且输入数据也只是为了获得任何简化的想法我已将问题转换为较小的级别。

我知道如何实现这一目标。我知道java的基础知识,但如果我能够理解,我可以自己编写代码。

由于

0 个答案:

没有答案