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:com.zytan.sdpn.peer.FullPeer.java

public static void main(String[] args) {

    boolean active = true;

    if (args.length != 0) {
        FullPeer peer = null;// ww  w.ja  va2  s.  c  o  m
        if (args.length == 3) {
            //args[0]=file peer configuration args[1]=key
            peer = new FullPeer(args[0], args[1]);

        } else if (args.length == 5) {
            //args[0]=file peer configuration args[1]=key args[2]=peer name args[3]=peer port
            peer = new FullPeer(args[0], args[1], args[2], new Integer(args[3]));

        }
        for (int i = 0; i < args.length; i++) {

            /*
             * join to bootstrapPeer
             */
            if (args[i].equals("-j")) {
                peer.joinToBootstrapPeer();

            }
            /*
             * request public address from SBC
             */
            else if (args[i].equals("-s")) {
                peer.contactSBC();
            }
            /*
             * join to bootstrapPeer, wait and send ping message to random peer
             */
            else if (args[i].equals("-jp")) {

                peer.joinToBootstrapPeer();
                //wait for 3 seconds
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                peer.pingToPeerRandomFromList();
            }
            /*
             * join to bootstrapPeer, wait and send ping message to random peer recursively
             */
            else if (args[i].equals("-jr")) {

                peer.joinToBootstrapPeer();

                while (active) {

                    //wait for 15 seconds
                    try {
                        Thread.sleep(15000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    //ping to bootstrap peer
                    peer.pingToPeer(peer.peerConfig.bootstrap_peer);

                }
            }

            else if (args[i].equals("-p")) {

                peer.pingToPeer(args[5]);
            }

            else if (args[i].equals("-sd")) {

                peer.contactSBC();
                try {
                    Thread.sleep(7000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                peer.disconnectGWP();

            }
            /*
             * contact SBC, wait, join to bootstrapPeer, wait and send ping message to random peer recursively
             */
            else if (args[i].equals("-a")) {

                peer.contactSBC();

                try {
                    Thread.sleep(4000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                peer.joinToBootstrapPeer();

                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                peer.pingToPeerRandomFromList();
            }

        }

    }
}

From source file:org.springmodules.validation.util.condition.range.AbstractBetweenConditionTests.java

public void testConstructor_WithNullLowerBound() throws Exception {
    try {/*from   w w w.  ja  va 2s.  c om*/
        createBetweenCondition(null, new Integer(3));
        fail("An IllegalArgumentException must be thrown if the condition is initialized with a null lower bound");
    } catch (IllegalArgumentException iae) {
        // expected
    }

    try {
        createBetweenCondition(null, new Integer(3), new ComparableComparator());
        fail("An IllegalArgumentException must be thrown if the condition is initialized with a null lower bound");
    } catch (IllegalArgumentException iae) {
        // expected
    }
}

From source file:com.pontorural.pedidovenda.converter.TabelaConverter.java

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    Tabela retorno = null;/*from   ww  w.jav  a  2s .  com*/

    if (StringUtils.isNotEmpty(value)) {
        Integer codigo = new Integer(value);
        retorno = tabelas.porId(codigo);
    }

    return retorno;
}

From source file:Main.java

@Override
public Object getValueAt(int row, int column) {
    return new Integer((row + 1) * (column + 1));
}

From source file:MyServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

    Cookie cookie = null;//from   w ww .  ja v  a  2s  .c  om
    //Get an array of Cookies associated with this domain
    Cookie[] cookies = request.getCookies();
    boolean newCookie = false;

    //Get the 'mycookie' Cookie if it exists
    if (cookies != null) {
        for (int i = 0; i < cookies.length; i++) {
            if (cookies[i].getName().equals("mycookie")) {
                cookie = cookies[i];
            }
        } //end for
    } //end if

    if (cookie == null) {
        newCookie = true;
        //Get the cookie's Max-Age from a context-param element
        //If the 'cookie-age' param is not set properly
        //then set the cookie to a default of -1, 'never expires'
        int maxAge;
        try {
            maxAge = new Integer(getServletContext().getInitParameter("cookie-age")).intValue();
        } catch (Exception e) {
            maxAge = -1;
        }

        //Create the Cookie object

        cookie = new Cookie("mycookie", "" + getNextCookieValue());
        cookie.setPath(request.getContextPath());
        cookie.setMaxAge(maxAge);
        response.addCookie(cookie);

    } //end if
      // get some info about the cookie
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();

    out.println("<html>");
    out.println("<head>");
    out.println("<title>Cookie info</title>");
    out.println("</head>");
    out.println("<body>");

    out.println("<h2> Information about the cookie named \"mycookie\"</h2>");

    out.println("Cookie value: " + cookie.getValue() + "<br>");
    if (newCookie) {
        out.println("Cookie Max-Age: " + cookie.getMaxAge() + "<br>");
        out.println("Cookie Path: " + cookie.getPath() + "<br>");
    }

    out.println("</body>");
    out.println("</html>");

    out.close();
}

From source file:Main.java

public Main() {
    super("JLayeredPane Demo");
    setSize(256, 256);/*w w  w .j a  va 2 s . c  o  m*/

    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    content.setOpaque(false);

    JLabel label1 = new JLabel("Username:");
    label1.setForeground(Color.white);
    content.add(label1);

    JTextField field = new JTextField(15);
    content.add(field);

    JLabel label2 = new JLabel("Password:");
    label2.setForeground(Color.white);
    content.add(label2);

    JPasswordField fieldPass = new JPasswordField(15);
    content.add(fieldPass);

    setLayout(new FlowLayout());
    add(content);
    ((JPanel) getContentPane()).setOpaque(false);

    ImageIcon earth = new ImageIcon("largeJava2sLogo.png");
    JLabel backlabel = new JLabel(earth);
    getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE));
    backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight());
    super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
}

From source file:net.sourceforge.jabm.spring.RandomIntegerFactoryBean.java

@Override
public Integer getObject() {
    return new Integer((int) Math.round(distribution.nextDouble()));
}

From source file:com.ea.core.web.bridge.sync.storm.client.RemoteClient.java

public RemoteClient() {
    super();/*from   www . j a  v  a 2 s.co  m*/
    if (BridgeConstant.CONNECTOR_MODE.STORM_REMOTE.getCode()
            .equals(CoreDefinition.getPropertyValue("sync.mode"))) {
        super.init(StormDefinition.getPropertyValue("drpc.server.host"),
                new Integer(StormDefinition.getPropertyValue("drpc.server.port")),
                new Integer(StormDefinition.getPropertyValue("drpc.server.timeout")));
    }
}

From source file:conceptor.chaos.Lyapunov.java

private static double[] getTestPoint(DynamicalSystem system, double d0) {
    double[] testPoint = new double[system.getDimension()];
    double denom = Math.sqrt((new Integer(system.getDimension())).doubleValue());
    double[] x = system.getState();

    for (int i = 0; i < x.length; i++) {
        testPoint[i] = x[i] + d0 / denom;
    }//w ww .  j  a  v  a  2  s  .  c om

    return testPoint;
}

From source file:Main.java

public static Object getNamedElemValue(Element parent, String elementName, Class basicType, Object defaultVal) {
    String val = getNamedElemValue(parent, elementName);
    if (val == null) {
        return defaultVal;
    }/*from  w  w  w  .  j ava  2s.c o  m*/

    try {
        if (Boolean.class.equals(basicType)) {
            return new Boolean(val);
        } else if (Integer.class.equals(basicType)) {
            return new Integer(val);
        } else if (Float.class.equals(basicType)) {
            return new Float(val);
        } else if (Double.class.equals(basicType)) {
            return new Double(val);
        } else
            return val;
    } catch (Exception e) {
        return defaultVal;
    }
}