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:org.openTwoFactor.clientExt.net.sf.ezmorph.object.NumberMorpher.java

/**
 * Creates a new morpher for the target type.
 *
 * @param type must be a primitive or wrapper type. BigDecimal and BigInteger
 *        are also supported.//from   w  w w  . j  a va  2 s .  c  o m
 */
public NumberMorpher(Class type) {
    super(false);

    if (type == null) {
        throw new MorphException("Must specify a type");
    }

    if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE
            && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type)
            && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type)
            && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type)
            && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type)
            && !BigDecimal.class.isAssignableFrom(type)) {
        throw new MorphException("Must specify a Number subclass");
    }

    this.type = type;
}

From source file:org.esa.s2tbx.dataio.jp2.BoxType.java

public Box createBox(long offset, long length, int dataOffset) {
    try {//from ww  w  .  j  av a  2  s. c  om
        Constructor<? extends Box> boxConstructor = type.getConstructor(BoxType.class, Long.TYPE, Long.TYPE,
                Integer.TYPE);
        return boxConstructor.newInstance(this, offset, length, dataOffset);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

From source file:cn.guoyukun.spring.jpa.repository.hibernate.type.CollectionToStringUserType.java

@Override
public void setParameterValues(Properties parameters) {
    String separator = (String) parameters.get("separator");
    if (!StringUtils.isEmpty(separator)) {
        this.separator = separator;
    } else {//from w  ww .j a  v  a  2 s  .  c  o m
        this.separator = ",";
    }

    String collectionType = (String) parameters.get("collectionType");
    if (!StringUtils.isEmpty(collectionType)) {
        try {
            this.collectionType = Class.forName(collectionType);
        } catch (ClassNotFoundException e) {
            throw new HibernateException(e);
        }
    } else {
        this.collectionType = java.util.ArrayList.class;
    }

    String elementType = (String) parameters.get("elementType");
    if (!StringUtils.isEmpty(elementType)) {
        try {
            this.elementType = Class.forName(elementType);
        } catch (ClassNotFoundException e) {
            throw new HibernateException(e);
        }
    } else {
        this.elementType = Long.TYPE;
    }
}

From source file:org.lunarray.model.descriptor.builder.annotation.util.RenderDefaultsUtil.java

/**
 * Fills the defaults./*  ww  w.  j a  v a  2 s .  c o  m*/
 */
private RenderDefaultsUtil() {
    this.renderDefaults = new HashMap<Class<?>, RenderType>();
    this.renderDefaults.put(Calendar.class, RenderType.DATE_PICKER);
    this.renderDefaults.put(Date.class, RenderType.DATE_PICKER);
    this.renderDefaults.put(java.sql.Date.class, RenderType.DATE_PICKER);
    this.renderDefaults.put(String.class, RenderType.TEXT);
    this.renderDefaults.put(Integer.class, RenderType.TEXT);
    this.renderDefaults.put(Double.class, RenderType.TEXT);
    this.renderDefaults.put(Float.class, RenderType.TEXT);
    this.renderDefaults.put(Long.class, RenderType.TEXT);
    this.renderDefaults.put(Byte.class, RenderType.TEXT);
    this.renderDefaults.put(Short.class, RenderType.TEXT);
    this.renderDefaults.put(Character.class, RenderType.TEXT);
    this.renderDefaults.put(Integer.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Double.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Float.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Long.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Byte.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Short.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Character.TYPE, RenderType.TEXT);
    this.renderDefaults.put(BigDecimal.class, RenderType.TEXT);
    this.renderDefaults.put(BigInteger.class, RenderType.TEXT);
    this.renderDefaults.put(Boolean.class, RenderType.CHECKBOX);
    this.renderDefaults.put(Boolean.TYPE, RenderType.CHECKBOX);
}

From source file:org.dbrain.data.jackson.modules.StandardModule.java

@Override
public void setupModule(SetupContext context) {
    SimpleSerializers serializers = new SimpleSerializers();

    JsonLongSerializer longSerializer = new JsonLongSerializer();
    serializers.addSerializer(Long.class, longSerializer);
    serializers.addSerializer(Long.TYPE, longSerializer);
    serializers.addSerializer(AtomicLong.class, longSerializer);
    serializers.addSerializer(BigDecimal.class, new JsonBigDecimalSerializer());
    serializers.addSerializer(BigInteger.class, new JsonBigIntegerSerializer());
    serializers.addSerializer(Path.class, new PathSerializer());
    serializers.addSerializer(Fqn.class, new FqnSerializer());
    serializers.addSerializer(Value.class, new JsonValueSerializer());
    context.addSerializers(serializers);

    SimpleDeserializers deserializers = new SimpleDeserializers();
    deserializers.addDeserializer(Value.class, new JsonValueDeserializer());
    deserializers.addDeserializer(ValueMap.class, new JsonValueMapDeserializer());
    deserializers.addDeserializer(ValueList.class, new JsonValueListDeserializer());
    deserializers.addDeserializer(Path.class, new PathDeserializer());
    deserializers.addDeserializer(Fqn.class, new FqnDeserializer());
    context.addDeserializers(deserializers);

}

From source file:org.seasar.mayaa.impl.util.ObjectUtil.java

protected static Class loadPrimitiveClass(String className) {
    if (StringUtil.isEmpty(className)) {
        throw new IllegalArgumentException();
    }/*  w w w  .  j av  a 2 s. c om*/
    if ("short".equals(className)) {
        return Short.TYPE;
    } else if ("int".equals(className)) {
        return Integer.TYPE;
    } else if ("long".equals(className)) {
        return Long.TYPE;
    } else if ("float".equals(className)) {
        return Float.TYPE;
    } else if ("double".equals(className)) {
        return Double.TYPE;
    } else if ("byte".equals(className)) {
        return Byte.TYPE;
    } else if ("char".equals(className)) {
        return Character.TYPE;
    } else if ("boolean".equals(className)) {
        return Boolean.TYPE;
    } else if ("void".equals(className)) {
        return Void.TYPE;
    }
    return null;
}

From source file:org.wings.template.DefaultPropertyValueConverter.java

/**
 * Describe <code>convertPropertyValue</code> method here.
 *
 * @param value       an <code>Object</code> value
 * @param targetClass a <code>Class</code> value
 * @return <description>//from   w  w  w  .  j av a 2 s  .co  m
 * @throws UnsupportedOperationException if an error occurs
 * @throws java.lang.UnsupportedOperationException
 *                                       <description>
 */
public Object convertPropertyValue(String value, Class targetClass) throws UnsupportedOperationException {
    if (value == null || "null".equals(value)) {
        return null;
    } // end of if ()

    if (targetClass == String.class) {
        return value;
    } // end of if ()

    if (targetClass == Boolean.TYPE || targetClass == Boolean.class) {
        return Boolean.valueOf(value);
    }

    if (targetClass == Integer.TYPE || targetClass == Integer.class) {
        return Integer.valueOf(value);
    }
    if (targetClass == Long.TYPE || targetClass == Long.class) {
        return Long.valueOf(value);
    }
    if (targetClass == Short.TYPE || targetClass == Short.class) {
        return Short.valueOf(value);
    }
    if (targetClass == Byte.TYPE || targetClass == Byte.class) {
        return Byte.valueOf(value);
    }
    if (targetClass == Float.TYPE || targetClass == Float.class) {
        return Float.valueOf(value);
    }
    if (targetClass == Double.TYPE || targetClass == Double.class) {
        return Double.valueOf(value);
    }
    if (targetClass == Character.TYPE || targetClass == Character.class) {
        return new Character(value.charAt(0));
    }

    if (targetClass == StringBuffer.class) {
        return new StringBuffer(value);
    } // end of if ()

    if (SIcon.class.isAssignableFrom(targetClass)) {
        return ResourceFactory.makeIcon(value);
    }

    if (targetClass == Color.class) {
        return ResourceFactory.makeColor(value);
    }

    if (targetClass == SDimension.class) {
        return ResourceFactory.makeDimension(value);
    }

    if (targetClass == SFont.class) {
        return TemplateUtil.parseFont(value);
    }

    if (Resource.class.isAssignableFrom(targetClass)) {
        return new ClassPathResource(value);
    }

    if (CSSAttributeSet.class.isAssignableFrom(targetClass)) {
        return ResourceFactory.makeAttributeSet(value);
    }

    if (StyleSheet.class.isAssignableFrom(targetClass)) {
        StyleSheet result;
        try {
            CSSStyleSheet styleSheet = new CSSStyleSheet();
            InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(value);
            styleSheet.read(in);
            in.close();
            result = styleSheet;
        } catch (Exception e) {
            log.warn("Exception", e);
            result = null;
        }
        return result;
    }

    if (ComponentCG.class.isAssignableFrom(targetClass)) {
        return ResourceFactory.makeComponentCG(value);
    }

    throw new UnsupportedOperationException("cannot create object of type " + targetClass.getName());
}

From source file:com.ms.commons.summer.web.util.json.JsonNumberMorpher.java

/**
 * Creates a new morpher for the target type with a default value.<br>
 * The defaultValue should be of the same class as the target type.
 * /*from   w  w  w.  j ava  2  s  .  c om*/
 * @param type must be a primitive or wrapper type. BigDecimal and BigInteger are also supported.
 * @param defaultValue return value if the value to be morphed is null
 */
public JsonNumberMorpher(Class<?> type, Number defaultValue) {
    super(true);

    if (type == null) {
        throw new MorphException("Must specify a type");
    }

    if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE
            && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type)
            && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type)
            && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type)
            && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type)
            && !BigDecimal.class.isAssignableFrom(type)) {
        throw new MorphException("Must specify a Number subclass");
    }

    this.type = type;
}

