All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.evilengineers.templates4j.extension.antlr4.XPathQueryFirstResultFunction Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package net.evilengineers.templates4j.extension.antlr4;

import java.util.List;

import org.antlr.v4.runtime.tree.ParseTree;

public class XPathQueryFirstResultFunction extends XPathQueryFunction {

	@Override
	public String getName() {
		return "xpath1";
	}

	public Object execute(ParserInterpreterProvider ctx, final ParseTree model, String path) {
		Object r = super.execute(ctx, model, path);
		if (r instanceof List) {
			return ((List) r).size() > 0 ? ((List) r).get(0) : null;
		} else {
			return r;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy