Example usage for java.lang Integer Integer

List of usage examples for java.lang Integer Integer

Introduction

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

Prototype

@Deprecated(since = "9")
public Integer(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Integer object that represents the int value indicated by the String parameter.

Usage

From source file:Watcher.java

void counter(int period) {
    for (; period >= 0; period--) {
        setChanged();/*from  w  w  w  .ja v a2s .c o m*/
        notifyObservers(new Integer(period));
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            System.out.println("Sleep interrupted");
        }
    }
}

From source file:Main.java

/**
 * Access the Hashtable s_exportBatches to see what the current page count
 * of this export batch is. This call decrements the value in the table.
 *///from www . j  a  v a 2  s  . c o  m
private static boolean isExportFileComplete(String p_fileId, int p_pageCount) {
    // Default is to write out the file.
    boolean result = true;
    int curPageCnt = -1;

    synchronized (s_exportBatches) {
        Integer oldPageCount = (Integer) s_exportBatches.get(p_fileId);
        if (oldPageCount == null) {
            // First page of this exportBatch.
            curPageCnt = p_pageCount - 1;
            if (curPageCnt == 0) {
                // The batch is complete, no need to put anything
                // in the hashtable.
                result = true;
            } else {
                result = false;
                s_exportBatches.put(p_fileId, new Integer(curPageCnt));
            }
        } else {
            curPageCnt = oldPageCount.intValue() - 1;
            if (curPageCnt == 0) {
                // The batch is complete, remove the value from the
                // hashtable.
                result = true;
                s_exportBatches.remove(p_fileId);
            } else {
                result = false;
                s_exportBatches.put(p_fileId, new Integer(curPageCnt));
            }
        }
    }

    return result;
}

From source file:Main.java

public static void logMessage(int id, Throwable t) {
    logMessage(new Integer(id).toString(), getStackTrace(t));
}

From source file:SessionTracker.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    HttpSession session = req.getSession(true);

    Integer count = (Integer) session.getAttribute("count");

    if (count == null) {
        count = new Integer(1);
    } else {/*from ww w.  j  a v a  2 s.  c o  m*/
        count = new Integer(count.intValue() + 1);
    }

    session.setAttribute("count", count);
    out.println("<html><head><title>SessionSnoop</title></head>");
    out.println("<body><h1>Session Details</h1>");
    out.println(
            "You've visited this page " + count + ((count.intValue() == 1) ? " time." : " times.") + "<br/>");
    out.println("<h3>Details of this session:</h3>");
    out.println("Session id: " + session.getId() + "<br/>");
    out.println("New session: " + session.isNew() + "<br/>");
    out.println("Timeout: " + session.getMaxInactiveInterval() + "<br/>");
    out.println("Creation time: " + new Date(session.getCreationTime()) + "<br/>");
    out.println("Last access time: " + new Date(session.getLastAccessedTime()) + "<br/>");
    out.println("</body></html>");
}

From source file:Main.java

public ShowAction() {
    super("About");

    putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A));
    putValue(Action.NAME, "Go to number ");
    putValue(Action.LARGE_ICON_KEY, MetalIconFactory.getFileChooserHomeFolderIcon());

}

From source file:Main.java

public ShowAction() {
    super("About");

    putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A));
    putValue(Action.NAME, "Go to number ");
    putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, 1);

}

From source file:MapHeavenV1.java

private void testMaps() {
    cIMap.put("key1", "value1");
    cIMap.put("key2", "value2");
    cIMap.put("KeY1", "value3");

    System.err.println("Value of key1: " + cIMap.get("key1")); // value3 because it is case insensitive

    Integer identRef = new Integer(1);
    Integer identRef2 = new Integer(1);
    identMap.put(identRef, "value1");
    identMap.put(identRef2, "value3");

    System.err.println("Value of identRef2: " + identMap.get(identRef2)); // value 3 even though both identRef and identRef2 are equal

    System.err.println(lazyMap); // only creates elements when they are accessed
    lazyMap.get("EmptyBuffer");
    System.err.println(lazyMap);// w  w  w. j av a 2s .  c  om
}

From source file:JarResources.java

public JarResources(String jarFileName) throws Exception {
    this.jarFileName = jarFileName;
    ZipFile zf = new ZipFile(jarFileName);
    Enumeration e = zf.entries();
    while (e.hasMoreElements()) {
        ZipEntry ze = (ZipEntry) e.nextElement();

        htSizes.put(ze.getName(), new Integer((int) ze.getSize()));
    }/*from w  ww . ja  v  a 2s  .  c om*/
    zf.close();

    // extract resources and put them into the hashtable.
    FileInputStream fis = new FileInputStream(jarFileName);
    BufferedInputStream bis = new BufferedInputStream(fis);
    ZipInputStream zis = new ZipInputStream(bis);
    ZipEntry ze = null;
    while ((ze = zis.getNextEntry()) != null) {
        if (ze.isDirectory()) {
            continue;
        }

        int size = (int) ze.getSize();
        // -1 means unknown size.
        if (size == -1) {
            size = ((Integer) htSizes.get(ze.getName())).intValue();
        }

        byte[] b = new byte[(int) size];
        int rb = 0;
        int chunk = 0;
        while (((int) size - rb) > 0) {
            chunk = zis.read(b, rb, (int) size - rb);
            if (chunk == -1) {
                break;
            }
            rb += chunk;
        }

        htJarContents.put(ze.getName(), b);
    }
}

From source file:com.persiste.sdk.Put.java

@SuppressWarnings("unchecked")
public Put(Log log) {
    this.log = new JSONObject();
    this.log.put("level", new Integer(log.level));
    this.log.put("title", log.title);
    this.log.put("description", log.description);
    this.log.put("emiter", log.emiter);
    this.log.put("custom_fields", log.custom_fields);
    this.log.put("stack_trace", log.stack_trace);
}

From source file:SimpleFTF.java

public SimpleFTF() {
    JFormattedTextField ftf[] = new JFormattedTextField[7];
    String des[] = new String[ftf.length]; // description of each field

    des[0] = "Date";
    ftf[0] = new JFormattedTextField(new java.util.Date());

    des[1] = "Integer";
    ftf[1] = new JFormattedTextField(new Integer(90032221));

    des[2] = "Float";
    ftf[2] = new JFormattedTextField(new Float(3.14));

    des[3] = "Float work-around"; // manually specify a NumberFormat
    ftf[3] = new JFormattedTextField(java.text.NumberFormat.getInstance());
    ftf[3].setValue(new Float(3.14));

    des[4] = "currency";
    ftf[4] = new JFormattedTextField(java.text.NumberFormat.getCurrencyInstance());
    ftf[4].setValue(new Float(5.99));

    des[5] = "percent";
    ftf[5] = new JFormattedTextField(java.text.NumberFormat.getPercentInstance());
    ftf[5].setValue(new Float(0.33));

    des[6] = "java.net.URL"; // works via 1-arg String constructor and
    // toString()
    java.net.URL u = null;/*from  www. j  a  va 2  s .com*/
    try {
        u = new java.net.URL("http://www.ora.com/");
    } catch (java.net.MalformedURLException ignored) {
    }
    ftf[6] = new JFormattedTextField(u);
    ftf[6].setColumns(24);

    // add each ftf[] to a BoxLayout
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    for (int j = 0; j < ftf.length; j += 1) {
        JPanel borderPanel = new JPanel(new java.awt.BorderLayout());
        borderPanel.setBorder(new javax.swing.border.TitledBorder(des[j]));
        borderPanel.add(ftf[j], java.awt.BorderLayout.CENTER);
        add(borderPanel);
    }
}