From source file:org.batoo.common.reflect.ReflectHelper.java

/**
 * Converts the number into number Type// ww  w. j a va  2  s .c  o  m
 * 
 * @param value
 *            the number value
 * @param numberType
 *            the number type
 * @return the converted number value
 * 
 * @since 2.0.1
 */
public static Number convertNumber(Number value, Class<?> numberType) {
    if (value == null) {
        return null;
    }

    if (numberType.isAssignableFrom(value.getClass())) {
        return value;
    }

    if ((numberType == Integer.class) || (numberType == Integer.TYPE)) {
        return value.intValue();
    }

    if ((numberType == Long.class) || (numberType == Long.TYPE)) {
        return value.longValue();
    }

    if ((numberType == Short.class) || (numberType == Short.TYPE)) {
        return value.shortValue();
    }

    if ((numberType == Byte.class) || (numberType == Byte.TYPE)) {
        return value.byteValue();
    }

    if ((numberType == Float.class) || (numberType == Float.TYPE)) {
        return value.floatValue();
    }

    if ((numberType == Double.class) || (numberType == Double.TYPE)) {
        return value.doubleValue();
    }

    if (numberType == BigDecimal.class) {
        return BigDecimal.valueOf(value.doubleValue());
    }

    if (numberType == BigInteger.class) {
        return BigInteger.valueOf(value.longValue());
    }

    throw new IllegalArgumentException(numberType + " not supported");
}

