List of usage examples for org.apache.commons.lang3 StringUtils removeEnd
public static String removeEnd(final String str, final String remove)
Removes a substring only if it is at the end of a source string, otherwise returns the source string.
A null source string will return null .
From source file:org.junit.extensions.dynamicsuite.engine.ClassPathScanner.java
private void loadJarEntries(JarFile jar) { Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry element = entries.nextElement(); String name = element.getName(); if (name.toLowerCase().endsWith(".class")) { String className = StringUtils.replace(name, "/", "."); className = StringUtils.removeEnd(className, ".class"); foundClasses.add(className); }//from w w w. j av a 2 s . c om } }
From source file:org.junit.extensions.dynamicsuite.engine.DirectoryScanner.java
protected String extractClassName(String basePath, String classFileName) { String className = classFileName; className = StringUtils.removeStart(className, basePath); className = StringUtils.removeStart(className, File.separator); className = StringUtils.removeEnd(className, CLASS_ENDING); className = StringUtils.removeEnd(className, SOURCE_ENDING); className = StringUtils.replace(className, File.separator, "."); return className; }
From source file:org.junit.extensions.dynamicsuite.engine.DirectoryScannerTest.java
private String toClassName(String path, String name) { return StringUtils.replace(path, separator, ".") + "." + StringUtils.removeEnd(StringUtils.removeEnd(name, ".class"), ".java"); }
From source file:org.kawanfw.sql.api.server.StatementAnalyser.java
/** * Remove all trailing ";" from SQL command * //from w ww .ja v a2 s. c o m * @param sql * the sql command * @return the sql command without the trailing ";" */ private String removeTrailingSemicolons(String sql) { sql = sql.trim(); // Remove the trailing ";", there may be some blanks, so we always trim while (sql.endsWith(";")) { sql = StringUtils.removeEnd(sql, ";"); sql = sql.trim(); } return sql; }
From source file:org.kawanfw.sql.api.util.PreparedStatementRunner.java
/** * Constructor./*from w w w . j av a 2 s. c o m*/ * * @param connection * the JDBC Connection instance * @param sql * the prepared statement base SQL request with all the '?' * @param params * the prepared statement parameters value in the awaited order */ public PreparedStatementRunner(Connection connection, String sql, Object... params) { if (connection == null) { throw new IllegalArgumentException("connection can\'t be null"); } if (sql == null) { throw new IllegalArgumentException("sql preparement statement string can\'t be null"); } sql = sql.trim(); while (sql.endsWith(";")) { sql = StringUtils.removeEnd(sql, ";"); } this.sql = sql; developedQuery = sql; // Build the string of the developed query for (int i = 0; i < params.length; i++) { this.params.add(params[i]); String strParam = params[i].toString(); developedQuery = developedQuery.replaceFirst("\\?", strParam); } this.connection = connection; }
From source file:org.kawanfw.sql.servlet.sql.DbVendorManagerUtil.java
/** * Remove ";" from trailing SQL order//from ww w. jav a 2s.com * * @param sqlOrder * @return sqlOrder without trailing ";" */ public static String removeSemicolon(String sqlOrder) { while (sqlOrder.trim().endsWith(";")) { sqlOrder = sqlOrder.trim(); sqlOrder = StringUtils.removeEnd(sqlOrder, ";"); } return sqlOrder; }
From source file:org.kisoonlineapp.startup.StartupSqlReader.java
final void readFromInputStream(InputStream is) throws IOException { final BufferedReader br = new BufferedReader(new InputStreamReader(is)); try {//from www. j a v a 2 s.c o m String key = null; StringBuilder value = new StringBuilder(); for (String line; (line = br.readLine()) != null;) { if (StringUtils.startsWithAny(line, new String[] { "#", "---" })) { continue; } line = StringUtils.removeEnd(line, "\\"); if (StringUtils.contains(line, '=')) { if (key == null) { String[] splitted = StringUtils.split(line, "=", 2); if (splitted.length == 2) { key = splitted[0]; value.append(splitted[1]); } else if (splitted.length == 1) { key = splitted[0]; value.append(""); } } else { value.append(line); } } else if (StringUtils.isBlank(line)) { if (key != null) { this.statementMap.put(key, value.toString()); key = null; value = new StringBuilder(); } } else { value.append(line); } } if (key != null) { this.statementMap.put(key, value.toString()); } } finally { br.close(); } }
From source file:org.kuali.coeus.common.impl.compliance.core.SpecialReviewServiceImpl.java
@Override public String getProtocolSaveLocationPrefix(Map<String, String[]> parameters) { String prefix = null;// w ww.j a v a2s . c o m for (String parameterName : parameters.keySet()) { if (parameterName.endsWith(PROTOCOL_NUMBER)) { prefix = StringUtils.removeEnd(parameterName, PROTOCOL_NUMBER); break; } } return prefix; }
From source file:org.kuali.coeus.common.questionnaire.framework.question.Question.java
/** * /* www.j a va2s .c o m*/ * This method returns the descriptive text of the lookupClass * @return descriptive text */ public String getLookupClassDescription() { if (this.lookupClass != null) { DataDictionaryService dataDictionaryService = KNSServiceLocator.getDataDictionaryService(); BusinessObjectEntry businessObjectEntry = (BusinessObjectEntry) dataDictionaryService .getDataDictionary().getBusinessObjectEntries().get(this.lookupClass); return StringUtils.removeEnd(businessObjectEntry.getLookupDefinition().getTitle().trim(), " Lookup"); } else { return ""; } }
From source file:org.kuali.coeus.org.kuali.rice.krad.uif.container.KcLightTable.java
/** * Process the expression for the item by putting placeholder values in for String properties and adding markers * for render expressions to the component; adds the original expression to the expressionMap * * @param name the property name/*from w w w. j a v a2s . co m*/ * @param item the component this expressio is on * @param expressionMap the map to add expressions to * @param toRemove the property name is added this map to be removed later */ public void processExpression(String name, Component item, Map<String, String> expressionMap, List<String> toRemove) { Class<?> clazz = ObjectPropertyUtils.getPropertyType(item, name); if (clazz == null) { return; } if (clazz.isAssignableFrom(String.class)) { //add expressions for string properties only expressionMap.put(name + SEPARATOR + item.getId(), item.getExpressionGraph().get(name)); toRemove.add(name); ObjectPropertyUtils.setPropertyValue(item, name, EXPRESSION_TOKEN + name + SEPARATOR + item.getId() + EXPRESSION_TOKEN); } else if (name.endsWith(RENDER) && clazz.isAssignableFrom(boolean.class)) { //setup render tokens to be able to determine where to remove content for render false, if needed Component renderComponent = item; //check for nested render (child element) if (!name.equals(RENDER)) { renderComponent = ObjectPropertyUtils.getPropertyValue(item, StringUtils.removeEnd(name, ".render")); } //add render expression to the map renderIdExpressionMap.put(renderComponent.getId(), item.getExpressionGraph().get(name)); toRemove.add(name); String renderMarker = A_TOKEN + RENDER + A_TOKEN + renderComponent.getId() + A_TOKEN; //setup pre render content token String pre = renderComponent.getPreRenderContent() == null ? "" : renderComponent.getPreRenderContent(); renderComponent.setPreRenderContent(renderMarker + pre); //setup post render content token String post = renderComponent.getPostRenderContent() == null ? "" : renderComponent.getPostRenderContent(); renderComponent.setPostRenderContent(post + renderMarker); //force render to true ObjectPropertyUtils.setPropertyValue(item, name, true); } }