Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

In this page you can find the example usage for java.lang Integer intValue.

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:Main.java

@SuppressWarnings({ "rawtypes" })
private static final int getFreq(final Object obj, final Map freqMap) {
    final Integer count = (Integer) freqMap.get(obj);
    if (count != null) {
        return count.intValue();
    }/*from w w  w.  j a v  a  2 s  .  co m*/
    return 0;
}

From source file:Main.java

public static double compareText(String text, String source) {
    Map<String, Integer> sourceMap = parseTextToWords(source);
    Map<String, Integer> textMap = parseTextToWords(text);

    int total = 0;
    int notFound = 0;
    for (Map.Entry<String, Integer> textEntry : textMap.entrySet()) {
        String word = textEntry.getKey();
        int count = textEntry.getValue();

        Integer sourceCount = sourceMap.get(word);
        int sCount = sourceCount != null ? sourceCount.intValue() : 0;

        total += count;//from w w w .j  a  v  a2 s . c om
        notFound += (count > sCount) ? count - sCount : 0;
    }

    return (double) (total - notFound) / (double) total;
}

From source file:Main.java

private static final int getFreq(final Object obj, final Map freqMap) {
    Integer count = (Integer) freqMap.get(obj);
    if (count != null) {
        return count.intValue();
    }/*  w ww.j  ava  2  s  .  c o m*/
    return 0;
}

From source file:Main.java

public static int[] toIntArray(List<Integer> list, int defaultValue) {
    if (isEmpty(list)) {
        return new int[0];
    }/*from  w w  w.  ja  v  a  2s . c o m*/
    int[] array = new int[list.size()];
    for (int I = 0; I < list.size(); I++) {
        Integer v = list.get(I);
        if (v == null) {
            array[I] = defaultValue;
        } else {
            array[I] = v.intValue();
        }
    }
    return array;
}

From source file:com.hbc.api.trade.bdata.common.util.ParameterValidator.java

/**
 * @param paramValue ??//from  w  w  w .java 2 s .c o m
 * @param paramNameTip ????
 */
public static void validateParamNumberGreaterThan0(Integer paramValue, String paramNameTip) {
    if (paramValue != null && paramValue.intValue() < 0) {
        throw new ParamValidateException(CommonReturnCodeEnum.PARAM_ERROR_WITHARG, paramNameTip);
    }
}

From source file:com.hbc.api.trade.ota.validator.ParameterValidator.java

/**
 * @param paramValue ??/*  w  w w  .  j  av  a 2s.  co  m*/
 * @param paramNameTip ????
 */
public static void validateParamNumberGreaterThan0(Integer paramValue, String paramNameTip) {
    if (paramValue == null || paramValue.intValue() < 0) {
        throw new ParamValidateException(CommonReturnCodeEnum.PARAM_ERROR_WITHARG, paramNameTip);
    }
}

From source file:com.kcs.core.utilities.SortOrder.java

public static SortOrder fromCode(Integer key) {
    if (key == null) {
        return null;
    }//from   ww  w  . jav  a2s .c o  m

    return fromCode(key.intValue());
}

From source file:Main.java

/**
 * Converts to primitive array./*w  w w .  j  av a2 s  .c om*/
 */
public static int[] values(Integer[] array) {
    int[] dest = new int[array.length];
    for (int i = 0; i < array.length; i++) {
        Integer v = array[i];
        if (v != null) {
            dest[i] = v.intValue();
        }
    }
    return dest;
}

From source file:com.healthmarketscience.jackcess.DataTypes.java

public static int toSQLType(byte dataType) throws SQLException {
    Integer i = (Integer) SQL_TYPES.get(new Byte(dataType));
    if (i != null) {
        return i.intValue();
    } else {/*from w  ww . ja v  a 2s .c  o  m*/
        throw new SQLException("Unsupported data type: " + dataType);
    }
}

From source file:Main.java

public static int[] toPrimitive(final Integer[] array, final int valueForNull) {
    if (array == null) {
        return null;
    } else if (array.length == 0) {
        return EMPTY_INT_ARRAY;
    }/*from w ww.j  a v  a 2 s  . c  om*/
    final int[] result = new int[array.length];
    for (int i = 0; i < array.length; i++) {
        final Integer b = array[i];
        result[i] = (b == null ? valueForNull : b.intValue());
    }
    return result;
}