Example usage for java.lang Double toString

List of usage examples for java.lang Double toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of this Double object.

Usage

From source file:com.aurel.track.exchange.excel.ExcelImportBL.java

/**
 * Gets the Integer value of a cell/*from   w ww  .ja  va  2s .  c o  m*/
 * 
 * @param cell
 * @return
 */
private static Integer getIntegerCellValue(Cell cell) throws ExcelImportInvalidCellValueException {
    Integer integerValue = null;
    int cellType = cell.getCellType();
    if (cellType == Cell.CELL_TYPE_NUMERIC) {
        Double doubleValue = null;
        try {
            double numericValue = cell.getNumericCellValue();
            doubleValue = new Double(numericValue);
            integerValue = new Integer(doubleValue.intValue());
        } catch (Exception e) {
            if (doubleValue == null) {
                doubleValue = new Double(Double.NaN);
            }
            throw new ExcelImportInvalidCellValueException(doubleValue.toString());
        }
    } else {
        if (cellType == Cell.CELL_TYPE_STRING) {
            RichTextString richTextString = null;
            richTextString = cell.getRichStringCellValue();
            if (richTextString != null) {
                String stringValue = richTextString.getString();
                if (stringValue != null && !"".equals(stringValue)) {
                    stringValue = stringValue.trim();
                    if (stringValue != null) {
                        try {
                            integerValue = Integer.valueOf(stringValue);
                        } catch (Exception e) {
                            throw new ExcelImportInvalidCellValueException(stringValue);
                        }
                    }
                }
            }
        } else {
            throw new ExcelImportInvalidCellValueException(getStringCellValue(cell));
        }
    }
    return integerValue;
}

From source file:com.urs.triptracks.TripUploader.java

private Vector<String> getTripData(long tripId) {
    Vector<String> tripData = new Vector<String>();
    mDb.openReadOnly();//w w w  .ja  v  a2s  . c o  m
    Cursor tripCursor = mDb.fetchTrip(tripId);

    //String note = tripCursor.getString(tripCursor
    //  .getColumnIndex(DbAdapter.K_TRIP_NOTE));
    String purpose = tripCursor.getString(tripCursor.getColumnIndex(DbAdapter.K_TRIP_PURP));
    Double startTime = tripCursor.getDouble(tripCursor.getColumnIndex(DbAdapter.K_TRIP_START));
    Double endTime = tripCursor.getDouble(tripCursor.getColumnIndex(DbAdapter.K_TRIP_END));
    String travelBy = tripCursor.getString(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_TRAVELED));
    Integer members = tripCursor.getInt(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_MEMBERS));
    Integer nonmembers = tripCursor.getInt(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_NONMEMBERS));
    Integer delays = tripCursor.getInt(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_DELAYS));
    Integer toll = tripCursor.getInt(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_PAYTOLL));
    Double tollAmt = tripCursor.getDouble(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_PAYTOLLAMT));
    Integer payForParking = tripCursor.getInt(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_PAYPARKING));
    Double payForParkingAmt = tripCursor
            .getDouble(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_PAYPARKINGAMT));
    Double fare = tripCursor.getDouble(tripCursor.getColumnIndex(DbAdapter.K_TRIP_EVERYSTOP_FARE));

    tripCursor.close();
    mDb.close();

    //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example
    //SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale locale);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
    //tripData.add(note);
    tripData.add(purpose);
    tripData.add(df.format(startTime));
    tripData.add(df.format(endTime));

    tripData.add(travelBy);
    tripData.add(members.toString());
    tripData.add(nonmembers.toString());
    tripData.add(delays.toString());
    tripData.add(toll.toString());
    tripData.add(tollAmt.toString());
    tripData.add(payForParking.toString());
    tripData.add(payForParkingAmt.toString());
    tripData.add(fare.toString());

    return tripData;
}

From source file:com.likethecolor.alchemy.api.entity.NamedEntityAlchemyEntityTest.java

@Test
public void testLatitude_String() {
    final Double expectedLatitude = 35.123D;
    final String latitude = expectedLatitude.toString();

    final NamedEntityAlchemyEntity entity = new NamedEntityAlchemyEntity();

    entity.setLatitude(latitude);/*from w  w w .  ja  va2s.c o  m*/

    assertEquals(expectedLatitude, entity.getLatitude());

    // null - should not change value
    entity.setLatitude(latitude);
    entity.setLatitude(null);

    assertEquals(expectedLatitude, entity.getLatitude());

    // empty string - should not change value
    entity.setLatitude(latitude);
    entity.setLatitude("");

    assertEquals(expectedLatitude, entity.getLatitude());

    // empty white space string - should not change value
    entity.setLatitude(latitude);
    entity.setLatitude("\t   \r\n  ");

    assertEquals(expectedLatitude, entity.getLatitude());

    // should be trimmed
    entity.setLatitude("\t   \r\n  \n\n" + latitude + "   ");

    assertEquals(expectedLatitude, entity.getLatitude());

    // non-number - should not change value
    entity.setLatitude(latitude);
    entity.setLatitude("foo");

    assertEquals(expectedLatitude, entity.getLatitude());
}

From source file:com.likethecolor.alchemy.api.entity.NamedEntityAlchemyEntityTest.java

@Test
public void testLongitude_String() {
    final Double expectedLongitude = -22.87D;
    final String longitude = expectedLongitude.toString();

    final NamedEntityAlchemyEntity entity = new NamedEntityAlchemyEntity();

    entity.setLongitude(longitude);//  w  w  w.j a  va 2 s .co  m

    assertEquals(expectedLongitude, entity.getLongitude());

    // null - should not change value
    entity.setLongitude(longitude);
    entity.setLongitude(null);

    assertEquals(expectedLongitude, entity.getLongitude());

    // empty string - should not change value
    entity.setLongitude(longitude);
    entity.setLongitude("");

    assertEquals(expectedLongitude, entity.getLongitude());

    // empty white space string - should not change value
    entity.setLongitude(longitude);
    entity.setLongitude("\t   \r\n  ");

    assertEquals(expectedLongitude, entity.getLongitude());

    // should be trimmed
    entity.setLongitude("\t   \r\n  \n\n" + longitude + "   ");

    assertEquals(expectedLongitude, entity.getLongitude());

    // non-number - should not change value
    entity.setLongitude(longitude);
    entity.setLongitude("foo");

    assertEquals(expectedLongitude, entity.getLongitude());
}

From source file:CalculatorMichaelSchmidt.java

private String doCalc(final String valAString, final String valBString, final char opChar) {
    String resultString = ERROR_STRING + NAN_STRING;
    Double valA = 0.0;/*from w w  w. j  a v  a  2  s . c o m*/
    Double valB = 0.0;
    Double valAnswer = 0.0;

    // Make sure register strings are numbers
    if (valAString.length() > 0) {
        try {
            valA = Double.parseDouble(valAString);
        } catch (NumberFormatException e) {
            return resultString;
        }
    } else {
        return resultString;
    }

    if (opChar != 'Q' && opChar != 'I') {
        if (valBString.length() > 0) {
            try {
                valB = Double.parseDouble(valBString);
            } catch (NumberFormatException e) {
                return resultString;
            }
        } else {
            return resultString;
        }
    }

    switch (opChar) {
    case 'Q': // Square Root
        valAnswer = Math.sqrt(valA);
        break;

    case 'I': // Inverse
        valB = 1.0;
        valAnswer = valB / valA;
        break;

    case '+': // Addition
        valAnswer = valA + valB;
        break;

    case '-': // Subtraction
        valAnswer = valA - valB;
        break;

    case '/': // Division
        valAnswer = valA / valB;
        break;

    case '*': // Multiplication
        valAnswer = valA * valB;
        break;

    default: // Do nothing - this should never happen
        break;

    }

    // Convert answer to string and format it before return.
    resultString = valAnswer.toString();
    resultString = trimString(resultString);
    return resultString;
}

