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

com.github.simy4.xpath.expr.UnaryExpr Maven / Gradle / Ivy

There is a newer version: 2.3.9
Show newest version
package com.github.simy4.xpath.expr;

import com.github.simy4.xpath.XmlBuilderException;
import com.github.simy4.xpath.navigator.Node;
import com.github.simy4.xpath.view.NumberView;
import com.github.simy4.xpath.view.ViewContext;

public class UnaryExpr implements Expr {

    private final Expr valueExpr;

    public UnaryExpr(Expr valueExpr) {
        this.valueExpr = valueExpr;
    }

    @Override
    public  NumberView resolve(ViewContext context) throws XmlBuilderException {
        return new NumberView(-valueExpr.resolve(context).toNumber());
    }

    @Override
    public String toString() {
        return "-(" + valueExpr + ')';
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy