List of usage examples for java.lang Integer Integer
@Deprecated(since = "9") public Integer(String s) throws NumberFormatException
From source file:gov.utah.dts.sdc.actions.LoginAction.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public String execute() { log.info("LoginAction execute..."); PersonService service = new PersonService(); HashMap<String, String> map = new HashMap<String, String>(); map.put("dn", (String) getSession().get(Constants.USER_DN)); Integer cnt = new Integer(0); try {/*from ww w . ja va2 s . c o m*/ log.info("LoginAction searching " + map.get("dn")); if (map.get("dn") != null) { cnt = service.getEqualsCount(map); log.debug("step 2"); } if (cnt.intValue() == 1) { /*Match found containing authenticated users DN *forward to the success page. */ List list = service.searchEquals(map); log.info("LoginAction (DN) Match Found " + list.size()); Person person = (Person) list.get(0); getSession().put(Constants.USER_KEY, person); } else { map.clear(); if (getSession().get(Constants.USER_EMAIL) != null) { map.put("email", getSession().get(Constants.USER_EMAIL).toString().toUpperCase()); cnt = service.getEqualsCount(map); } if (cnt.intValue() == 1) { /*A email match was found in the DB for further *identificaiton purposes forward to the registration *page and request additional information */ List list = service.searchEquals(map); log.info("LoginAction (Email) match Found " + list.size()); Person person = (Person) list.get(0); person = setUMDValues(person); getSession().put(Constants.USER_KEY, person); return Constants.REGISTER_MERGE; } else if (cnt.intValue() < 1) { log.info("No match found "); Person person = setUMDValues(); getSession().put(Constants.USER_KEY, person); return Constants.REGISTER; } } } catch (Exception e) { log.error("ERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR", e); e.printStackTrace(); addActionError(e.getMessage()); } if (hasErrors()) { return ERROR; } else { return SUCCESS; } }
From source file:TestSoftRef.java
public void testOutOfMemory() throws Exception { Object obj = pool.borrowObject(); pool.returnObject(obj);/*from w ww . ja v a 2 s . c om*/ obj = null; assertEquals(5, pool.getNumIdle()); try { HashMap map = new HashMap(); for(int i = 0; i < 1000000; i++) { map.put(new Integer(i), new String("Fred Flintstone" + i)); } }catch(OutOfMemoryError ex) { pool.borrowObject(); pool.borrowObject(); pool.borrowObject(); pool.borrowObject(); pool.borrowObject(); // assertEquals(0, pool.getNumIdle()); } }
From source file:Main.java
public ShowAction() { super("About"); PropertyChangeListener lis = new PropertyChangeListener() { @Override//from w ww.ja v a 2s.co m public void propertyChange(PropertyChangeEvent e) { System.out.println(e); } }; addPropertyChangeListener(lis); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A)); putValue(Action.NAME, "Go to number "); putValue(Action.LONG_DESCRIPTION, "Change the number to "); removePropertyChangeListener(lis); }
From source file:ArrowButtonExample.java
ArrowButtonExample() { d = new Display(); s = new Shell(d); s.setSize(250, 250);//ww w .ja va2 s .c o m s.setText("A Button Example"); final Button b1 = new Button(s, SWT.ARROW | SWT.UP); b1.setBounds(100, 55, 20, 15); final Button b2 = new Button(s, SWT.ARROW | SWT.DOWN); b2.setBounds(100, 70, 20, 15); final Text t1 = new Text(s, SWT.BORDER | SWT.SINGLE | SWT.CENTER); t1.setBounds(80, 55, 20, 30); t1.setText("1"); t1.selectAll(); b1.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int n = new Integer(t1.getText()).intValue(); n++; t1.setText(new Integer(n).toString()); t1.selectAll(); } }); b2.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int n = new Integer(t1.getText()).intValue(); n--; t1.setText(new Integer(n).toString()); t1.selectAll(); } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:mikolaj.torrent.command.actions.Shares.java
public Result perform(HashMap<String, String> paramsMap) { String host = paramsMap.get("host"); String port = paramsMap.get("port"); Client client = new Client(host, new Integer(port), Client.SERVER_PULL_STRING); JSONArray jsonArray = new Result().fromJsonArray(client.sendMessage(this.getName())); System.out.println(String.format("Shared files of %s:", host)); for (Object file : jsonArray) { JSONObject fileObject = (JSONObject) file; System.out.println(//w w w . jav a 2 s . co m String.format(" %s (checksum %s)", fileObject.get("fileName"), fileObject.get("checkSum"))); } return new Result(); }
From source file:org.beanfuse.notification.mail.DefaultMailNotifierTest.java
@Test public void testGmail() throws Exception { JavaMailSenderImpl mailSender = new org.springframework.mail.javamail.JavaMailSenderImpl(); mailSender.setHost("smtp.gmail.com"); mailSender.setUsername("eams.demon"); mailSender.setPassword("eamsadmin"); mailSender.setPort(465);/*from w w w . j av a 2s . c o m*/ mailSender.setProtocol("smtp"); // Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); mailSender.getJavaMailProperties().put("mail.smtp.auth", "true"); mailSender.getJavaMailProperties().put("mail.smtp.port", new Integer(465)); mailSender.getJavaMailProperties().put("mail.smtp.starttls.enable", "true"); mailSender.getJavaMailProperties().put("mail.smtp.socketFactory.port", new Integer(465)); mailSender.getJavaMailProperties().put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); mailSender.getJavaMailProperties().put("mail.smtp.socketFactory.fallback", "false"); MailMessage mmc = new MailMessage("eams.demon@gmail.com", "", "???"); DefaultMailNotifier mailNotifier = new DefaultMailNotifier(); mailNotifier.setJavaMailSender(mailSender); mailNotifier.setFromMailbox("eams.demon@gmail.com"); mailNotifier.setFromName("name"); if (online) mailNotifier.sendMessage(mmc); }
From source file:org.openmrs.module.sync.SyncUtilTest.java
@Test public void getSetterMethod_shouldReturnMethodForPrimitiveInt() { Method m = SyncUtil.getSetterMethod(new Xform().getClass(), "intField", new Integer(1).getClass()); Assert.notNull(m);//from w ww .j a v a 2 s. c o m }
From source file:com.github.ipaas.ifw.util.IPUtil.java
/** * IP???//from www . ja v a2 s . c o m * * @param ip * @return */ public static long convertIpToInt(String ip) { // IP String[] ipArray = StringUtils.split(ip, '.'); // IP long ipInt = 0; // try { for (int i = 0; i < ipArray.length; i++) { if (ipArray[i] == null || ipArray[i].trim().equals("")) { ipArray[i] = "0"; } if (new Integer(ipArray[i].toString()).intValue() < 0) { Double j = new Double(Math.abs(new Integer(ipArray[i].toString()).intValue())); ipArray[i] = j.toString(); } if (new Integer(ipArray[i].toString()).intValue() > 255) { ipArray[i] = "255"; } } ipInt = new Double(ipArray[0]).longValue() * 256 * 256 * 256 + new Double(ipArray[1]).longValue() * 256 * 256 + new Double(ipArray[2]).longValue() * 256 + new Double(ipArray[3]).longValue(); // } catch (Exception e) { e.printStackTrace(); } return ipInt; }
From source file:com.mmone.gpdati.allotment.reader.AvailCrud.java
private static int modifyAllotment(XmlRpcClient client, java.util.Date dateStart, java.util.Date dateEnd, String action, int availability, int reservation, Integer invCode, Integer hotelCode) { Vector parameters = new Vector(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); parameters.add(new Integer(hotelCode)); //1 parameters.add(new Integer(invCode)); //2 //todo gestire con inventario unico -1 int rate = 1; ///fisso nr da verificare per iu parameters.add(new Integer(rate)); //3 offerta parameters.add(new Integer(availability)); //4 disponibilit parameters.add(new Integer(reservation)); //5 prenotazione parameters.add(action); //6 Azione : set,increase,decrease parameters.add(df.format(dateStart).toString()); //7 parameters.add(df.format(dateEnd).toString()); //8 Vector result = new Vector(); int ret = XRPC_SET_ALLOTMENT_RESULT_ERROR; String logData = "hotelCode=" + hotelCode + " - invCode=" + invCode + " - offerta=" + rate + " - availability=" + availability + " - reservation=" + reservation + " - action=" + action + " - dateStart=" + df.format(dateStart).toString() + " - dateEnd=" + df.format(dateEnd).toString() ;// ww w .ja v a 2 s . c om Logger.getLogger("AvailCrud").log(Level.INFO, logData); try { result = (Vector) client.execute("backend.modifyAllotment", parameters); } catch (Exception e) { Logger.getLogger("AvailCrud").log(Level.SEVERE, "", e); // addError(ResponseBuilder.EWT_UNKNOWN, ResponseBuilder.ERR_SYSTEM_ERROR, "Error on updating allotment (modifyAllotment)"); return ret; } try { Map hret = (Map) result.get(0); ret = new Integer((String) hret.get("unique_allotment_service_response")); } catch (Exception e) { } Map hret = (Map) result.get(0); ret = new Integer((String) hret.get("unique_allotment_service_response")); Logger.getLogger("AvailCrud").log(Level.INFO, "Xrpc done "); return ret; }
From source file:com.ixcode.framework.model.lookup.LookupContext.java
public Lookup getLookup(int id) { Integer key = new Integer(id); if (!_lookups.containsKey(key)) { throw new IllegalStateException("Could not find lookup for key '" + key + "' in lookup context"); }// w w w. ja va 2 s.c o m return (Lookup) _lookups.get(key); }