ASF Bugzilla – Attachment 29900 Details for
Bug 54499
Implementation of Extensible EL Interpreter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
ELRuntime Utility for JasperELInterpreter
ELRuntimeUtil.java (text/plain), 5.91 KB, created by
Sheldon Shao
on 2013-01-29 08:27:55 UTC
(
hide
)
Description:
ELRuntime Utility for JasperELInterpreter
Filename:
MIME Type:
Creator:
Sheldon Shao
Created:
2013-01-29 08:27:55 UTC
Size:
5.91 KB
patch
obsolete
>/* > * Licensed to the Apache Software Foundation (ASF) under one or more > * contributor license agreements. See the NOTICE file distributed with > * this work for additional information regarding copyright ownership. > * The ASF licenses this file to You under the Apache License, Version 2.0 > * (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ >package org.apache.jasper.runtime; > >import java.math.BigDecimal; >import java.math.BigInteger; >import java.util.Collection; >import java.util.Map; > >import javax.el.ELException; > >import org.apache.el.lang.ELSupport; > >/** > * EL Interpreter runtime utility > * > * @author Sheldon Shao <XShao@ebay.com> > */ >public class ELRuntimeUtil { > public static boolean lessThan(Object obj0, Object obj1) { > if (obj0 == null) { > return false; > } > if (obj1 == null) { > return false; > } > return (ELSupport.compare(obj0, obj1) < 0) ? true : false; > } > > public static boolean greaterThan(Object obj0, Object obj1) { > if (obj0 == null) { > return false; > } > if (obj1 == null) { > return false; > } > return (ELSupport.compare(obj0, obj1) > 0) ? true : false; > } > > public static boolean lessThanEqual(Object obj0, Object obj1) { > if (obj0 == null) { > return false; > } > if (obj1 == null) { > return false; > } > return (ELSupport.compare(obj0, obj1) <= 0) ? true : false; > } > > public static boolean greaterThanEqual(Object obj0, Object obj1) { > if (obj0 == null) { > return false; > } > if (obj1 == null) { > return false; > } > return (ELSupport.compare(obj0, obj1) >= 0) ? true : false; > } > > public static Object negative(Object obj) { > if (obj == null) { > return Long.valueOf(0); > } > if (obj instanceof BigDecimal) { > return ((BigDecimal) obj).negate(); > } > if (obj instanceof BigInteger) { > return ((BigInteger) obj).negate(); > } > if (obj instanceof String) { > if (ELSupport.isStringFloat((String) obj)) { > return new Double(-Double.parseDouble((String) obj)); > } > return Long.valueOf(-Long.parseLong((String) obj)); > } > if (obj instanceof Long) { > return Long.valueOf(-((Long) obj).longValue()); > } > if (obj instanceof Double) { > return new Double(-((Double) obj).doubleValue()); > } > if (obj instanceof Integer) { > return Integer.valueOf(-((Integer) obj).intValue()); > } > if (obj instanceof Float) { > return new Float(-((Float) obj).floatValue()); > } > if (obj instanceof Short) { > return Short.valueOf((short) -((Short) obj).shortValue()); > } > if (obj instanceof Byte) { > return Byte.valueOf((byte) -((Byte) obj).byteValue()); > } > Long num = (Long) ELSupport.coerceToNumber(obj, Long.class); > return Long.valueOf(-num.longValue()); > } > > public static boolean isEmpty(Object obj) { > if (obj == null) { > return true; > } else if (obj instanceof String) { > return ((String) obj).length() == 0; > } else if (obj instanceof Object[]) { > return ((Object[]) obj).length == 0; > } else if (obj instanceof Collection<?>) { > return ((Collection<?>) obj).isEmpty(); > } else if (obj instanceof Map<?,?>) { > return ((Map<?,?>) obj).isEmpty(); > } > return false; > } > > public static Number toFloatingPoint(Object value) { > if (value instanceof String) { > String str = (String)value; > try { > return new Double(str); > } catch (ArithmeticException e0) { > return new BigDecimal(str); > } > } > else if (value instanceof Double) { > return (Double)value; > } > else if (value instanceof Number) { > return new Double(((Number)value).doubleValue()); > } > return null; > } > > public static Number toInteger(Object value) { > if (value instanceof String) { > String str = (String)value; > try { > return new Long(str); > } catch (ArithmeticException e0) { > return new BigInteger(str); > } > } > else if (value instanceof Long) { > return (Long)value; > } > else if (value instanceof Number) { > return new Long(((Number)value).longValue()); > } > return null; > } > > public static Object toType(Object obj, Class<?> type) throws ELException { > if (type == null || Object.class == type) { > return obj; > } > if (obj != null) { > if (type == obj.getClass()) { > return obj; > } > if (obj instanceof String) { > if ("".equals(obj)) > return null; > } > return obj; > } > else { > return null; > } > } > > > public static String xmlEscape(Object value) { > if (value == null) { > return null; > } > if (value instanceof String) { > return PageContextImpl.XmlEscape((String)value); > } > else { > String str = value.toString(); > return PageContextImpl.XmlEscape(str); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 54499
:
29898
|
29899
| 29900 |
29901
|
29902
|
29907