List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:tax.MainForm.java
private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { String text = afmTextS.getText(); if (text.length() == 9) { try { int num = Integer.parseInt(text); } catch (Exception e) { afmTextS.setText(""); return; }//from w w w .j a v a 2s.co m // Util.fadeInAndOut(afmTextS, Util.darkGreen); addNameBut.doClick(); } else { Util.fadeInAndOut(afmTextS, Util.darkOrange); } } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown() && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) { EventQueue.invokeLater(new Runnable() { @Override public void run() { String text = afmTextS.getText(); int afmLength = text.length(); while (lastAFMTextSLength == afmLength) { try { Thread.sleep(100); System.out.println("text: " + text); System.out.println(lastAFMTextSLength + " " + afmLength); return; } catch (InterruptedException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } text = afmTextS.getText(); afmLength = text.length(); } try { int num = Integer.decode(text); if (afmLength > 9) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } } catch (Exception e) { if (text.length() > 0) afmTextS.setText(text.substring(0, afmLength - 1)); else afmTextS.setText(""); return; } lastAFMTextSLength = afmLength; } }); } }
From source file:org.openhab.binding.dscalarm1.internal.DSCAlarmActiveBinding.java
/** * Handle Verbose Trouble Status events for the EyezOn Envisalink 3/2DS DSC Alarm Interface * * @param event//from w w w .j a v a 2 s . com */ private void verboseTroubleStatusHandler(EventObject event) { DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event; APIMessage apiMessage = dscAlarmEvent.getAPIMessage(); DSCAlarmItemType[] dscAlarmItemTypes = { DSCAlarmItemType.PANEL_SERVICE_REQUIRED, DSCAlarmItemType.PANEL_AC_TROUBLE, DSCAlarmItemType.PANEL_TELEPHONE_TROUBLE, DSCAlarmItemType.PANEL_FTC_TROUBLE, DSCAlarmItemType.PANEL_ZONE_FAULT, DSCAlarmItemType.PANEL_ZONE_TAMPER, DSCAlarmItemType.PANEL_ZONE_LOW_BATTERY, DSCAlarmItemType.PANEL_TIME_LOSS }; String itemName; int bitField = Integer.decode("0x" + apiMessage.getAPIData()); int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 }; int[] bits = new int[8]; for (int i = 0; i < 8; i++) { bits[i] = bitField & masks[i]; itemName = getItemName(dscAlarmItemTypes[i], 0, 0); if (StringUtils.isNotEmpty(itemName)) { updateItem(itemName, bits[i] != 0 ? 1 : 0, ""); } } }
From source file:org.openhab.binding.dscalarm.internal.DSCAlarmActiveBinding.java
/** * Handle Verbose Trouble Status events for the EyezOn Envisalink 3/2DS DSC Alarm Interface * /*from ww w. j av a2s . c o m*/ * @param event */ private void verboseTroubleStatusHandler(EventObject event) { DSCAlarmEvent dscAlarmEvent = (DSCAlarmEvent) event; APIMessage apiMessage = dscAlarmEvent.getAPIMessage(); DSCAlarmItemType[] dscAlarmItemTypes = { DSCAlarmItemType.PANEL_SERVICE_REQUIRED, DSCAlarmItemType.PANEL_AC_TROUBLE, DSCAlarmItemType.PANEL_TELEPHONE_TROUBLE, DSCAlarmItemType.PANEL_FTC_TROUBLE, DSCAlarmItemType.PANEL_ZONE_FAULT, DSCAlarmItemType.PANEL_ZONE_TAMPER, DSCAlarmItemType.PANEL_ZONE_LOW_BATTERY, DSCAlarmItemType.PANEL_TIME_LOSS }; String itemName; int bitField = Integer.decode("0x" + apiMessage.getAPIData()); int[] masks = { 1, 2, 4, 8, 16, 32, 64, 128 }; int[] bits = new int[8]; for (int i = 0; i < 8; i++) { bits[i] = bitField & masks[i]; itemName = getItemName(dscAlarmItemTypes[i], 0, 0); if (itemName != "") { updateDeviceProperties(itemName, bits[i] != 0 ? 1 : 0, ""); updateItem(itemName); } } }
From source file:org.rti.zcore.dar.struts.action.FormAction.java
/** * Check formId to see what is the next form to be served. * * @param request/*from ww w. jav a2 s.c o m*/ * @param mapping * @param patientId * @param eventUuid * @param dynaForm * @param session * @param formId * @param vo Useful when you need to pass the encounterId in the url parameters * @return the next page/form */ private ActionForward createForward(HttpServletRequest request, ActionMapping mapping, Long patientId, String eventUuid, DynaValidatorForm dynaForm, HttpSession session, int formId, EncounterData vo) { BaseSessionSubject sessionPatient = null; Principal user = request.getUserPrincipal(); String username = user.getName(); String formName = mapping.getParameter().trim(); Connection conn = null; Form nextForm = new Form(); Integer maxRows = 0; if (request.getParameter("maxRows") != null) { maxRows = Integer.decode(request.getParameter("maxRows")); } else if (request.getAttribute("maxRows") != null) { maxRows = Integer.decode(request.getAttribute("maxRows").toString()); } else { switch (formId) { case 128: maxRows = 0; break; case 129: maxRows = 0; break; case 130: maxRows = 0; break; case 131: maxRows = 0; break; case 181: maxRows = 0; break; default: maxRows = 20; break; } } try { conn = DatabaseUtils.getZEPRSConnection(username); try { sessionPatient = SessionUtil.getInstance(session).getSessionPatient(); } catch (SessionUtil.AttributeNotFoundException e) { //log.error("Unable to get TimsSessionSubject"); } Form form = (Form) DynaSiteObjects.getForms().get(Long.valueOf(formId)); Long formTypeId = form.getFormTypeId(); // part of reload prevention scheme: resetToken(request); dynaForm.reset(mapping, request); StrutsUtils.removeFormBean(mapping, request); ActionForward forwardForm = null; String forwardString = null; switch (formId) { case 1: // Patient Registration forwardString = "/ArtRegimen/new.do?patientId=" + patientId.toString(); break; case 137: // ART Regimen forwardString = "/PatientItem/new.do?patientId=" + patientId.toString(); break; case 132: // Dispensary //forwardString = "/patientTask.do?flowId=" + flowId.toString(); forwardString = "/Appointment/new.do?patientId=" + patientId.toString(); //forwardString = "/chart.do?patientId=" + patientId.toString() + "&formId=" + formId; break; /*case 136: forwardString = "/chart.do?patientId=" + patientId.toString() + "&formId=" + formId; break;*/ case 136: // PatientCondition forwardString = "/PatientCondition/new.do?patientId=" + patientId.toString(); break; case 179: // Appt if (Constants.APPOINTMENT_COUNT_THRESHOLD != null) { Appointment appt = (Appointment) vo; Date apptDate = appt.getAppointment_date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat( org.rti.zcore.Constants.DATE_FORMAT_SHORT); sdf.setTimeZone(TimeZone.getDefault()); String apptDateStr = sdf.format(appt.getAppointment_date().getTime()); ResultSet rs = null; Integer countAppts = 0; String warningMessage = ""; try { String sql = "SELECT COUNT(encounter.id) AS countAppts " + "FROM encounter, appointment " + "WHERE appointment.id=encounter.id " + "AND appointment_date = ? "; PreparedStatement ps = conn.prepareStatement(sql); ps.setDate(1, apptDate); rs = ps.executeQuery(); while (rs.next()) { countAppts = rs.getInt("countAppts"); } } catch (Exception ex) { log.error(ex); } Integer apptCountThreshold = Integer.valueOf(Constants.APPOINTMENT_COUNT_THRESHOLD); if (countAppts != null && countAppts > 0) { Integer warningThreshold = apptCountThreshold - 10; if ((countAppts >= warningThreshold) && (countAppts < apptCountThreshold)) { warningMessage = "Warning: Approaching Threshold of " + apptCountThreshold + " Appointments"; } else if (countAppts >= apptCountThreshold) { warningMessage = "Warning: Passed Threshold of " + apptCountThreshold + " Appointments."; } forwardString = "/Appointment/new.do?patientId=" + patientId.toString() + "&warningMessage=" + warningMessage + "&countAppts=" + countAppts + "&apptDate=" + apptDateStr; } else { forwardString = "/Appointment/new.do?patientId=" + patientId.toString() + "&countAppts=" + countAppts + "&apptDate=" + apptDateStr; } } else { forwardString = "/Appointment/new.do?patientId=" + patientId.toString(); } break; case 180: // Appt forwardString = "/PatientStatus_changes/new.do?patientId=" + patientId.toString(); break; default: switch (formTypeId.intValue()) { case 5: // admin forwardString = "/admin/records/list.do?formId=" + formId + "&maxRows=" + maxRows; break; case 7: // charts forwardString = "/chart.do?id=" + formId; break; case 8: // lists forwardString = "/recordList.do?formId=" + formId + "&patientId=" + patientId.toString(); break; default: if (sessionPatient != null) { Long flowId = sessionPatient.getCurrentFlowId(); forwardString = "/patientTask.do?flowId=" + flowId.toString(); } else { forwardString = "/home.do"; } break; } break; } forwardForm = new ActionForward(forwardString); forwardForm.setRedirect(true); return forwardForm; } catch (ServletException e) { log.error(e); } finally { try { if (conn != null && !conn.isClosed()) { conn.close(); } } catch (SQLException e) { log.error(e); } } return (new ActionForward(mapping.getInput())); }
From source file:com.l2jfree.gameserver.model.zone.L2Zone.java
private void parseSettings(Node n) throws Exception { Node pvp = n.getAttributes().getNamedItem("pvp"); Node noWyvern = n.getAttributes().getNamedItem("noWyvern"); Node landing = n.getAttributes().getNamedItem("landing"); Node noEscape = n.getAttributes().getNamedItem("noEscape"); Node noPrivateStore = n.getAttributes().getNamedItem("noPrivateStore"); Node noSummon = n.getAttributes().getNamedItem("noSummon"); // Forbids summon friend skills. Node boss = n.getAttributes().getNamedItem("boss"); Node affected = n.getAttributes().getNamedItem("affected"); Node buffRepeat = n.getAttributes().getNamedItem("buffRepeat"); Node abnorm = n.getAttributes().getNamedItem("abnormal"); Node exitOnDeath = n.getAttributes().getNamedItem("exitOnDeath"); Node hpDamage = n.getAttributes().getNamedItem("hpDamage"); Node mpDamage = n.getAttributes().getNamedItem("mpDamage"); Node noHeal = n.getAttributes().getNamedItem("noHeal"); Node uniqueId = n.getAttributes().getNamedItem("questZoneId"); _pvp = (pvp != null) ? PvpSettings.valueOf(pvp.getNodeValue().toUpperCase()) : PvpSettings.GENERAL; _noWyvern = (noWyvern != null) && Boolean.parseBoolean(noWyvern.getNodeValue()); _landing = (landing != null) && Boolean.parseBoolean(landing.getNodeValue()); _noEscape = (noEscape != null) && Boolean.parseBoolean(noEscape.getNodeValue()); _noPrivateStore = (noPrivateStore != null) && Boolean.parseBoolean(noPrivateStore.getNodeValue()); _noSummon = (noSummon != null) && Boolean.parseBoolean(noSummon.getNodeValue()); _boss = (boss != null) ? Boss.valueOf(boss.getNodeValue().toUpperCase()) : null; _affected = (affected != null) ? Affected.valueOf(affected.getNodeValue().toUpperCase()) : Affected.PLAYABLE;//w ww . j av a 2 s. c o m _buffRepeat = (buffRepeat != null) && Boolean.parseBoolean(buffRepeat.getNodeValue()); _abnormal = (abnorm != null) ? Integer.decode("0x" + abnorm.getNodeValue()) : 0; _exitOnDeath = (exitOnDeath != null) && Boolean.parseBoolean(exitOnDeath.getNodeValue()); _hpDamage = (hpDamage != null) ? Integer.parseInt(hpDamage.getNodeValue()) : 0; _mpDamage = (mpDamage != null) ? Integer.parseInt(mpDamage.getNodeValue()) : 0; _noHeal = (noHeal != null) && Boolean.parseBoolean(noHeal.getNodeValue()); _uniqueId = (uniqueId != null) ? Integer.parseInt(uniqueId.getNodeValue()) : 0; }
From source file:org.kchine.r.server.http.RHttpProxy.java
public static String logOnDB(String url, String sessionId, String login, String pwd, HashMap<String, Object> options) throws TunnelingException { if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) { mainHttpClient.getHostConfiguration().setProxy(System.getProperty("proxy_host"), Integer.decode(System.getProperty("proxy_port"))); }//from ww w .ja v a 2 s . co m GetMethod pingServer = null; try { Object result = null; try { pingServer = new GetMethod(url + "?method=ping"); mainHttpClient.executeMethod(pingServer); result = new ObjectInputStream(pingServer.getResponseBodyAsStream()).readObject(); if (!result.equals("pong")) throw new ConnectionFailedException(); } catch (Exception e) { e.printStackTrace(); throw new ConnectionFailedException(); } } finally { if (pingServer != null) { pingServer.releaseConnection(); } } GetMethod getSession = null; try { Object result = null; try { getSession = new GetMethod(url + "?method=logondb&login=" + PoolUtils.objectToHex(login) + "&pwd=" + PoolUtils.objectToHex(pwd) + "&options=" + PoolUtils.objectToHex(options)); getSession.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); if (sessionId != null && !sessionId.equals("")) { getSession.setRequestHeader("Cookie", "JSESSIONID=" + sessionId); } else { getSession.setRequestHeader("Cookie", "JSESSIONID=" + ""); } mainHttpClient.executeMethod(getSession); result = new ObjectInputStream(getSession.getResponseBodyAsStream()).readObject(); } catch (ConnectException e) { e.printStackTrace(); throw new ConnectionFailedException(); } catch (Exception e) { e.printStackTrace(); throw new TunnelingException("Client Side", e); } if (result != null && result instanceof TunnelingException) { throw (TunnelingException) result; } return (String) result; } finally { if (getSession != null) { getSession.releaseConnection(); } } }
From source file:com.eryansky.common.utils.DateUtil.java
public static String getJi(String strYue) { int intYue = Integer.decode(strYue).intValue(); if (intYue >= 1 && intYue <= 3) { return "1"; } else if (intYue >= 4 && intYue <= 6) { return "2"; } else if (intYue >= 7 && intYue <= 9) { return "3"; } else {/*from w w w. j a va 2 s . co m*/ return "4"; } }
From source file:com.neophob.sematrix.core.properties.ApplicationConfigurationHelper.java
/** * /*from www . j ava 2 s. com*/ * @return a set, so no duplicate entires are allowed */ public int[] getOutputMappingValues() { String rawConfig = config.getProperty(ConfigConstant.OUTPUT_MAPPING); if (rawConfig == null) { return new int[0]; } String[] tmp = rawConfig.split(","); if (tmp == null || tmp.length == 0) { return new int[0]; } int ofs = 0; int[] ret = new int[tmp.length]; for (String s : tmp) { try { ret[ofs] = Integer.decode(s.trim()); ofs++; } catch (Exception e) { LOG.log(Level.WARNING, FAILED_TO_PARSE, s); } } return ret; }
From source file:com.comcast.oscar.configurationfile.ConfigurationFileExport.java
/** * //from ww w .j a v a2s .c om * @param joTopLevelTLV * @param iIndentation * @return StringBuilder * @throws JSONException */ private StringBuilder topLevelTLVCodeBlock(JSONObject joTopLevelTLV, int iIndentation) throws JSONException { Boolean localDebug = Boolean.FALSE; StringBuilder sbTopLevelTLVCodeBlock = new StringBuilder(); StringBuilder sbIndentation = new StringBuilder(); if ((!this.boolVerboseExport) && (!(joTopLevelTLV.has(Dictionary.VALUE)))) { return sbTopLevelTLVCodeBlock; } for (int iNumIndent = 1; iNumIndent < iIndentation; iNumIndent++) sbIndentation.append('\t'); //If the Value contain a JSON Array, it can only be a OID if ((joTopLevelTLV.has(Dictionary.VALUE)) && (JSONTools.containJSONArray(joTopLevelTLV, Dictionary.VALUE))) { JSONArray jaTopLevelTLVOID = joTopLevelTLV.getJSONArray(Dictionary.VALUE); jaTopLevelTLVOID.getJSONObject(0).getString("OID"); //Check to see if this is a 2 byte VarBind, if so convert from ASCII to HexSting if (joTopLevelTLV.getInt(Dictionary.BYTE_LENGTH) < 2) { sbTopLevelTLVCodeBlock.append('\t').append(joTopLevelTLV.get(Dictionary.TLV_NAME)).append(' ') .append(NetSNMP.toOIDFormat(jaTopLevelTLVOID.getJSONObject(0).getString("OID"), boolDottextOutputFormat)) .append(' ') .append(BER_DATA_TYPE .get(Integer.decode(jaTopLevelTLVOID.getJSONObject(0).getString("DATA_TYPE")))) .append(" \"").append(jaTopLevelTLVOID.getJSONObject(0).getString("VALUE")).append("\";") .append("\t /* TLV: ").append(joTopLevelTLV.get(Dictionary.PARENT_TYPE_LIST).toString() .replace("-1,", "").replaceAll(",", ".")) .append("*/\n"); } else { sbTopLevelTLVCodeBlock.append('\t').append(joTopLevelTLV.get(Dictionary.TLV_NAME)).append(' ') .append(NetSNMP.toOIDFormat(jaTopLevelTLVOID.getJSONObject(0).getString("OID"), boolDottextOutputFormat)) .append(' ') .append(BER_DATA_TYPE .get(Integer.decode(jaTopLevelTLVOID.getJSONObject(0).getString("DATA_TYPE")))) .append(" \"") .append(HexString.asciiToHex(jaTopLevelTLVOID.getJSONObject(0).getString("VALUE"), ":")) .append("\";").append("\t /* TLV: ").append(joTopLevelTLV.get(Dictionary.PARENT_TYPE_LIST) .toString().replace("-1,", "").replaceAll(",", ".")) .append("*/\n"); } if (debug | localDebug) System.out.println("topLevelTLVCodeBlock(jo,i): " + sbTopLevelTLVCodeBlock); //Top Level TLV Only } else { if (joTopLevelTLV.has(Dictionary.VALUE)) { sbTopLevelTLVCodeBlock.append('\t').append(joTopLevelTLV.get(Dictionary.TLV_NAME)).append(' ') .append(joTopLevelTLV.get(Dictionary.VALUE)).append(';').append("\t /* TLV: ") .append(joTopLevelTLV.get(Dictionary.PARENT_TYPE_LIST).toString().replace("-1,", "") .replaceAll(",", ".")) .append("*/\n"); } else { if ((joTopLevelTLV.get(Dictionary.TLV_NAME).equals("Snmp11")) || (joTopLevelTLV.get(Dictionary.TLV_NAME).equals("Snmp64"))) { if (debug) { System.out.println( "++++++++++++++++++++++Ignoring Snmp11 || Snmp64 +++++++++++++++++++++++++++++++++++++"); } return sbTopLevelTLVCodeBlock; } sbTopLevelTLVCodeBlock.append('\t').append(joTopLevelTLV.get(Dictionary.TLV_NAME)).append(' ') .append(';').append("\t /* TLV: ").append(joTopLevelTLV.get(Dictionary.PARENT_TYPE_LIST) .toString().replace("-1,", "").replaceAll(",", ".")) .append("*/\n"); } if (debug | localDebug) System.out.println("topLevelTLVCodeBlock(jo,i): " + sbTopLevelTLVCodeBlock); } return sbTopLevelTLVCodeBlock; }
From source file:org.apache.ofbiz.accounting.thirdparty.verisign.PayflowPro.java
private static PayflowAPI init(Delegator delegator, String paymentGatewayConfigId, String resource, Map<String, ? extends Object> context) { // No more used // String certsPath = FlexibleStringExpander.expandString(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "certsPath", resource, "payment.verisign.certsPath", "pfcerts"), context); String hostAddress = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "hostAddress", resource, "payment.verisign.hostAddress", "pilot-payflowpro.paypal.com"); Integer hostPort = Integer.decode(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "hostPort", resource, "payment.verisign.hostPort", "443")); Integer timeout = Integer.decode(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "timeout", resource, "payment.verisign.timeout", "80")); String proxyAddress = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "proxyAddress", resource, "payment.verisign.proxyAddress", ""); Integer proxyPort = Integer.decode(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "proxyPort", resource, "payment.verisign.proxyPort", "80")); String proxyLogon = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "proxyLogon", resource, "payment.verisign.proxyLogon", ""); String proxyPassword = getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "proxyPassword", resource, "payment.verisign.proxyPassword", ""); String logFileName = FlexibleStringExpander.expandString(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "logFileName", resource, "payment.verisign.logFileName", ""), context); Integer loggingLevel = Integer.decode(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "loggingLevel", resource, "payment.verisign.loggingLevel", "6")); Integer maxLogFileSize = Integer.decode(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "maxLogFileSize", resource, "payment.verisign.maxLogFileSize", "1000000")); boolean stackTraceOn = "Y".equalsIgnoreCase(getPaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "stackTraceOn", resource, "payment.verisign.stackTraceOn", "N")); PayflowAPI pfp = new PayflowAPI(hostAddress, hostPort.intValue(), timeout.intValue(), proxyAddress, proxyPort.intValue(), proxyLogon, proxyPassword); SDKProperties.setLogFileName(logFileName); SDKProperties.setLoggingLevel(loggingLevel); SDKProperties.setMaxLogFileSize(maxLogFileSize); SDKProperties.setStackTraceOn(stackTraceOn); return pfp;//from www .j a v a2 s . co m }