Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 34479e8

Browse files
committed
1 parent 16e5a81 commit 34479e8

File tree

1 file changed

+12
-12
lines changed
  • org.metafacture.fix/src/main/java/org/metafacture/metamorph

1 file changed

+12
-12
lines changed

org.metafacture.fix/src/main/java/org/metafacture/metamorph/Metafix.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import java.io.Reader;
5858
import java.io.StringReader;
5959
import java.util.ArrayList;
60-
import java.util.Arrays;
6160
import java.util.Collection;
6261
import java.util.Collections;
6362
import java.util.Deque;
@@ -91,12 +90,6 @@ public class Metafix implements StreamPipe<StreamReceiver>, NamedValuePipe, Maps
9190
private static final InterceptorFactory NULL_INTERCEPTOR_FACTORY = new NullInterceptorFactory();
9291
private static final Map<String, String> NO_VARS = Collections.emptyMap();
9392

94-
// See https://www.w3.org/TR/json-ld11/#keywords
95-
private static final List<String> JSONLD_KEYWORDS = Arrays.asList(
96-
"@base", "@container", "@context", "@direction", "@graph", "@id", "@import", "@included", "@index", "@json",
97-
"@language", "@list", "@nest", "@none", "@prefix", "@propagate", "@protected", "@reverse", "@set", "@type",
98-
"@value", "@version", "@vocab");
99-
10093
// warning: auxiliary class WildcardRegistry in WildcardDataRegistry.java should not be accessed from outside its own source file
10194
//private final Registry<NamedValueReceiver> dataRegistry = new WildcardRegistry<>();
10295
private final Registry<NamedValueReceiver> dataRegistry = new Registry<NamedValueReceiver>() {
@@ -372,11 +365,11 @@ else if (fallback != null) {
372365
elseNestedEntityStarted = true;
373366
}
374367

375-
send(currentLiteralName, value, fallback);
368+
send(escapeFeedbackChar(currentLiteralName), value, fallback);
376369
}
377370
}
378371
else {
379-
send(path, value, fallback);
372+
send(escapeFeedbackChar(path), value, fallback);
380373
}
381374
}
382375
}
@@ -417,9 +410,8 @@ public void receive(final String name, final String value, final NamedValueSourc
417410
throw new IllegalArgumentException(
418411
"encountered literal with name='null'. This indicates a bug in a function or a collector.");
419412
}
420-
final int end = Math.min(name.indexOf(flattener.getEntityMarker()), name.indexOf(FixBuilder.ARRAY_MARKER));
421-
final String firstNameSegment = end == -1 ? name : name.substring(0, end);
422-
if (name.length() != 0 && name.charAt(0) == FEEDBACK_CHAR && !JSONLD_KEYWORDS.contains(firstNameSegment)) {
413+
414+
if (startsWithFeedbackChar(name)) {
423415
dispatch(name, value, null, false);
424416
return;
425417
}
@@ -436,6 +428,14 @@ public void receive(final String name, final String value, final NamedValueSourc
436428
outputStreamReceiver.literal(unescapedName, value);
437429
}
438430

431+
private boolean startsWithFeedbackChar(final String name) {
432+
return name.length() != 0 && name.charAt(0) == FEEDBACK_CHAR;
433+
}
434+
435+
private String escapeFeedbackChar(final String name) {
436+
return name == null ? null : (startsWithFeedbackChar(name) ? ESCAPE_CHAR : "") + name;
437+
}
438+
439439
@Override
440440
public Map<String, String> getMap(final String mapName) {
441441
return maps.getOrDefault(mapName, Collections.emptyMap());

0 commit comments

Comments
 (0)