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

org.jsimpledb.parse.expr.VarNode Maven / Gradle / Ivy

The newest version!

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package org.jsimpledb.parse.expr;

import org.jsimpledb.parse.ParseSession;

/**
 * {@link Node} representing a parsed {@link ParseSession} variable.
 *
 * @see ParseSession#getVars
 */
public class VarNode extends ConstNode {

    /**
     * Constructor.
     *
     * @param name variable name
     * @throws IllegalArgumentException if name is null
     * @throws IllegalArgumentException if name is not a valid Java identifier
     */
    public VarNode(String name) {
        super(new VarValue(name));
    }

    @Override
    public VarValue evaluate(ParseSession session) {
        return (VarValue)super.evaluate(session);
    }

    @Override
    public Class getType(ParseSession session) {
        return ((VarValue)super.evaluate(session)).getType(session);
    }

    /**
     * Get the variable name.
     *
     * @return variable name
     */
    public String getName() {
        return this.evaluate(null).getName();
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy