Skip to content

Commit 812fa89

Browse files
committed
Fix issue #115: WellFormednessChecker should check for null in ids.
Added a check for null record ids to the WellFormednessChecker.
1 parent 6036bb5 commit 812fa89

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/main/java/org/culturegraph/mf/stream/sink/WellFormednessChecker.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,33 @@
1919
import org.culturegraph.mf.framework.StreamReceiver;
2020

2121
/**
22-
* A stream receiver that throws an {@link WellformednessException} if
23-
* the stream event methods are called in an invalid order. Additionally,
22+
* A stream receiver that throws an {@link WellformednessException} if
23+
* the stream event methods are called in an invalid order. Additionally,
2424
* the stream receiver checks that entity and literal names are not null.
25-
*
25+
*
2626
* @see StreamValidator
2727
* @see WellformednessException
28-
*
28+
*
2929
* @author Christoph Böhme
30-
*
30+
*
3131
*/
3232
public final class WellFormednessChecker implements StreamReceiver {
33-
33+
34+
private static final String ID_MUST_NOT_BE_NULL = "id must not be null";
3435
private static final String NAME_MUST_NOT_BE_NULL = "name must not be null";
35-
36+
3637
private static final String NOT_IN_RECORD = "Not in record";
3738
private static final String NOT_IN_ENTITY = "Not in entity";
3839
private static final String IN_ENTITY = "In entity";
3940
private static final String IN_RECORD = "In record";
40-
41+
4142
private int nestingLevel;
42-
43+
4344
@Override
4445
public void startRecord(final String identifier) {
46+
if (identifier == null) {
47+
throw new WellformednessException(ID_MUST_NOT_BE_NULL);
48+
}
4549
if (nestingLevel > 0) {
4650
throw new WellformednessException(IN_RECORD);
4751
}
@@ -50,10 +54,10 @@ public void startRecord(final String identifier) {
5054

5155
@Override
5256
public void endRecord() {
53-
if (nestingLevel < 1) {
57+
if (nestingLevel < 1) {
5458
throw new WellformednessException(NOT_IN_RECORD);
5559
} else if (nestingLevel > 1) {
56-
throw new WellformednessException(IN_ENTITY);
60+
throw new WellformednessException(IN_ENTITY);
5761
}
5862
nestingLevel -= 1;
5963
}
@@ -86,7 +90,7 @@ public void literal(final String name, final String value) {
8690
throw new WellformednessException(NOT_IN_RECORD);
8791
}
8892
}
89-
93+
9094
@Override
9195
public void resetStream() {
9296
nestingLevel = 0;

0 commit comments

Comments
 (0)