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

/**
 * Generates a XML string from DOM./*from  w w  w. j  a va  2 s. c o m*/
 * 
 * @param xmlDocument the DOM
 * @return XML string
 */
public static String build(Document xmlDocument) throws TransformerException {
    if (transformer == null) {
        TransformerFactory xformFactory = TransformerFactory.newInstance();
        try {
            xformFactory.setAttribute("indent-number", new Integer(4));
        } catch (IllegalArgumentException e) {
            // ignore
        }
        transformer = xformFactory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    }
    StringWriter out = new StringWriter();
    transformer.transform(new DOMSource(xmlDocument), new StreamResult(out));
    return out.getBuffer().toString();
}

From source file:Main.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static Map getCardinalityMap(final Collection coll) {
    final Map count = new HashMap();
    for (final Iterator it = coll.iterator(); it.hasNext();) {
        final Object obj = it.next();
        final Integer c = (Integer) (count.get(obj));
        if (c == null) {
            count.put(obj, INTEGER_ONE);
        } else {/* w  w w  .j  a v a 2 s  . c  o m*/
            count.put(obj, new Integer(c.intValue() + 1));
        }
    }
    return count;
}

From source file:SetValueAtToSetValue.java

public SetValueAtToSetValue() {
    final AbstractTableModel model = new MyModel();
    final JTable table = new JTable(model);
    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
    model.setValueAt(new Integer(1), 0, 0);

    JButton button = new JButton("Increment selected cell");
    getContentPane().add(button, BorderLayout.SOUTH);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = table.getSelectedRow();
            int column = table.convertColumnIndexToModel(table.getSelectedColumn());
            int currentValue = ((Integer) model.getValueAt(row, column)).intValue();
            model.setValueAt(new Integer(currentValue + 1), row, column);
        }/*from  w  w  w.j av  a  2s.com*/
    });

    pack();
}

From source file:TreeCellRendererImplementation.java

public TreeCellRendererImplementation() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("+");
    root.add(new DefaultMutableTreeNode(new Integer(3)));
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("*");
    node.add(new DefaultMutableTreeNode("string"));
    node.add(new DefaultMutableTreeNode(new Short((short) 5)));
    root.add(node);//from   w  ww .  j  av  a  2s.  c o m

    TreeModel tm = new DefaultTreeModel(root);
    JTree tree = new JTree(tm);
    tree.setShowsRootHandles(true);
    tree.setCellRenderer(new MyRenderer());
    getContentPane().add(tree, BorderLayout.CENTER);
    setSize(400, 300);
    setVisible(true);
}

From source file:MyServlet.java

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

    HttpSession session = req.getSession();

    Integer count = (Integer) session.getAttribute("snoop.count");
    if (count == null)
        count = new Integer(1);
    else/*from w ww .  j  a  v a2  s  .com*/
        count = new Integer(count.intValue() + 1);
    session.setAttribute("snoop.count", count);

    out.println("<HTML><HEAD><TITLE>SessionSnoop</TITLE></HEAD>");
    out.println("<BODY><H1>Session Snoop</H1>");

    out.println("You've visited this page " + count + ((count.intValue() == 1) ? " time." : " times."));

    out.println("<P>");

    out.println("<H3>Here is your saved session data:</H3>");
    Enumeration e = session.getAttributeNames();
    while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        out.println(name + ": " + session.getAttribute(name) + "<BR>");
    }

    out.println("<H3>Here are some vital stats on your session:</H3>");
    out.println("Session id: " + session.getId() + " <I>(keep it secret)</I><BR>");
    out.println("New session: " + session.isNew() + "<BR>");
    out.println("Timeout: " + session.getMaxInactiveInterval());
    out.println("<I>(" + session.getMaxInactiveInterval() / 60 + " minutes)</I><BR>");
    out.println("Creation time: " + session.getCreationTime());
    out.println("<I>(" + new Date(session.getCreationTime()) + ")</I><BR>");
    out.println("Last access time: " + session.getLastAccessedTime());
    out.println("<I>(" + new Date(session.getLastAccessedTime()) + ")</I><BR>");

    out.println("Requested session ID from cookie: " + req.isRequestedSessionIdFromCookie() + "<BR>");
    out.println("Requested session ID from URL: " + req.isRequestedSessionIdFromURL() + "<BR>");
    out.println("Requested session ID valid: " + req.isRequestedSessionIdValid() + "<BR>");

    out.println("<H3>Test URL Rewriting</H3>");
    out.println("Click <A HREF=\"" + res.encodeURL(req.getRequestURI()) + "\">here</A>");
    out.println("to test that session tracking works via URL");
    out.println("rewriting even when cookies aren't supported.");

    out.println("</BODY></HTML>");
}

