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:com.adito.server.Main.java

/**
 * Entry point/*ww w .  j  a  va2 s .c  o m*/
 * 
 * @param args
 * @throws Throwable
 */
public static void main(String[] args) throws Throwable {

    // This is a hack to allow the Install4J installer to get the java
    // runtime that will be used
    if (args.length > 0 && args[0].equals("--jvmdir")) {
        System.out.println(SystemProperties.get("java.home"));
        System.exit(0);
    }
    useWrapper = System.getProperty("wrapper.key") != null;
    final Main main = new Main();
    ContextHolder.setContext(main);

    if (useWrapper) {
        WrapperManager.start(main, args);
    } else {
        Integer returnCode = main.start(args);
        if (returnCode != null) {
            if (main.gui) {
                if (main.startupException == null) {
                    main.startupException = new Exception("An exit code of " + returnCode + " was returned.");
                }
                try {
                    if (SystemProperties.get("os.name").toLowerCase().startsWith("windows")) {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    }
                } catch (Exception e) {
                }
                String mesg = main.startupException.getMessage() == null ? "No message supplied."
                        : main.startupException.getMessage();
                StringBuffer buf = new StringBuffer();
                int l = 0;
                char ch = ' ';
                for (int i = 0; i < mesg.length(); i++) {
                    ch = mesg.charAt(i);
                    if (l > 50 && ch == ' ') {
                        buf.append("\n");
                        l = 0;
                    } else {
                        if (ch == '\n') {
                            l = 0;
                        } else {
                            l++;
                        }
                        buf.append(ch);
                    }
                }
                mesg = buf.toString();
                final String fMesg = mesg;
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(null, fMesg, "Startup Error", JOptionPane.ERROR_MESSAGE);
                    }
                });
            }
            System.exit(returnCode.intValue());
        } else {
            Runtime.getRuntime().addShutdownHook(new Thread() {
                public void run() {
                    if (!main.shuttingDown) {
                        main.stop(0);
                    }
                }
            });
        }
    }
}

From source file:Main.java

public static int[] toIntArray(final List<Integer> list) {
    int[] ret = new int[list.size()];
    int i = -1;/* www  .  j a v  a  2s  . com*/
    for (Integer e : list) {
        ret[++i] = e.intValue();
    }
    return ret;
}

From source file:Main.java

/**
 * Encodes and Integer./* w ww.  jav a 2 s. co  m*/
 * 
 * @param value
 *          Integer
 * @return a String
 */
public static String encodeInteger(Integer value) {
    return value.intValue() + "";
}

From source file:Main.java

public static int getTotalValueCount(HashMap<String, Integer> hm) {
    int count = 0;
    for (Integer intVal : hm.values()) {
        count += intVal.intValue();
    }/*w ww .  ja  v  a2 s .  c o m*/
    return count;
}

From source file:Main.java

public static int[] toArray(Collection<Integer> col) {
    if (col == null)
        return null;
    int[] arr = new int[col.size()];
    int i = 0;/*from   w w  w . ja  va2s  .c  o m*/
    for (Integer v : col)
        arr[i++] = v.intValue();
    return arr;
}

From source file:Main.java

public static double getAverage(List<Integer> list) {
    if (list == null || list.size() == 0)
        return 0;
    double total = 0;
    int size = list.size();
    for (Integer i : list) {
        if (i == null || i.intValue() <= 0) {
            size--;/*  ww  w. j  ava2  s . co  m*/
            continue;
        }
        total += i;
    }
    if (size <= 0) {
        return 0;
    }
    return total / size;
}

From source file:Main.java

public static String getPhoneTypeString(Integer paramInteger) {
    return (String) sKnownPhoneTypesMap_ItoS.get(paramInteger.intValue());
}

From source file:Main.java

/**
 * Extract a set of Integer indices into an int[].
 * @param coll {@code HashSet} of {@code Integer}
 * @return int[]//from www  .j a  va2  s. c  o  m
 * @since 3.0.1
 */
private static int[] extractIndices(HashSet<Integer> coll) {
    int[] result = new int[coll.size()];
    int i = 0;
    for (Integer index : coll) {
        result[i++] = index.intValue();
    }
    return result;
}

From source file:Main.java

public static int getFileTypeForMimeType(String mimeType) {
    Integer value = sMimeTypeMap.get(mimeType);
    return (value == null ? 0 : value.intValue());
}

From source file:Main.java

/**
 * Extract a set of Integer indices into an int[].
 * //from  ww w  .j  a  v a 2s . com
 * @param coll
 *            {@code HashSet} of {@code Integer}
 * @return int[]
 * @since 3.0.1
 */
public static int[] extractIndices(HashSet<Integer> coll) {
    int[] result = new int[coll.size()];
    int i = 0;
    for (Integer index : coll) {
        result[i++] = index.intValue();
    }
    return result;
}