
de.codecentric.dwcaller.test.Location Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of data-weave-caller Show documentation
Show all versions of data-weave-caller Show documentation
Library to call DataWeave from Java and execute DW unit tests.
package de.codecentric.dwcaller.test;
import java.util.Map;
/**
* Location within a script.
*/
public class Location {
public static final Location UNKNOWN = new Location();
private int index;
private int line;
private int column;
private Location() {
// only for UNKNOWN
}
public Location(Map data) {
index = nullToMinusOone(data.get("index"));
line = nullToMinusOone(data.get("line"));
column = nullToMinusOone(data.get("column"));
}
private int nullToMinusOone(Object object) {
if (object instanceof Number) {
return ((Number) object).intValue() + 1;
}
return -1;
}
/**
* @return Position in file, 1 based.
*/
public int getIndex() {
return index;
}
/**
* @return Line number, 1 based.
*/
public int getLine() {
return line;
}
/**
* @return Column number, 1 based.
*/
public int getColumn() {
return column;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy