List of usage examples for org.apache.commons.lang StringUtils removeEnd
public static String removeEnd(String str, String remove)
Removes a substring only if it is at the end of a source string, otherwise returns the source string.
From source file:com.michelin.cio.hudson.plugins.wasbuilder.WASInstallation.java
/** * Removes the '\' or '/' character that may be present at the end of the * specified string./*from w w w .j a v a2s. co m*/ */ private static String removeTrailingBackslash(String s) { return StringUtils.removeEnd(StringUtils.removeEnd(s, "/"), "\\"); }
From source file:hudson.plugins.openid.OpenIdLoginService.java
private String getFinishUrl() { StaplerRequest req = Stapler.getCurrentRequest(); String contextPath = req.getContextPath(); if (StringUtils.isBlank(contextPath) || "/".equals(contextPath)) { return "federatedLoginService/openid/finish"; } else {// ww w . j a v a 2s .com // hack alert... work around some less than consistent servlet containers return StringUtils.removeEnd(StringUtils.removeStart(contextPath, "/"), "/") + "/federatedLoginService/openid/finish"; } }
From source file:com.hangum.tadpole.db.metadata.MakeContentAssistUtil.java
/** * List of assis schema name/*from w ww .j a v a 2 s . c o m*/ * * @param userDB * @return */ public String getAssistSchemaList(final UserDBDAO userDB) { StringBuffer strSchemaList = new StringBuffer(); if (userDB.getDBDefine() == DBDefine.POSTGRE_DEFAULT) { try { for (Object object : DBSystemSchema.getSchemas(userDB)) { Map map = (Map) object; strSchemaList.append(makeObjectPattern(null, "" + map.get("schema"), "Schema")); //$NON-NLS-1$ } userDB.setSchemaListSeparator(StringUtils.removeEnd(strSchemaList.toString(), _PRE_GROUP)); //$NON-NLS-1$ } catch (Exception e) { logger.error("getSchema list", e); } } return strSchemaList.toString(); }
From source file:jenkins.scm.impl.subversion.SubversionSCMSource.java
@DataBoundConstructor @SuppressWarnings("unused") // by stapler public SubversionSCMSource(String id, String remoteBase, String credentialsId, String includes, String excludes) {/*w w w . ja v a 2 s . c o m*/ super(id); this.remoteBase = StringUtils.removeEnd(remoteBase, "/") + "/"; this.credentialsId = credentialsId; this.includes = StringUtils.defaultIfEmpty(includes, DEFAULT_INCLUDES); this.excludes = StringUtils.defaultIfEmpty(excludes, DEFAULT_EXCLUDES); }
From source file:com.hangum.tadpole.application.initialize.wizard.SystemAdminWizardDefaultUserPage.java
/** * validate //from w w w .j av a2 s . com * * @param strEmail * @param strPass * @param strRePass */ private void validateValue(String strEmail, String strPass, String strRePass) { strEmail = StringUtils.trimToEmpty(strEmail); strPass = StringUtils.trimToEmpty(strPass); strRePass = StringUtils.trimToEmpty(strRePass); strPass = StringUtils.removeEnd(strPass, "\t"); strPass = StringUtils.removeEnd(strPass, "\n"); strRePass = StringUtils.removeEnd(strRePass, "\t"); strRePass = StringUtils.removeEnd(strRePass, "\n"); isComplete = false; if ("".equals(strEmail)) { //$NON-NLS-1$ errorSet(textEmail, Messages.get().SystemAdminWizardPage_35); return; } else if (!ValidChecker.isValidEmailAddress(strEmail)) { errorSet(textEmail, Messages.get().SystemAdminWizardPage_48); return; } else if (!ValidChecker.isSimplePasswordChecker(strPass)) { //$NON-NLS-1$ errorSet(textPasswd, Messages.get().SystemAdminWizardPage_37); return; } else if (!strPass.equals(strRePass)) { //$NON-NLS-1$ errorSet(textRePasswd, Messages.get().SystemAdminWizardPage_39); return; } isComplete = true; setErrorMessage(null); setPageComplete(true); }
From source file:com.huawei.streaming.config.ConfVariable.java
private void parseVariableConf(String value) { //trim???/*from w w w.j a v a 2s. c om*/ String variable = StringUtils .removeEnd(StringUtils.removeStart(value, CONF_VARIABLE_PREFIX), CONF_VARIABLE_POSTFIX).trim(); if (Strings.isNullOrEmpty(variable)) { return; } if (variable.toLowerCase(Locale.US).startsWith(SYSTEM_PREFIX)) { parseSystemVariable(variable); return; } if (variable.toLowerCase(Locale.US).startsWith(CQLCONF_PREFIX)) { parseConfVariable(variable); return; } }
From source file:ddf.catalog.backup.CatalogBackupPlugin.java
private void renameTempFile(File source) throws IOException { File destination = new File(StringUtils.removeEnd(source.getAbsolutePath(), TEMP_FILE_EXTENSION)); boolean success = source.renameTo(destination); if (!success) { LOGGER.warn("Failed to move {} to {}.", source.getAbsolutePath(), destination.getAbsolutePath()); }/* w w w.j ava 2 s. c o m*/ }
From source file:com.hangum.tadpole.rdb.core.editors.main.composite.direct.SQLResultEditingSupport.java
/** * make where statement//from w w w.j a v a2s . c o m * * @return */ private String makeWhereStaement(HashMap<Integer, String> data) { StringBuffer sbWhere = new StringBuffer(); Map<Integer, String> mapTableNames = rsDAO.getColumnTableName(); Map<Integer, String> mapColumnNames = rsDAO.getColumnName(); Map<Integer, Integer> mapColumnType = rsDAO.getColumnType(); String selectTableName = mapTableNames.get(intColumnIndex); for (int i = 1; i < mapColumnNames.size(); i++) { if (selectTableName.equals(mapTableNames.get(i))) { sbWhere.append(mapColumnNames.get(i)); if (data.get(i) == null) { sbWhere.append(" IS "); } else { sbWhere.append(" = "); } if (data.get(i) == null) { sbWhere.append(" null "); } else { if (RDBTypeToJavaTypeUtils.isNumberType(mapColumnType.get(i))) sbWhere.append(data.get(i)); else sbWhere.append("'" + data.get(i) + "'"); } sbWhere.append(" AND "); } } String returnWhere = sbWhere.toString(); returnWhere = StringUtils.removeEnd(returnWhere, "AND "); if (logger.isDebugEnabled()) logger.debug("make where statement is : " + returnWhere); return returnWhere; }
From source file:com.alibaba.otter.node.etl.common.pipe.impl.http.AttachmentHttpPipe.java
private File unpackFile(HttpPipeKey key) { Pipeline pipeline = configClientService.findPipeline(key.getIdentity().getPipelineId()); DataRetriever dataRetriever = dataRetrieverFactory.createRetriever(pipeline.getParameters().getRetriever(), key.getUrl(), downloadDir);/* w ww.jav a 2s.co m*/ File archiveFile = null; try { dataRetriever.connect(); dataRetriever.doRetrieve(); archiveFile = dataRetriever.getDataAsFile(); } catch (Exception e) { dataRetriever.abort(); throw new PipeException("download_error", e); } finally { dataRetriever.disconnect(); } // ?? if (StringUtils.isNotEmpty(key.getKey()) && StringUtils.isNotEmpty(key.getCrc())) { decodeFile(archiveFile, key.getKey(), key.getCrc()); } // .gzip?? String dir = StringUtils.removeEnd(archiveFile.getPath(), FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(archiveFile.getPath())); File unpackDir = new File(dir); // getArchiveBean().unpack(archiveFile, unpackDir); return unpackDir; }
From source file:com.hangum.tadpole.engine.query.sql.DBSystemSchema.java
/** * get function list/*from www . j av a 2s . c o m*/ * * @param userDB * @return * @throws TadpoleSQLManagerException * @throws SQLException */ public static List<ProcedureFunctionDAO> getFunctionList(final UserDBDAO userDB) throws TadpoleSQLManagerException, SQLException { if (userDB.getDBDefine() == DBDefine.TAJO_DEFAULT || userDB.getDBDefine() == DBDefine.HIVE_DEFAULT || userDB.getDBDefine() == DBDefine.HIVE2_DEFAULT || userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) return new ArrayList<ProcedureFunctionDAO>(); SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); List<ProcedureFunctionDAO> listFunction = sqlClient.queryForList("functionList", userDB.getDb()); //$NON-NLS-1$ // 1. ? ?? . ' " ???. // 2. create to default keyword StringBuffer strFunctionlist = new StringBuffer(); for (ProcedureFunctionDAO pfDao : listFunction) { pfDao.setSysName(SQLUtil.makeIdentifierName(userDB, pfDao.getName())); strFunctionlist.append(MakeContentAssistUtil.makeObjectPattern(pfDao.getSchema_name(), pfDao.getSysName(), "Function")); //$NON-NLS-1$ } userDB.setFunctionLisstSeparator( StringUtils.removeEnd(strFunctionlist.toString(), MakeContentAssistUtil._PRE_GROUP)); return listFunction; }