From source file:com.attentec.AttentecService.java

/**
 * Saves and sends a new (our own) location to server.
 * @param location new location/*from  w w w . j a va2  s . c o  m*/
 */
private void handleNewLocation(final Location location) {
    Log.d(TAG, "handleNewLocation");
    if (location != null) {

        Double lat = location.getLatitude();
        Double lng = location.getLongitude();

        //save the location in preferences
        SharedPreferences sp = getSharedPreferences("attentec_preferences", MODE_PRIVATE);

        String username = sp.getString("username", "");
        String phoneKey = sp.getString("phone_key", "");

        Date d = new Date();

        SharedPreferences.Editor editor = sp.edit();
        editor.putFloat("latitude", lat.floatValue());
        editor.putFloat("longitude", lng.floatValue());
        editor.putLong("location_updated_at", d.getTime() / DevelopmentSettings.MILLISECONDS_IN_SECOND);
        editor.commit();

        //check if we need to update the server
        if (d.getTime() - lastUpdatedToServer < PreferencesHelper.getLocationsUpdateInterval(ctx) / 2) {
            Log.d(TAG, "Not updating location to server, to soon since last time: "
                    + (d.getTime() - lastUpdatedToServer));
            return;
        }

        Log.d(TAG, "Updating location to server");
        //get logindata for server contact
        Hashtable<String, List<NameValuePair>> postdata = ServerContact.getLogin(username, phoneKey);

        //add location to POST data
        List<NameValuePair> locationdata = new ArrayList<NameValuePair>();
        locationdata.add(new BasicNameValuePair("latitude", lat.toString()));
        locationdata.add(new BasicNameValuePair("longitude", lng.toString()));
        postdata.put("location", locationdata);

        //send location to server
        String url = "/app/app_update_user_info.json";

        try {
            ServerContact.postJSON(postdata, url, ctx);
        } catch (LoginException e) {
            //Login was wrong, so close activity
            endAllActivities();
            return;
        }
        lastUpdatedToServer = new Date().getTime();
    }
}

From source file:org.openmrs.web.controller.ConceptFormControllerTest.java

/**
 * @see ConceptFormController#onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)
 *//*  www .  jav  a 2  s. c om*/
