GreaterThan.java revision 608:7e06bf1dcb09
1193323Sed/* 2193323Sed * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. 3193323Sed * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4193323Sed * 5193323Sed * This code is free software; you can redistribute it and/or modify it 6193323Sed * under the terms of the GNU General Public License version 2 only, as 7193323Sed * published by the Free Software Foundation. Oracle designates this 8193323Sed * particular file as subject to the "Classpath" exception as provided 9193323Sed * by Oracle in the LICENSE file that accompanied this code. 10193323Sed * 11193323Sed * This code is distributed in the hope that it will be useful, but WITHOUT 12193323Sed * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13193323Sed * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14193323Sed * version 2 for more details (a copy is included in the LICENSE file that 15193323Sed * accompanied this code). 16193323Sed * 17193323Sed * You should have received a copy of the GNU General Public License version 18218893Sdim * 2 along with this work; if not, write to the Free Software Foundation, 19193323Sed * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20249423Sdim * 21239462Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22218893Sdim * or visit www.oracle.com if you need additional information or have any 23239462Sdim * questions. 24239462Sdim */ 25193323Sed/* 26193323Sed * COMPONENT_NAME: idl.parser 27218893Sdim * 28218893Sdim * ORIGINS: 27 29218893Sdim * 30218893Sdim * Licensed Materials - Property of IBM 31218893Sdim * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999 32218893Sdim * RMI-IIOP v1.0 33218893Sdim * 34218893Sdim */ 35239462Sdim 36239462Sdimpackage com.sun.tools.corba.se.idl.constExpr; 37239462Sdim 38239462Sdim// NOTES: 39239462Sdim 40239462Sdimimport com.sun.tools.corba.se.idl.Util; 41239462Sdimimport java.math.BigInteger; 42239462Sdim 43239462Sdimpublic class GreaterThan extends BinaryExpr 44239462Sdim{ 45239462Sdim protected GreaterThan (Expression leftOperand, Expression rightOperand) 46239462Sdim { 47239462Sdim super (">", leftOperand, rightOperand); 48239462Sdim } // ctor 49276479Sdim 50239462Sdim public Object evaluate () throws EvaluationException 51239462Sdim { 52239462Sdim try 53239462Sdim { 54193323Sed Object left = left ().evaluate (); 55193323Sed Object right = right ().evaluate (); 56201360Srdivacky if (left instanceof Boolean) 57218893Sdim { 58243830Sdim String[] parameters = {Util.getMessage ("EvaluationException.greaterThan"), left ().value ().getClass ().getName (), right ().value ().getClass ().getName ()}; 59243830Sdim throw new EvaluationException (Util.getMessage ("EvaluationException.1", parameters)); 60218893Sdim } 61218893Sdim else 62243830Sdim { 63221345Sdim Number l = (Number)left; 64221345Sdim Number r = (Number)right ().evaluate (); 65221345Sdim if (l instanceof Float || l instanceof Double || r instanceof Float || r instanceof Double) 66218893Sdim value (new Boolean (l.doubleValue () > r.doubleValue ())); 67218893Sdim else 68218893Sdim //daz value (new Boolean (l.longValue () > r.longValue ())); 69218893Sdim value (new Boolean ( ((BigInteger)l).compareTo ((BigInteger)r) > 0)); 70218893Sdim } 71218893Sdim } 72218893Sdim catch (ClassCastException e) 73276479Sdim { 74218893Sdim String[] parameters = {Util.getMessage ("EvaluationException.greaterThan"), left ().value ().getClass ().getName (), right ().value ().getClass ().getName ()}; 75218893Sdim throw new EvaluationException (Util.getMessage ("EvaluationException.1", parameters)); 76218893Sdim } 77218893Sdim return value (); 78218893Sdim } // evaluate 79218893Sdim} // class GreaterThan 80218893Sdim