List of usage examples for org.apache.commons.lang3 StringUtils substring
public static String substring(final String str, int start, int end)
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start/end n characters from the end of the String.
The returned substring starts with the character in the start position and ends before the end position.
From source file:org.javabeanstack.util.Strings.java
/** * Extrae caracteres de un string//from w w w .j a v a 2 s .c om * @param str variable string * @param start posicin a partir de la cual extraera los caracteres de la variable. * @param end posicin final hasta donde extraera los caracteres. * @return caracteres extraidos de la variable alfanumrica. */ public static String substring(String str, int start, int end) { return StringUtils.substring(str, start, end); }
From source file:org.javabeanstack.util.Strings.java
/** * Extrae caracteres de un string/*w w w.j av a 2s .c o m*/ * @param str variable string * @param start posicin a partir de la cual extraera los caracteres de la variable. * @param charactersReturned cantidad de caracteres a retornar. * @return caracteres extraidos de la variable alfanumrica. */ public static String substr(String str, int start, int charactersReturned) { return StringUtils.substring(str, start, start + charactersReturned); }
From source file:org.jevis.commons.unit.UnitFormula.java
private UnitFormula getNextSubPart(String formula, int from, int to) { // System.out.println("split: " + formula); // int start = StringUtils.indexOf(formula, PUNCTUATION_START);//start? // int end = getPartEnd(formula, _lastPart); // System.out.println("range: " + start + " " + end); String subString = StringUtils.substring(formula, from, to); // System.out.println("substring: " + subString); UnitFormula part = new UnitFormula(subString, null); return part;/*from w w w.j av a2 s . c om*/ }
From source file:org.kalypso.shape.deegree.GenericShapeDataFactory.java
private static String findFieldName(final IPropertyType property) { final String localPart = property.getQName().getLocalPart(); final int pos = localPart.lastIndexOf('.'); if (pos < 0) return StringUtils.substring(localPart, 0, 11); return localPart.substring(pos + 1, Math.min(pos + 12, localPart.length())); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.NSFCoverPageV1_6Generator.java
private void setFundingOpportunityNumber(NSFCoverPage16 nsfCoverPage16) { nsfCoverPage16.setFundingOpportunityNumber( StringUtils.substring(pdDoc.getDevelopmentProposal().getProgramAnnouncementNumber(), 0, PROGRAM_ANNOUNCEMENT_NUMBER_MAX_LENGTH)); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.NSFKeyPersonExpandedV1_0Generator.java
private void setPersonalProfileDetailsToProfile(PersonProfileDataType profileDataType, Profile profile, ProposalPersonContract PI) {/* w ww .ja va2 s . c o m*/ assignRolodexId(PI); profile.setName(globLibV20Generator.getHumanNameDataType(PI)); setDirectoryTitleToProfile(profile, PI); profile.setAddress(globLibV20Generator.getAddressDataType(PI)); profile.setPhone(PI.getOfficePhone()); if (StringUtils.isNotEmpty(PI.getFaxNumber())) { profile.setFax(PI.getFaxNumber()); } setDegreeInfo(PI, profile); profile.setEmail(PI.getEmailAddress()); DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); setOrganizationName(profile, developmentProposal); setDepartmentNameToProfile(profile, PI); String divisionName = PI.getDivision(); if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } else { String personId = PI.getPersonId(); KcPersonContract kcPersonContact = kcPersonRepositoryService.findKcPersonByPersonId(personId); if (!kcPersonContact.getOrganizationIdentifier().isEmpty()) { divisionName = getPIDivision(kcPersonContact.getOrganizationIdentifier()); } if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } } if (PI.getEraCommonsUserName() != null) { profile.setCredential(PI.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + PI.getFullName(), AuditError.GG_LINK)); } } profile.setProjectRole(ProjectRoleDataType.PD_PI); setAttachments(profile, PI); profileDataType.setProfile(profile); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.NSFKeyPersonExpandedV1_0Generator.java
private void setDepartmentNameToProfile(Profile profile, ProposalPersonContract PI) { if (PI.getHomeUnit() != null && PI.getPerson() != null && PI.getPerson().getUnit() != null) { final String departmentName = PI.getPerson().getUnit().getUnitName(); profile.setDepartmentName(StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else {/*from www.j a va 2s . c o m*/ DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profile.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.NSFKeyPersonExpandedV1_0Generator.java
private void setAllkeyPersonDetailsToKeyPerson(ProposalPersonContract keyPerson, Profile profileKeyPerson) { assignRolodexId(keyPerson);/* www . j av a 2 s .c o m*/ profileKeyPerson.setName(globLibV20Generator.getHumanNameDataType(keyPerson)); setDirectoryTitleToProfile(profileKeyPerson, keyPerson); profileKeyPerson.setAddress(globLibV20Generator.getAddressDataType(keyPerson)); profileKeyPerson.setPhone(keyPerson.getOfficePhone()); if (StringUtils.isNotEmpty(keyPerson.getFaxNumber())) { profileKeyPerson.setFax(keyPerson.getFaxNumber()); } setDegreeInfo(keyPerson, profileKeyPerson); profileKeyPerson.setEmail(keyPerson.getEmailAddress()); DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); setOrganizationName(profileKeyPerson, developmentProposal); setDepartmentNameToProfile(profileKeyPerson, keyPerson); String divisionName = keyPerson.getDivision(); if (divisionName != null) { profileKeyPerson.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (keyPerson.getEraCommonsUserName() != null) { profileKeyPerson.setCredential(keyPerson.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + keyPerson.getFullName(), AuditError.GG_LINK)); } } } setProjectRole(keyPerson, profileKeyPerson); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398CoverPageSupplement_3_0V3_0Generator.java
private void setVertebrateAnimalsSubQuestions(VertebrateAnimals vertebrateAnimals) { String answer = getAnswer(PROPOSAL_YNQ_QUESTION_146, answerHeaders); if (answer != null && YnqConstant.YES.code().equals(answer)) { vertebrateAnimals.setAnimalEuthanasiaIndicator(YesNoDataType.Y_YES); } else if (answer != null && YnqConstant.NO.code().equals(answer)) { vertebrateAnimals.setAnimalEuthanasiaIndicator(YesNoDataType.N_NO); }// w w w .j av a2s.c om answer = getAnswer(PROPOSAL_YNQ_QUESTION_147, answerHeaders); if (answer != null && YnqConstant.YES.code().equals(answer)) { vertebrateAnimals.setAVMAConsistentIndicator(YesNoDataType.Y_YES); } else if (answer != null && YnqConstant.NO.code().equals(answer)) { vertebrateAnimals.setAVMAConsistentIndicator(YesNoDataType.N_NO); answer = getAnswer(PROPOSAL_YNQ_QUESTION_148, answerHeaders); if (answer != null) { vertebrateAnimals.setEuthanasiaMethodDescription( StringUtils.substring(answer.trim(), 0, MAX_EUTHANASIA_METHOD_DESC)); } } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398CoverPageSupplement_3_0V3_0Generator.java
protected static String getProjectIncomeDescription(BudgetProjectIncomeContract projectIncome) { return projectIncome.getDescription() != null ? StringUtils.substring(projectIncome.getDescription(), 0, PROJECT_INCOME_DESCRIPTION_MAX_LENGTH) : null;//from ww w.ja va 2 s. c om }