List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:com.fortify.processrunner.common.bugtracker.issue.SubmittedIssueCommentHelper.java
/** * Parse a {@link SubmittedIssue} from the given comment string that was previously generated using * {@link #getCommentForSubmittedIssue(String, SubmittedIssue)} * @param comment/*from ww w .j ava2s . co m*/ * @return */ public static final SubmittedIssue getSubmittedIssueFromComment(String comment) { try { Object[] fields = FMT_COMMENT.parse(comment); String id = StringUtils.removeStart(StringUtils.trim((String) fields[1]), "ID "); String deepLink = StringUtils.trim((String) fields[2]); return new SubmittedIssue(id, deepLink); } catch (Exception e) { throw new RuntimeException("Error parsing comment " + comment); } }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.forms.TfsLoginForm.java
@Override public String getServerName() { return StringUtils.trim(serverUrl.getText()); }
From source file:com.surveypanel.web.admin.TemplateAction.java
@Override protected SurveyTemplate bind() { SurveyTemplate template = new SurveyTemplate(); template.setSource(StringUtils.trim(source)); template.setName(StringUtils.trim(name)); template.setId(id == null ? 0 : id); template.setSurveyId(surveyId);//from w w w .j av a 2s . co m return template; }
From source file:com.mirth.connect.client.ui.components.rsta.ac.js.MirthSourceCompletionProvider.java
@Override protected List<Completion> getCompletionsImpl(JTextComponent comp) { Set<Completion> set = new HashSet<Completion>(super.getCompletionsImpl(comp)); String text = StringUtils.trim(getAlreadyEnteredText(comp)); if (StringUtils.isNotBlank(text)) { int dot = text.lastIndexOf('.'); if (dot > 0) { int nextToLastDot = text.lastIndexOf('.', dot - 1); String identifier;/* w ww . j av a 2s . c o m*/ if (nextToLastDot >= 0) { identifier = text.substring(nextToLastDot + 1, dot).trim(); } else { identifier = text.substring(0, dot).trim(); } identifier = PARENTHESES_PATTERN.matcher(identifier).replaceAll("").trim(); int index = identifier.lastIndexOf(' '); if (index >= 0) { identifier = identifier.substring(index + 1); } String partialText = text.substring(dot + 1).trim(); if (StringUtils.isNotBlank(identifier)) { set.addAll(completionCache.getFunctionCompletions(comp, identifier, partialText)); } } else if (text.equals("new") || text.startsWith("new ")) { String partialText = text.substring(3).trim(); set.addAll(completionCache.getConstructorCompletions(comp, partialText)); } else { set.addAll(completionCache.getVariableCompletions(comp, text)); set.addAll(completionCache.getClassCompletions(comp, text)); set.addAll(completionCache.getGlobalFunctionCompletions(comp, text)); set.addAll(completionCache.getCodeCompletions(comp, text)); } } else { set.addAll(completionCache.getVariableCompletions(comp, "")); set.addAll(completionCache.getClassCompletions(comp, "")); set.addAll(completionCache.getGlobalFunctionCompletions(comp, "")); set.addAll(completionCache.getCodeCompletions(comp, "")); } return new ArrayList<Completion>(set); }
From source file:com.qualitesys.sonarqcr4pblplugin.pbl.PblFile.java
/** * @param unitTest whether it is a unit test file or a source file *///w ww . ja v a 2 s . c o m public PblFile(String key, boolean unitTest) { super(); if (key != null && key.indexOf('$') >= 0) { throw new IllegalArgumentException("Pbl inner classes are not supported : " + key); } String realKey = StringUtils.trim(key); this.unitTest = unitTest; if (realKey.contains(".")) { this.filename = StringUtils.substringAfterLast(realKey, "."); this.packageKey = StringUtils.substringBeforeLast(realKey, "."); this.longName = realKey; } else { this.filename = realKey; this.longName = realKey; this.packageKey = PblPackage.DEFAULT_PACKAGE_NAME; realKey = new StringBuilder().append(PblPackage.DEFAULT_PACKAGE_NAME).append(".").append(realKey) .toString(); } setKey(realKey); }
From source file:com.redhat.rhn.common.security.acl.AclFactory.java
/** * Get an instance of an Acl/*from w w w. j av a2 s . c o m*/ * @param mixinsIn the String with a comma separated list of classnames * @return Acl created */ public Acl getAcl(String mixinsIn) { Acl aclObj = new Acl(); Access access = new Access(); aclObj.registerHandler(access); // Add the mixin handlers as well. if (mixinsIn != null) { String[] mixin = StringUtils.split(mixinsIn, ","); for (int i = 0; i < mixin.length; i++) { aclObj.registerHandler(StringUtils.trim(mixin[i])); } } return aclObj; }
From source file:ar.com.zauber.garfio.modules.mantis.model.actions.FixInVersionAction.java
/** * Creates the AddNoteToIssueAction.//from w ww. j a va 2s.c o m * * @param issue involved issue * @param session tracker session * @throws JMTException on i/o error. */ public FixInVersionAction(final MantisIssue issue, final MantisTrackerSession session, final String aversion) throws JMTException { super(issue, session); Validate.isTrue(!StringUtils.isBlank(aversion), "you must set a version number"); final String versionNumber = StringUtils.trim(aversion); final ProjectVersionData[] versions = session.getSession() .getVersions(mantisIssue.getIssueData().getProject().getId().longValue()); String tmp = null; for (final ProjectVersionData v : versions) { if (v.getName().equalsIgnoreCase(versionNumber)) { if (v.getReleased()) { throw new IllegalArgumentException("you specified version `" + versionNumber + "' but it has already been released. " + "Ignoring action."); } else { tmp = v.getName(); break; } } } if (tmp == null) { final StringBuilder sb = new StringBuilder(); sb.append("you specified version `"); sb.append(versionNumber); sb.append("' but posible versions are: "); for (final ProjectVersionData v : versions) { if (!v.getReleased()) { sb.append(v.getName()); sb.append(' '); } } sb.append(". Ignoring action."); throw new IllegalArgumentException(sb.toString()); } this.version = tmp; }
From source file:com.memonews.solr.search.HighlightQParserPlugin.java
@Override @SuppressWarnings("rawtypes") public void init(NamedList args) { if (args != null) { String fields = (String) args.get("fields"); if (StringUtils.isNotBlank(fields)) { for (String field : fields.split(",")) { fieldNames.add(StringUtils.trim(field)); }//from ww w. j a v a2 s . c o m } } }
From source file:io.kahu.hawaii.util.call.http.util.UriBuilder.java
public URI build() throws ServerException { assert baseUrl != null : "Base URL must be set."; StringBuilder urlBuilder = new StringBuilder(baseUrl); if (StringUtils.isNotBlank(path)) { String trimmedPath = StringUtils.trim(path); if (trimmedPath.startsWith("/") && baseUrl.endsWith("/")) { trimmedPath = trimmedPath.substring(1); }// www .ja v a 2 s .c om urlBuilder.append(trimmedPath); } if (pathVariables != null && pathVariables.length > 0) { String url = urlBuilder.toString(); urlBuilder = new StringBuilder(); substitutePathVariables(urlBuilder, url); } if (queryParameters != null && !queryParameters.isEmpty()) { appendQueryParameters(urlBuilder, queryParameters); } try { return new URI(urlBuilder.toString()); } catch (URISyntaxException e) { throw new ServerException(ServerError.URI_INVALID, e.getMessage(), e); } }
From source file:com.dattack.dbtools.drules.beans.Identifier.java
private static String normalize(final String text) { return StringUtils.trim(StringUtils.lowerCase(text)); }