Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

In this page you can find the example usage for java.lang Integer toString.

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Integer 's value.

Usage

From source file:org.openmhealth.shim.ihealth.mapper.IHealthPhysicalActivityDataPointMapper.java

@Override
protected Optional<DataPoint<PhysicalActivity>> asDataPoint(JsonNode listEntryNode,
        Integer measureUnitMagicNumber) {

    String activityName = asRequiredString(listEntryNode, "SportName");

    if (activityName.isEmpty()) {

        return Optional.empty();
    }/*  w  w w .j  a v  a  2  s. com*/

    PhysicalActivity.Builder physicalActivityBuilder = new PhysicalActivity.Builder(activityName);

    Optional<Long> startTimeUnixEpochSecs = asOptionalLong(listEntryNode, "SportStartTime");
    Optional<Long> endTimeUnixEpochSecs = asOptionalLong(listEntryNode, "SportEndTime");
    Optional<Integer> timeZoneOffset = asOptionalInteger(listEntryNode, "TimeZone");

    if (startTimeUnixEpochSecs.isPresent() && endTimeUnixEpochSecs.isPresent() && timeZoneOffset.isPresent()) {

        Integer timeZoneOffsetValue = timeZoneOffset.get();
        String timeZoneString = timeZoneOffsetValue.toString();

        // Zone offset cannot parse a positive string offset that's missing a '+' sign (i.e., "0200" vs "+0200")
        if (timeZoneOffsetValue >= 0) {
            timeZoneString = "+" + timeZoneOffsetValue.toString();
        }

        physicalActivityBuilder.setEffectiveTimeFrame(ofStartDateTimeAndEndDateTime(
                getDateTimeWithCorrectOffset(startTimeUnixEpochSecs.get(), ZoneOffset.of(timeZoneString)),
                getDateTimeWithCorrectOffset(endTimeUnixEpochSecs.get(), ZoneOffset.of(timeZoneString))));
    }

    asOptionalDouble(listEntryNode, "Calories").ifPresent(
            calories -> physicalActivityBuilder.setCaloriesBurned(new KcalUnitValue(KILOCALORIE, calories)));

    PhysicalActivity physicalActivity = physicalActivityBuilder.build();

    return Optional
            .of(new DataPoint<>(createDataPointHeader(listEntryNode, physicalActivity), physicalActivity));
}

From source file:hello.processors.DivProcessor.java

/**
 * When you receive a message, print it out, then shut down the application.
 * Finally, clean up any ActiveMQ server stuff.
 *//*from w w w .j  a  va 2s . c o  m*/
@JmsListener(destination = "div_queue", containerFactory = "queueJmsContainerFactory")
public void receiveMessage(String message) {
    System.out.println("Processing : " + message);
    String[] split = message.split("/");

    JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);

    try {

        Integer a = Integer.parseInt(split[0]);
        Integer b = Integer.parseInt(split[1]);

        if (b == 0) {
            jmsTemplate.convertAndSend(new ActiveMQTopic("sum_response_topic"),
                    message + " cannot divide by 0.");
        }

        Integer result = a / b;
        jmsTemplate.convertAndSend(new ActiveMQTopic("sum_response_topic"),
                message + " = " + result.toString());

    } catch (NumberFormatException e) {
        jmsTemplate.convertAndSend(new ActiveMQTopic("sum_response_topic"), "Cannot parse request: " + message);
    }
}

From source file:org.envirocar.harvest.DummyTrackCreator.java

private void publishTracks() throws ClientProtocolException, IOException {
    int count = 0;
    Double lat = -89.195;/* ww  w  . j  ava2 s. co m*/
    Double lon = -179.195;

    StringBuilder sb;
    Integer lonCount = 10000;
    while (lon < 180) {
        sb = new StringBuilder();
        sb.append(startTemplate.replace("${trackId}", lonCount.toString()));

        while (lat < 90) {
            sb.append(featureTemplate.replace("${lat}", lat.toString()).replace("${lon}", lon.toString()));
            count++;
            lat += 0.15;
        }

        sb.deleteCharAt(sb.length() - 1);
        sb.append(endTemplate);

        pushToConsumer(sb.toString());

        lat = -89.125;
        lon += 0.15;
        lonCount++;

        logger.info("finished longitude {}; pushed track #: {} ", lon, (lonCount - 10000));
    }

    logger.info("Total feature count: {}", count);
}

From source file:cherry.foundation.crypto.SecureIntegerEncoderTest.java