From source file:Main.java

private static Integer signalParamHash(int signalType, int alertPitch, int signal) {
    if ((signalType < 0) || (signalType > 256) || (alertPitch > 256) || (alertPitch < 0) || (signal > 256)
            || (signal < 0)) {/*from   w ww  . java  2 s  . co m*/
        return new Integer(CDMA_INVALID_TONE);
    }
    // Based on 3GPP2 C.S0005-E, seciton 3.7.5.5 Signal,
    // the alert pitch field is ignored by the mobile station unless
    // SIGNAL_TYPE is '10',IS-54B Alerting.
    // Set alert pitch to TAPIAMSSCDMA_SIGNAL_PITCH_UNKNOWN
    // so the alert pitch is not involved in hash calculation
    // when signal type is not IS-54B.
    if (signalType != IS95_CONST_IR_SIGNAL_IS54B) {
        alertPitch = TAPIAMSSCDMA_SIGNAL_PITCH_UNKNOWN;
    }
    return new Integer(signalType * 256 * 256 + alertPitch * 256 + signal);
}

From source file:org.openfaces.component.chart.impl.PropertiesConverter.java

public static int getSize(String pxSize, int defaultSize) {
    int intSize = defaultSize;

    if (pxSize == null)
        return intSize;

    if (pxSize.endsWith("px")) {
        try {//from   ww w.j av a 2s .  co m
            String number = pxSize.substring(0, pxSize.indexOf("px"));
            intSize = new Integer(number);
        } catch (RuntimeException e) {
            throw new DataConversionException(
                    "Unable to convert size value. Correct value must looks like 200px. Currently defined: "
                            + pxSize);
        }
    }
    return intSize;
}

From source file:Main.java

/**
 *
 * @param namespace String/*from www  . java 2  s .c  o  m*/
 * @param parent Element
 * @param name String
 * @param value int
 */
public static void appendAttributeNode(String namespace, Element parent, String name, int value) {
    parent.setAttributeNS(namespace, name, new Integer(value).toString());
}

From source file:controllers.services.ServicesApp.java

/**
 * ?//from  www.  java 2s. c  om
 */
@Transactional(readOnly = true)
public static Result index() {
    DynamicForm requestData = Form.form().bindFromRequest();
    ListOrderedMap cts = SkillTag.getCacheCategory();
    Integer page = StringUtils.isBlank(requestData.get("page")) ? 1 : new Integer(requestData.get("page"));
    Integer pageSize = StringUtils.isBlank(requestData.get("pageSize")) ? 10
            : new Integer(requestData.get("pageSize"));
    Long categoryId = StringUtils.isBlank(requestData.get("categoryId")) ? (Long) cts.asList().get(0)
            : new Long(requestData.get("categoryId"));
    String type = requestData.get("type") == null ? "html" : requestData.get("type");
    Page<ServiceListVO> returnPage = Service.queryServiceByPage(page, pageSize, categoryId);
    if (!type.equals("json")) {
        return ok(views.html.services.index.render(returnPage, cts, categoryId));
    }
    return ok(play.libs.Json.toJson(returnPage));
}

From source file:framepackage.MyPieChart.java

public MyPieChart() {

    DefaultPieDataset pieDataset = new DefaultPieDataset();
    pieDataset.setValue("Online", new Integer(10));
    pieDataset.setValue("Offline", new Integer(20));
    pieDataset.setValue("Busy", new Integer(30));
    pieDataset.setValue("Away", new Integer(40));
    JFreeChart chart = ChartFactory.createPieChart("my pie", pieDataset, true, true, true);

    PiePlot P = (PiePlot) chart.getPlot();
    //P.setForegroundAlpha(TOP_ALIGNMENT);
    ChartFrame f = new ChartFrame("chart", chart);
    f.setVisible(true);//from   w w  w  . j a  v  a  2 s .  c  o m
    f.setSize(500, 700);
}