List of usage examples for java.lang Long shortValue
public short shortValue()
From source file:Main.java
public static void main(String[] args) { Long longObject = new Long("1234567"); short s = longObject.shortValue(); System.out.println("short:" + s); }
From source file:Main.java
public static void main(String[] args) { Long lObj = new Long("10"); byte b = lObj.byteValue(); System.out.println(b);//from ww w.j ava 2 s . c o m short s = lObj.shortValue(); System.out.println(s); int i = lObj.intValue(); System.out.println(i); float f = lObj.floatValue(); System.out.println(f); double d = lObj.doubleValue(); System.out.println(d); }
From source file:org.jkcsoft.java.util.JavaHelper.java
public static boolean equals(Long obj1, long obj2) { boolean eq = false; if (obj1 != null) { eq = obj1.shortValue() == obj2; }/*from w w w . j ava2 s . c om*/ return eq; }
From source file:com.evolveum.midpoint.repo.sql.util.RUtil.java
public static Short toShort(Long l) { if (l == null) { return null; }/*w w w .ja va2 s.c om*/ if (l > Short.MAX_VALUE || l < Short.MIN_VALUE) { throw new IllegalArgumentException("Couldn't cast value to short " + l); } return l.shortValue(); }
From source file:org.sonar.core.technicaldebt.TechnicalDebtConverter.java
public WorkDayDuration fromMinutes(Long inMinutes) { int oneHourInMinute = 60; int days = 0; int hours = 0; int minutes = 0; int oneWorkingDay = hoursInDay * oneHourInMinute; if (inMinutes >= oneWorkingDay) { Long nbDays = inMinutes / oneWorkingDay; days = nbDays.shortValue(); inMinutes = inMinutes - (nbDays * oneWorkingDay); }/*ww w.j a v a2 s.c om*/ if (inMinutes >= oneHourInMinute) { Long nbHours = inMinutes / oneHourInMinute; hours = nbHours.shortValue(); inMinutes = inMinutes - (nbHours * oneHourInMinute); } minutes = inMinutes.shortValue(); return WorkDayDuration.of(minutes, hours, days); }
From source file:com.infinira.aerospike.dataaccess.model.Entity.java
/** * Get Short object for a given field value * @param name field name//from w w w .j av a 2 s . c o m * @return Short value */ protected Short getShort(String name) { Long value = this.getLong(name); return value != null ? value.shortValue() : null; }
From source file:org.mifos.ui.core.controller.SystemUserController.java
public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) { OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue()); formBean.setOfficeId(officeId);/*from w ww .j a v a 2s .c om*/ formBean.setOfficeName(selectedOffice.getName()); MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields(); formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1()); formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2()); formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3()); formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity()); formBean.getAddress().setStateHidden(dtoFields.isHideSystemState()); formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry()); formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode()); DefinePersonnelDto userRefData = this.personnelServiceFacade .retrieveInfoForNewUserDefinition(officeId.shortValue()); Map<String, String> genderOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getGenderList()) { genderOptions.put(option.getId().toString(), option.getName()); } formBean.setGenderOptions(genderOptions); Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getMaritalStatusList()) { maritalStatusOptions.put(option.getId().toString(), option.getName()); } formBean.setMaritalStatusOptions(maritalStatusOptions); Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getLanguageList()) { preferredLanguageOptions.put(option.getId().toString(), option.getName()); } formBean.setPreferredLanguageOptions(preferredLanguageOptions); Map<String, String> userTitleOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getTitleList()) { userTitleOptions.put(option.getId().toString(), option.getName()); } formBean.setUserTitleOptions(userTitleOptions); Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getPersonnelLevelList()) { userHierarchyOptions.put(option.getId().toString(), option.getName()); } formBean.setUserHierarchyOptions(userHierarchyOptions); Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getRolesList()) { availableRolesOptions.put(option.getId().toString(), option.getName()); } formBean.setAvailableRolesOptions(availableRolesOptions); formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>()); DateTime today = new DateTime(); formBean.setMfiJoiningDateDay(today.getDayOfMonth()); formBean.setMfiJoiningDateMonth(today.getMonthOfYear()); formBean.setMfiJoiningDateYear(today.getYearOfEra()); return formBean; }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJInt16Editor.java
public Short getInt16Value() { final String S_ProcName = "getInt16Value"; Short retval;/*from www .j a va2 s . c o m*/ String text = getText(); if ((text == null) || (text.length() <= 0)) { retval = null; } else { if (!isEditValid()) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, "Field is not valid"); } try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = null; } else if (obj instanceof Short) { Short s = (Short) obj; short v = s.shortValue(); if ((v < getMinValue()) || (v > getMaxValue())) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, getMinValue(), getMaxValue()); } retval = (Short) s; } else if (obj instanceof Integer) { Integer i = (Integer) obj; int v = i.intValue(); if ((v < getMinValue()) || (v > getMaxValue())) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, getMinValue(), getMaxValue()); } retval = new Short(i.shortValue()); } else if (obj instanceof Long) { Long l = (Long) obj; long v = l.longValue(); if ((v < getMinValue()) || (v > getMaxValue())) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, getMinValue(), getMaxValue()); } retval = new Short(l.shortValue()); } else if (obj instanceof Number) { Number n = (Number) obj; long v = n.longValue(); if ((v < getMinValue()) || (v > getMaxValue())) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, getMinValue(), getMaxValue()); } retval = new Short(n.shortValue()); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, or Number"); } } return (retval); }
From source file:org.mifos.application.servicefacade.PersonnelServiceFacadeWebTier.java
@Override public PersonnelInformationDto getPersonnelInformationDto(final Long userId, final String globalNumber) { PersonnelBO personnel = null;//from w ww .ja v a2s . co m if (userId != null) { personnel = personnelDao.findPersonnelById(userId.shortValue()); } else { personnel = personnelDao.findByGlobalPersonnelNum(globalNumber); } if (personnel == null) { throw new MifosRuntimeException("personnel not found for id" + userId); } String displayName = personnel.getDisplayName(); PersonnelStatusEntity personnelStatus = personnel.getStatus(); String statusName = ApplicationContextProvider.getBean(MessageLookup.class) .lookup(personnelStatus.getLookUpValue()); ListElement status = new ListElement(new Integer(personnelStatus.getId()), statusName); boolean locked = personnel.isLocked(); PersonnelDetailsEntity personnelDetailsEntity = personnel.getPersonnelDetails(); Address address = personnelDetailsEntity.getAddress(); AddressDto addressDto = new AddressDto(address.getLine1(), address.getLine2(), address.getLine3(), address.getCity(), address.getState(), address.getCountry(), address.getZip(), address.getPhoneNumber()); Name name = personnelDetailsEntity.getName(); PersonnelDetailsDto personnelDetails = new PersonnelDetailsDto( personnelDetailsEntity.getGovernmentIdNumber(), new DateTime(personnelDetailsEntity.getDob()).toDateMidnight().toDateTime(), personnelDetailsEntity.getMaritalStatus(), personnelDetailsEntity.getGender(), new DateTime(personnelDetailsEntity.getDateOfJoiningMFI()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfJoiningBranch()).toDateMidnight().toDateTime(), new DateTime(personnelDetailsEntity.getDateOfLeavingBranch()).toDateMidnight().toDateTime(), addressDto, name.getFirstName(), name.getMiddleName(), name.getSecondLastName(), name.getLastName()); String emailId = personnel.getEmailId(); Short preferredLocale = personnel.getPreferredLocale(); String languageName = Localization.getInstance().getDisplayName(preferredLocale); if (preferredLocale != null) { languageName = Localization.getInstance().getDisplayName(preferredLocale); } PersonnelLevelEntity level = personnel.getLevel(); OfficeBO office = personnel.getOffice(); Integer title = personnel.getTitle(); Set<PersonnelRoleEntity> personnelRoleEntities = personnel.getPersonnelRoles(); Set<ListElement> personnelRoles = new LinkedHashSet<ListElement>(); for (PersonnelRoleEntity entity : personnelRoleEntities) { ListElement element = new ListElement(entity.getRole().getId().intValue(), entity.getRole().getName()); personnelRoles.add(element); } Short personnelId = personnel.getPersonnelId(); String userName = personnel.getUserName(); Set<PersonnelCustomFieldEntity> personnelCustomFields = personnel.getCustomFields(); Set<CustomFieldDto> customFields = new LinkedHashSet<CustomFieldDto>(); for (PersonnelCustomFieldEntity fieldDef : personnelCustomFields) { customFields.add(new CustomFieldDto(fieldDef.getFieldId(), fieldDef.getFieldValue())); } Set<PersonnelNotesEntity> personnelNotesEntity = personnel.getPersonnelNotes(); Set<PersonnelNoteDto> personnelNotes = new LinkedHashSet<PersonnelNoteDto>(); for (PersonnelNotesEntity entity : personnelNotesEntity) { personnelNotes.add(new PersonnelNoteDto(new DateTime(entity.getCommentDate()), entity.getComment(), entity.getPersonnelName())); } return new PersonnelInformationDto(personnel.getPersonnelId().intValue(), personnel.getGlobalPersonnelNum(), displayName, status, locked, personnelDetails, emailId, languageName, preferredLocale.intValue(), level.getId(), office.getOfficeId().intValue(), office.getOfficeName(), title, personnelRoles, personnelId, userName, customFields, personnelNotes); }
From source file:org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.DlmsHelperService.java
public Short readShort(final GetResult getResult, final String description) throws ProtocolAdapterException { this.checkResultCode(getResult, description); final Long value = this.readLong(getResult.getResultData(), description); return (value == null) ? null : value.shortValue(); }