/* * JMEP - Java Mathematical Expression Parser. * Copyright (C) 1999 Jo Desmet * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * You can contact the Original submitter of this library by * email at: Jo_Desmet@yahoo.com. * */ package com.iabcinc.jmep.tokens; public class VALToken extends Token { private Object value; public VALToken(int dValue,int iPosition) { super(Token.VAL,iPosition); value = new int[]{dValue}; } public VALToken(String sValue,int iPosition) { super(Token.VAL,iPosition); value = new Object[]{sValue}; } public VALToken(Object value,int iPosition) { super(Token.VAL,iPosition); if (value instanceof Integer){ this.value = new int[]{(Integer)value}; } else if (value instanceof Number){ this.value = new float[]{((Number)value).floatValue()}; } else { this.value = new Object[]{value}; System.out.println("Warning: nonnumeric literal"); } } public VALToken(double fValue,int iPosition) { super(Token.VAL,iPosition); value = new float[]{(float)fValue}; } public Object getValue() { return value; } public boolean isConstant() { return true; } }