@Test
public void testEncodeDecode() throws Exception {
    SecureIntegerEncoder encoder = createSecureIntegerEncoder();
    for (int i = 0; i < 100; i++) {
        Integer plain = Integer.valueOf(random.nextInt());
        String crypto = encoder.encode(plain);
        assertThat(crypto, is(not(plain.toString())));
        assertThat(encoder.decode(crypto), is(plain));
    }//from ww w .  jav  a 2 s .  c o m
}

From source file:com.orchestra.portale.controller.FavoriteController.java

@RequestMapping(value = "/ifFavorite", method = RequestMethod.GET)
public @ResponseBody String ifFavorite(@RequestParam String id_user, @RequestParam String id_poi) {

    Integer rating = pm.ifFavorite(Integer.parseInt(id_user), id_poi);

    return rating.toString();
}

From source file:com.eho.fhir.econsult.RestControllers.PractitionerController.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "text/plain;charset=UTF-8")
public ResponseEntity<String> practitionerGET(@PathVariable String id) throws Exception {
    Item item = DynamoDBConnection.get_item_by_ID(id);
    if (item == null)
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    Integer last_version = item.getInt("version");
    return new ResponseEntity(item.get("text" + last_version.toString()), HttpStatus.OK);
}

From source file:com.eho.fhir.econsult.RestControllers.PatientController.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "text/plain;charset=UTF-8")
public ResponseEntity<String> patientGET(@PathVariable String id) throws Exception {
    Item item = DynamoDBConnection.get_item_by_ID(id);
    if (item == null)
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    Integer last_version = item.getInt("version");
    return new ResponseEntity(item.get("text" + last_version.toString()), HttpStatus.OK);
}

From source file:com.haulmont.cuba.restapi.CommitRequest.java

private String generateId(String entityName) {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    MetaClass metaClass = metadata.getSession().getClass(entityName);

    MetaProperty primaryKeyProp = metadata.getTools().getPrimaryKeyProperty(metaClass);
    if (primaryKeyProp == null)
        throw new UnsupportedOperationException("Cannot generate ID for " + entityName);

    if (primaryKeyProp.getJavaType().equals(UUID.class)) {
        UuidSource uuidSource = AppBeans.get(UuidSource.NAME);
        UUID uuid = uuidSource.createUuid();
        return uuid.toString();
    } else if (primaryKeyProp.getJavaType().equals(Long.class)) {
        NumberIdSource numberIdSource = AppBeans.get(NumberIdSource.NAME);
        Long longId = numberIdSource.createLongId(entityName);
        return longId.toString();
    } else if (primaryKeyProp.getJavaType().equals(Integer.class)) {
        NumberIdSource numberIdSource = AppBeans.get(NumberIdSource.NAME);
        Integer intId = numberIdSource.createIntegerId(entityName);
        return intId.toString();
    } else {/*w ww.  jav a2s  . c o  m*/
        throw new UnsupportedOperationException("Cannot generate ID for " + entityName);
    }
}

From source file:org.openmrs.module.orderextension.util.OrderSetEditor.java

/**
 * @see PropertyEditorSupport#getAsText()
 *///from ww w  .  j a v a 2s .  c  o m
public String getAsText() {
    OrderSet orderSet = (OrderSet) getValue();
    if (orderSet == null) {
        return "";
    } else {
        Integer orderTypeId = orderSet.getId();
        if (orderTypeId == null) {
            return "";
        } else {
            return orderTypeId.toString();
        }
    }
}

From source file:se.backede.jeconomix.forms.report.TransactionsTotalReport.java

private void initChart(Integer year) {

    yearLabel.setText(year.toString());

    List<TransactionReportDto> calculatedBillReport = ReportUtils.getCalculatedReport(CategoryTypeEnum.BILL,
            currentYear);/*  w w  w  . j a va 2  s. c  o m*/
    List<TransactionReportDto> calculatedExpenseReport = ReportUtils
            .getCalculatedReport(CategoryTypeEnum.EXPENSE, currentYear);
    List<TransactionReportDto> calculatedIncomeReport = ReportUtils.getCalculatedReport(CategoryTypeEnum.INCOME,
            currentYear);

    List<TransactionReportDto> aggregatedExpenseReport = new LinkedList<>();
    aggregatedExpenseReport.addAll(calculatedBillReport);
    aggregatedExpenseReport.addAll(calculatedExpenseReport);

    Map<String, List<TransactionReportDto>> reports = new HashMap<>();
    reports.put("Income", calculatedIncomeReport);
    reports.put("Expense", aggregatedExpenseReport);

    addLineChart(reports);
}