List of usage examples for org.apache.commons.lang3 StringUtils right
public static String right(final String str, final int len)
Gets the rightmost len characters of a String.
If len characters are not available, or the String is null , the String will be returned without an an exception.
From source file:org.noroomattheinn.visibletesla.OverviewController.java
private void reflectVINOrFirmware() { VehicleState car = vtVehicle.vehicleState.get(); String text;/* w w w . ja v a2 s . c om*/ switch (toggleChoice) { case SW: text = "v" + Firmware.getSoftwareVersion(car.version); break; case FW: text = "FW: " + car.version; break; case VIN: default: text = "VIN " + StringUtils.right(vtVehicle.getVehicle().getVIN(), 6); break; } vinButton.setText(text); }
From source file:org.slf4j.impl.CasDelegatingLogger.java
/** * Remove ticket id from the log message. * * @param msg the message/* www .j av a 2s .co m*/ * @return the modified message with tgt id removed */ private String removeTicketId(final String msg) { String modifiedMessage = msg; final Matcher matcher = TICKET_ID_PATTERN.matcher(msg); while (matcher.find()) { final String match = matcher.group(); final String newId = matcher.group(1) + "-" + StringUtils.repeat("*", match.length() - VISIBLE_ID_TAIL_LENGTH) + StringUtils.right(match, VISIBLE_ID_TAIL_LENGTH); modifiedMessage = modifiedMessage.replaceAll(match, newId); } return modifiedMessage; }
From source file:org.talend.dataquality.semantic.validator.impl.SedolValidator.java
@Override public boolean isValid(String str) { if (str == null || str.length() != 7) { return false; }// www.j a va2 s . co m String sedolStr = StringUtils.left(str, 6); // Extract the checksum digit. int checksum = -1; try { String csStr = StringUtils.right(str, 1); checksum = Integer.valueOf(csStr); } catch (NumberFormatException e) { throw new RuntimeException("Invalid checksum digit. ", e); } int checksumFromSedol = getSedolCheckDigit(sedolStr); return checksum == checksumFromSedol; }
From source file:org.wise.portal.dao.user.impl.HibernateUserDao.java
/** * Capitalizes the first letter of a given String * /*from ww w . j ava 2 s . co m*/ * @param string * @return String */ private String capitalizeFirst(String string) { return StringUtils.upperCase(StringUtils.left(string, 1)) + StringUtils.right(string, string.length() - 1); }
From source file:uk.org.funcube.fcdw.server.processor.HighResolutionProcessorImpl.java
private void saveHighPrecision(final int satelliteId, final long seqNo, final List<String> frames, final Date receivedDate, EpochEntity epoch) { HighResolutionEntity hrEntity = null; StringBuffer sb = new StringBuffer(); for (int i = 0; i < 3; i++) { sb.append(StringUtils.right(frames.get(i), 400)); }//from www . j a va 2s . com final String binaryString = DataProcessor.convertHexBytePairToBinary(sb.toString()); // get the epoch sequence number Long epochSequenceNumber = epoch.getSequenceNumber(); // get the epoch satelliteTime Long epochTimeLong = epoch.getReferenceTime().getTime(); // get current time Long currentSequenceTimeLong = ((seqNo - epochSequenceNumber) * 2 * 60 * 1000) + epochTimeLong; for (int i = 0; i < 60; i++) { switch (satelliteId) { case 0: hrEntity = new GomSpaceHPEntity(satelliteId, seqNo, binaryString.substring(i * 80, i * 80 + 80), receivedDate); break; case 1: hrEntity = new FC2HPEntity(satelliteId, seqNo, binaryString.substring(i * 80, i * 80 + 80), receivedDate); break; case 2: hrEntity = new GomSpaceHPEntity(satelliteId, seqNo, binaryString.substring(i * 80, i * 80 + 80), receivedDate); break; default: LOG.error("Cannot process High Precision data for satellite ID: " + satelliteId); break; } Timestamp satelliteTime = new Timestamp(currentSequenceTimeLong + (i * 1000)); hrEntity.setSatelliteTime(satelliteTime); highResolutionDao.save(hrEntity); } }
From source file:uk.org.funcube.fcdw.server.processor.WholeOrbitDataProcessorImpl.java
private void extractAndSaveWod(final Long satelliteId, final long seqNo, final List<String> frames, final Date receivedDate) { final Date frameTime = new Date(receivedDate.getTime() - 104 * 60 * 1000); final StringBuffer sb = new StringBuffer(); for (int i = 0; i < 12; i++) { sb.append(StringUtils.right(frames.get(i), 400)); }// w w w . ja v a2s . c o m int start = 0; int end = 46; for (int i = 0; i < 104; i++) { final long frameNumber = seqNo * 2 + i; if (wholeOrbitDataDao.findBySatelliteIdAndFrameNumber(satelliteId, frameNumber).size() == 0) { WholeOrbitDataEntity wod = null; switch (satelliteId.intValue()) { case 0: wod = new GomSpaceWODEntity(satelliteId, seqNo, frameNumber, convertHexBytePairToBinary(sb.substring(start, end)), frameTime); break; case 1: wod = new ClydeSpaceWODEntity(satelliteId, seqNo, frameNumber, convertHexBytePairToBinary(sb.substring(start, end)), frameTime); break; case 2: wod = new GomSpaceWODEntity(satelliteId, seqNo, frameNumber, convertHexBytePairToBinary(sb.substring(start, end)), frameTime); break; default: break; } if (wod != null) { wholeOrbitDataDao.save(wod); } start += 46; end += 46; } // move the frame time forward a minute frameTime.setTime(frameTime.getTime() + 60 * 1000); } }