1 55 56 package org.apache.commons.el; 57 58 import javax.servlet.jsp.el.ELException ; 59 60 67 68 public class IntegerDivideOperator 69 extends BinaryOperator 70 { 71 75 public static final IntegerDivideOperator SINGLETON = 76 new IntegerDivideOperator (); 77 78 83 public IntegerDivideOperator () 84 { 85 } 86 87 94 public String getOperatorSymbol () 95 { 96 return "idiv"; 97 } 98 99 104 public Object apply (Object pLeft, 105 Object pRight, 106 Logger pLogger) 107 throws ELException 108 { 109 if (pLeft == null && 110 pRight == null) { 111 if (pLogger.isLoggingWarning ()) { 112 pLogger.logWarning 113 (Constants.ARITH_OP_NULL, 114 getOperatorSymbol ()); 115 } 116 return PrimitiveObjects.getInteger (0); 117 } 118 119 long left = 120 Coercions.coerceToPrimitiveNumber (pLeft, Long .class, pLogger). 121 longValue (); 122 long right = 123 Coercions.coerceToPrimitiveNumber (pRight, Long .class, pLogger). 124 longValue (); 125 126 try { 127 return PrimitiveObjects.getLong (left / right); 128 } 129 catch (Exception exc) { 130 if (pLogger.isLoggingError ()) { 131 pLogger.logError 132 (Constants.ARITH_ERROR, 133 getOperatorSymbol (), 134 "" + left, 135 "" + right); 136 } 137 return PrimitiveObjects.getInteger (0); 138 } 139 } 140 141 } 143 | Popular Tags |