/* * 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; import com.iabcinc.jmep.hooks.Unit; import com.iabcinc.jmep.XUndefinedUnit; public class UNIToken extends Token { private Unit m_oCallBack; private String m_sName; public UNIToken(String sName,Unit oCallBack,int iPosition) { super(Token.UNI,iPosition); m_oCallBack = oCallBack; m_sName = sName; } public UNIToken(String sName,int iPosition) { super(Token.UNI,iPosition); m_oCallBack = null; m_sName = sName; } public Object evaluate(Object oValue) throws XUndefinedUnit{ Object oReturnValue = null; if (m_oCallBack != null) return m_oCallBack.apply(oValue); if (oReturnValue == null) throw new XUndefinedUnit(getPosition(),m_sName); return oReturnValue; } }