List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:com.okwei.walletportal.web.CompanyAccountController.java
@RequestMapping(value = "/addAcount") public String addAcount(Model model) { LoginUser user = super.getLoginUser(); String businessLicenceImg = ""; UPublicBanks accountInfo = null;//from w w w.j a v a 2 s. c o m boolean isPassed = false;// boolean isSupImg = false;//? try { accountInfo = companyAccountService.getCompanyAccount(user.getWeiID()); // if (accountInfo != null) { if (StringUtils.isNotEmpty(accountInfo.getLicense())) { businessLicenceImg = ImgDomain.GetFullImgUrl(accountInfo.getLicense()); } isPassed = companyAccountService.getPublicBanksPassCount(user.getWeiID()); } // else { if (user.getYunS() == 1 || user.getBatchS() == 1) { UYunSupplier yunsupplyer = companyAccountService.getById(UYunSupplier.class, user.getWeiID()); if (yunsupplyer != null) { if (Short.valueOf(SupplierStatusEnum.PayIn.toString()).equals(yunsupplyer.getStatus())) { USupplyer supplyer = companyAccountService.getById(USupplyer.class, user.getWeiID()); if (supplyer != null) { if (StringUtils.isNotEmpty(supplyer.getBusinessLicence())) { businessLicenceImg = ImgDomain.GetFullImgUrl(supplyer.getBusinessLicence()); accountInfo = new UPublicBanks(); accountInfo.setLicense(supplyer.getBusinessLicence()); isSupImg = true; } } } } } else { return "company/accountInfo"; } } } catch (Exception e) { logger.error(e.getMessage()); } model.addAttribute("accountInfo", accountInfo); model.addAttribute("businessLicenceImg", businessLicenceImg); model.addAttribute("userinfo", user); model.addAttribute("isPassed", isPassed); model.addAttribute("isSupImg", isSupImg); return "company/addAcount"; }
From source file:org.mifos.customers.struts.action.CustSearchAction.java
@TransactionDemarcate(joinToken = true) public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception { CustSearchActionForm actionForm = (CustSearchActionForm) form; boolean isCenterHierarchyExist = ClientRules.getCenterHierarchyExists(); if (StringUtils.isNotBlank(actionForm.getLoanOfficerId())) { Short loanOfficerId = Short.valueOf(actionForm.getLoanOfficerId()); List<CustomerDetailDto> customerList = this.centerServiceFacade .retrieveCustomersUnderUser(loanOfficerId); SessionUtils.setCollectionAttribute(CustomerSearchConstants.CUSTOMERLIST, customerList, request); SessionUtils.setAttribute("GrpHierExists", isCenterHierarchyExist, request); SessionUtils.setAttribute(CustomerSearchConstants.LOADFORWARD, CustomerSearchConstants.LOADFORWARDLOANOFFICER, request); }/*from ww w . jav a 2s. c om*/ if (StringUtils.isNotBlank(actionForm.getOfficeId())) { List<PersonnelBO> personnelList = legacyPersonnelDao .getActiveLoanOfficersUnderOffice(getShortValue(actionForm.getOfficeId())); SessionUtils.setCollectionAttribute(CustomerSearchConstants.LOANOFFICERSLIST, personnelList, request); } UserContext userContext = getUserContext(request); Short userBranchId = userContext.getBranchId(); String officeName = retrieveOfficeName(actionForm, userBranchId); SessionUtils.setAttribute("isCenterHierarchyExists", isCenterHierarchyExist, request); SessionUtils.setAttribute(CustomerSearchConstants.OFFICE, officeName, request); SessionUtils.setAttribute(CustomerSearchConstants.LOADFORWARD, CustomerSearchConstants.LOADFORWARDNONLOANOFFICER, request); return mapping.findForward(CustomerSearchConstants.LOADFORWARDLOANOFFICER_SUCCESS); }
From source file:org.eobjects.analyzer.util.convert.StandardTypeConverter.java
@Override public Object fromString(Class<?> type, String str) { if (ReflectionUtils.isString(type)) { return str; }//from ww w .ja v a 2 s . co m if (ReflectionUtils.isBoolean(type)) { return Boolean.valueOf(str); } if (ReflectionUtils.isCharacter(type)) { return Character.valueOf(str.charAt(0)); } if (ReflectionUtils.isInteger(type)) { return Integer.valueOf(str); } if (ReflectionUtils.isLong(type)) { return Long.valueOf(str); } if (ReflectionUtils.isByte(type)) { return Byte.valueOf(str); } if (ReflectionUtils.isShort(type)) { return Short.valueOf(str); } if (ReflectionUtils.isDouble(type)) { return Double.valueOf(str); } if (ReflectionUtils.isFloat(type)) { return Float.valueOf(str); } if (ReflectionUtils.is(type, Class.class)) { try { return Class.forName(str); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Class not found: " + str, e); } } if (type.isEnum()) { try { Object[] enumConstants = type.getEnumConstants(); // first look for enum constant matches Method nameMethod = Enum.class.getMethod("name"); for (Object e : enumConstants) { String name = (String) nameMethod.invoke(e); if (name.equals(str)) { return e; } } // check for aliased enums for (Object e : enumConstants) { String name = (String) nameMethod.invoke(e); Field field = type.getField(name); Alias alias = ReflectionUtils.getAnnotation(field, Alias.class); if (alias != null) { String[] aliasValues = alias.value(); for (String aliasValue : aliasValues) { if (aliasValue.equals(str)) { return e; } } } } } catch (Exception e) { throw new IllegalStateException("Unexpected error occurred while examining enum", e); } throw new IllegalArgumentException("No such enum '" + str + "' in enum class: " + type.getName()); } if (ReflectionUtils.isDate(type)) { return toDate(str); } if (ReflectionUtils.is(type, File.class)) { return new File(str.replace('\\', File.separatorChar)); } if (ReflectionUtils.is(type, Calendar.class)) { Date date = toDate(str); Calendar c = Calendar.getInstance(); c.setTime(date); return c; } if (ReflectionUtils.is(type, Pattern.class)) { try { return Pattern.compile(str); } catch (PatternSyntaxException e) { throw new IllegalArgumentException("Invalid regular expression syntax in '" + str + "'.", e); } } if (ReflectionUtils.is(type, java.sql.Date.class)) { Date date = toDate(str); return new java.sql.Date(date.getTime()); } if (ReflectionUtils.isNumber(type)) { return ConvertToNumberTransformer.transformValue(str); } if (ReflectionUtils.is(type, Serializable.class)) { logger.warn("fromString(...): No built-in handling of type: {}, using deserialization", type.getName()); byte[] bytes = (byte[]) parentConverter.fromString(byte[].class, str); ChangeAwareObjectInputStream objectInputStream = null; try { objectInputStream = new ChangeAwareObjectInputStream(new ByteArrayInputStream(bytes)); objectInputStream.addClassLoader(type.getClassLoader()); Object obj = objectInputStream.readObject(); return obj; } catch (Exception e) { throw new IllegalStateException("Could not deserialize to " + type + ".", e); } finally { FileHelper.safeClose(objectInputStream); } } throw new IllegalArgumentException("Could not convert to type: " + type.getName()); }
From source file:com.beetle.framework.util.ObjectUtil.java
public final static void populate(Object obj, Map<String, Object> map) { Set<?> s = map.entrySet(); Iterator<?> it = s.iterator(); while (it.hasNext()) { String key = ""; Object o = null;/*w w w . j av a 2s . com*/ @SuppressWarnings("rawtypes") Map.Entry me = (Map.Entry) it.next(); try { key = me.getKey().toString(); o = me.getValue(); if (o == null) { continue; } setValue(key, obj, o); } catch (IllegalArgumentException e) { Class<Object> type = ObjectUtil.getType(key, obj); String tstr = type.toString(); if (tstr.equals(Integer.class.toString())) { ObjectUtil.setValue(key, obj, Integer.valueOf(o.toString())); } else if (tstr.equals(Long.class.toString())) { ObjectUtil.setValue(key, obj, Long.valueOf(o.toString())); } else if (tstr.equals(Float.class.toString())) { ObjectUtil.setValue(key, obj, Float.valueOf(o.toString())); } else if (tstr.equals(Double.class.toString())) { ObjectUtil.setValue(key, obj, Double.valueOf(o.toString())); } else if (tstr.equals(Short.class.toString())) { ObjectUtil.setValue(key, obj, Short.valueOf(o.toString())); } else if (tstr.equals(Byte.class.toString())) { ObjectUtil.setValue(key, obj, Byte.valueOf(o.toString())); } else if (tstr.equals(Date.class.toString())) { if (o instanceof Date) { ObjectUtil.setValue(key, obj, (Date) o); } else { long time = ((Double) o).longValue(); ObjectUtil.setValue(key, obj, new Date(time)); } } else if (tstr.equals(java.sql.Timestamp.class.toString())) { if (o instanceof java.sql.Timestamp) { ObjectUtil.setValue(key, obj, (Date) o); } else { long time = ((Double) o).longValue(); ObjectUtil.setValue(key, obj, new java.sql.Timestamp(time)); } } else { throw e; } tstr = null; type = null; } } }
From source file:com.p5solutions.core.utils.NumberUtils.java
/** * Parses the number.//from w w w.ja v a 2 s.c o m * * @param number * the number * @param clazz * the clazz * @return the object */ @SuppressWarnings("unchecked") public static <T> T valueOf(String number, Class<?> clazz) { // if the string representation of the number is empty or null // then return a null, as it cannot be parsed by the <ClassNumber>.valueOf() if (Comparison.isEmptyOrNullTrim(number)) { return (T) null; } if (ReflectionUtility.isByteClass(clazz)) { return (T) Byte.valueOf(number); } else if (ReflectionUtility.isShortClass(clazz)) { return (T) Short.valueOf(number); } else if (ReflectionUtility.isIntegerClass(clazz)) { return (T) Integer.valueOf(number); } else if (ReflectionUtility.isLongClass(clazz)) { return (T) Long.valueOf(number); } else if (ReflectionUtility.isFloatClass(clazz)) { return (T) Short.valueOf(number); } else if (ReflectionUtility.isDoubleClass(clazz)) { return (T) Double.valueOf(number); } else if (ReflectionUtility.isBigDecimalClass(clazz)) { return (T) BigDecimal.valueOf(Double.valueOf(number)); } return (T) null; }
From source file:org.mifos.customers.office.struts.action.OffAction.java
@TransactionDemarcate(saveToken = true) public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception { OffActionForm actionForm = (OffActionForm) form; actionForm.clear();/*from w w w. j a va2 s. c o m*/ String officeLevel = request.getParameter("officeLevel"); Short officeLevelId = null; if (StringUtils.isNotBlank(officeLevel)) { officeLevelId = Short.valueOf(officeLevel); } OfficeFormDto officeFormDto = this.officeServiceFacade.retrieveOfficeFormInformation(officeLevelId); if (StringUtils.isNotBlank(officeLevel)) { actionForm.setOfficeLevel(officeLevel); OfficeDto office = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request); List<OfficeDto> validParentOffices = new ArrayList<OfficeDto>(); if (actionForm.getInput() != null && actionForm.getInput().equals("edit") && office != null) { for (OfficeDto view : officeFormDto.getParents()) { if (!view.getId().equals(office.getOfficeId())) { validParentOffices.add(view); } } } else { validParentOffices.addAll(officeFormDto.getParents()); } SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, validParentOffices, request); } actionForm.setCustomFields(officeFormDto.getCustomFields()); SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, officeFormDto.getCustomFields(), request); SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeFormDto.getOfficeLevels(), request); SessionUtils.setAttribute(CustomerConstants.URL_MAP, null, request.getSession(false)); return mapping.findForward(ActionForwards.load_success.toString()); }
From source file:org.brekka.stillingar.example.FieldTypesDOMTest.java
/** * /*www .j av a 2 s . c o m*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate().getTime(), t.getDateAsCalendar().getTime()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsCalendar().getTime()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime()).toString(), t.getDateTime().toString()); assertEquals(new LocalDate(testing.getDate()).toString(), t.getLocalDate().toString()); assertEquals(new LocalTime(testing.getTime()).toString(), t.getLocalTime().toString()); assertEquals(String.format("%tT", testing.getTime()), String.format("%tT", t.getTimeAsCalendar().getTime())); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:org.brekka.stillingar.example.FieldTypesJAXBTest.java
/** * /* w w w .j a v a 2 s . c o m*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate().getTime(), t.getDateAsCalendar().getTime()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsCalendar().getTime()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime()).toString(), t.getDateTime().toString()); assertEquals(new LocalDate(testing.getDate()).toString(), t.getLocalDate().toString()); assertEquals(new LocalTime(testing.getTime()).toString(), t.getLocalTime().toString()); assertEquals(String.format("%tT", testing.getTime()), String.format("%tT", t.getTimeAsCalendar().getTime())); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertNotNull(t.getTestingObject() instanceof org.brekka.stillingar.example.Configuration.Testing); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:com.ssic.education.provider.controller.ProUserRegController.java
private void saveLicenses(String supplierId, String[] licenses, String creatorId, SupplierDto supplierDto) { if (licenses != null) { for (String licesse : licenses) { if (!StringUtils.isEmpty(licesse)) { String licenseName = licesse.split("#")[0]; String licPic = licesse.split("#")[1]; String licNo = licesse.split("#")[2]; String licType = licesse.split("#")[3]; ProLicenseDto proLicenseDto = new ProLicenseDto(); proLicenseDto.setLicType(DataStatus.DISABLED); proLicenseDto.setLicName(licenseName); proLicenseDto.setLicPic(licPic); proLicenseDto.setLicType(Integer.valueOf(licType)); ;//from w ww . j a v a 2 s .com proLicenseDto.setLicNo(licNo); proLicenseDto.setRelationId(supplierId); proLicenseDto.setCerSource(Short.valueOf("0")); proLicenseDto.setCreator(creatorId); iProLicenseService.saveProLicense(proLicenseDto); if (Objects.equal(licType, "4")) { supplierDto.setBusinessLicense(licNo); } else if (Objects.equal(licType, "0")) { supplierDto.setFoodServiceCode(licNo); } else if (Objects.equal(licType, "2")) { supplierDto.setFoodCirculationCode(licNo); } else if (Objects.equal(licType, "3")) { supplierDto.setFoodProduceCode(licNo); } } } supplierDto.setId(supplierId); supplierDto.setReviewed(Byte.valueOf("0")); supplierDto.setSupplierType(Integer.valueOf(1));//? 0?1???2 iSupplierService.insertSupplier(supplierDto);//saveOrUpdateSupplier(supplierDto); } // business_license ? 4 // organization_code ? // food_service_code ???? 0 // food_service_code_date ???? // food_business_code ?????? // food_business_code_date ?????? // food_circulation_code ???? 2 // food_circulation_code_date ???? // food_produce_code ??? 3 // food_produce_code_date ??? }
From source file:org.andromda.cartridges.database.DatabaseTemplateObject.java
/** * Sets the generated DDL name maximum length. This is so names don't get to * long, for example, Oracle names can't be longer than 30 characters so the * maxSqlNameLength would be set to 30./*from www. j a va2 s.com*/ * * @param maxSqlNameLength the maximum length an name can be. */ public void setMaxSqlNameLength(String maxSqlNameLength) { if (maxSqlNameLength != null) { this.maxSqlNameLength = Short.valueOf(maxSqlNameLength); } }