Example usage for java.lang Long TYPE

List of usage examples for java.lang Long TYPE

Introduction

In this page you can find the example usage for java.lang Long TYPE.

Prototype

Class TYPE

To view the source code for java.lang Long TYPE.

Click Source Link

Document

The Class instance representing the primitive type long .

Usage

From source file:com.offbynull.coroutines.instrumenter.MethodAnalyzer.java

private CacheVariables allocateCacheVariableSlots(VariableTable varTable, TypeTracker invocationReturnTypes,
        boolean invocationFoundWrappedInTryCatch) {
    Variable intReturnCacheVar = null;/*from w  w  w. j  av  a 2s  .c om*/
    Variable longReturnCacheVar = null;
    Variable floatReturnCacheVar = null;
    Variable doubleReturnCacheVar = null;
    Variable objectReturnCacheVar = null;
    Variable throwableCacheVar = null;
    if (invocationReturnTypes.intFound) {
        intReturnCacheVar = varTable.acquireExtra(Integer.TYPE);
    }
    if (invocationReturnTypes.longFound) {
        longReturnCacheVar = varTable.acquireExtra(Long.TYPE);
    }
    if (invocationReturnTypes.floatFound) {
        floatReturnCacheVar = varTable.acquireExtra(Float.TYPE);
    }
    if (invocationReturnTypes.doubleFound) {
        doubleReturnCacheVar = varTable.acquireExtra(Double.TYPE);
    }
    if (invocationReturnTypes.objectFound) {
        objectReturnCacheVar = varTable.acquireExtra(Object.class);
    }
    if (invocationFoundWrappedInTryCatch) {
        throwableCacheVar = varTable.acquireExtra(Throwable.class);
    }

    return new CacheVariables(intReturnCacheVar, longReturnCacheVar, floatReturnCacheVar, doubleReturnCacheVar,
            objectReturnCacheVar, throwableCacheVar);
}

From source file:org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.java

public static Class<?> getTypeForPrimitive(Class<?> primitiveType) {
    if (primitiveType == Boolean.TYPE) {
        return Boolean.class;
    } else if (primitiveType == Integer.TYPE) {
        return Integer.class;
    } else if (primitiveType == Long.TYPE) {
        return Long.class;
    } else if (primitiveType == Float.TYPE) {
        return Float.class;
    } else if (primitiveType == Double.TYPE) {
        return Double.class;
    } else if (primitiveType == Character.TYPE) {
        return Character.class;
    } else if (primitiveType == Byte.TYPE) {
        return Byte.class;
    } else if (primitiveType == Short.TYPE) {
        return Short.class;
    }/*w  ww .j a va 2 s .c o m*/
    return primitiveType;
}

From source file:org.apache.jasper.compiler.JspUtil.java

/**
 * Produces a String representing a call to the EL interpreter.
 * @param expression a String containing zero or more "${}" expressions
 * @param expectedType the expected type of the interpreted result
 * @param fnmapvar Variable pointing to a function map.
 * @param XmlEscape True if the result should do XML escaping
 * @return a String representing a call to the EL interpreter.
 *//*from w ww. j a v  a  2s.c o  m*/
public static String interpreterCall(boolean isTagFile, String expression, Class expectedType, String fnmapvar,
        boolean XmlEscape) {
    /*
     * Determine which context object to use.
     */
    String jspCtxt = null;
    if (isTagFile)
        jspCtxt = "this.getJspContext()";
    else
        jspCtxt = "pageContext";

    /*
          * Determine whether to use the expected type's textual name
     * or, if it's a primitive, the name of its correspondent boxed
     * type.
          */
    String targetType = expectedType.getName();
    String primitiveConverterMethod = null;
    if (expectedType.isPrimitive()) {
        if (expectedType.equals(Boolean.TYPE)) {
            targetType = Boolean.class.getName();
            primitiveConverterMethod = "booleanValue";
        } else if (expectedType.equals(Byte.TYPE)) {
            targetType = Byte.class.getName();
            primitiveConverterMethod = "byteValue";
        } else if (expectedType.equals(Character.TYPE)) {
            targetType = Character.class.getName();
            primitiveConverterMethod = "charValue";
        } else if (expectedType.equals(Short.TYPE)) {
            targetType = Short.class.getName();
            primitiveConverterMethod = "shortValue";
        } else if (expectedType.equals(Integer.TYPE)) {
            targetType = Integer.class.getName();
            primitiveConverterMethod = "intValue";
        } else if (expectedType.equals(Long.TYPE)) {
            targetType = Long.class.getName();
            primitiveConverterMethod = "longValue";
        } else if (expectedType.equals(Float.TYPE)) {
            targetType = Float.class.getName();
            primitiveConverterMethod = "floatValue";
        } else if (expectedType.equals(Double.TYPE)) {
            targetType = Double.class.getName();
            primitiveConverterMethod = "doubleValue";
        }
    }

    if (primitiveConverterMethod != null) {
        XmlEscape = false;
    }

    /*
          * Build up the base call to the interpreter.
          */
    // XXX - We use a proprietary call to the interpreter for now
    // as the current standard machinery is inefficient and requires
    // lots of wrappers and adapters.  This should all clear up once
    // the EL interpreter moves out of JSTL and into its own project.
    // In the future, this should be replaced by code that calls
    // ExpressionEvaluator.parseExpression() and then cache the resulting
    // expression objects.  The interpreterCall would simply select
    // one of the pre-cached expressions and evaluate it.
    // Note that PageContextImpl implements VariableResolver and
    // the generated Servlet/SimpleTag implements FunctionMapper, so
    // that machinery is already in place (mroth).
    targetType = toJavaSourceType(targetType);
    StringBuffer call = new StringBuffer(
            "(" + targetType + ") " + "org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate" + "("
                    + Generator.quote(expression) + ", " + targetType + ".class, " + "(PageContext)" + jspCtxt
                    + ", " + fnmapvar + ", " + XmlEscape + ")");

    /*
          * Add the primitive converter method if we need to.
          */
    if (primitiveConverterMethod != null) {
        call.insert(0, "(");
        call.append(")." + primitiveConverterMethod + "()");
    }

    return call.toString();
}

