List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:com.alibaba.dubbo.governance.web.common.module.screen.Restful.java
private static Object convertPrimitive(Class<?> cls, String value) { if (cls == boolean.class || cls == Boolean.class) { return value == null || value.length() == 0 ? false : Boolean.valueOf(value); } else if (cls == byte.class || cls == Byte.class) { return value == null || value.length() == 0 ? 0 : Byte.valueOf(value); } else if (cls == char.class || cls == Character.class) { return value == null || value.length() == 0 ? '\0' : value.charAt(0); } else if (cls == short.class || cls == Short.class) { return value == null || value.length() == 0 ? 0 : Short.valueOf(value); } else if (cls == int.class || cls == Integer.class) { return value == null || value.length() == 0 ? 0 : Integer.valueOf(value); } else if (cls == long.class || cls == Long.class) { return value == null || value.length() == 0 ? 0 : Long.valueOf(value); } else if (cls == float.class || cls == Float.class) { return value == null || value.length() == 0 ? 0 : Float.valueOf(value); } else if (cls == double.class || cls == Double.class) { return value == null || value.length() == 0 ? 0 : Double.valueOf(value); }// w ww. j a v a2 s.c o m return value; }
From source file:com.floreantpos.actions.ClockInOutAction.java
public void performDriverOut(User user) { try {//from w w w. j a v a 2s . c o m if (user == null) { return; } Shift currentShift = ShiftUtil.getCurrentShift(); Terminal terminal = Application.getInstance().getTerminal(); Calendar currentTime = Calendar.getInstance(); user.setAvailableForDelivery(false); user.setLastClockOutTime(currentTime.getTime()); LogFactory.getLog(Application.class).info("terminal id befor saving clockIn=" + terminal.getId()); //$NON-NLS-1$ EmployeeInOutHistory attendenceHistory = new EmployeeInOutHistory(); attendenceHistory.setOutTime(currentTime.getTime()); attendenceHistory.setOutHour(Short.valueOf((short) currentTime.get(Calendar.HOUR_OF_DAY))); attendenceHistory.setClockOut(true); attendenceHistory.setUser(user); attendenceHistory.setTerminal(terminal); attendenceHistory.setShift(currentShift); UserDAO.getInstance().saveDriverOut(user, attendenceHistory, currentShift, currentTime); POSMessageDialog.showMessage( "Driver " + user.getFirstName() + " " + user.getLastName() + " is out for delivery."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } catch (Exception e) { POSMessageDialog.showError(Application.getPosWindow(), e.getMessage(), e); } }
From source file:cn.hanbell.erp.ejb.PurvdrBean.java
@Override public Boolean initByOAPSN(String psn) { details.put(purvdrBuyerBean, purvdrBuyerList); details.put(miscodeBean, miscodeAdded); details.put(invwhBean, invwhAdded);/* w ww.ja va 2 s .com*/ details.put(invwhclkBean, invwhclkAdded); HKCG016 oa = beanHKCG016.findByPSN(psn); if (oa == null) { throw new NullPointerException(); } Purvdr erp = new Purvdr(); String facno, code, newvdrno; switch (oa.getFacno()) { //SHB?SHB case "C": case "G": case "J": case "N": case "C4": facno = "C"; code = "S"; break; default: facno = oa.getFacno(); code = facno; } //???? setCompany(facno); Purvdr e = this.findByVdrds(oa.getVdrds()); if (e != null) { oa.setVdrno(e.getVdrno()); beanHKCG016.update(oa); return true; } Miscode m; this.miscodeBean.setCompany(facno); //m = miscodeBean.findByCdesc(oa.getTtbankna()); m = miscodeBean.findByCkindAndCdesc("NB", oa.getTtbankna()); if (m == null) { m = new Miscode("NB", miscodeBean.getFormId("NB", "B", 4)); m.setCdesc(oa.getTtbankna()); m.setStatus('Y'); m.setMascreyn('N'); m.setCusds(oa.getTtbankna()); miscodeBean.persist(m); } erp.setVdrna(oa.getVdrna()); if (oa.getVdrsta() != null && !oa.getVdrsta().equals("")) { erp.setVdrsta(oa.getVdrsta().charAt(0)); } erp.setVdrds(oa.getVdrds()); erp.setVdrdse(oa.getVdrdse()); erp.setAddress(oa.getAddress()); if (oa.getDecode() != null && !oa.getDecode().equals("")) { erp.setDecode(oa.getDecode().charAt(0)); } erp.setZonenum(oa.getZonenum()); erp.setCoin(oa.getCoin()); erp.setTax(oa.getTax()); if (oa.getTaxrate() != null && !oa.getTaxrate().equals("")) { erp.setTaxrate(BigDecimal.valueOf(Double.parseDouble(oa.getTaxrate()))); } erp.setUniform(oa.getUniform()); erp.setPurkind(oa.getPurkind()); erp.setTermcode(oa.getTermcode()); erp.setAreacode(oa.getAreacode()); if (oa.getPaycom() != null && !oa.getPaycom().equals("")) { erp.setPaycom(oa.getPaycom().charAt(0)); } erp.setCuycode(oa.getCuycode()); if (oa.getPaycode() != null && !oa.getPaycode().equals("")) { erp.setPaycode(oa.getPaycode().charAt(0)); } if (oa.getTickdays() != null && !oa.getTickdays().equals("")) { erp.setTickdays(Short.valueOf(oa.getTickdays())); } erp.setBoss(oa.getBoss()); erp.setMark1(oa.getMark1()); erp.setSndcode(oa.getSndcode()); erp.setContactman(oa.getContactman()); erp.setTtbankno(m.getMiscodePK().getCode()); erp.setTtbankna(oa.getTtbankna()); erp.setTtbanknum(oa.getTtbanknum()); erp.setTtname(oa.getTtname()); if (oa.getYeramt() != null && !oa.getYeramt().equals("")) { erp.setYeramt(BigDecimal.valueOf(Double.parseDouble(oa.getYeramt()))); } if (oa.getCapamt() != null && !oa.getCapamt().equals("")) { erp.setCapamt(BigDecimal.valueOf(Double.parseDouble(oa.getCapamt()))); } erp.setTel1(oa.getTel1()); erp.setTel2(oa.getTel2()); erp.setWebsite(oa.getWebsite()); if (oa.getAbccode() != null && !oa.getAbccode().equals("")) { erp.setAbccode(oa.getAbccode().charAt(0)); } erp.setFax1(oa.getFax1()); erp.setFax2(oa.getFax2()); erp.setBegdate(oa.getBegdate()); erp.setLatdate(oa.getLatdate()); erp.setTitle(oa.getTitle()); erp.setFkfs(oa.getFktype()); erp.setPaysepcode('1'); erp.setHandays1((short) 30); //?? newvdrno = getFormId(BaseLib.getDate(), code + erp.getCuycode(), null, 5, "purvdr", "vdrno"); erp.setVdrno(newvdrno); //? PurvdrBuyer b = new PurvdrBuyer(facno, "1", newvdrno); b.setBuyer(oa.getUserno()); //? if ("Y".equals(oa.getIsvdrwareh())) { Invwh w = new Invwh(); w.setFacno(facno); w.setProno("1"); w.setWareh("JT" + newvdrno); if (erp.getVdrna().length() < 3) { w.setWhdsc("-" + erp.getVdrna()); } else { //????? if (erp.getVdrna().length() <= 4) { w.setWhdsc("-" + erp.getVdrna().substring(2)); } else if (erp.getVdrna().length() > 4) { w.setWhdsc("-" + erp.getVdrna().substring(2, 4)); } } w.setMrpco('N'); w.setCostyn('Y'); w.setWclerk(oa.getJtwareher()); w.setIndate(BaseLib.getDate()); w.setUserno("mis"); invwhAdded.add(w); //? Invwhclk u = new Invwhclk(w.getFacno(), w.getProno(), w.getWareh(), w.getWclerk()); u.setMainyn('Y'); u.setIndate(BaseLib.getDate()); u.setUserno("mis"); invwhclkAdded.add(u); } //?MISCODE Miscode c = new Miscode("PJ", newvdrno); c.setCdesc(erp.getVdrna()); c.setStatus('Y'); c.setMascreyn('Y'); c.setCusds(erp.getVdrds()); purvdrBuyerList.add(b); miscodeAdded.add(c); try { persist(erp, details); getEntityManager().flush(); oa.setVdrno(newvdrno); beanHKCG016.update(oa); switch (oa.getFacno()) { case "G": //?ERP resetFacno("G"); syncGZBean.persist(erp, details); syncGZBean.getEntityManager().flush(); break; case "J": //??ERP resetFacno("J"); syncJNBean.persist(erp, details); syncJNBean.getEntityManager().flush(); break; case "N": //??ERP resetFacno("N"); syncNJBean.persist(erp, details); syncNJBean.getEntityManager().flush(); break; case "C4": //??ERP resetFacno("C4"); syncCQBean.persist(erp, details); syncCQBean.getEntityManager().flush(); break; default: } return true; } catch (Exception ex) { Logger.getLogger(PurvdrBean.class.getName()).log(Level.SEVERE, null, ex); return false; } finally { resetObjects(); } }
From source file:ca.sqlpower.dao.json.SPJSONMessageDecoder.java
public static Object getWithType(@Nonnull JSONObject jo, DataType type, String propName) throws JSONException { if (getNullable(jo, propName) == null) return null; switch (type) { case BOOLEAN: return Boolean.valueOf(jo.getBoolean(propName)); case DOUBLE:/*from www. j av a 2 s. c om*/ return Double.valueOf(jo.getDouble(propName)); case INTEGER: return Integer.valueOf(jo.getInt(propName)); case LONG: return Long.valueOf(jo.getLong(propName)); case SHORT: return Short.valueOf(jo.getShort(propName)); case FLOAT: return Float.valueOf(jo.getFloat(propName)); case PNG_IMG: getNullable(jo, propName); String base64Data = jo.getString(propName); byte[] decodedBytes; try { decodedBytes = Base64.decodeBase64(base64Data.getBytes("ascii")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("ASCII should always be supported!", e); } return new ByteArrayInputStream(decodedBytes); case NULL: case STRING: case REFERENCE: default: return getNullable(jo, propName); } }
From source file:org.evosuite.testcase.ValueMinimizer.java
@SuppressWarnings("unchecked") private <N extends Number> N getZero(N n) { if (n instanceof Double) { return (N) (Double.valueOf(0.0)); } else if (n instanceof Float) { return (N) (Float.valueOf(0F)); } else if (n instanceof Integer) { return (N) (Integer.valueOf(0)); } else if (n instanceof Long) { return (N) Long.valueOf(0L); } else if (n instanceof Short) { return (N) Short.valueOf((short) 0); } else if (n instanceof Byte) { return (N) Byte.valueOf((byte) 0); } else if (n == null) { throw new NullPointerException(); } else {/*from w w w.ja va 2 s . c om*/ throw new IllegalArgumentException("Unexpected number type: " + n.getClass()); } }
From source file:com.permutassep.ui.FragmentCreatePost.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_createpost, container, false); getActivity().setTitle(R.string.app_main_toolbar_post_action); getActivity().invalidateOptionsMenu(); if (savedInstanceState != null) { mWizardModel.load(savedInstanceState.getBundle("model")); }/*from w w w . j ava 2 s .c o m*/ mWizardModel.registerListener(this); mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager()); mPager = (ViewPager) rootView.findViewById(R.id.pager); mPager.setAdapter(mPagerAdapter); mStepPagerStrip = (StepPagerStrip) rootView.findViewById(R.id.strip); mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() { @Override public void onPageStripSelected(int position) { position = Math.min(mPagerAdapter.getCount() - 1, position); if (mPager.getCurrentItem() != position) { mPager.setCurrentItem(position); } } }); mNextButton = (Button) rootView.findViewById(R.id.next_button); mPrevButton = (Button) rootView.findViewById(R.id.prev_button); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mStepPagerStrip.setCurrentPage(position); if (mConsumePageSelectedEvent) { mConsumePageSelectedEvent = false; return; } mEditingAfterReview = false; updateBottomBar(); } }); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (suggestDataCompletion && mCurrentPageSequence.get(mPager.getCurrentItem()) .getKey() == PermutaSepWizardModel.CONTACT_INFO_KEY) { DialogFragment dg = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.wizard_contact_suggest_data_completion_dialog_msg) .setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { suggestDataCompletion = false; } }) .create(); } }; dg.show(getActivity().getSupportFragmentManager(), "contact_data_dialog"); } else if (mPager.getCurrentItem() == mCurrentPageSequence.size()) { DialogFragment dg = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.submit_confirm_message) .setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Post post = new Post(); post.setPostDate(new Date()); for (Page p : mWizardModel.getCurrentPageSequence()) { switch (p.getKey()) { case PermutaSepWizardModel.CONTACT_INFO_KEY: User user = ComplexPreferences .getComplexPreferences(getActivity(), Config.APP_PREFERENCES_NAME, Context.MODE_PRIVATE) .getObject(PrefUtils.PREF_USER_KEY, User.class); post.setUser(user); break; case PermutaSepWizardModel.CITY_FROM_KEY: State sf = p.getData().getParcelable( ProfessorCityFromPage.STATE_DATA_KEY); City cf = p.getData().getParcelable( ProfessorCityFromPage.MUNICIPALITY_DATA_KEY); Town tf = p.getData().getParcelable( ProfessorCityFromPage.LOCALITY_DATA_KEY); post.setStateFrom(sf.getId()); post.setCityFrom(Short.valueOf( String.valueOf(cf.getClaveMunicipio()))); post.setTownFrom(Short.valueOf(tf.getClave())); post.setLatFrom(tf.getLatitud()); post.setLonFrom(tf.getLongitud()); break; case PermutaSepWizardModel.CITY_TO_KEY: State st = p.getData().getParcelable( ProfessorCityToPage.STATE_TO_DATA_KEY); City ct = p.getData().getParcelable( ProfessorCityToPage.MUNICIPALITY_TO_DATA_KEY); Town tt = p.getData().getParcelable( ProfessorCityToPage.LOCALITY_TO_DATA_KEY); post.setStateTo(st.getId()); post.setCityTo(Short.valueOf( String.valueOf(ct.getClaveMunicipio()))); post.setTownTo(Short.valueOf(tt.getClave())); post.setLatTo(tt.getLatitud()); post.setLonTo(tt.getLongitud()); break; case PermutaSepWizardModel.ACADEMIC_LEVEL_KEY: post.setAcademicLevel( p.getData().getString(p.SIMPLE_DATA_KEY)); break; case PermutaSepWizardModel.POSITION_TYPE_KEY: post.setPositionType( p.getData().getString(p.SIMPLE_DATA_KEY)); break; case PermutaSepWizardModel.WORKDAY_TYPE_KEY: post.setWorkdayType( p.getData().getString(p.SIMPLE_DATA_KEY)); break; case PermutaSepWizardModel.TEACHING_CAREER_KEY: post.setIsTeachingCareer( p.getData().getString(p.SIMPLE_DATA_KEY) .equals("Si") ? true : false); break; case PermutaSepWizardModel.POST_TEXT_KEY: post.setPostText(p.getData() .getString(PostTextPage.TEXT_DATA_KEY)); break; } } showDialog(getString(R.string.wizard_post_dlg_title), getString(R.string.wizard_post_dlg_text)); GsonBuilder gsonBuilder = new GsonBuilder() // .registerTypeHierarchyAdapter(User.class, new UserTypeAdapter(getActivity())) .registerTypeHierarchyAdapter(Post.class, new PostTypeAdapter(getActivity())) .setDateFormat(Config.APP_DATE_FORMAT); Gson gson = gsonBuilder.create(); new PermutasSEPRestClient(new GsonConverter(gson)).get() .newPost(post, new Callback<Post>() { @Override public void success(Post post, retrofit.client.Response response) { replaceFragment(); hideDialog(); } @Override public void failure(RetrofitError error) { // TODO: Add the error message dialog hideDialog(); } }); } }) .setNegativeButton(android.R.string.cancel, null).create(); } }; dg.show(getActivity().getSupportFragmentManager(), "place_order_dialog"); } else { if (mEditingAfterReview) { mPager.setCurrentItem(mPagerAdapter.getCount() - 1); } else { mPager.setCurrentItem(mPager.getCurrentItem() + 1); } } } }); mPrevButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mPager.setCurrentItem(mPager.getCurrentItem() - 1); } }); onPageTreeChanged(); updateBottomBar(); return rootView; }
From source file:ezbake.data.elastic.thrift.Page.java
public Object getFieldValue(_Fields field) { switch (field) { case OFFSET:/* w w w .j a v a2s. c om*/ return Integer.valueOf(getOffset()); case PAGE_SIZE: return Short.valueOf(getPageSize()); } throw new IllegalStateException(); }
From source file:org.apache.rocketmq.jms.domain.message.JmsBaseMessage.java
@Override public short getShortProperty(String name) throws JMSException { if (propertyExists(name)) { Object value = getObjectProperty(name); return value instanceof Short ? (Short) value : Short.valueOf(value.toString()); }/* w w w. ja v a 2s .c om*/ return 0; }
From source file:org.mifos.application.meeting.struts.action.MeetingAction.java
private MeetingUpdateRequest createMeetingUupdateRequest(CustomerBO customerInSession, MeetingActionForm actionForm) {/* w w w . ja v a 2 s . co m*/ MeetingUpdateRequest meetingUpdateRequest; Short weekDay = null; if (StringUtils.isNotBlank(actionForm.getWeekDay())) { weekDay = Short.valueOf(actionForm.getWeekDay()); } Short monthDay = null; if (StringUtils.isNotBlank(actionForm.getMonthDay())) { monthDay = Short.valueOf(actionForm.getMonthDay()); } Short dayOfWeekOfMonth = null; if (StringUtils.isNotBlank(actionForm.getMonthWeek())) { dayOfWeekOfMonth = Short.valueOf(actionForm.getMonthWeek()); } Short weekRankOfMonth = null; if (StringUtils.isNotBlank(actionForm.getMonthRank())) { weekRankOfMonth = Short.valueOf(actionForm.getMonthRank()); } switch (actionForm.getRecurrenceType()) { case DAILY: throw new UnsupportedOperationException("Daily recurrence is not supported for customer meetings."); case WEEKLY: meetingUpdateRequest = new MeetingUpdateRequest(customerInSession.getCustomerId(), customerInSession.getVersionNo(), actionForm.getRecurrenceType().getValue(), actionForm.getMeetingPlace(), actionForm.getRecurWeekValue(), weekDay, monthDay, dayOfWeekOfMonth, weekRankOfMonth); break; case MONTHLY: meetingUpdateRequest = new MeetingUpdateRequest(customerInSession.getCustomerId(), customerInSession.getVersionNo(), actionForm.getRecurrenceType().getValue(), actionForm.getMeetingPlace(), actionForm.getRecurWeekValue(), weekDay, monthDay, dayOfWeekOfMonth, weekRankOfMonth); break; default: throw new UnsupportedOperationException("Unknown recurrence for customer meetings."); } return meetingUpdateRequest; }
From source file:org.mifos.accounts.loan.business.LoanBORedoDisbursalIntegrationTest.java
@Ignore @Test/*w w w .j av a 2 s . co m*/ public void testRedoLoanApplyWholeMiscPenaltyBeforeRepayments() throws Exception { LoanBO loan = redoLoanWithMondayMeetingAndVerify(userContext, 14, new ArrayList<AccountFeesEntity>()); disburseLoanAndVerify(userContext, loan, 14); Double feeAmount = new Double("33.0"); Assert.assertTrue(MoneyUtils.isRoundedAmount(feeAmount)); applyCharge(loan, Short.valueOf(AccountConstants.MISC_PENALTY), feeAmount); Assert.assertFalse(loan.havePaymentsBeenMade()); LoanTestUtils.assertInstallmentDetails(loan, 1, 50.9, 0.1, 0.0, 0.0, 0.0); LoanTestUtils.assertInstallmentDetails(loan, 2, 50.9, 0.1, 0.0, 0.0, 33.0); LoanTestUtils.assertInstallmentDetails(loan, 3, 50.9, 0.1, 0.0, 0.0, 0.0); LoanTestUtils.assertInstallmentDetails(loan, 4, 50.9, 0.1, 0.0, 0.0, 0.0); LoanTestUtils.assertInstallmentDetails(loan, 5, 50.9, 0.1, 0.0, 0.0, 0.0); LoanTestUtils.assertInstallmentDetails(loan, 6, 45.5, 0.5, 0.0, 0.0, 0.0); }