List of usage examples for java.lang Integer Integer
@Deprecated(since = "9") public Integer(String s) throws NumberFormatException
From source file:net.bioclipse.opentox.api.HttpMethodHelper.java
public static HttpMethodBase addMethodHeaders(HttpMethodBase method, Map<String, String> extraHeaders) { // set the time out method.getParams().setParameter("http.socket.timeout", new Integer(Activator.TIME_OUT)); // log in on OpenTox if needed... if (Activator.getToken() != null) { method.setRequestHeader("subjectid", Activator.getToken()); }/*from w w w.j a va2 s. c o m*/ // add other headers if (extraHeaders != null) { for (String header : extraHeaders.keySet()) { method.setRequestHeader(header, extraHeaders.get(header)); } } return method; }
From source file:ShowAction.java
public ShowAction(Component parentComponent) { super("About"); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A)); this.parentComponent = parentComponent; }
From source file:Main.java
public static String encode(String s, String cr) { if (entityTableEncode == null) { buildEntityTables();// w w w.j a v a 2 s. co m } if (s == null) { return ""; } StringBuilder sb = new StringBuilder(s.length() * 2); char ch; for (int i = 0; i < s.length(); ++i) { ch = s.charAt(i); if ((ch >= 48 && ch <= 59) || (ch >= 63 && ch <= 90) || (ch >= 97 && ch <= 122) || (ch == ' ')) { sb.append(ch); } else if (ch == '\n') { sb.append(cr); } else { // cherry pick some safe non-seq chars if (ch == '(' || ch == ')' || ch == '+' || ch == '-' || ch == '*' || ch == '_') { sb.append(cr); } else { String chEnc = encodeSingleChar(String.valueOf(ch)); if (chEnc != null) { sb.append(chEnc); } else { // Not 7 Bit use the unicode system sb.append("&#"); sb.append(new Integer(ch).toString()); sb.append(';'); } } } } return sb.toString(); }
From source file:Main.java
/** * Given an array of objects, traverses the array and determines the most * suitable data type to perform the calculation in. An empty object of * the correct class is returned;// ww w .j a v a 2s . co m * * @param objects * */ static Object getObject(Object[] objects) { Class bestClass = bestClass(objects); if (bestClass == String.class) { return new String(""); //$NON-NLS-1$ } else if (bestClass == Double.class) { return new Double(0); } else if (bestClass == Float.class) { return new Float(0); } else if (bestClass == Long.class) { return new Long(0); } else if (bestClass == Integer.class) { return new Integer(0); } else { //it's a type we don't have here yet return null; } }
From source file:Main.java
public Main() { Vector dummyMacData = new Vector(10, 10); dummyMacData.addElement(new Data(new Integer(100), "A", "1", "C", "E")); dummyMacData.addElement(new Data(new Integer(105), "R", "2", "S", "E")); m_simpleTableModel = new SimpleTableModel(dummyMacData); m_simpleTable = new JTable(m_simpleTableModel); JScrollPane scrollPane = new JScrollPane(m_simpleTable); getContentPane().add(scrollPane);// w w w.ja v a 2 s . c o m }
From source file:Main.java
public Main() { 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 ww . j av a 2s.c om }); pack(); }
From source file:Main.java
/** * Convert entities to umlaute/*from w ww .j a v a 2 s. c o m*/ */ public static String decode(String value) { StringBuffer buffer = new StringBuffer(value); int pos; boolean found; for (int i = 0; i < buffer.length(); i++) { if (buffer.charAt(i) == '_' && buffer.charAt(i + 1) == '_') { pos = i + 2; found = false; while (buffer.charAt(pos) >= '0' && buffer.charAt(pos) <= '9') { found = true; pos++; } if (found == true && pos > i + 2 && buffer.charAt(pos) == ';') { int ent = new Integer(buffer.substring(i + 2, pos)).intValue(); buffer.replace(i, pos + 1, "" + (char) ent); } } } return buffer.toString(); }
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("tracker.count"); if (count == null) count = new Integer(1); else//from w ww. j a va2 s. c o m count = new Integer(count.intValue() + 1); session.setAttribute("tracker.count", count); out.println("<HTML><HEAD><TITLE>SessionTracker</TITLE></HEAD>"); out.println("<BODY><H1>Session Tracking Demo</H1>"); out.println("You've visited this page " + count + ((count.intValue() == 1) ? " time." : " times.")); out.println("<P>"); out.println("<H2>Here is your session data:</H2>"); Enumeration e = session.getAttributeNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); out.println(name + ": " + session.getAttribute(name) + "<BR>"); } out.println("</BODY></HTML>"); }
From source file:Main.java
/** * Sums an array of numbers together while using the correct class type. * * @param numbers//from w w w . j av a 2 s . c o m * * @return the sum contained in the most appropriate number class */ static Number sum(Number[] numbers) { Number newSum = (Number) getObject(numbers); if (newSum == null) { return null; } //Integer, Long, Float, Double if (newSum instanceof Integer) { int sum = 0; int nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].intValue(); sum += nextValue; } newSum = new Integer(sum); } else if (newSum instanceof Long) { long sum = 0; long nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].longValue(); sum += nextValue; } newSum = new Long(sum); } else if (newSum instanceof Float) { float sum = 0; float nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].floatValue(); sum += nextValue; } newSum = new Float(sum); } else if (newSum instanceof Double) { double sum = 0; double nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].doubleValue(); sum += nextValue; } newSum = new Double(sum); } else { return null; } return newSum; }
From source file:Main.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static Map getCardinalityMap(final Collection coll) { Map count = new HashMap(); for (Iterator it = coll.iterator(); it.hasNext();) { Object obj = it.next();/*from w ww . ja v a 2s.co m*/ Integer c = (Integer) (count.get(obj)); if (c == null) { count.put(obj, INTEGER_ONE); } else { count.put(obj, new Integer(c.intValue() + 1)); } } return count; }