List of usage examples for java.lang Integer byteValue
public byte byteValue()
From source file:Main.java
static List<Byte> unicode2han3last_direct(Character c) { Integer code = (int) c.charValue(); if (code >= 44032 && code <= 55203) { // Korean Area code -= 44032;//from www . java 2s .c om Integer last = code % 28; code = (code / 28); Integer middle = code % 21; Integer first = code / 21; return Arrays.asList(concatAll(first_set[first], middle_set[middle], last_set[last])); } if (code >= 12593 && code <= 12643) { // child sound return Arrays.asList(single_set[code - 12593]); } return Arrays.asList(code.byteValue()); }
From source file:com.github.jessemull.microflex.util.IntegerUtil.java
/** * Converts a list of integers to a list of bytes. * @param List<Integer> list of integers * @return list of bytes *///from w w w . j a va 2 s . c o m public static List<Byte> toByteList(List<Integer> list) { List<Byte> byteList = new ArrayList<Byte>(); for (Integer val : list) { if (!OverFlowUtil.byteOverflow(val)) { OverFlowUtil.overflowError(val); } byteList.add(val.byteValue()); } return byteList; }
From source file:org.diorite.utils.math.ByteRange.java
/** * Parses given string to range, string is valid range when contains 2 numbers (second greater than first) and splt char: <br> * " - ", " : ", " ; ", ", ", " ", ",", ";", ":", "-" * * @param string string to parse./*from ww w. j a v a2 s .c o m*/ * * @return parsed range or null. */ public static ByteRange valueOf(String string) { if (string.isEmpty()) { return null; } String[] nums = null; int i = 0; final boolean firstMinus = string.charAt(0) == '-'; if (firstMinus) { string = string.substring(1); } while ((i < SPLITS.length) && ((nums == null) || (nums.length != 2))) { nums = StringUtils.splitByWholeSeparator(string, SPLITS[i++], 2); } if ((nums == null) || (nums.length != 2)) { return null; } final Integer min = DioriteMathUtils.asInt(firstMinus ? ("-" + nums[0]) : nums[0]); if ((min == null) || (min < Byte.MIN_VALUE)) { return null; } final Integer max = DioriteMathUtils.asInt(nums[1]); if ((max == null) || (max > Byte.MAX_VALUE) || (min > max)) { return null; } return new ByteRange(min.byteValue(), max.byteValue()); }
From source file:ConversionUtil.java
public static byte[] convertToByteArray(Object object) throws Exception { byte[] returnArray = null; Class clazz = object.getClass(); String clazzName = clazz.getName(); if (clazz.equals(Integer.class)) { Integer aValue = (Integer) object; int intValue = aValue.intValue(); returnArray = convertToByteArray(intValue); } else if (clazz.equals(String.class)) { String aValue = (String) object; returnArray = convertToByteArray(aValue); } else if (clazz.equals(Byte.class)) { Byte aValue = (Byte) object; byte byteValue = aValue.byteValue(); returnArray = convertToByteArray(byteValue); } else if (clazz.equals(Long.class)) { Long aValue = (Long) object; long longValue = aValue.longValue(); returnArray = convertToByteArray(longValue); } else if (clazz.equals(Short.class)) { Short aValue = (Short) object; short shortValue = aValue.shortValue(); returnArray = convertToByteArray(shortValue); } else if (clazz.equals(Boolean.class)) { Boolean aValue = (Boolean) object; boolean booleanValue = aValue.booleanValue(); returnArray = convertToByteArray(booleanValue); } else if (clazz.equals(Character.class)) { Character aValue = (Character) object; char charValue = aValue.charValue(); returnArray = convertToByteArray(charValue); } else if (clazz.equals(Float.class)) { Float aValue = (Float) object; float floatValue = aValue.floatValue(); returnArray = convertToByteArray(floatValue); } else if (clazz.equals(Double.class)) { Double aValue = (Double) object; double doubleValue = aValue.doubleValue(); returnArray = convertToByteArray(doubleValue); } else {/* w w w. j av a 2 s. c o m*/ throw new Exception("Cannot convert object of type " + clazzName); } return returnArray; }
From source file:org.openintents.safe.CryptoHelper.java
public static byte[] hexStringToBytes(String hex) { byte[] bytes = new byte[hex.length() / 2]; int j = 0;/*from www . ja va 2s. c o m*/ for (int i = 0; i < hex.length(); i += 2) { try { String hexByte = hex.substring(i, i + 2); Integer k = Integer.decode("0x" + hexByte); bytes[j++] = k.byteValue(); } catch (NumberFormatException e) { Log.i(TAG, e.getLocalizedMessage()); return bytes; } catch (StringIndexOutOfBoundsException e) { Log.i(TAG, "StringIndexOutOfBoundsException"); return bytes; } } return bytes; }
From source file:org.apache.hadoop.hive.ql.udf.UDFToByte.java
public Byte evaluate(Integer i) { if (i == null) { return null; } else {/*from w w w. ja v a 2 s .c o m*/ return Byte.valueOf(i.byteValue()); } }
From source file:com.meidusa.venus.benchmark.venus.VenusBenchmark.java
@Override public BackendConnectionFactory getConnectionFactory() { if (factory == null) { factory = new VenusBenchmarkConnectionFactory(); String password = (String) parser.getOptionValue(passwordOption); String username = (String) parser.getOptionValue(userOption); if (!StringUtils.isEmpty(password)) { UserPasswordAuthenticator authenticator = new UserPasswordAuthenticator(); authenticator.setPassword(password); authenticator.setUsername(username); factory.setAuthenticator(authenticator); }/*from ww w . ja v a2s.c o m*/ Integer clientId = (Integer) parser.getOptionValue(clientIdOption); if (clientId != null) { Authenticator authenticator = factory.getAuthenticator(); if (authenticator instanceof DummyAuthenticator) { DummyAuthenticator dor = (DummyAuthenticator) authenticator; dor.setClientId(clientId); } } Integer serialValue = (Integer) parser.getOptionValue(serialOption); if (serialValue != null) { byte value = serialValue.byteValue(); factory.getAuthenticator().setSerializeType(value); } else { factory.getAuthenticator().setSerializeType(PacketConstant.CONTENT_TYPE_JSON); } } return factory; }
From source file:com.ssic.education.handle.service.impl.EduUsersServiceImpl.java
@Transactional public EduUsersDto save(EduUsersRegDto usersDto) { // TODO Auto-generated method stub EduSchool eduSchool = BeanUtils.createBeanByTarget(usersDto, EduSchool.class); Integer reviewed = DataStatus.DISABLED; eduSchool.setReviewed(reviewed.byteValue()); eduSchoolDao.insertSelective(eduSchool); EduUsers eduUsers = BeanUtils.createBeanByTarget(usersDto, EduUsers.class); eduUsers.setSourceId(eduSchool.getId()); eduUsers.setName(eduSchool.getSchoolName()); eduUsers.setIsadmin(1);/*from w w w. ja v a2 s . c o m*/ eduUsersDao.insertSelective(eduUsers); EduCanteen eduCanteen = BeanUtils.createBeanByTarget(usersDto, EduCanteen.class); if (null != eduCanteen && StringUtils.isNotBlank(eduCanteen.getCanteenName())) { eduCanteen.setSchoolId(eduSchool.getId()); eduCanteen.setCreator(eduUsers.getId()); eduCanteenDao.insertSelective(eduCanteen); } List<ProLicenseDto> proLicenseDtos = new Gson().fromJson(usersDto.getJsonLic(), new TypeToken<List<ProLicenseDto>>() { }.getType()); if (proLicenseDtos != null && proLicenseDtos.size() > 0) { for (ProLicenseDto proLicenseDto : proLicenseDtos) { if (null != proLicenseDto && StringUtils.isNotBlank(proLicenseDto.getLicPic())) { ProLicense proLicense = BeanUtils.createBeanByTarget(proLicenseDto, ProLicense.class); proLicense.setRelationId(eduCanteen.getId()); proLicense.setCerSource(usersDto.getCerSource().shortValue()); proLicense.setCreator(eduUsers.getId()); proLicenseDao.insertSelective(proLicense); } } } return BeanUtils.createBeanByTarget(eduUsers, EduUsersDto.class); }
From source file:org.apache.asterix.event.service.ZooKeeperService.java
@Override public void reportClusterState(String instanceName, ClusterState state) throws Exception { String clusterStatePath = ZooKeeperService.ASTERIX_INSTANCE_BASE_PATH + File.separator + instanceName + ASTERIX_INSTANCE_STATE_PATH; Integer value = state.ordinal(); byte[] stateValue = new byte[] { value.byteValue() }; // Create a place to put the state of the cluster in zk.create(clusterStatePath + ASTERIX_INSTANCE_STATE_REPORT, stateValue, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);/*from www.ja v a 2 s . c om*/ return; }
From source file:com.alliander.osgp.acceptancetests.devicemanagement.ReceiveEventNotificationsSteps.java
@DomainStep("a OSLP event notification message with (.*) and (.*) and (.*)") public void givenAOslpEventNotification(final String event, final String description, final String index) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { LOGGER.info("GIVEN: \"a OSLP event notification message with {} and {} and {}\".", event, description, index);/* w w w . j a v a 2 s . c o m*/ final EventNotification.Builder builder = EventNotification.newBuilder().setEvent(Event.valueOf(event)) .setDescription(description); // Fill index parameter if present if (!index.equals(EMPTY_INDEX)) { final Integer numericIndex = Integer.parseInt(index); builder.setIndex(ByteString.copyFrom(new byte[] { numericIndex.byteValue() })); } this.request = EventNotificationRequest.newBuilder().addNotifications(builder).build(); this.setupMessage(); }