Example usage for java.lang Short floatValue

List of usage examples for java.lang Short floatValue

Introduction

In this page you can find the example usage for java.lang Short floatValue.

Prototype

public float floatValue() 

Source Link

Document

Returns the value of this Short as a float after a widening primitive conversion.

Usage

From source file:Main.java

public static void main(String[] args) {
    Short shortObject = new Short("10");

    float f = shortObject.floatValue();
    System.out.println("float" + f);

}

From source file:Main.java

public static void main(String[] args) {
    Short sObj = new Short("10");

    byte b = sObj.byteValue();
    System.out.println(b);//from www.j  a  va  2 s.  c  om

    short s = sObj.shortValue();
    System.out.println(s);

    int i = sObj.intValue();
    System.out.println(i);

    float f = sObj.floatValue();
    System.out.println(f);

    double d = sObj.doubleValue();
    System.out.println(d);

    long l = sObj.longValue();
    System.out.println(l);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJFloatEditor.java

public boolean isEditValid() {
    final String S_ProcName = "isEditValid";
    if (!hasValue()) {
        setValue(null);/*  w w w . j  a va 2s  .c  o  m*/
        return (true);
    }

    boolean retval = super.isEditValid();
    if (retval) {
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = false;
        } else if (obj instanceof Float) {
            Float v = (Float) obj;
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Double) {
            Double v = (Double) obj;
            Double min = getMinValue().doubleValue();
            Double max = getMaxValue().doubleValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            Float v = new Float(s.floatValue());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            Float v = new Float(i.floatValue());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            Float v = new Float(l.floatValue());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof BigDecimal) {
            BigDecimal b = (BigDecimal) obj;
            Float v = new Float(b.toString());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            Float v = new Float(n.toString());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, BigDecimal, Float, Double or Number");
        }
    }
    return (retval);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJFloatEditor.java

public Float getFloatValue() {
    final String S_ProcName = "getFloatValue";
    Float retval;/*ww w . j  a  v a 2s  .  c  o  m*/
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Float) {
            Float v = (Float) obj;
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Double) {
            Double v = (Double) obj;
            Double min = getMinValue().doubleValue();
            Double max = getMaxValue().doubleValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = new Float(v.floatValue());
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            Float v = new Float(s.floatValue());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            Float v = new Float(i.floatValue());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            Float v = new Float(l.floatValue());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof BigDecimal) {
            BigDecimal b = (BigDecimal) obj;
            Float v = new Float(b.toString());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            Float v = new Float(n.toString());
            Float min = getMinValue();
            Float max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, BigDecimal or Number");
        }
    }
    return (retval);
}