From source file:org.enerj.apache.commons.collections.TestTransformerUtils.java

public void testInstantiateTransformerNull() {
    try {//from  ww  w.  j  a va2  s .  c  o  m
        Transformer trans = TransformerUtils.instantiateTransformer(null, new Object[] { "str" });
        fail();
    } catch (IllegalArgumentException ex) {
    }
    try {
        Transformer trans = TransformerUtils.instantiateTransformer(new Class[] {}, new Object[] { "str" });
        fail();
    } catch (IllegalArgumentException ex) {
    }

    Transformer trans = TransformerUtils.instantiateTransformer(new Class[] { Long.class },
            new Object[] { null });
    try {
        trans.transform(String.class);
        fail();
    } catch (FunctorException ex) {
    }

    trans = TransformerUtils.instantiateTransformer();
    assertEquals("", trans.transform(String.class));

    trans = TransformerUtils.instantiateTransformer(new Class[] { Long.TYPE },
            new Object[] { new Long(1000L) });
    assertEquals(new Date(1000L), trans.transform(Date.class));
}

From source file:com.sun.faces.el.impl.Coercions.java

/**
 * Coerces a double to the given primitive number class
 *///from  w  w w. jav a2 s.co m
static Number coerceToPrimitiveNumber(double pValue, Class pClass) throws ElException {
    if (pClass == Byte.class || pClass == Byte.TYPE) {
        return PrimitiveObjects.getByte((byte) pValue);
    } else if (pClass == Short.class || pClass == Short.TYPE) {
        return PrimitiveObjects.getShort((short) pValue);
    } else if (pClass == Integer.class || pClass == Integer.TYPE) {
        return PrimitiveObjects.getInteger((int) pValue);
    } else if (pClass == Long.class || pClass == Long.TYPE) {
        return PrimitiveObjects.getLong((long) pValue);
    } else if (pClass == Float.class || pClass == Float.TYPE) {
        return PrimitiveObjects.getFloat((float) pValue);
    } else if (pClass == Double.class || pClass == Double.TYPE) {
        return PrimitiveObjects.getDouble(pValue);
    } else {
        return PrimitiveObjects.getInteger(0);
    }
}

From source file:org.evosuite.testcase.statements.FunctionalMockStatement.java

public void fillWithNullRefs() {
    for (int i = 0; i < parameters.size(); i++) {
        VariableReference ref = parameters.get(i);
        if (ref == null) {
            Class<?> expected = getExpectedParameterType(i);
            Object value = null;/*w w w. j  a  v a2 s.  c  o  m*/
            if (expected.isPrimitive()) {
                //can't fill a primitive with null
                if (expected.equals(Integer.TYPE)) {
                    value = 0;
                } else if (expected.equals(Float.TYPE)) {
                    value = 0f;
                } else if (expected.equals(Double.TYPE)) {
                    value = 0d;
                } else if (expected.equals(Long.TYPE)) {
                    value = 0L;
                } else if (expected.equals(Boolean.TYPE)) {
                    value = false;
                } else if (expected.equals(Short.TYPE)) {
                    value = Short.valueOf("0");
                } else if (expected.equals(Character.TYPE)) {
                    value = 'a';
                }
            }
            parameters.set(i, new ConstantValue(tc, new GenericClass(expected), value));
        }
    }
}

