List of usage examples for org.apache.commons.lang StringUtils leftPad
public static String leftPad(String str, int size, String padStr)
Left pad a String with a specified String.
From source file:com.novartis.pcs.ontology.service.OntologyTermServiceImpl.java
private String nextReferenceId(Ontology ontology) { StringBuilder referenceId = new StringBuilder(); String prefix = ontology.getReferenceIdPrefix(); if (prefix != null && prefix.length() > 0) { referenceId.append(prefix).append(':'); }//from w w w .j a v a2s.c o m int value = ontology.getReferenceIdValue() + 1; ontology.setReferenceIdValue(value); referenceId.append(StringUtils.leftPad(Integer.toString(value), 7, "0")); return referenceId.toString(); }
From source file:de.cismet.cids.custom.utils.alkis.VermessungsrissPictureFinder.java
/** * DOCUMENT ME!//from w ww . jav a2 s .co m * * @param schluessel DOCUMENT ME! * @param gemarkung DOCUMENT ME! * * @return DOCUMENT ME! * * @throws UnsupportedEncodingException DOCUMENT ME! */ public String getBuchwerkFolder(final String schluessel, final CidsBean gemarkung) throws UnsupportedEncodingException { final StringBuffer buf = new StringBuffer(); if (SCHLUESSEL_NAMENSVERZEICHNIS.equals(schluessel)) { buf.append(alkisConf.getVermessungHostNamensverzeichnis()).append(SEP).append(PREFIX_NAMENSVERZEICHNIS) .append("_").append(StringUtils.leftPad(schluessel, 3, '0')).append("-") .append(String.format("%04d", (Integer) gemarkung.getProperty("id"))); } else if (SCHLUESSEL_FLURBUECHER1.equals(schluessel) || SCHLUESSEL_FLURBUECHER2.equals(schluessel)) { buf.append(alkisConf.getVermessungHostFlurbuecher()); } else if (SCHLUESSEL_LIEGENSCHAFTSBUECHER1.equals(schluessel) || SCHLUESSEL_LIEGENSCHAFTSBUECHER2.equals(schluessel)) { buf.append(alkisConf.getVermessungHostLiegenschaftsbuecher()).append(SEP) .append(URLEncoder.encode((String) gemarkung.getProperty("name"), "UTF-8")); } return buf.toString(); }
From source file:com.prowidesoftware.swift.model.AbstractSwiftMessage.java
/** * Returns the internal unique id as fixed length string, padded with zeros. * @return string with 10 characters with this message identifier *//*from ww w. j a v a 2 s . c om*/ public String getPaddedId() { String id = this.id != null ? this.id.toString() : "0"; return StringUtils.leftPad(id, 10, "0"); }
From source file:ca.uhn.hl7v2.testpanel.controller.Prefs.java
public void setOpenProfiles(List<ProfileGroup> theProfiles, TableFileList theTableFileList) { int index = 0; List<File> files = new ArrayList<File>(); try {//ww w .j a v a2 s. c o m for (ProfileGroup profileGroup : theProfiles) { index++; String seq = StringUtils.leftPad(Integer.toString(index), 10, '0'); File fileName = createProfileGroupFileName(seq, profileGroup); files.add(fileName); FileOutputStream fos = new FileOutputStream(fileName); Writer nextWriter = new OutputStreamWriter(fos, Charset.forName("UTF-8")); if (isNotBlank(profileGroup.getSourceUrl())) { ExportedProfileGroupFile exported = new ExportedProfileGroupFile(profileGroup, theTableFileList); nextWriter.append(exported.exportConfigToXm()); } else { nextWriter.append(profileGroup.exportConfigToXml()); } nextWriter.close(); } IOUtils.deleteAllFromDirectoryExcept(getProfileGroupFileDirectory(), files); } catch (IOException e) { ourLog.error("Failed to flush profile group file", e); } }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
public String getNextGeneratedBiospecimenUID(Study study) { Study studyToUse = null;/* www . java2 s.co m*/ if (study.getParentStudy() != null) { studyToUse = study.getParentStudy(); } else { studyToUse = study; } BiospecimenUidTemplate biospecimenUidTemplate = getBiospecimenUidTemplate(studyToUse); String biospecimenUidPrefix = new String(""); String biospecimenUidToken = new String(""); String biospecimenUidPaddedIncrementor = new String(""); String biospecimenUidPadChar = new String("0"); StringBuilder nextIncrementedBiospecimenUid = new StringBuilder(""); StringBuilder biospecimenUid = new StringBuilder(); if (biospecimenUidTemplate != null) { if (biospecimenUidTemplate.getBiospecimenUidPrefix() != null) biospecimenUidPrefix = biospecimenUidTemplate.getBiospecimenUidPrefix(); if (biospecimenUidTemplate.getBiospecimenUidToken() != null && biospecimenUidTemplate.getBiospecimenUidToken().getName() != null) { biospecimenUidToken = biospecimenUidTemplate.getBiospecimenUidToken().getName(); } if (biospecimenUidTemplate.getBiospecimenUidPadChar() != null && biospecimenUidTemplate.getBiospecimenUidPadChar().getName() != null) { biospecimenUidPadChar = biospecimenUidTemplate.getBiospecimenUidPadChar().getName().trim(); } int incrementedValue = getNextUidSequence(studyToUse).intValue(); nextIncrementedBiospecimenUid = nextIncrementedBiospecimenUid.append(incrementedValue); int size = Integer.parseInt(biospecimenUidPadChar); biospecimenUidPaddedIncrementor = StringUtils.leftPad(nextIncrementedBiospecimenUid.toString(), size, "0"); biospecimenUid.append(biospecimenUidPrefix); biospecimenUid.append(biospecimenUidToken); biospecimenUid.append(biospecimenUidPaddedIncrementor); } else { biospecimenUid = null; } // handle for a null BiospecimenUID if (biospecimenUid == null || biospecimenUid.length() == 0) { //String uid = UniqueIdGenerator.generateUniqueId(); String uid = "" + getNextUidSequence(studyToUse); biospecimenUid = new StringBuilder(); biospecimenUid.append(uid); //log.error("Biospecimen Template is not defined for the Study: " + studyToUse.getName()); } return biospecimenUid.toString(); }
From source file:gtu.zcognos.DimensionUI.java
static String randomTableName() { return "rscd" + StringUtils.leftPad(String.valueOf((int) (Math.random() * 10000)), 4, "0"); }
From source file:com.icebreak.p2p.trade.impl.InvestServiceImpl.java
/** * ??/*from w w w.ja va 2s .com*/ * @param detail * @throws Exception */ protected void addTradeFlowCode(TradeDetail detail) throws Exception { long tradeId = detail.getTradeId(); long detailId = detail.getId(); Trade trade = tradeDao.getByTradeIdWithRowLock(tradeId); //?? LoanDemandDO loan = loanDemandManager.queryLoanDemandByDemandId(trade.getDemandId()); TradeFlowCode tradeFlow = new TradeFlowCode(); tradeFlow.setTblBaseId(BusinessNumberUtil.gainNumber()); tradeFlow.setTradeDetailId(detailId); long countIndex = tradeDao.countInvestedTransactions(tradeId); tradeFlow.setTradeFlowCode( loan.getGuaranteeLicenseNo() + "T" + StringUtils.leftPad(String.valueOf(countIndex), 3, "0")); tradeFlow.setRowAddTime(new Date()); tradeFlow.setNote("??"); tradeDao.addTradeFlowCode(tradeFlow); }
From source file:de.cismet.cids.custom.objecteditors.utils.VermessungUmleitungPanel.java
@Override public void beansDropped(final ArrayList<CidsBean> droppedBeans) { try {/*w w w . ja v a 2 s. c o m*/ if (droppedBeans.size() > 1) { LOG.info( "There were more than one bean dropped on the vermessungs riss umleitungs text field. Just regarding the first one"); } final CidsBean bean = droppedBeans.get(0); if (bean != null) { if (bean.getMetaObject().getMetaClass().getTableName().equalsIgnoreCase("vermessung_riss")) { final String schluessel = bean.getProperty("schluessel").toString(); final CidsBean gemarkungBean = (CidsBean) bean.getProperty("gemarkung"); Integer gemarkung = 0; if (gemarkungBean != null) { gemarkung = (Integer) gemarkungBean.getProperty("id"); } final String flur = bean.getProperty("flur").toString(); final String blatt = bean.getProperty("blatt").toString(); final StringBuffer buf = new StringBuffer(); buf.append(StringUtils.leftPad(schluessel, 3, '0')); buf.append("-"); buf.append(String.format("%04d", gemarkung)); buf.append("-"); buf.append(StringUtils.leftPad(flur, 3, '0')); buf.append("-"); buf.append(StringUtils.leftPad(blatt, 8, '0')); tfName.setText(buf.toString()); } } } catch (Exception ex) { LOG.error("Problem when adding the DroppedBeans", ex); } }
From source file:com.alibaba.china.talos.service.impl.AuthDataItemTransportAO.java
/** * @param dataPoolId/*from w w w . j a v a2 s.c om*/ * @return */ private String getAuthDataItemStatusTableName(Long dataPoolId) { return "auth_data_item_status_" + StringUtils.leftPad("" + (dataPoolId % 64), 4, "0"); }
From source file:com.alibaba.china.talos.service.impl.AuthDataItemTransportAO.java
/** * @param dataPoolId//from w w w . ja v a2s. c o m * @return */ private String getAuthDataItemTableName(Long dataPoolId) { return "auth_data_item_" + StringUtils.leftPad("" + (dataPoolId % 128), 4, "0"); }