@Test
@Verifies(value = "should copy numeric values into numeric concepts", method = "onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)")
public void onSubmit_shouldCopyNumericValuesIntoNumericConcepts() throws Exception {
    final Double EXPECTED_LOW_ABSOLUTE = 100.0;
    final Double EXPECTED_LOW_CRITICAL = 103.0;
    final Double EXPECTED_LOW_NORMAL = 105.0;
    final Double EXPECTED_HI_NORMAL = 110.0;
    final Double EXPECTED_HI_CRITICAL = 117.0;
    final Double EXPECTED_HI_ABSOLUTE = 120.0;

    ConceptService cs = Context.getConceptService();

    ConceptFormController conceptFormController = (ConceptFormController) applicationContext
            .getBean("conceptForm");

    MockHttpServletRequest mockRequest = new MockHttpServletRequest();

    mockRequest.setMethod("POST");
    mockRequest.setParameter("action", "");
    mockRequest.setParameter("namesByLocale[en_GB].name", "WEIGHT (KG)");
    mockRequest.setParameter("conceptId", "5089");
    mockRequest.setParameter("concept.datatype", "1");
    mockRequest.setParameter("lowAbsolute", EXPECTED_LOW_ABSOLUTE.toString());
    mockRequest.setParameter("lowCritical", EXPECTED_LOW_CRITICAL.toString());
    mockRequest.setParameter("lowNormal", EXPECTED_LOW_NORMAL.toString());
    mockRequest.setParameter("hiNormal", EXPECTED_HI_NORMAL.toString());
    mockRequest.setParameter("hiCritical", EXPECTED_HI_CRITICAL.toString());
    mockRequest.setParameter("hiAbsolute", EXPECTED_HI_ABSOLUTE.toString());

    ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
    assertNotNull(mav);
    assertTrue(mav.getModel().isEmpty());

    ConceptNumeric concept = (ConceptNumeric) cs.getConcept(5089);
    Assert.assertEquals(EXPECTED_LOW_NORMAL, concept.getLowNormal());
    Assert.assertEquals(EXPECTED_HI_NORMAL, concept.getHiNormal());
    Assert.assertEquals(EXPECTED_LOW_ABSOLUTE, concept.getLowAbsolute());
    Assert.assertEquals(EXPECTED_HI_ABSOLUTE, concept.getHiAbsolute());
    Assert.assertEquals(EXPECTED_LOW_CRITICAL, concept.getLowCritical());
    Assert.assertEquals(EXPECTED_HI_CRITICAL, concept.getHiCritical());
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398TrainingBudgetV1_0Generator.java

private PHS398TrainingBudget getPHS398TrainingBudget(
        ProposalDevelopmentDocumentContract proposalDevelopmentDocument) throws S2SException {
    DevelopmentProposalContract developmentProposal = proposalDevelopmentDocument.getDevelopmentProposal();
    ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService.getBudget(developmentProposal);

    PHS398TrainingBudget trainingBudgetType = PHS398TrainingBudget.Factory.newInstance();
    if (budget != null) {
        trainingBudgetType.setFormVersion(FormVersion.v1_0.getVersion());
        trainingBudgetType.setBudgetType(BudgetType.PROJECT);
        setOrganizationData(trainingBudgetType, developmentProposal);
    } else {/*from  w  ww.j  a v  a2  s . c o m*/
        return trainingBudgetType;
    }

    int numPeople = 0;

    BigDecimal stipendAmountOtherFull = new BigDecimal("0"), stipendAmountOtherShort = new BigDecimal("0");
    BigDecimal stipendAmountF = new BigDecimal("0"), stipendAmountJ = new BigDecimal("0");
    BigDecimal stipendAmountPreSingFull = new BigDecimal("0"), stipendAmountPreDualFull = new BigDecimal("0");
    BigDecimal stipendAmountPreSingShort = new BigDecimal("0"), stipendAmountPreDualShort = new BigDecimal("0");
    BigDecimal stipendAmount0 = new BigDecimal("0"), stipendAmount1 = new BigDecimal("0"),
            stipendAmount2 = new BigDecimal("0"), stipendAmount3 = new BigDecimal("0"),
            stipendAmount4 = new BigDecimal("0");
    BigDecimal stipendAmount5 = new BigDecimal("0"), stipendAmount6 = new BigDecimal("0"),
            stipendAmount7 = new BigDecimal("0");
    BigDecimal stipendAmountDeg0 = new BigDecimal("0"), stipendAmountDeg1 = new BigDecimal("0"),
            stipendAmountDeg2 = new BigDecimal("0"), stipendAmountDeg3 = new BigDecimal("0"),
            stipendAmountDeg4 = new BigDecimal("0");
    BigDecimal stipendAmountDeg5 = new BigDecimal("0"), stipendAmountDeg6 = new BigDecimal("0"),
            stipendAmountDeg7 = new BigDecimal("0");
    BigDecimal stipendAmountNonDeg0 = new BigDecimal("0"), stipendAmountNonDeg1 = new BigDecimal("0"),
            stipendAmountNonDeg2 = new BigDecimal("0"), stipendAmountNonDeg3 = new BigDecimal("0"),
            stipendAmountNonDeg4 = new BigDecimal("0");
    BigDecimal stipendAmountNonDeg5 = new BigDecimal("0"), stipendAmountNonDeg6 = new BigDecimal("0"),
            stipendAmountNonDeg7 = new BigDecimal("0");

    /***** cumulative stipends **/
    BigDecimal cumUndergradStipends = new BigDecimal("0"), cumPreDocSingleStipends = new BigDecimal("0"),
            cumPreDocDualStipends = new BigDecimal("0"), cumPreDocTotalStipends = new BigDecimal("0");
    BigDecimal cumPostDocNonDegStipends = new BigDecimal("0"), cumPostDocDegStipends = new BigDecimal("0"),
            cumPostDocTotalStipends = new BigDecimal("0");
    BigDecimal cumOtherStipends = new BigDecimal("0");

    /***** cumulative tuition **/
    BigDecimal cumUndergradTuition = new BigDecimal("0"), cumPreDocSingleTuition = new BigDecimal("0"),
            cumPreDocDualTuition = new BigDecimal("0"), cumPreDocTotalTuition = new BigDecimal("0");
    BigDecimal cumPostDocNonDegTuition = new BigDecimal("0"), cumPostDocDegTuition = new BigDecimal("0"),
            cumPostDocTotalTuition = new BigDecimal("0");
    BigDecimal cumOtherTuition = new BigDecimal("0");

    /********** cumulative costs **/
    BigDecimal cumTrainingCosts = new BigDecimal("0"), cumTravelCosts = new BigDecimal("0"),
            cumConsCosts = new BigDecimal("0");
    BigDecimal cumResearchTotalDirectCosts = new BigDecimal("0"),
            cumTotalOtherDirectCosts = new BigDecimal("0"), cumTotalDirectCosts = new BigDecimal("0");
    BigDecimal cumTotalIndCosts1 = new BigDecimal("0"), cumTotalIndCosts2 = new BigDecimal("0"),
            cumTotalIndCosts = new BigDecimal("0");
    BigDecimal cumTotalDirectAndIndCosts = new BigDecimal("0");

    BigDecimal researchDirectCosts = new BigDecimal("0");
    BigDecimal totalOtherDirectCostsRequested = new BigDecimal("0");
    /********************************
     * get budget periods
     *********************************/
    List<? extends BudgetPeriodContract> budgetPeriods = budget.getBudgetPeriods();
    for (BudgetPeriodContract budgetPeriod : budgetPeriods) {
        PHS398TrainingBudgetYearDataType phs398TrainingBudgetYearDataType = trainingBudgetType
                .addNewBudgetYear();
        ScaleTwoDecimal trainingTraveCost = getBudgetPeriodCost(budgetPeriod,
                ConfigurationConstants.TRAINEE_TRAVEL_COST_ELEMENTS);
        phs398TrainingBudgetYearDataType.setTraineeTravelRequested(trainingTraveCost.bigDecimalValue());
        ScaleTwoDecimal trainingCost = getBudgetPeriodCost(budgetPeriod,
                ConfigurationConstants.TRAINING_REL_COST_ELEMENTS);
        phs398TrainingBudgetYearDataType.setTrainingRelatedExpensesRequested(trainingCost.bigDecimalValue());
        ScaleTwoDecimal consTrainingCost = getBudgetPeriodCost(budgetPeriod,
                ConfigurationConstants.SUBCONTRACT_COST_ELEMENTS);
        phs398TrainingBudgetYearDataType
                .setConsortiumTrainingCostsRequested(consTrainingCost.bigDecimalValue());

        phs398TrainingBudgetYearDataType.setPostdocNonDegreeTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_POSTDOC_NONDEG_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType.setPostdocDegreeTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_POSTDOC_DEG_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType.setUndergraduateTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_UNDERGRAD_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType.setPredocDualDegreeTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_PREDOC_DUAL_DEG_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType
                .setPredocSingleDegreeTuitionAndFeesRequested(getBudgetPeriodCost(budgetPeriod,
                        ConfigurationConstants.TUITION_PREDOC_SINGLE_DEG_COST_ELEMENTS).bigDecimalValue());
        phs398TrainingBudgetYearDataType.setOtherTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_OTHER_COST_ELEMENTS)
                        .bigDecimalValue());

        phs398TrainingBudgetYearDataType.setPeriodEndDate(DateUtils.toCalendar(budgetPeriod.getEndDate()));
        phs398TrainingBudgetYearDataType.setPeriodStartDate(DateUtils.toCalendar(budgetPeriod.getStartDate()));

        /******************************
         * add to cumulative amounts for tuition and costs
         ******************************/
        cumUndergradTuition = cumUndergradTuition
                .add(phs398TrainingBudgetYearDataType.getUndergraduateTuitionAndFeesRequested());
        cumPreDocSingleTuition = cumPreDocSingleTuition
                .add(phs398TrainingBudgetYearDataType.getPredocSingleDegreeTuitionAndFeesRequested());
        cumPreDocDualTuition = cumPreDocDualTuition
                .add(phs398TrainingBudgetYearDataType.getPredocDualDegreeTuitionAndFeesRequested());

        cumPostDocNonDegTuition = cumPostDocNonDegTuition
                .add(phs398TrainingBudgetYearDataType.getPostdocNonDegreeTuitionAndFeesRequested());
        cumPostDocDegTuition = cumPostDocDegTuition
                .add(phs398TrainingBudgetYearDataType.getPostdocDegreeTuitionAndFeesRequested());
        cumPostDocTotalTuition = cumPostDocNonDegTuition.add(cumPostDocDegTuition);
        cumOtherTuition = cumOtherTuition
                .add(phs398TrainingBudgetYearDataType.getOtherTuitionAndFeesRequested());
        cumTrainingCosts = cumTrainingCosts
                .add(phs398TrainingBudgetYearDataType.getTrainingRelatedExpensesRequested());
        cumTravelCosts = cumTravelCosts.add(phs398TrainingBudgetYearDataType.getTraineeTravelRequested());
        cumConsCosts = cumConsCosts.add(phs398TrainingBudgetYearDataType.getConsortiumTrainingCostsRequested());

        /************************
         * getting first two indirect cost type
         ************************/

        IndirectCostDto indirectCostInfo = s2sBudgetCalculatorService.getIndirectCosts(budget, budgetPeriod);
        List<IndirectCostDetailsDto> cvIndirectCost = indirectCostInfo.getIndirectCostDetails();
        BigDecimal totIndCosts = new BigDecimal("0");
        for (int i = 0; i < cvIndirectCost.size() & i < CV_INDIRECT_COST_LIMIT; i++) {
            IndirectCostDetailsDto indireCost = cvIndirectCost.get(i);
            totIndCosts = totIndCosts.add(indireCost.getFunds().bigDecimalValue());
            switch (i) {
            case (0):
                phs398TrainingBudgetYearDataType.setIndirectCostType1(indireCost.getCostType());
                phs398TrainingBudgetYearDataType.setIndirectCostBase1(indireCost.getBase().bigDecimalValue());
                phs398TrainingBudgetYearDataType
                        .setIndirectCostFundsRequested1(indireCost.getFunds().bigDecimalValue());
                phs398TrainingBudgetYearDataType.setIndirectCostRate1(indireCost.getRate().bigDecimalValue());
                cumTotalIndCosts1 = cumTotalIndCosts1
                        .add(phs398TrainingBudgetYearDataType.getIndirectCostFundsRequested1());
                break;
            case (1):
                phs398TrainingBudgetYearDataType.setIndirectCostType1(indireCost.getCostType());
                phs398TrainingBudgetYearDataType.setIndirectCostBase2(indireCost.getBase().bigDecimalValue());
                phs398TrainingBudgetYearDataType
                        .setIndirectCostFundsRequested2(indireCost.getFunds().bigDecimalValue());
                phs398TrainingBudgetYearDataType.setIndirectCostRate2(indireCost.getRate().bigDecimalValue());
                cumTotalIndCosts2 = cumTotalIndCosts2
                        .add(phs398TrainingBudgetYearDataType.getIndirectCostFundsRequested2());
                break;
            default:
                break;
            }

        }
        phs398TrainingBudgetYearDataType.setTotalIndirectCostsRequested(totIndCosts);

        int numPostDocLevel0, numPostDocLevel1, numPostDocLevel2, numPostDocLevel3, numPostDocLevel4 = 0;
        int numPostDocLevel5, numPostDocLevel6, numPostDocLevel7 = 0;

        Map<String, String> hmNonDegree = new HashMap<>();
        Map<String, String> hmDegree = new HashMap<>();

        hmNonDegree.put("fulllevel0", "0");
        hmNonDegree.put("fulllevel1", "0");
        hmNonDegree.put("fulllevel2", "0");
        hmNonDegree.put("fulllevel3", "0");
        hmNonDegree.put("fulllevel4", "0");
        hmNonDegree.put("fulllevel5", "0");
        hmNonDegree.put("fulllevel6", "0");
        hmNonDegree.put("fulllevel7", "0");
        hmNonDegree.put("shortlevel0", "0");
        hmNonDegree.put("shortlevel1", "0");
        hmNonDegree.put("shortlevel2", "0");
        hmNonDegree.put("shortlevel3", "0");
        hmNonDegree.put("shortlevel4", "0");
        hmNonDegree.put("shortlevel5", "0");
        hmNonDegree.put("shortlevel6", "0");
        hmNonDegree.put("shortlevel7", "0");

        /********************************************************
         * get questionnaire answers for undergrads and predocs and others
         ********************************************************/

        String answer = null;
        int preDocCountFull = 0, preDocCountShort = 0;
        int undergradFirstYearNum = 0, undergradJrNum = 0;
        BigDecimal otherShortStipends = new BigDecimal("0"), otherFullStipends = new BigDecimal("0");
        List<? extends AnswerHeaderContract> answerHeaders = findQuestionnaireWithAnswers(developmentProposal);
        if (answerHeaders != null) {
            for (AnswerHeaderContract answerHeader : answerHeaders) {
                QuestionnaireContract questionnaire = getQuestionAnswerService()
                        .findQuestionnaireById(answerHeader.getQuestionnaireId());
                List<? extends QuestionnaireQuestionContract> questionnaireQuestions = questionnaire
                        .getQuestionnaireQuestions();
                for (QuestionnaireQuestionContract questionnaireQuestion : questionnaireQuestions) {
                    AnswerContract answerBO = getAnswer(questionnaireQuestion, answerHeader);
                    answer = answerBO.getAnswer();
                    QuestionContract question = questionnaireQuestion.getQuestion();
                    if (answer != null) {
                        int answerIntVal = 0;
                        try {
                            answerIntVal = Integer.parseInt(answer);
                        } catch (NumberFormatException ex) {
                        }
                        if (isPreDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod)) {
                            switch (question.getQuestionSeqId()) {
                            case 72:
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setUndergraduateNumFullTime(answerIntVal);
                                break;
                            case 73:
                                // short term undergrad
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setUndergraduateNumShortTerm(answerIntVal);
                                break;
                            case 74:
                                // stipends first year
                                if (answer != null)
                                    undergradFirstYearNum = undergradFirstYearNum + answerIntVal;

                                break;
                            case 75:
                                // stipends junior
                                if (answer != null)
                                    undergradJrNum = undergradJrNum + answerIntVal;

                                break;
                            case 77:
                                // full time single degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocSingleDegreeNumFullTime(answerIntVal);
                                    preDocCountFull = preDocCountFull + phs398TrainingBudgetYearDataType
                                            .getPredocSingleDegreeNumFullTime();
                                }
                                break;
                            case 78:
                                // short term single degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocSingleDegreeNumShortTerm(answerIntVal);
                                    preDocCountShort = preDocCountShort + phs398TrainingBudgetYearDataType
                                            .getPredocSingleDegreeNumShortTerm();
                                }
                                break;
                            case 79:
                                // full term dual degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocDualDegreeNumFullTime(answerIntVal);
                                    preDocCountFull = preDocCountFull
                                            + phs398TrainingBudgetYearDataType.getPredocDualDegreeNumFullTime();
                                }
                                break;
                            case 80:
                                // short term dual degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocDualDegreeNumShortTerm(answerIntVal);
                                    preDocCountShort = preDocCountShort + phs398TrainingBudgetYearDataType
                                            .getPredocDualDegreeNumShortTerm();
                                }
                                break;
                            case 95:
                                // others full term
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setOtherNumFullTime(answerIntVal);
                                break;
                            case 97:
                                // others short term
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setOtherNumShortTerm(answerIntVal);
                                break;
                            case 96:
                                // others full term stipend
                                if (answer != null)
                                    otherFullStipends = new BigDecimal(answer);
                                break;
                            case 98:
                                // others short term stipend
                                if (answer != null)
                                    otherShortStipends = new BigDecimal(answer);
                                break;
                            }
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                FN_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmNonDegree.put("fulllevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmNonDegree.put("fulllevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmNonDegree.put("fulllevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmNonDegree.put("fulllevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmNonDegree.put("fulllevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmNonDegree.put("fulllevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmNonDegree.put("fulllevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmNonDegree.put("fulllevel7", answer);
                                break;
                            default:
                                break;
                            }
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                SN_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmNonDegree.put("shortlevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmNonDegree.put("shortlevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmNonDegree.put("shortlevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmNonDegree.put("shortlevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmNonDegree.put("shortlevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmNonDegree.put("shortlevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmNonDegree.put("shortlevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmNonDegree.put("shortlevel7", answer);
                                break;
                            default:
                                break;

                            }
                        }
                    }
                }
            }
        }
        phs398TrainingBudgetYearDataType.setUndergraduateNumFirstYearSophomoreStipends(undergradFirstYearNum);
        phs398TrainingBudgetYearDataType.setUndergraduateNumJuniorSeniorStipends(undergradJrNum);
        phs398TrainingBudgetYearDataType.setOtherStipendsRequested(otherShortStipends.add(otherFullStipends));
        phs398TrainingBudgetYearDataType.setPredocTotalNumShortTerm(preDocCountShort);
        phs398TrainingBudgetYearDataType.setPredocTotalNumFullTime(preDocCountFull);
        cumOtherStipends = cumOtherStipends.add(phs398TrainingBudgetYearDataType.getOtherStipendsRequested());

        /***********************************************************
         * set post doc non degree full time total number
         ***********************************************************/

        int postDocNumNonDegreeFullTime = Integer.parseInt(hmNonDegree.get("fulllevel0"))
                + Integer.parseInt(hmNonDegree.get("fulllevel1"))
                + Integer.parseInt(hmNonDegree.get("fulllevel2"))
                + Integer.parseInt(hmNonDegree.get("fulllevel3"))
                + Integer.parseInt(hmNonDegree.get("fulllevel4"))
                + Integer.parseInt(hmNonDegree.get("fulllevel5"))
                + Integer.parseInt(hmNonDegree.get("fulllevel6"))
                + Integer.parseInt(hmNonDegree.get("fulllevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumNonDegreeFullTime(postDocNumNonDegreeFullTime);

        /***********************************************************
         * set post doc non degree short term total number
         ***********************************************************/

        int postDocNumNonDegreeShortTerm = Integer.parseInt(hmNonDegree.get("shortlevel0"))
                + Integer.parseInt(hmNonDegree.get("shortlevel1"))
                + Integer.parseInt(hmNonDegree.get("shortlevel2"))
                + Integer.parseInt(hmNonDegree.get("shortlevel3"))
                + Integer.parseInt(hmNonDegree.get("shortlevel4"))
                + Integer.parseInt(hmNonDegree.get("shortlevel5"))
                + Integer.parseInt(hmNonDegree.get("shortlevel6"))
                + Integer.parseInt(hmNonDegree.get("shortlevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumNonDegreeShortTerm(postDocNumNonDegreeShortTerm);

        /************************************************
         * set post doc non degree level numbers
         *************************************************/
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel0(Integer.parseInt(hmNonDegree.get("fulllevel0"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel0")));

        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel1(Integer.parseInt(hmNonDegree.get("fulllevel1"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel1")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel2(Integer.parseInt(hmNonDegree.get("fulllevel2"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel2")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel3(Integer.parseInt(hmNonDegree.get("fulllevel3"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel3")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel4(Integer.parseInt(hmNonDegree.get("fulllevel4"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel4")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel5(Integer.parseInt(hmNonDegree.get("fulllevel5"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel5")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel6(Integer.parseInt(hmNonDegree.get("fulllevel6"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel6")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel7(Integer.parseInt(hmNonDegree.get("fulllevel7"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel7")));

        answer = null;

        hmDegree.put("fulllevel0", "0");
        hmDegree.put("fulllevel1", "0");
        hmDegree.put("fulllevel2", "0");
        hmDegree.put("fulllevel3", "0");
        hmDegree.put("fulllevel4", "0");
        hmDegree.put("fulllevel5", "0");
        hmDegree.put("fulllevel6", "0");
        hmDegree.put("fulllevel7", "0");
        hmDegree.put("shortlevel0", "0");
        hmDegree.put("shortlevel1", "0");
        hmDegree.put("shortlevel2", "0");
        hmDegree.put("shortlevel3", "0");
        hmDegree.put("shortlevel4", "0");
        hmDegree.put("shortlevel5", "0");
        hmDegree.put("shortlevel6", "0");
        hmDegree.put("shortlevel7", "0");
        if (answerHeaders != null) {
            for (AnswerHeaderContract answerHeader : answerHeaders) {
                QuestionnaireContract questionnaire = getQuestionAnswerService()
                        .findQuestionnaireById(answerHeader.getQuestionnaireId());
                List<? extends QuestionnaireQuestionContract> questionnaireQuestions = questionnaire
                        .getQuestionnaireQuestions();
                for (QuestionnaireQuestionContract questionnaireQuestion : questionnaireQuestions) {
                    AnswerContract answerBO = getAnswer(questionnaireQuestion, answerHeader);
                    answer = answerBO.getAnswer();
                    QuestionContract question = questionnaireQuestion.getQuestion();
                    if (answer != null) {
                        int answerIntVal = 0;
                        try {
                            answerIntVal = Integer.parseInt(answer);
                        } catch (NumberFormatException ex) {
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                FD_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmDegree.put("fulllevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmDegree.put("fulllevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmDegree.put("fulllevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmDegree.put("fulllevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmDegree.put("fulllevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmDegree.put("fulllevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmDegree.put("fulllevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmDegree.put("fulllevel7", answer);
                                break;
                            default:
                                break;

                            }
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                SD_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmDegree.put("shortlevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmDegree.put("shortlevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmDegree.put("shortlevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmDegree.put("shortlevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmDegree.put("shortlevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmDegree.put("shortlevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmDegree.put("shortlevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmDegree.put("shortlevel7", answer);
                                break;
                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }

        /******************************************************
         * set post doc degree seeking numbers for each level
         ******************************************************/
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel0(
                Integer.parseInt(hmDegree.get("fulllevel0")) + Integer.parseInt(hmDegree.get("shortlevel0")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel1(
                Integer.parseInt(hmDegree.get("fulllevel1")) + Integer.parseInt(hmDegree.get("shortlevel1")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel2(
                Integer.parseInt(hmDegree.get("fulllevel2")) + Integer.parseInt(hmDegree.get("shortlevel2")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel3(
                Integer.parseInt(hmDegree.get("fulllevel3")) + Integer.parseInt(hmDegree.get("shortlevel3")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel4(
                Integer.parseInt(hmDegree.get("fulllevel4")) + Integer.parseInt(hmDegree.get("shortlevel4")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel5(
                Integer.parseInt(hmDegree.get("fulllevel5")) + Integer.parseInt(hmDegree.get("shortlevel5")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel6(
                Integer.parseInt(hmDegree.get("fulllevel6")) + Integer.parseInt(hmDegree.get("shortlevel6")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel7(
                Integer.parseInt(hmDegree.get("fulllevel7")) + Integer.parseInt(hmDegree.get("shortlevel7")));

        /************************************************
         * set post doc degree seeking full time number
         **********************************************/

        int postDocNumDegreeFulltime = Integer.parseInt(hmDegree.get("fulllevel0"))
                + Integer.parseInt(hmDegree.get("fulllevel1")) + Integer.parseInt(hmDegree.get("fulllevel2"))
                + Integer.parseInt(hmDegree.get("fulllevel3")) + Integer.parseInt(hmDegree.get("fulllevel4"))
                + Integer.parseInt(hmDegree.get("fulllevel5")) + Integer.parseInt(hmDegree.get("fulllevel6"))
                + Integer.parseInt(hmDegree.get("fulllevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumDegreeFullTime(postDocNumDegreeFulltime);

        /***********************************************
         *set post doc degree seeking short term number
         * ************************************************/

        int postDocNumDegreeShortTerm = Integer.parseInt(hmDegree.get("shortlevel0"))
                + Integer.parseInt(hmDegree.get("shortlevel1")) + Integer.parseInt(hmDegree.get("shortlevel2"))
                + Integer.parseInt(hmDegree.get("shortlevel3")) + Integer.parseInt(hmDegree.get("shortlevel4"))
                + Integer.parseInt(hmDegree.get("shortlevel5")) + Integer.parseInt(hmDegree.get("shortlevel6"))
                + Integer.parseInt(hmDegree.get("shortlevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumDegreeShortTerm(postDocNumDegreeShortTerm);

        // Total numbers of post docs
        phs398TrainingBudgetYearDataType
                .setPostdocTotalShortTerm(phs398TrainingBudgetYearDataType.getPostdocNumDegreeShortTerm()
                        + phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeShortTerm());

        phs398TrainingBudgetYearDataType
                .setPostdocTotalFullTime(phs398TrainingBudgetYearDataType.getPostdocNumDegreeFullTime()
                        + phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeFullTime());

        // total numbers of post docs for each level
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel0(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel0()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel0());

        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel1(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel1()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel1());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel2(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel2()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel2());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel3(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel3()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel3());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel4(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel4()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel4());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel5(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel5()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel5());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel6(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel6()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel6());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel7(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel7()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel7());

        /******************************************************
         * get stipend amounts
         ******************************************************/

        // undergrad
        numPeople = phs398TrainingBudgetYearDataType.getUndergraduateNumFirstYearSophomoreStipends();
        stipendAmountF = getStipendAmount(budgetPeriod, UNDERGRADS, 0, numPeople);
        numPeople = phs398TrainingBudgetYearDataType.getUndergraduateNumJuniorSeniorStipends();
        stipendAmountJ = getStipendAmount(budgetPeriod, UNDERGRADS, 1, numPeople);
        phs398TrainingBudgetYearDataType.setUndergraduateStipendsRequested(stipendAmountF.add(stipendAmountJ));

        cumUndergradStipends = cumUndergradStipends
                .add(phs398TrainingBudgetYearDataType.getUndergraduateStipendsRequested());

        // predoc
        numPeople = phs398TrainingBudgetYearDataType.getPredocSingleDegreeNumFullTime();
        stipendAmountPreSingFull = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);
        numPeople = phs398TrainingBudgetYearDataType.getPredocDualDegreeNumFullTime();
        stipendAmountPreDualFull = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);

        numPeople = phs398TrainingBudgetYearDataType.getPredocSingleDegreeNumShortTerm();
        stipendAmountPreSingShort = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);
        numPeople = phs398TrainingBudgetYearDataType.getPredocDualDegreeNumShortTerm();
        stipendAmountPreDualShort = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);

        phs398TrainingBudgetYearDataType.setPredocSingleDegreeStipendsRequested(
                stipendAmountPreSingFull.add(stipendAmountPreSingShort));
        phs398TrainingBudgetYearDataType
                .setPredocDualDegreeStipendsRequested(stipendAmountPreDualFull.add(stipendAmountPreDualShort));
        phs398TrainingBudgetYearDataType.setPredocTotalStipendsRequested(stipendAmountPreSingFull
                .add(stipendAmountPreDualFull.add(stipendAmountPreSingShort).add(stipendAmountPreDualShort)));

        // cumulative amounts
        cumPreDocSingleStipends = cumPreDocSingleStipends.add(stipendAmountPreSingFull)
                .add(stipendAmountPreSingShort);
        cumPreDocDualStipends = cumPreDocDualStipends.add(stipendAmountPreDualFull)
                .add(stipendAmountPreDualShort);
        cumPreDocTotalStipends = cumPreDocSingleStipends.add(cumPreDocDualStipends);
        cumPreDocTotalTuition = cumPreDocDualTuition.add(cumPreDocSingleTuition);

        // postdoc

        numPostDocLevel0 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel0();
        stipendAmountNonDeg0 = getStipendAmount(budgetPeriod, POSTDOC, 0, numPostDocLevel0);
        numPostDocLevel0 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel0();
        stipendAmountDeg0 = getStipendAmount(budgetPeriod, POSTDOC, 0, numPostDocLevel0);

        numPostDocLevel1 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel1();
        stipendAmountNonDeg1 = getStipendAmount(budgetPeriod, POSTDOC, 1, numPostDocLevel1);
        numPostDocLevel1 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel1();
        stipendAmountDeg1 = getStipendAmount(budgetPeriod, POSTDOC, 1, numPostDocLevel1);

        numPostDocLevel2 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel2();
        stipendAmountNonDeg2 = getStipendAmount(budgetPeriod, POSTDOC, 2, numPostDocLevel2);
        numPostDocLevel2 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel2();
        stipendAmountDeg2 = getStipendAmount(budgetPeriod, POSTDOC, 2, numPostDocLevel2);

        numPostDocLevel3 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel3();
        stipendAmountNonDeg3 = getStipendAmount(budgetPeriod, POSTDOC, 3, numPostDocLevel3);
        numPostDocLevel3 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel3();
        stipendAmountDeg3 = getStipendAmount(budgetPeriod, POSTDOC, 3, numPostDocLevel3);

        numPostDocLevel4 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel4();
        stipendAmountNonDeg4 = getStipendAmount(budgetPeriod, POSTDOC, 4, numPostDocLevel4);
        numPostDocLevel4 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel4();
        stipendAmountDeg4 = getStipendAmount(budgetPeriod, POSTDOC, 4, numPostDocLevel4);

        numPostDocLevel5 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel5();
        stipendAmountNonDeg5 = getStipendAmount(budgetPeriod, POSTDOC, 5, numPostDocLevel5);
        numPostDocLevel5 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel5();
        stipendAmountDeg5 = getStipendAmount(budgetPeriod, POSTDOC, 5, numPostDocLevel5);

        numPostDocLevel6 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel6();
        stipendAmountNonDeg6 = getStipendAmount(budgetPeriod, POSTDOC, 6, numPostDocLevel6);
        numPostDocLevel6 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel6();
        stipendAmountDeg6 = getStipendAmount(budgetPeriod, POSTDOC, 6, numPostDocLevel6);

        numPostDocLevel7 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel7();
        stipendAmountNonDeg7 = getStipendAmount(budgetPeriod, POSTDOC, 7, numPostDocLevel7);
        numPostDocLevel7 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel7();
        stipendAmountDeg7 = getStipendAmount(budgetPeriod, POSTDOC, 7, numPostDocLevel7);

        phs398TrainingBudgetYearDataType.setPostdocDegreeStipendsRequested(stipendAmountDeg0
                .add(stipendAmountDeg1).add(stipendAmountDeg2).add(stipendAmountDeg3).add(stipendAmountDeg4)
                .add(stipendAmountDeg5).add(stipendAmountDeg6).add(stipendAmountDeg7));

        phs398TrainingBudgetYearDataType
                .setPostdocNonDegreeStipendsRequested(stipendAmountNonDeg0.add(stipendAmountNonDeg1)
                        .add(stipendAmountNonDeg2).add(stipendAmountNonDeg3).add(stipendAmountNonDeg4)
                        .add(stipendAmountNonDeg5).add(stipendAmountNonDeg6).add(stipendAmountNonDeg7));

        phs398TrainingBudgetYearDataType.setPostdocTotalStipendsRequested(
                phs398TrainingBudgetYearDataType.getPostdocNonDegreeStipendsRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocDegreeStipendsRequested()));

        /******************************************************
         * set total amounts
         ******************************************************/

        phs398TrainingBudgetYearDataType.setPostdocTotalTuitionAndFeesRequested(
                phs398TrainingBudgetYearDataType.getPostdocDegreeTuitionAndFeesRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocNonDegreeTuitionAndFeesRequested()));
        phs398TrainingBudgetYearDataType.setPredocTotalTuitionAndFeesRequested(
                phs398TrainingBudgetYearDataType.getPredocDualDegreeTuitionAndFeesRequested()
                        .add(phs398TrainingBudgetYearDataType.getPredocSingleDegreeTuitionAndFeesRequested()));
        phs398TrainingBudgetYearDataType.setTotalTuitionAndFeesRequested(
                phs398TrainingBudgetYearDataType.getPredocTotalTuitionAndFeesRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocTotalTuitionAndFeesRequested().add(
                                phs398TrainingBudgetYearDataType.getUndergraduateTuitionAndFeesRequested()))
                        .add(phs398TrainingBudgetYearDataType.getOtherTuitionAndFeesRequested()));
        phs398TrainingBudgetYearDataType
                .setTotalStipendsRequested(phs398TrainingBudgetYearDataType.getPostdocTotalStipendsRequested()
                        .add(phs398TrainingBudgetYearDataType.getPredocTotalStipendsRequested()
                                .add(phs398TrainingBudgetYearDataType.getUndergraduateStipendsRequested()))
                        .add(phs398TrainingBudgetYearDataType.getOtherStipendsRequested()));
        phs398TrainingBudgetYearDataType.setTotalStipendsAndTuitionFeesRequested(
                phs398TrainingBudgetYearDataType.getTotalStipendsRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocTotalTuitionAndFeesRequested()
                                .add(phs398TrainingBudgetYearDataType.getPredocTotalTuitionAndFeesRequested()
                                        .add(phs398TrainingBudgetYearDataType
                                                .getUndergraduateTuitionAndFeesRequested()
                                                .add(phs398TrainingBudgetYearDataType
                                                        .getOtherTuitionAndFeesRequested())))));

        // the total tdirect costs from r and r budget line, which is RESEARCH_DIRECT_COST, has to have the
        // total stipends and tuition subtracted from it.

        researchDirectCosts = budgetPeriod.getTotalDirectCost().subtract(trainingCost)
                .subtract(trainingTraveCost).subtract(consTrainingCost).bigDecimalValue();
        researchDirectCosts = researchDirectCosts
                .subtract(phs398TrainingBudgetYearDataType.getTotalStipendsAndTuitionFeesRequested());
        phs398TrainingBudgetYearDataType.setResearchDirectCostsRequested(researchDirectCosts);
        if (phs398TrainingBudgetYearDataType.getResearchDirectCostsRequested() != null) {
            Double researchDirectCostValue = phs398TrainingBudgetYearDataType.getResearchDirectCostsRequested()
                    .doubleValue();
            if (researchDirectCostValue < ZERO) {
                String researchDirectCostValueStipend = researchDirectCostValue.toString();
                String budgetYear = budgetPeriod.getBudgetPeriod().toString();
                AuditError stipendError = new AuditError(AuditError.NO_FIELD_ERROR_KEY,
                        GRANTS_GOV_STIPEND_ERROR_MESSAGE, AuditError.GG_LINK);
                String errorMessage = stipendError.getMessageKey();
                errorMessage = errorMessage.replace(STIPEND_AMOUNT, researchDirectCostValueStipend);
                errorMessage = errorMessage.replace(BUDGET_PERIOD, budgetYear);
                stipendError.setMessageKey(errorMessage);
                getAuditErrors().add(stipendError);
            }
        }

        totalOtherDirectCostsRequested = budgetPeriod.getTotalDirectCost().bigDecimalValue();
        totalOtherDirectCostsRequested = totalOtherDirectCostsRequested
                .subtract(phs398TrainingBudgetYearDataType.getTotalStipendsAndTuitionFeesRequested());
        phs398TrainingBudgetYearDataType.setTotalOtherDirectCostsRequested(totalOtherDirectCostsRequested);

        phs398TrainingBudgetYearDataType.setTotalDirectCostsRequested(
                phs398TrainingBudgetYearDataType.getTotalOtherDirectCostsRequested()
                        .add(phs398TrainingBudgetYearDataType.getTotalStipendsAndTuitionFeesRequested()));

        phs398TrainingBudgetYearDataType.setTotalDirectAndIndirectCostsRequested(
                phs398TrainingBudgetYearDataType.getTotalDirectCostsRequested()
                        .add(phs398TrainingBudgetYearDataType.getTotalIndirectCostsRequested()));

        /******************************************************
         * add to cumulative amounts
         ******************************************************/

        cumPostDocNonDegStipends = cumPostDocNonDegStipends
                .add(phs398TrainingBudgetYearDataType.getPostdocNonDegreeStipendsRequested());
        cumPostDocDegStipends = cumPostDocDegStipends
                .add(phs398TrainingBudgetYearDataType.getPostdocDegreeStipendsRequested());
        cumPostDocTotalStipends = cumPostDocNonDegStipends.add(cumPostDocDegStipends);

        cumResearchTotalDirectCosts = cumResearchTotalDirectCosts
                .add(phs398TrainingBudgetYearDataType.getResearchDirectCostsRequested());
        cumTotalOtherDirectCosts = cumTotalOtherDirectCosts
                .add(phs398TrainingBudgetYearDataType.getTotalOtherDirectCostsRequested());

    }

    // cumulative amounts
    trainingBudgetType.setCumulativeUndergraduateStipendsRequested(cumUndergradStipends);
    trainingBudgetType.setCumulativeUndergraduateTuitionAndFeesRequested(cumUndergradTuition);

    trainingBudgetType.setCumulativeOtherStipendsRequested(cumOtherStipends);
    trainingBudgetType.setCumulativeOtherTuitionAndFeesRequested(cumOtherTuition);
    trainingBudgetType.setCumulativePostdocDegreeStipendsRequested(cumPostDocDegStipends);
    trainingBudgetType.setCumulativePostdocDegreeTuitionAndFeesRequested(cumPostDocDegTuition);
    trainingBudgetType.setCumulativePostdocNonDegreeStipendsRequested(cumPostDocNonDegStipends);
    trainingBudgetType.setCumulativePostdocNonDegreeTuitionAndFeesRequested(cumPostDocNonDegTuition);
    trainingBudgetType.setCumulativePostdocTotalStipendsRequested(cumPostDocTotalStipends);
    trainingBudgetType.setCumulativePostdocTotalTuitionAndFeesRequested(cumPostDocTotalTuition);

    trainingBudgetType.setCumulativePredocDualDegreeStipendsRequested(cumPreDocDualStipends);
    trainingBudgetType.setCumulativePredocDualDegreeTuitionAndFeesRequested(cumPreDocDualTuition);
    trainingBudgetType.setCumulativePredocSingleDegreeStipendsRequested(cumPreDocSingleStipends);
    trainingBudgetType.setCumulativePredocSingleDegreeTuitionAndFeesRequested(cumPreDocSingleTuition);
    trainingBudgetType.setCumulativePredocTotalStipendsRequested(cumPreDocTotalStipends);
    trainingBudgetType.setCumulativePredocTotalTuitionAndFeesRequested(cumPreDocTotalTuition);

    trainingBudgetType.setCumulativeTotalStipendsRequested(cumPostDocTotalStipends.add(cumPreDocTotalStipends)
            .add(cumOtherStipends).add(cumUndergradStipends));

    trainingBudgetType.setCumulativeTuitionAndFeesRequested(
            cumPostDocTotalTuition.add(cumPreDocTotalTuition).add(cumOtherTuition).add(cumUndergradTuition));
    trainingBudgetType.setCumulativeTotalStipendsAndTuitionFeesRequested(
            trainingBudgetType.getCumulativeTotalStipendsRequested()
                    .add(trainingBudgetType.getCumulativeTuitionAndFeesRequested()));

    trainingBudgetType.setCumulativeConsortiumTrainingCostsRequested(cumConsCosts);
    trainingBudgetType.setCumulativeResearchDirectCostsRequested(cumResearchTotalDirectCosts);

    trainingBudgetType.setCumulativeTotalDirectCostsRequested(trainingBudgetType
            .getCumulativeTotalStipendsAndTuitionFeesRequested().add(cumTotalOtherDirectCosts));
    trainingBudgetType.setCumulativeTotalIndirectCostsRequested(cumTotalIndCosts1.add(cumTotalIndCosts2));
    trainingBudgetType.setCumulativeTotalOtherDirectCostsRequested(cumTotalOtherDirectCosts);
    trainingBudgetType.setCumulativeTotalDirectAndIndirectCostsRequested(trainingBudgetType
            .getCumulativeTotalDirectCostsRequested().add(cumTotalIndCosts1.add(cumTotalIndCosts2)));
    trainingBudgetType.setCumulativeTraineeTravelRequested(cumTravelCosts);
    trainingBudgetType.setCumulativeTrainingRelatedExpensesRequested(cumTrainingCosts);

    AttachedFileDataType attachedFileDataType = null;
    for (NarrativeContract narrative : developmentProposal.getNarratives()) {
        if (narrative.getNarrativeType().getCode() != null) {
            if (Integer.parseInt(
                    narrative.getNarrativeType().getCode()) == PHS_TRAINING_BUDGET_BUDGETJUSTIFICATION_130) {
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType == null) {
                } else {
                    break;
                }
            }
        }
    }
    if (attachedFileDataType == null) {
        attachedFileDataType = AttachedFileDataType.Factory.newInstance();
    }
    trainingBudgetType.setBudgetJustification(attachedFileDataType);

    return trainingBudgetType;
}

From source file:com.bloatit.web.HtmlTools.java

/**
 * <p>/*from  ww  w.j  a  v a  2 s.c  om*/
 * Compress karma and make it easier to display
 * </p>
 * <p>
 * Example of results :
 * <li>1 = 1</li>
 * <li>100 = 100</li>
 * <li>1000 = 1k</li>
 * <li>100 000 = 100k</li>
 * <li>1 000 000 = 1M</li>
 * <li>100 000 000 = 100M</li>
 * <li>1 000 000 000 = 1T</li>
 * <li>100 000 000 000 = 100T</li>
 * <li>1 000 000 000 000 = </li>
 * </p>
 * 
 * @param karma the karma value to compress
 * @return the compressed String to display
 */
public static String compressKarma(final long karma) {
    final double abs_karma = Math.abs(karma);
    String result = "";
    if (abs_karma < THOUSAND) {
        result = cutNumber(String.valueOf(abs_karma));
    } else if (abs_karma < MILLION) {
        result = cutNumber(Double.toString(abs_karma / THOUSAND).toString()) + "K";
    } else if (abs_karma < BILLION) {
        result = cutNumber(Double.toString(abs_karma / MILLION)) + "M";

    } else if (abs_karma < TRILLION) {
        result = cutNumber(Double.toString(abs_karma / BILLION).toString()) + "T";
    } else {
        result = "";
    }
    if (karma >= 0) {
        return result;
    }
    return "-" + result;
}

From source file:nzilbb.bas.BAS.java

/**
 * Invoke the general MAUS service, for forced alignment given a WAV file and a phonemic transcription.
 * @param LANGUAGE <a href="https://tools.ietf.org/html/rfc5646">RFC 5646</a> tag for identifying the language.
 * @param SIGNAL The signal, in WAV format.
 * @param BPF Phonemic transcription of the utterance to be segmented. Format is a <a href="http://www.bas.uni-muenchen.de/forschung/Bas/BasFormatseng.html">BAS Partitur Format (BPF)</a> file with a KAN tier.
 * @param MINPAUSLEN Controls the behaviour of optional inter-word silence. If set to 1, maus will detect all inter-word silence intervals that can be found (minimum length for a silence interval is then 10 msec = 1 frame). If set to values n&gt;1, the minimum length for an inter-word silence interval to be detected is set to n&times;10 msec.
 * @param STARTWORD If set to a value n&gt;0, this option causes maus to start the segmentation with the word number n (word numbering in BPF starts with 0).
 * @param ENDWORD If set to a value n&lt;999999, this option causes maus to end the segmentation with the word number n (word numbering in BPF starts with 0). 
 * @param RULESET MAUS rule set file; UTF-8 encoded; one rule per line; two different file types defined by the extension: '*.nrul' : phonological rule set without statistical information
 * @param OUTFORMAT Defines the output format:
 *  <ul>//from   ww w .ja va  2  s.  c om
 *   <li>"TextGrid" - a praat compatible TextGrid file</li> 
 *   <li>"par" or "mau-append" - the input BPF file with a new (or replaced) tier MAU</li>
 *   <li>"csv" or "mau" - only the BPF MAU tier (CSV table)</li> 
 *   <li>"legacyEMU" - a file with extension *.EMU that contains in the first part the Emu hlb file (*.hlb) and in the second part the Emu phonetic segmentation (*.phonetic)</li>
 *   <li>emuR - an Emu compatible *_annot.json file</li>
 *  </ul>
 * @param MAUSSHIFT If set to n, this option causes the calculated MAUS segment boundaries to be shifted by n msec (default: 10) into the future.
 * @param INSPROB The option INSPROB influences the probability of deletion of segments. It is a constant factor (a constant value added to the log likelihood score) after each segment. Therefore, a higher value of INSPROB will cause the probability of segmentations with more segments go up, thus decreasing the probability of deletions (and increasing the probability of insertions, which are rarely modelled in the rule sets).
 * @param INSKANTEXTGRID Switch to create an additional tier in the TextGrid output file with a word segmentation labelled with the canonic phonemic transcript.
 * @param INSORTTEXTGRID Switch to create an additional tier ORT in the TextGrid output file with a word segmentation labelled with the orthographic transcript (taken from the input ORT tier)
 * @param USETRN  If set to true, the service searches the input BPF for a TRN tier. The synopsis for a TRN entry is: 'TRN: (start-sample) (duration-sample) (word-link-list) (label)', e.g. 'TRN: 23654 56432 0,1,2,3,4,5,6 sentence1' (the speech within the recording 'sentence1' starts with sample 23654, last for 56432 samples and covers the words 0-6). If only one TRN entry is found, the segmentation is restricted within a time range given by this TRN tier entry.
 * @param OUTSYMBOL Defines the encoding of phonetic symbols in output. 
 *  <ul>
 *   <li>"sampa" - (default), phonetic symbols are encoded in language specific SAM-PA (with some coding differences to official SAM-PA</li>
 *   <li>"ipa" - the service produces UTF-8 IPA output.</li> 
 *   <li>"manner" - the service produces IPA manner of articulation for each segment; possible values are: silence, vowel, diphthong, plosive, nasal, fricative, affricate, approximant, lateral-approximant, ejective.</li>
 *   <li>"place" - the service produces IPA place of articulation for each segment; possible values are: silence, labial, dental, alveolar, post-alveolar, palatal, velar, uvular, glottal, front, central, back.</li> </ul>
 * @param NOINITIALFINALSILENCE Switch to suppress the automatic modeling on a leading/trailing silence interval. 
 * @param WEIGHT weights the influence of the statistical pronunciation model against the acoustical scores. More precisely WEIGHT is multiplied to the pronunciation model score (log likelihood) before adding the score to the acoustical score within the search. Since the pronunciation model in most cases favors the canonical pronunciation, increasing WEIGHT will at some point cause MAUS to choose always the canonical pronunciation; lower values of WEIGHT will favor less probable paths be selected according to acoustic evidence
 * @param MODUS Operation modus of MAUS: 
 *  <ul>
 *   <li>"standard" (default) - the segmentation and labelling using the MAUS technique as described in Schiel ICPhS 1999.</li> 
 *   <li>"align" - a forced alignment is performed on the input SAM-PA string defined in the KAN tier of the BPF.</li>
 * </ul>
 * @return The response to the request.
 * @throws IOException If an IO error occurs.
 * @throws ParserConfigurationException If the XML parser for parsing the response could not be configured.
 */
public BASResponse MAUS(String LANGUAGE, InputStream SIGNAL, InputStream BPF, String OUTFORMAT,
        String OUTSYMBOL, Integer MINPAUSLEN, Integer STARTWORD, Integer ENDWORD, InputStream RULESET,
        Integer MAUSSHIFT, Double INSPROB, Boolean INSKANTEXTGRID, Boolean INSORTTEXTGRID, Boolean USETRN,
        Boolean NOINITIALFINALSILENCE, Double WEIGHT, String MODUS)
        throws IOException, ParserConfigurationException {
    if (OUTSYMBOL == null)
        OUTSYMBOL = "sampa";
    // "40 msec seems to be the border of perceivable silence, we set this option default to 5"
    if (MINPAUSLEN == null)
        MINPAUSLEN = 5;
    HttpPost request = new HttpPost(getMAUSUrl());
    MultipartEntityBuilder builder = MultipartEntityBuilder.create()
            .addTextBody("LANGUAGE", languageTagger.tag(LANGUAGE))
            .addBinaryBody("SIGNAL", SIGNAL, ContentType.create("audio/wav"), "BAS.wav")
            .addBinaryBody("BPF", BPF, ContentType.create("text/plain-bas"), "BAS.par")
            .addTextBody("OUTFORMAT", OUTFORMAT).addTextBody("OUTSYMBOL", OUTSYMBOL);
    if (USETRN != null)
        builder.addTextBody("USETRN", USETRN.toString());
    if (MINPAUSLEN != null)
        builder.addTextBody("MINPAUSLEN", MINPAUSLEN.toString());
    if (STARTWORD != null)
        builder.addTextBody("STARTWORD", STARTWORD.toString());
    if (ENDWORD != null)
        builder.addTextBody("ENDWORD", ENDWORD.toString());
    if (RULESET != null)
        builder.addBinaryBody("RULESET", RULESET, ContentType.create("text/plain"), "RULESET.txt");
    if (MAUSSHIFT != null)
        builder.addTextBody("MAUSSHIFT", MAUSSHIFT.toString());
    if (INSPROB != null)
        builder.addTextBody("INSPROB", INSPROB.toString());
    if (INSKANTEXTGRID != null)
        builder.addTextBody("INSKANTEXTGRID", INSKANTEXTGRID.toString());
    if (INSORTTEXTGRID != null)
        builder.addTextBody("INSORTTEXTGRID", INSORTTEXTGRID.toString());
    if (NOINITIALFINALSILENCE != null)
        builder.addTextBody("NOINITIALFINALSILENCE", NOINITIALFINALSILENCE.toString());
    if (WEIGHT != null)
        builder.addTextBody("WEIGHT", WEIGHT.toString());
    if (MODUS != null)
        builder.addTextBody("MODUS", MODUS.toString());
    HttpEntity entity = builder.build();
    request.setEntity(entity);
    HttpResponse httpResponse = httpclient.execute(request);
    HttpEntity result = httpResponse.getEntity();
    return new BASResponse(result.getContent());
}