From source file:nl.knaw.dans.common.ldap.repo.LdapMapper.java

private Object getPrimitive(Class<?> type, String s) throws NamingException {
    Object value = s;//from w  w w .j  a v a  2  s . c  om
    if (Integer.TYPE.equals(type)) {
        value = Integer.parseInt(s);
    } else if (Boolean.TYPE.equals(type)) {
        value = new Boolean("TRUE".equals(s));
    } else if (Long.TYPE.equals(type)) {
        value = Long.parseLong(s);
    } else if (Float.TYPE.equals(type)) {
        value = Float.parseFloat(s);
    } else if (Double.TYPE.equals(type)) {
        value = Double.parseDouble(s);
    } else if (Byte.TYPE.equals(type)) {
        value = Byte.parseByte(s);
    } else if (Short.TYPE.equals(type)) {
        value = Short.parseShort(s);
    }
    return value;
}

From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjectorTest.java

public org.apache.commons.configuration.Configuration mockConfiguration(Field field, boolean isInconfig) {
    if (field == null) {
        return null;
    }//from  w w w .  j av  a  2s.c  om
    org.apache.commons.configuration.Configuration configuration = mock(
            org.apache.commons.configuration.Configuration.class);
    when(configuration.containsKey(field.getName())).thenReturn(isInconfig);
    if (isInconfig) {
        Class<?> type = field.getType();
        String configParamName = field.getAnnotation(Configuration.class).value();
        if (type.isArray()) {
            type = type.getComponentType();

            if (type == Integer.TYPE || type == Integer.class) {
                when(configuration.getStringArray(configParamName))
                        .thenReturn(new String[] { String.valueOf(Integer.MAX_VALUE) });
            } else if (type == Boolean.TYPE || type == Boolean.class) {
                when(configuration.getStringArray(configParamName)).thenReturn(new String[] { "true" });
            } else if (type == Short.TYPE || type == Short.class) {
                when(configuration.getStringArray(configParamName))
                        .thenReturn(new String[] { String.valueOf(Short.MAX_VALUE) });
            } else if (type == Byte.TYPE || type == Byte.class) {
                when(configuration.getStringArray(configParamName))
                        .thenReturn(new String[] { String.valueOf(Byte.MAX_VALUE) });
            } else if (type == Long.TYPE || type == Long.class) {
                when(configuration.getStringArray(configParamName))
                        .thenReturn(new String[] { String.valueOf(Long.MAX_VALUE) });
            } else if (type == Float.TYPE || type == Float.class) {
                when(configuration.getStringArray(configParamName))
                        .thenReturn(new String[] { String.valueOf(Float.MAX_VALUE) });
            } else if (type == Double.TYPE || type == Double.class) {
                when(configuration.getStringArray(configParamName))
                        .thenReturn(new String[] { String.valueOf(Double.MAX_VALUE) });
            } else if (type == Character.TYPE || type == Character.class) {
                when(configuration.getStringArray(configParamName)).thenReturn(new String[] { "t" });
            } else if (type == String.class) {
                when(configuration.getStringArray(configParamName)).thenReturn(new String[] { "test" });
            } else
                throw new IllegalArgumentException("Type " + type + " cannot be mocked");
        } else {
            if (type == Integer.TYPE || type == Integer.class) {
                when(configuration.getString(configParamName)).thenReturn(String.valueOf(Integer.MAX_VALUE));
            } else if (type == Boolean.TYPE || type == Boolean.class) {
                when(configuration.getString(configParamName)).thenReturn("true");
            } else if (type == Short.TYPE || type == Short.class) {
                when(configuration.getString(configParamName)).thenReturn(String.valueOf(Short.MAX_VALUE));
            } else if (type == Byte.TYPE || type == Byte.class) {
                when(configuration.getString(configParamName)).thenReturn(String.valueOf(Byte.MAX_VALUE));
            } else if (type == Long.TYPE || type == Long.class) {
                when(configuration.getString(configParamName)).thenReturn(String.valueOf(Long.MAX_VALUE));
            } else if (type == Float.TYPE || type == Float.class) {
                when(configuration.getString(configParamName)).thenReturn(String.valueOf(Float.MAX_VALUE));
            } else if (type == Double.TYPE || type == Double.class) {
                when(configuration.getString(configParamName)).thenReturn(String.valueOf(Double.MAX_VALUE));
            } else if (type == Character.TYPE || type == Character.class) {
                when(configuration.getString(configParamName)).thenReturn("t");
            } else if (type == String.class) {
                when(configuration.getString(configParamName)).thenReturn("test");
            } else
                throw new IllegalArgumentException("Type " + type + " cannot be mocked");
        }
    }
    return configuration;
}

From source file:com.sun.faces.el.impl.Coercions.java

