FileDocCategorySizeDatePackage
IntegralType.javaAPI DocGlassfish v2 API3805Fri May 04 22:35:08 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.query.util.type

IntegralType

public class IntegralType extends NumericType
This class represents the types byte, short int, long and char
author
Michael Bouschen
version
0.1

Fields Summary
Constructors Summary
public IntegralType(String name, Class clazz, int enumType)

        super(name, clazz, enumType);
    
Methods Summary
public java.lang.NumbergetValue(java.lang.Number value)
Converts the specified value into a value of this numeric type. E.g. an Integer is converted into a Long, if this represents the numeric type long.

param
value value to be converted
return
converted value

        Number ret = null;

        if (value == null)
            ret = null;
        else if ("int".equals(getName()))
            ret = new Integer(value.intValue());
        else if ("long".equals(getName()))
            ret = new Long(value.longValue());
        else if ("byte".equals(getName()))
            ret = new Byte(value.byteValue());
        else if ("short".equals(getName()))
            ret = new Short(value.shortValue());

        return ret;
    
public java.lang.Numbernegate(java.lang.Number value)
Returns -value.

param
value value to be negated
return
-value

        Number ret = null;

        if (value == null)
            ret = null;
        else if ("int".equals(getName()))
            ret = new Integer(-value.intValue());
        else if ("long".equals(getName()))
            ret = new Long(-value.longValue());
        else if ("byte".equals(getName()))
            ret = new Byte((byte)-value.byteValue());
        else if ("short".equals(getName()))
            ret = new Short((short)-value.shortValue());

        return ret;