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:CounterRewrite.java

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    HttpSession session = req.getSession(true);
    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();
    int count = 1;
    Integer i = (Integer) session.getAttribute(COUNTER_KEY);
    if (i != null) {
        count = i.intValue() + 1;//from   www.ja  va2  s  . c o m
    }
    session.setAttribute(COUNTER_KEY, new Integer(count));
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Session Counter</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("Your session ID is <b>" + session.getId());
    out.println("</b> and you have hit this page <b>" + count + "</b> time(s) during this browser session");

    String url = req.getRequestURI();
    out.println("<form method=GET action=\"" + resp.encodeURL(url) + "\">");
    out.println("<input type=submit " + "value=\"Hit page again\">");
    out.println("</form>");
    out.println("</body>");
    out.println("</html>");
    out.flush();
}

From source file:Main.java

public void setMyProperty(int newValue) {
    int oldValue = myProperty;
    myProperty = newValue;//from w w w  .j a va 2  s .  c  o m
    pceListeners.firePropertyChange("myProperty", new Integer(oldValue), new Integer(newValue));
}

From source file:Randomizer.java

public int[] nextInt(int n, int size) {
    if (size > n) {
        size = n;/*from w  w  w .j a  v a  2  s  . c om*/
    }

    Set set = new LinkedHashSet();

    for (int i = 0; i < size; i++) {
        while (true) {
            Integer value = new Integer(nextInt(n));

            if (!set.contains(value)) {
                set.add(value);

                break;
            }
        }
    }

    int[] array = new int[set.size()];

    Iterator itr = set.iterator();

    for (int i = 0; i < array.length; i++) {
        array[i] = ((Integer) itr.next()).intValue();
    }

    return array;
}

From source file:CounterServer.java

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    HttpSession session = req.getSession(true);
    int count = 1;
    Integer i = (Integer) session.getAttribute(COUNTER_KEY);
    if (i != null) {
        count = i.intValue() + 5;/* w w w  .j  a  va2 s  .  c o m*/
    }
    session.setAttribute(COUNTER_KEY, new Integer(count));
    DataInputStream in = new DataInputStream(req.getInputStream());
    resp.setContentType("application/octet-stream");
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(byteOut);
    out.writeInt(count);
    out.flush();
    byte[] buf = byteOut.toByteArray();
    resp.setContentLength(buf.length);
    ServletOutputStream servletOut = resp.getOutputStream();
    servletOut.write(buf);
    servletOut.close();
}

From source file:GetValueAtLogic.java

public Object getValueAt(int r, int c) {
    return (c == 0) ? new Integer(x[r]) : new Integer(2 * x[r] + 1);
}

From source file:Main.java

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

From source file:ItemEventComponent.java

public Object[] getSelectedObjects() {
    Object o[] = new Object[1];
    o[0] = new Integer(i);
    return o;
}

From source file:de.odysseus.calyxo.base.util.ParseUtils.java

private static Object nullValue(Class type) {
        if (type.isPrimitive()) {
            if (type == boolean.class)
                return Boolean.FALSE;
            if (type == byte.class)
                return new Byte((byte) 0);
            if (type == char.class)
                return new Character((char) 0);
            if (type == short.class)
                return new Short((short) 0);
            if (type == int.class)
                return new Integer(0);
            if (type == long.class)
                return new Long(0);
            if (type == float.class)
                return new Float(0);
            if (type == double.class)
                return new Double(0);
        }//  w  w  w. ja va 2  s  .c  om
        return null;
    }

From source file:JchartTest.GetChartAction.java

@Override
public String execute() throws Exception {
    ValueAxis xAxis = new NumberAxis("Input Increase");
    ValueAxis yAxis = new NumberAxis("Production");
    XYSeries xySeries = new XYSeries(new Integer(1));
    xySeries.add(0, 200);//from  www.  j av a2 s .  co m
    xySeries.add(1, 300);
    xySeries.add(2, 500);
    xySeries.add(3, 700);
    xySeries.add(4, 700);
    xySeries.add(5, 900);
    XYSeriesCollection xyDataset = new XYSeriesCollection(xySeries);
    // create XYPlot
    XYPlot xyPlot = new XYPlot(xyDataset, xAxis, yAxis,
            new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES));
    chart = new JFreeChart(xyPlot);
    return SUCCESS;
}

From source file:com.phoenixst.plexus.examples.RandomGraphFactory.java

/**
 *  Creates a random graph with <code>n</code> nodes where each
 *  pair of nodes has probability <code>prob</code> of having an
 *  edge between them.//from  w w  w  . ja v  a 2 s .  c  om
 */
public static Graph createStandardGraph(int n, double prob) {
    if (prob < 0.0 || prob > 1.0) {
        throw new IllegalArgumentException("Probability must be between 0.0 and 1.0, inclusive.");
    }
    Graph graph = new DefaultGraph(new EmptyGraph(n));
    for (int head = 1; head < n; head++) {
        Object headNode = new Integer(head);
        for (int tail = 0; tail < head; tail++) {
            if (Math.random() < prob) {
                graph.addEdge(null, new Integer(tail), headNode, true);
            }
        }
    }
    return graph;
}