Java Code Examples for org.apache.commons.lang.StringUtils#stripEnd()
The following examples show how to use
org.apache.commons.lang.StringUtils#stripEnd() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFuncTrim.java From dble with GNU General Public License v2.0 | 6 votes |
@Override public String valStr() { String toTrim = args.get(0).valStr(); if (nullValue = args.get(0).isNullValue()) return null; String remove = null; if (getArgCount() == 2) { remove = args.get(1).valStr(); if (nullValue = args.get(1).isNullValue()) return null; } String ret = null; if (mTrimLeading) ret = StringUtils.stripStart(toTrim, remove); if (mTrimTrailing) ret = StringUtils.stripEnd(toTrim, remove); return ret; }
Example 2
Source File: OjbKualiHashFieldConversion.java From rice with Educational Community License v2.0 | 6 votes |
/** * @see FieldConversion#javaToSql(Object) */ public Object javaToSql(Object source) { Object converted = source; if ( converted != null ) { // don't convert if already a hashed value if ( converted.toString().endsWith( EncryptionService.HASH_POST_PREFIX ) ) { converted = StringUtils.stripEnd( converted.toString(), EncryptionService.HASH_POST_PREFIX ); } else { try { converted = CoreApiServiceLocator.getEncryptionService().hash(converted); } catch (GeneralSecurityException e) { throw new RuntimeException("Unable to hash value to db: " + e.getMessage()); } } } return converted; }
Example 3
Source File: PostDataLoadEncryptionDaoJdbc.java From rice with Educational Community License v2.0 | 6 votes |
protected String getSelectBackupTableColumnsSql(String tableName, List<String> columnNames, int numberOfRowsToCommitAfter){ tableName = tableName + BACKUP_TABLE_EXTENSION; StringBuffer columnsNamesBuf = new StringBuffer(); for(String columnName: columnNames){ columnsNamesBuf.append(columnName).append(COMMA_SEPARATOR); } String selectColumns = StringUtils.stripEnd(columnsNamesBuf.toString(), COMMA_SEPARATOR); return new StringBuffer("SELECT ") .append(selectColumns) .append(" FROM ") .append(tableName) .append(" WHERE ") .append(BACKUP_TABLE_ENCRYPT_IND) .append(" IS NULL AND ROWNUM<=") .append(numberOfRowsToCommitAfter).toString(); }
Example 4
Source File: HashConverter.java From rice with Educational Community License v2.0 | 6 votes |
/** * {@inheritDoc} * * This implementation hashes the value going to the database. */ @Override public String convertToDatabaseColumn(String objectValue) { // don't attempt to encrypt nulls or empty strings if (objectValue == null) { return null; } if (StringUtils.isEmpty(objectValue.toString())) { return ""; } // don't convert if already a hashed value if (objectValue.toString().endsWith(EncryptionService.HASH_POST_PREFIX)) { return StringUtils.stripEnd(objectValue.toString(), EncryptionService.HASH_POST_PREFIX); } else { try { return CoreApiServiceLocator.getEncryptionService().hash(objectValue); } catch (Exception e) { throw new RuntimeException("Exception while attempting to hash value for DB: ", e); } } }
Example 5
Source File: HiveORCSearchArgumentBuilder.java From pxf with Apache License 2.0 | 6 votes |
private static Object boxLiteral(Object literal) { if (literal instanceof String || literal instanceof Long || literal instanceof Double || literal instanceof Date || literal instanceof Timestamp || literal instanceof HiveDecimal || literal instanceof BigDecimal || literal instanceof Boolean) { return literal; } else if (literal instanceof HiveChar || literal instanceof HiveVarchar) { return StringUtils.stripEnd(literal.toString(), null); } else if (literal instanceof Byte || literal instanceof Short || literal instanceof Integer) { return ((Number) literal).longValue(); } else if (literal instanceof Float) { // to avoid change in precision when upcasting float to double // we convert the literal to string and parse it as double. (HIVE-8460) return Double.parseDouble(literal.toString()); } else { throw new IllegalArgumentException("Unknown type for literal " + literal); } }
Example 6
Source File: AbstractRegexSpecificationBase.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Trims the trailing space only from the given line, though only if trimLineBeforeMatch is true * @param line the line to perhaps trim trailing spaces from * @return the maybe trimmed line */ protected String trimLine(String line) { if (isTrimLineBeforeMatch()) { return StringUtils.stripEnd(line, " \t\n\f\r"); } return line; }
Example 7
Source File: HttpProfilerFactory.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Nullable @Override public ProfilerIndexInterface createProfilerIndex(@NotNull Project project) { String profilerHttpUrl = Settings.getInstance(project).profilerHttpUrl; if(!profilerHttpUrl.startsWith("http")) { return null; } return new HttpProfilerIndex(project, StringUtils.stripEnd(profilerHttpUrl, "/")); }
Example 8
Source File: MarcoScopeVariableCollector.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override public void collect(@NotNull TwigFileVariableCollectorParameter parameter, @NotNull Map<String, Set<String>> variables) { ASTNode macroStatement = TreeUtil.findParent(parameter.getElement().getNode(), TwigElementTypes.MACRO_STATEMENT); if(macroStatement == null) { return; } PsiElement psiElement = macroStatement.getPsi(); if(psiElement == null) { return; } PsiElement marcoTag = psiElement.getFirstChild(); if(marcoTag == null) { return; } Pair<String, String> pair = TwigUtil.getTwigMacroNameAndParameter(marcoTag); if(pair == null || pair.getSecond() == null) { return; } // strip braces "(foobar, foo)" String args = StringUtils.stripStart(pair.getSecond(), "( "); args = StringUtils.stripEnd(args, ") "); for (String s : args.split("\\s*,\\s*")) { variables.put(s, Collections.emptySet()); } }
Example 9
Source File: KualiMaintainableImpl.java From rice with Educational Community License v2.0 | 5 votes |
/** * Special hidden parameters are set on the maintenance jsp starting with a * prefix that tells us which fields have been encrypted. This field finds * the those parameters in the map, whose value gives us the property name * that has an encrypted value. We then need to decrypt the value in the Map * before the business object is populated. * * @param fieldValues * - possibly with encrypted values * @return Map fieldValues - with no encrypted values */ protected Map<String, String> decryptEncryptedData(Map<String, String> fieldValues, MaintenanceDocument maintenanceDocument, String methodToCall) { try { MaintenanceDocumentRestrictions auths = KNSServiceLocator.getBusinessObjectAuthorizationService() .getMaintenanceDocumentRestrictions(maintenanceDocument, GlobalVariables.getUserSession().getPerson()); for (Iterator<String> iter = fieldValues.keySet().iterator(); iter.hasNext();) { String fieldName = iter.next(); String fieldValue = (String) fieldValues.get(fieldName); if (fieldValue != null && !"".equals(fieldValue) && fieldValue.endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) { if (shouldFieldBeEncrypted(maintenanceDocument, fieldName, auths, methodToCall)) { String encryptedValue = fieldValue; // take off the postfix encryptedValue = StringUtils.stripEnd(encryptedValue, EncryptionService.ENCRYPTION_POST_PREFIX); if(CoreApiServiceLocator.getEncryptionService().isEnabled()) { String decryptedValue = getEncryptionService().decrypt(encryptedValue); fieldValues.put(fieldName, decryptedValue); } } else throw new RuntimeException("The field value for field name " + fieldName + " should not be encrypted."); } else if (fieldValue != null && !"".equals(fieldValue) && auths.hasRestriction(fieldName) && shouldFieldBeEncrypted(maintenanceDocument, fieldName, auths, methodToCall)) throw new RuntimeException("The field value for field name " + fieldName + " should be encrypted."); } } catch (GeneralSecurityException e) { throw new RuntimeException("Unable to decrypt secure data: " + e.getMessage()); } return fieldValues; }
Example 10
Source File: TimestampDatum.java From incubator-tajo with Apache License 2.0 | 5 votes |
@Override public String asChars() { if (getMillisOfSecond() > 0) { return StringUtils.stripEnd(dateTime.toString(FRACTION_FORMATTER), "0"); } else { return dateTime.toString(DEFAULT_FORMATTER); } }
Example 11
Source File: IndyFactory.java From pnc with Apache License 2.0 | 5 votes |
@Inject public IndyFactory(GlobalModuleGroup globalConfig, IndyRepoDriverModuleConfig config) { this.defaultRequestTimeout = config.getDefaultRequestTimeout(); String baseUrl = StringUtils.stripEnd(globalConfig.getIndyUrl(), "/"); if (!baseUrl.endsWith("/api")) { baseUrl += "/api"; } this.baseUrl = baseUrl; }
Example 12
Source File: VcfToAdpc.java From picard with MIT License | 5 votes |
private IlluminaGenotype getIlluminaGenotype(final Genotype genotype, final VariantContext context) { final IlluminaGenotype illuminaGenotype; if (genotype.isCalled()) { // Note that we remove the trailing '*' that appears in alleles that are reference. final String illuminaAlleleA = StringUtils.stripEnd(getStringAttribute(context, InfiniumVcfFields.ALLELE_A), "*"); final String illuminaAlleleB = StringUtils.stripEnd(getStringAttribute(context, InfiniumVcfFields.ALLELE_B), "*"); if (genotype.getAlleles().size() != 2) { throw new PicardException("Unexpected number of called alleles in variant context " + context + " found alleles: " + genotype.getAlleles()); } final Allele calledAllele1 = genotype.getAllele(0); final Allele calledAllele2 = genotype.getAllele(1); if (calledAllele1.basesMatch(illuminaAlleleA)) { if (calledAllele2.basesMatch(illuminaAlleleA)) { illuminaGenotype = picard.arrays.illumina.IlluminaGenotype.AA; } else if (calledAllele2.basesMatch(illuminaAlleleB)) { illuminaGenotype = picard.arrays.illumina.IlluminaGenotype.AB; } else { throw new PicardException("Error matching called alleles to Illumina alleles. Context: " + context); } } else if (calledAllele1.basesMatch(illuminaAlleleB)) { if (calledAllele2.basesMatch(illuminaAlleleA)) { illuminaGenotype = picard.arrays.illumina.IlluminaGenotype.AB; } else if (calledAllele2.basesMatch(illuminaAlleleB)) { illuminaGenotype = picard.arrays.illumina.IlluminaGenotype.BB; } else { throw new PicardException("Error matching called alleles to Illumina alleles. Context: " + context); } } else { // We didn't match up the illumina alleles to called alleles throw new PicardException("Error matching called alleles to Illumina alleles. Context: " + context); } } else { illuminaGenotype = picard.arrays.illumina.IlluminaGenotype.NN; } return illuminaGenotype; }
Example 13
Source File: WorkspaceHelper.java From azure-devops-intellij with MIT License | 5 votes |
/** * This metho appends the one level mapping suffix to the server path. */ public static String getOneLevelServerPath(final String serverPath) { if (StringUtils.isEmpty(serverPath)) { // This is a strange case, but it seems correct to simply return the suffix return ONE_LEVEL_MAPPING_SUFFIX; } if (!isOneLevelMapping(serverPath)) { // remove any remaining /'s and add the /* return StringUtils.stripEnd(serverPath, "/") + ONE_LEVEL_MAPPING_SUFFIX; } // It already has the /* at the end return serverPath; }
Example 14
Source File: RecordDiffer.java From yugong with GNU General Public License v2.0 | 5 votes |
private static String getNumberString(Object value1) { String v1; if (value1 instanceof BigDecimal) { v1 = ((BigDecimal) value1).toPlainString(); if (StringUtils.indexOf(v1, ".") != -1) { v1 = StringUtils.stripEnd(v1, "0");// 如果0是末尾,则删除之 v1 = StringUtils.stripEnd(v1, ".");// 如果.是末尾,则删除之 } } else { v1 = value1.toString(); } return v1; }
Example 15
Source File: RepositoryManagerDriver.java From pnc with Apache License 2.0 | 4 votes |
@Inject public RepositoryManagerDriver(Configuration configuration, BuildRecordRepository buildRecordRepository) { this.buildRecordRepository = buildRecordRepository; GlobalModuleGroup globalConfig; IndyRepoDriverModuleConfig indyDriverConfig; try { globalConfig = configuration.getGlobalConfig(); indyDriverConfig = configuration.getModuleConfig(new PncConfigProvider<>(IndyRepoDriverModuleConfig.class)); } catch (ConfigurationParseException e) { throw new IllegalStateException("Cannot read configuration for " + DRIVER_ID + ".", e); } this.DEFAULT_REQUEST_TIMEOUT = indyDriverConfig.getDefaultRequestTimeout(); this.BUILD_PROMOTION_TARGET = indyDriverConfig.getBuildPromotionTarget(); this.TEMP_BUILD_PROMOTION_TARGET = indyDriverConfig.getTempBuildPromotionTarget(); baseUrl = StringUtils.stripEnd(globalConfig.getIndyUrl(), "/"); if (!baseUrl.endsWith("/api")) { baseUrl += "/api"; } ignoredRepoPatterns = indyDriverConfig.getIgnoredRepoPatterns(); IgnoredPatterns ignoredPathPatternsPromotion = null; IgnoredPatterns ignoredPathPatternsData = null; IgnoredPathPatterns ignoredPathPatterns = indyDriverConfig.getIgnoredPathPatterns(); if (ignoredPathPatterns != null) { ignoredPathPatternsPromotion = ignoredPathPatterns.getPromotion(); ignoredPathPatternsData = ignoredPathPatterns.getData(); } if (ignoredPathPatternsPromotion == null) { this.ignoredPathPatternsPromotion = new IgnoredPatterns(); } else { this.ignoredPathPatternsPromotion = ignoredPathPatternsPromotion; } if (ignoredPathPatternsData == null) { this.ignoredPathPatternsData = new IgnoredPatterns(); } else { this.ignoredPathPatternsData = ignoredPathPatternsData; } }
Example 16
Source File: Util.java From gauge-java with Apache License 2.0 | 4 votes |
public static String trimQuotes(String text) { return StringUtils.stripEnd(StringUtils.stripStart(text, "\""), "\""); }
Example 17
Source File: BaremetalKickStartPxeResource.java From cloudstack with Apache License 2.0 | 4 votes |
private Answer execute(VmDataCommand cmd) { com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22); try { List<String[]> vmData = cmd.getVmData(); StringBuilder sb = new StringBuilder(); for (String[] data : vmData) { String folder = data[0]; String file = data[1]; String contents = (data[2] == null) ? "none" : data[2]; sb.append(cmd.getVmIpAddress()); sb.append(","); sb.append(folder); sb.append(","); sb.append(file); sb.append(","); sb.append(contents); sb.append(";"); } String arg = StringUtils.stripEnd(sb.toString(), ";"); sshConnection.connect(null, 60000, 60000); if (!sshConnection.authenticateWithPassword(_username, _password)) { s_logger.debug("SSH Failed to authenticate"); throw new ConfigurationException(String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password)); } String script = String.format("python /usr/bin/baremetal_user_data.py '%s'", arg); if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) { return new Answer(cmd, false, "Failed to add user data, command:" + script); } return new Answer(cmd, true, "Success"); } catch (Exception e) { s_logger.debug("Prepare for creating baremetal template failed", e); return new Answer(cmd, false, e.getMessage()); } finally { if (sshConnection != null) { sshConnection.close(); } } }
Example 18
Source File: HttpProfilerIndex.java From idea-php-symfony2-plugin with MIT License | 4 votes |
public HttpProfilerIndex(@NotNull Project project, @NotNull String url) { this.project = project; this.url = StringUtils.stripEnd(url, "/"); }
Example 19
Source File: Email.java From email-mime-parser with Apache License 2.0 | 4 votes |
private String stripContentID(String contentId) { contentId = StringUtils.stripStart(contentId, "<"); contentId = StringUtils.stripEnd(contentId, ">"); return contentId; }
Example 20
Source File: FileResourceVisitorUtil.java From idea-php-symfony2-plugin with MIT License | 4 votes |
@NotNull public static String normalize(@NotNull String resource) { return StringUtils.stripEnd(resource.replace("\\", "/").replaceAll("/+", "/"), "/"); }