/**
 * Coerces a Number to the given primitive number class
 *//*from w  w  w  .  j a  v  a2  s.co m*/
static Number coerceToPrimitiveNumber(Number pValue, Class pClass) throws ElException {
    if (pClass == Byte.class || pClass == Byte.TYPE) {
        return PrimitiveObjects.getByte(pValue.byteValue());
    } else if (pClass == Short.class || pClass == Short.TYPE) {
        return PrimitiveObjects.getShort(pValue.shortValue());
    } else if (pClass == Integer.class || pClass == Integer.TYPE) {
        return PrimitiveObjects.getInteger(pValue.intValue());
    } else if (pClass == Long.class || pClass == Long.TYPE) {
        return PrimitiveObjects.getLong(pValue.longValue());
    } else if (pClass == Float.class || pClass == Float.TYPE) {
        return PrimitiveObjects.getFloat(pValue.floatValue());
    } else if (pClass == Double.class || pClass == Double.TYPE) {
        return PrimitiveObjects.getDouble(pValue.doubleValue());
    } else if (pClass == BigInteger.class) {
        if (pValue instanceof BigDecimal)
            return ((BigDecimal) pValue).toBigInteger();
        else
            return BigInteger.valueOf(pValue.longValue());
    } else if (pClass == BigDecimal.class) {
        if (pValue instanceof BigInteger)
            return new BigDecimal((BigInteger) pValue);
        else
            return new BigDecimal(pValue.doubleValue());
    } else {
        return PrimitiveObjects.getInteger(0);
    }
}

From source file:de.micromata.genome.util.bean.PrivateBeanUtils.java

/**
 * Gets the bean size intern.//from   w w w  .j av  a2  s  . c  o  m
 *
 * @param bean the bean
 * @param clazz the clazz
 * @param m the m
 * @param classNameMatcher the class name matcher
 * @param fieldNameMatcher the field name matcher
 * @return the bean size intern
 */
public static int getBeanSizeIntern(Object bean, Class<?> clazz, IdentityHashMap<Object, Object> m,
        Matcher<String> classNameMatcher, Matcher<String> fieldNameMatcher) {
    if (classNameMatcher.match(clazz.getName()) == false) {
        return 0;
    }
    if (clazz.isArray() == true) {
        if (clazz == boolean[].class) {
            return (((boolean[]) bean).length * 4);
        } else if (clazz == char[].class) {
            return (((char[]) bean).length * 2);
        } else if (clazz == byte[].class) {
            return (((byte[]) bean).length * 1);
        } else if (clazz == short[].class) {
            return (((short[]) bean).length * 2);
        } else if (clazz == int[].class) {
            return (((int[]) bean).length * 4);
        } else if (clazz == long[].class) {
            return (((long[]) bean).length * 4);
        } else if (clazz == float[].class) {
            return (((float[]) bean).length * 4);
        } else if (clazz == double[].class) {
            return (((double[]) bean).length * 8);
        } else {
            int length = Array.getLength(bean);
            int ret = (length * 4);
            for (int i = 0; i < length; ++i) {
                ret += getBeanSize(Array.get(bean, i), m, classNameMatcher, fieldNameMatcher);
            }
            return ret;
        }
    }
    int ret = 0;
    try {
        for (Field f : clazz.getDeclaredFields()) {
            int mod = f.getModifiers();
            if (Modifier.isStatic(mod) == true) {
                continue;
            }
            if (fieldNameMatcher.match(clazz.getName() + "." + f.getName()) == false) {
                continue;
            }
            if (f.getType() == Boolean.TYPE) {
                ret += 4;
            } else if (f.getType() == Character.TYPE) {
                ret += 2;
            } else if (f.getType() == Byte.TYPE) {
                ret += 1;
            } else if (f.getType() == Short.TYPE) {
                ret += 2;
            } else if (f.getType() == Integer.TYPE) {
                ret += 4;
            } else if (f.getType() == Long.TYPE) {
                ret += 8;
            } else if (f.getType() == Float.TYPE) {
                ret += 4;
            } else if (f.getType() == Double.TYPE) {
                ret += 8;
            } else {

                ret += 4;
                Object o = null;
                try {
                    o = readField(bean, f);
                    if (o == null) {
                        continue;
                    }
                } catch (NoClassDefFoundError ex) {
                    // nothing
                    continue;
                }
                int nestedsize = getBeanSize(o, o.getClass(), m, classNameMatcher, fieldNameMatcher);
                ret += nestedsize;
            }
        }
    } catch (NoClassDefFoundError ex) {
        // ignore here.
    }
    if (clazz == Object.class || clazz.getSuperclass() == null) {
        return ret;
    }
    ret += getBeanSizeIntern(bean, clazz.getSuperclass(), m, classNameMatcher, fieldNameMatcher);
    return ret;
}