List of usage examples for org.apache.commons.lang NumberUtils isNumber
public static boolean isNumber(String str)
Checks whether the String a valid Java number.
Valid numbers include hexadecimal marked with the 0x
qualifier, scientific notation and numbers marked with a type qualifier (e.g.
From source file:bankingclient.TaoTaiKhoanFrame.java
public TaoTaiKhoanFrame(NewOrOldAccFrame acc) { initComponents();/*from w w w . jav a2 s .c o m*/ this.jText_ten_tk.setText(""); this.jText_sd.setText(""); this.noAcc = acc; this.mainCustomerName = null; this.setVisible(false); jBt_ht.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (NumberUtils.isNumber(jText_sd.getText()) && (Long.parseLong(jText_sd.getText()) > 0)) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(3); dout.writeUTF(jText_ten_tk.getText() + "\n" + mainCustomerName + "\n" + jText_sd.getText()); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); byte check = din.readByte(); if (check == 1) { JOptionPane.showMessageDialog(rootPane, "da tao tai khoan thanh cong"); } else { JOptionPane.showMessageDialog(rootPane, "tao tai khoan khong thanh cong"); } client.close(); } catch (Exception ex) { ex.printStackTrace(); } noAcc.setVisible(true); TaoTaiKhoanFrame.this.setVisible(false); } else { JOptionPane.showMessageDialog(rootPane, "Can nhap lai so tien gui"); } } }); jBt_ql.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { noAcc.setVisible(true); TaoTaiKhoanFrame.this.setVisible(false); } }); }
From source file:com.hangum.tadpole.commons.libs.core.utils.ValidChecker.java
/** * number checker util/* ww w . j ava 2s. c om*/ * * @param text * @param msg * @return */ public static boolean checkNumberCtl(Text text, String msg) { if (!NumberUtils.isNumber(text.getText())) { MessageDialog.openWarning(null, Messages.get().Warning, msg + Messages.get().CheckNumberString); text.setFocus(); return false; } return true; }
From source file:bankingclient.DKFrame.java
public DKFrame(MainFrame vmain) { initComponents();/*from ww w .ja v a2 s .c o m*/ this.main = vmain; this.jTextField1.setText(""); this.jTextField2.setText(""); this.jTextField3.setText(""); this.jTextField4.setText(""); this.jTextField5.setText(""); this.setVisible(false); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (jTextField2.getText().equals(jTextField3.getText()) && NumberUtils.isNumber(jTextField4.getText()) && NumberUtils.isNumber(jTextField5.getText())) { try { Socket client = new Socket("113.22.46.207", 6013); String cusName = jTextField1.getText(); String pass = jTextField2.getText(); String sdt = jTextField4.getText(); String cmt = jTextField5.getText(); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(1); dout.writeUTF(cusName + "\n" + pass + "\n" + sdt + "\n" + cmt); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); byte check = din.readByte(); if (check == 1) { JOptionPane.showMessageDialog(rootPane, "da dang ki tai khoan thanh cong"); } else { JOptionPane.showMessageDialog(rootPane, "dang ki tai khoan khong thanh cong"); } client.close(); } catch (Exception ee) { ee.printStackTrace(); } main.setVisible(true); DKFrame.this.setVisible(false); } else { JOptionPane.showMessageDialog(rootPane, "Nhap thong tin sai, moi nhap lai"); } } }); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { main.setVisible(true); DKFrame.this.setVisible(false); } }); }
From source file:massbank.extend.ChemicalFormulaUtils.java
/** * qfL??/* w w w . ja v a 2 s . co m*/ */ public static Map<String, Integer> getAtomList(String formula) { Map<String, Integer> atomList = new HashMap(); int startPos = 0; int endPos = formula.length(); int i = 0; for (int pos = 1; pos <= endPos; pos++) { String chr = ""; if (pos < endPos) { chr = formula.substring(pos, pos + 1); } if (pos == endPos || (!NumberUtils.isNumber(chr) && chr.equals(chr.toUpperCase()))) { // fL? + ???o String item = formula.substring(startPos, pos); // fL?? boolean isFound = false; for (i = 1; i < item.length(); i++) { chr = item.substring(i, i + 1); if (NumberUtils.isNumber(chr)) { isFound = true; break; } } String atom = item.substring(0, i); int num = 1; if (isFound) { num = Integer.parseInt(item.substring(i)); } // f?? if (atomList.get(atom) != null) { num = num + atomList.get(atom); } // li[ atomList.put(atom, num); startPos = pos; } } return atomList; }
From source file:bankingclient.ChonThaoTacFrame.java
public ChonThaoTacFrame(NewOrOldAccFrame acc) { initComponents();/*from ww w .ja va2 s .com*/ jTextField1.setText(""); jLabel4.setVisible(false); jComboBox2.setVisible(false); jLabel2.setVisible(false); jLabel3.setVisible(false); jTextField1.setVisible(false); jBt_xn1.setVisible(false); jBt_xn2.setVisible(false); this.accList = null; this.cusList = null; this.noAcc = acc; this.tt = new Thong_Tin_TK(this); this.setVisible(false); jBt_xn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (NumberUtils.isNumber(jTextField1.getText()) && (Long.parseLong(jTextField1.getText()) > 0)) { long currentMoney = 0; try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(8); dout.writeUTF((String) jComboBox1.getSelectedItem()); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); Scanner lineScanner = new Scanner(din.readUTF()); currentMoney = Long.parseLong(lineScanner.nextLine()); System.out.println(currentMoney); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "Li kt ni mng,bn cn kim tra kt ni"); } if (jCheck_gt.isSelected()) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(5); dout.writeUTF((String) jComboBox1.getSelectedItem() + "\n" + jTextField1.getText() + "\n" + (noAcc.getCustomer())); dout.flush(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Xy ra...."); } JOptionPane.showMessageDialog(rootPane, "Gi Ti?n Thnh Cng..."); } if (jCheck_rt.isSelected()) { if ((Long.parseLong(jTextField1.getText()) <= currentMoney)) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(6); dout.writeUTF((String) jComboBox1.getSelectedItem() + "\n" + jTextField1.getText() + "\n" + (noAcc.getCustomer())); dout.flush(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Xy Ra....."); } JOptionPane.showMessageDialog(rootPane, "Rt Ti?n Thnh Cng ..."); } else { System.out.println("Khng Ti?n Trong ti khon.." + currentMoney); JOptionPane.showMessageDialog(null, "Ti Khon Khng ? ? Rt ..."); } } noAcc.setVisible(true); ChonThaoTacFrame.this.setVisible(false); } else { JOptionPane.showMessageDialog(rootPane, "Cn Nhp Li S Ti?n Cn Gi Hoc Rt.."); } } }); jBt_tt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tt.setTk((String) jComboBox1.getSelectedItem()); tt.hienTenTk(); long currentMoney = 0; try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(8); dout.writeUTF((String) jComboBox1.getSelectedItem()); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); Scanner lineScanner = new Scanner(din.readUTF()); currentMoney = Long.parseLong(lineScanner.nextLine()); // System.out.println(currentMoney); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "Li kt ni mng,bn cn kim tra kt ni"); } tt.hienSoDu(((Long) currentMoney).toString()); tt.setVisible(true); try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(10); dout.writeUTF((String) jComboBox1.getSelectedItem()); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); Scanner cusScanner = new Scanner(din.readUTF()); while (cusScanner.hasNextLine()) { tt.addCus(cusScanner.nextLine()); } } catch (Exception ee) { ee.printStackTrace(); } tt.hienChuTaiKhoan(); try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(12); dout.writeUTF((String) jComboBox1.getSelectedItem()); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); Scanner dateScanner = new Scanner(din.readUTF()); int day = Integer.parseInt(dateScanner.nextLine()); int month = Integer.parseInt(dateScanner.nextLine()); int year = Integer.parseInt(dateScanner.nextLine()); String date = (day + "-" + month + "-" + year); tt.hienNgayLapTaiKhoan(date); while (dateScanner.hasNextLine()) { // System.out.println("aaa"); tt.addGiaoDich(dateScanner.nextLine()); } tt.hienGiaoDich(); } catch (Exception ex) { ex.printStackTrace(); } ChonThaoTacFrame.this.setVisible(false); } }); jBt_xn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (jCheck_tctk.isSelected()) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(7); dout.writeUTF((String) jComboBox1.getSelectedItem() + "\n" + (String) jComboBox2.getSelectedItem()); dout.flush(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Xy Ra\n Thm Ch Tht Bi..."); } JOptionPane.showMessageDialog(rootPane, "Thm Ch Ti Khon Thnh Cng.."); } else { System.out.println("nothing to do..."); } } }); jBt_xtk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(11); String sent = (String) (jComboBox1.getSelectedItem()) + "\n" + noAcc.getCustomer(); dout.writeUTF(sent); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); byte check = din.readByte(); if (check == 1) { JOptionPane.showMessageDialog(rootPane, "xoa tai khoan thanh cong"); } else { JOptionPane.showMessageDialog(rootPane, "<html>xoa tai khoan <b>khong</b> thanh cong <br> chi chu chinh moi co the xoa tai khoan</html>"); } } catch (Exception ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "Li Kt Ni ,Vui Lng Kim Tra Li.."); } } }); /*dont touch*/ jBt_ql.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { noAcc.setVisible(true); ChonThaoTacFrame.this.setVisible(false); } }); /*dont touch*/ jComboBox1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); jComboBox2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); /*dont touch jcheckbox*/ jCheck_tctk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (jCheck_tctk.isSelected()) { jLabel4.setVisible(true); jComboBox2.setVisible(true); jBt_xn2.setVisible(true); } else { jLabel4.setVisible(false); jComboBox2.setVisible(false); jBt_xn2.setVisible(false); } } }); jCheck_gt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (jCheck_gt.isSelected()) { if (jCheck_rt.isSelected()) { jCheck_rt.setSelected(false); } jLabel2.setVisible(true); jLabel3.setVisible(true); jTextField1.setVisible(true); jBt_xn1.setVisible(true); } else { jLabel2.setVisible(false); jLabel3.setVisible(false); jTextField1.setVisible(false); jBt_xn1.setVisible(false); } } }); jCheck_rt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (jCheck_rt.isSelected()) { if (jCheck_gt.isSelected()) { jCheck_gt.setSelected(false); } jLabel2.setVisible(true); jLabel3.setVisible(true); jTextField1.setVisible(true); jBt_xn1.setVisible(true); } else { jLabel2.setVisible(false); jLabel3.setVisible(false); jTextField1.setVisible(false); jBt_xn1.setVisible(false); } } }); /*dont touch jcheckbox*/ }
From source file:ijfx.ui.explorer.view.GroupExplorable.java
public boolean checkNumber(String metaData) { if (!NumberUtils.isNumber(SortExplorableUtils.getValueMetaData(listItems.get(0), metaData))) { return true; } else {/*from ww w . ja v a 2s .c om*/ List<Explorable> filtered = filterExplorable(listItems, metaData); SortExplorableUtils.sort(metaData, filtered); return SortExplorableUtils.findLimits(metaData, filtered).size() <= 25; } }
From source file:bankingclient.DNFrame.java
public DNFrame(MainFrame vmain) { initComponents();// w w w . ja v a 2 s . co m this.jTextField1.setText(""); this.jTextField2.setText(""); this.jTextField_cmt.setText(""); this.jTextField_sdt.setText(""); this.main = vmain; noAcc = new NewOrOldAccFrame(this); this.setVisible(false); jL_sdt.setVisible(false); jL_cmtnd.setVisible(false); jTextField_cmt.setVisible(false); jTextField_sdt.setVisible(false); jBt_dn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!jCheck_qmk.isSelected()) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(2); dout.writeUTF(jTextField1.getText() + "\n" + jTextField2.getText()); dout.flush(); while (true) { break; } DataInputStream din = new DataInputStream(client.getInputStream()); byte check = din.readByte(); if (check == 1) { noAcc.setVisible(true); DNFrame.this.setVisible(false); noAcc.setMainCustomer(jTextField1.getText()); } else { JOptionPane.showMessageDialog(new JFrame(), "Tn ?ang Nhp Khng Tn Ti, hoac mat khau sai"); } } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(rootPane, "C Li Kt Ni Mng...."); } } else if ((!jTextField_cmt.getText().equals("")) && (!jTextField_sdt.getText().equals("")) && (NumberUtils.isNumber(jTextField_cmt.getText())) && (NumberUtils.isNumber(jTextField_sdt.getText()))) { try { Socket client = new Socket("113.22.46.207", 6013); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(9); dout.writeUTF(jTextField1.getText() + "\n" + jTextField_sdt.getText() + "\n" + jTextField_cmt.getText()); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); byte check = din.readByte(); if (check == 1) { noAcc.setVisible(true); DNFrame.this.setVisible(false); noAcc.setMainCustomer(jTextField1.getText()); } else { JOptionPane.showMessageDialog(new JFrame(), "Khong dang nhap duoc, thong tin sai"); } } catch (Exception ex) { ex.printStackTrace(); } } else { JOptionPane.showMessageDialog(new JFrame(), "Can dien day du thong tin va dung mau"); } } }); jBt_ql.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { main.setVisible(true); DNFrame.this.setVisible(false); } }); jCheck_qmk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jCheck_qmk.isSelected()) { jL_sdt.setVisible(true); jL_cmtnd.setVisible(true); jTextField_cmt.setVisible(true); jTextField_sdt.setVisible(true); } else { jL_sdt.setVisible(false); jL_cmtnd.setVisible(false); jTextField_cmt.setVisible(false); jTextField_sdt.setVisible(false); } } }); }
From source file:massbank.api.ApiParameter.java
/** * searchSpectrum ?\bhp??[^`FbN/* ww w .j ava 2 s. c o m*/ */ private void checkSearchSpectrum() { //--------------------------------------- // tolerance //--------------------------------------- String unit = (String) mapParam.get("unit"); String tolerance = (String) mapParam.get("tolerance"); if (unit.toLowerCase().equals("unit") || unit.equals("")) { param += "&TOLUNIT=unit"; if (tolerance.equals("")) { param += "&TOLERANCE=0.3"; } else { param += "&TOLERANCE=" + tolerance; } } else if (unit.toLowerCase().equals("ppm")) { param += "&TOLUNIT=ppm"; if (tolerance.equals("")) { param += "&TOLERANCE=50"; } else { param += "&TOLERANCE=" + tolerance; } } else { // "unit", "ppm" OG?[ errDetails.add("unit=" + unit); } // ?l`FbN if (!tolerance.equals("") && !NumberUtils.isNumber(tolerance)) { errDetails.add("tolerance=" + tolerance); } //--------------------------------------- // cutoff //--------------------------------------- String cutoff = (String) mapParam.get("cutoff"); if (cutoff.equals("")) { cutoff = "50"; } else if (NumberUtils.isNumber(cutoff)) { int val = Integer.parseInt(cutoff); if (val < 0 || val > 999) { errDetails.add("cutoff=" + cutoff); } } else { errDetails.add("cutoff=" + cutoff); } param += "&CUTOFF=" + cutoff; //--------------------------------------- // m/z, intensity //--------------------------------------- String[] mzs = (String[]) mapParam.get("mzs"); String[] intensities = (String[]) mapParam.get("intensities"); // mzsintensities?`FbN if (mzs.length != intensities.length) { errDetails.add("number of \"mzs\" NOT EQUAL number of \"intensities\""); } else { // ?->x Double maxInte = 0.0; for (int i = 0; i < intensities.length; i++) { Double inte = Double.parseDouble(intensities[i]); if (inte > maxInte) { maxInte = inte; } } String[] relIntensities = new String[intensities.length]; for (int i = 0; i < intensities.length; i++) { if (maxInte != 999) { Double inte = Double.parseDouble(intensities[i]); Double dblRelInte = inte / maxInte * 999 + 0.5; relIntensities[i] = String.valueOf(dblRelInte.intValue()); } else { relIntensities[i] = String.valueOf(intensities[i]); } } String peak = ""; for (int i = 0; i < mzs.length; i++) { peak += mzs[i] + "," + relIntensities[i] + "@"; } param += "&VAL=" + peak; } }
From source file:com.redsqirl.SshBean.java
/** confirmNewSsh * //from w w w.j a v a 2 s .co m * Method to execute the connection * * @return * @author Igor.Souza * @throws Exception */ public void confirmNewSsh() { try { String error = null; logger.info("confirmNewSsh"); Map<String, String> values = new HashMap<String, String>(); if (getHost() != null && !"".equals(getHost())) { values.put("host name", getHost()); } else { error = "Error trying to add store with empty Host Name"; } if (error == null && getPort() != null && !"".equals(getPort())) { if (NumberUtils.isNumber(getPort())) { values.put("port", getPort()); } else { error = "Error trying to add store with wrong Port number"; } } if (error == null && getPassword() != null && !"".equals(getPassword())) { values.put("password", getPassword()); setSelectedSaveSsh(false); try { dsa.addStore(values); } catch (Exception e) { error = "Error trying to add store with Password " + e.getMessage(); logger.error(error); } } else { if (error == null) { if (isSelectedSaveSsh()) { error = dsa.addKnownStore(values); } else { try { dsa.addStore(values); } catch (Exception e) { error = "Error trying to add store " + e.getMessage(); logger.error(error); } } } } setSelectedpassword(false); if (error == null) { error = dsa.initKnownStores(); tabs = new ArrayList<String>(); mapPaths = new HashMap<String, String>(); for (Entry<String, DataStore> e : dsa.getStores().entrySet()) { tabs.add(e.getKey()); mapPaths.put(e.getKey(), e.getValue().getPath()); } setSelectedTab(tabs.get(0)); setDataStore(dsa.getStores().get(selectedTab)); setPath(dsa.getStores().get(selectedTab).getPath()); mountTable(); } else { for (Map<String, String> map : dsa.getKnownStoreDetails()) { if (map.get("host name").equals(getHost())) { dsa.removeKnownStore(map); } } dsa.removeStore(getHost()); } if (error != null) { MessageUseful.addErrorMessage(error); HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance() .getExternalContext().getRequest(); request.setAttribute("msnError", "msnError"); usageRecordLog().addError("ERROR NEWSSH", error); } usageRecordLog().addSuccess("NEWSSH"); } catch (Exception e) { logger.error(e, e); } }
From source file:massbank.QueryFileUtil.java
/** * NG?Xg/*from w w w .j ava2s.c o m*/ */ private void addList(String name, String peak) { DecimalFormat df = new DecimalFormat("000000"); int no = this.nameList.size() + 1; if (name.equals("")) { name = "Compound_" + df.format(no); } this.nameList.add(name); String[] items = peak.split(";"); int num = items.length; String[] mzs = new String[num]; String[] intes = new String[num]; for (int i = 0; i < items.length; i++) { String pair = items[i].trim(); pair = pair.replaceAll(" +", ","); pair = pair.replaceAll("\t+", ","); String[] vals = pair.split(","); if (vals.length < 2 || !NumberUtils.isNumber(vals[0]) || !NumberUtils.isNumber(vals[1])) { mzs[i] = ("-1"); intes[i] = ("-1"); } else { mzs[i] = vals[0]; intes[i] = vals[1]; } } mzList.add(mzs); intensityList.add(intes); }