From source file:com.base.dao.sql.ReflectionUtils.java

public static Object convertValue(Object value, Class toType) {
    Object result = null;// w w w  . j  ava2s .c om
    if (value != null) {
        if (value.getClass().isArray() && toType.isArray()) {
            Class componentType = toType.getComponentType();
            result = Array.newInstance(componentType, Array.getLength(value));
            for (int i = 0, icount = Array.getLength(value); i < icount; i++) {
                Array.set(result, i, convertValue(Array.get(value, i), componentType));
            }
        } else {
            if ((toType == Integer.class) || (toType == Integer.TYPE))
                result = Integer.valueOf((int) longValue(value));
            if ((toType == Double.class) || (toType == Double.TYPE))
                result = new Double(doubleValue(value));
            if ((toType == Boolean.class) || (toType == Boolean.TYPE))
                result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE;
            if ((toType == Byte.class) || (toType == Byte.TYPE))
                result = Byte.valueOf((byte) longValue(value));
            if ((toType == Character.class) || (toType == Character.TYPE))
                result = new Character((char) longValue(value));
            if ((toType == Short.class) || (toType == Short.TYPE))
                result = Short.valueOf((short) longValue(value));
            if ((toType == Long.class) || (toType == Long.TYPE))
                result = Long.valueOf(longValue(value));
            if ((toType == Float.class) || (toType == Float.TYPE))
                result = new Float(doubleValue(value));
            if (toType == BigInteger.class)
                result = bigIntValue(value);
            if (toType == BigDecimal.class)
                result = bigDecValue(value);
            if (toType == String.class)
                result = stringValue(value);
            if (toType == Date.class) {
                result = DateUtils.toDate(stringValue(value));
            }
            if (Enum.class.isAssignableFrom(toType))
                result = enumValue((Class<Enum>) toType, value);
        }
    } else {
        if (toType.isPrimitive()) {
            result = primitiveDefaults.get(toType);
        }
    }
    return result;
}