Skip to content

Commit

Permalink
MapVersionException: Add dummy Location impl to avoid deprecated-code…
Browse files Browse the repository at this point in the history
…-usage warning.
  • Loading branch information
kingjon3377 committed Apr 10, 2024
1 parent e2a6da0 commit 5fd904b
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package impl.xmlio.exceptions;

import common.xmlio.SPFormatException;
import org.jetbrains.annotations.Nullable;

import javax.xml.stream.Location;
import javax.xml.stream.events.StartElement;
import java.io.Serial;

Expand All @@ -12,6 +14,33 @@ public class MapVersionException extends SPFormatException {
@Serial
private static final long serialVersionUID = 1L;

private static final class DummyLocation implements Location {
@Override
public int getLineNumber() {
return -1;
}

@Override
public int getColumnNumber() {
return -1;
}

@Override
public int getCharacterOffset() {
return -1;
}

@Override
public @Nullable String getPublicId() {
return null;
}

@Override
public @Nullable String getSystemId() {
return null;
}
}

private static String messageFragment(final int minimum, final int maximum) {
if (minimum == maximum) {
return ": must be " + minimum;
Expand Down Expand Up @@ -39,7 +68,7 @@ public MapVersionException(final StartElement context, final int version, final
*/
private MapVersionException(final int version, final int minimum, final int maximum) {
super("Unsupported SP map version %d%s".formatted(version,
messageFragment(minimum, maximum)), -1, -1);
messageFragment(minimum, maximum)), new DummyLocation());
}

/**
Expand Down

0 comments on commit 5fd904b

Please sign in to comment.