List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .
From source file:com.esri.geoportal.commons.csw.client.impl.DcList.java
/** * Gets the dc string// w w w . j av a 2 s.c o m * * @param scheme the scheme (if null or empty, EMPTY_SCHEME will be used) * @return list dc strings */ public List<String> get(String scheme) { scheme = StringUtils.trimToEmpty(scheme); if ("".equals(scheme)) { scheme = EMPTY_SCHEME; } List<String> valueList = new LinkedList<String>(); Iterator<DcList.Value> iter = this.iterator(); while (iter.hasNext()) { Value value = iter.next(); if (value == null) { continue; } if (value.getScheme().equalsIgnoreCase(scheme)) { valueList.add(value.getValue()); } } return valueList; }
From source file:ke.co.tawi.babblesms.server.servlet.admin.Login.java
/** * @param request//from w w w. j a v a 2s. c o m * @param response * @throws ServletException * @throws IOException */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); String username = StringUtils.trimToEmpty(request.getParameter("username")); String password = StringUtils.trimToEmpty(request.getParameter("password")); hiddenCaptchaStr = request.getParameter("captchaHidden"); String captchaAnswer = request.getParameter("captchaAnswer").trim(); if (!validateCaptcha(hiddenCaptchaStr, captchaAnswer)) { session.setAttribute(SessionConstants.ADMIN_SIGN_IN_ERROR_KEY, ACCOUNT_SIGN_IN_BAD_CAPTCHA); response.sendRedirect("index.jsp"); // The username supplied does not match what is in the config file } else if (!StringUtils.equals(username, PropertiesConfig.getConfigValue("ADMIN_USERNAME"))) { session.setAttribute(SessionConstants.ADMIN_SIGN_IN_ERROR_KEY, SessionConstants.ADMIN_SIGN_IN_ERROR_KEY); response.sendRedirect("index.jsp"); // The password supplied does not match what is in the config file } else if (!StringUtils.equals(password, PropertiesConfig.getConfigValue("ADMIN_PASSWORD"))) { session.setAttribute(SessionConstants.ADMIN_SIGN_IN_ERROR_KEY, SessionConstants.ADMIN_SIGN_IN_ERROR_VALUE); response.sendRedirect("index.jsp"); // The login is correct } else { session.setAttribute(SessionConstants.ADMIN_SESSION_KEY, "admin"); session.setAttribute(SessionConstants.ADMIN_LOGIN_TIME_KEY, new Date()); //initCache(); response.sendRedirect("accounts.jsp"); } }
From source file:com.mirth.connect.plugins.httpauth.userutil.AuthenticationResult.java
/** * Convenience method to create a new AuthenticationResult with the CHALLENGED status. * //from w w w .ja v a 2s . com * @param authenticateHeader * The value to include in the WWW-Authenticate response header. */ public static AuthenticationResult Challenged(String authenticateHeader) { AuthenticationResult result = new AuthenticationResult(AuthStatus.CHALLENGED); result.addResponseHeader("WWW-Authenticate", StringUtils.trimToEmpty(authenticateHeader)); return result; }
From source file:com.cz4031.SAXHandler.java
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String tempValue = stringBuilder.toString(); String tempAccent = StringUtils.stripAccents(tempValue); String value = StringUtils.trimToEmpty(tempAccent); stringBuilder.setLength(0);// w w w . j a va 2 s. c o m if (publication != null) { if (qName.equalsIgnoreCase("author")) { String authorName = value.toLowerCase(); AuthorList instance = AuthorList.getInstance(); HashMap<Author, Set<Integer>> authorList = instance.getAuthorList(); Author author = new Author(); author.setName(authorName); if (authorList.containsKey(author)) { Set<Integer> publicationList = authorList.get(author); publicationList.add(publication.getPubId()); } else { author.setId(++authorID); Set<Integer> publicationList = new HashSet<>(); publicationList.add(publication.getPubId()); authorList.put(author, publicationList); } } else if (qName.equalsIgnoreCase("article") || qName.equalsIgnoreCase("book") || qName.equalsIgnoreCase("incollection") || qName.equalsIgnoreCase("inproceedings")) { CSVWriter csvWriter = CSVWriter.getInstance(); csvWriter.writeToPublication(publication); publication = null; } else if (qName.equalsIgnoreCase("title")) { publication.setTitle(value); } else if (qName.equalsIgnoreCase("year")) { int year = Integer.parseInt(value); publication.setYear(year); } else if (qName.equalsIgnoreCase("journal")) { publication.setJournal(value); } else if (qName.equalsIgnoreCase("volume")) { publication.setVolume(value); } else if (qName.equalsIgnoreCase("number")) { publication.setNumber(value); } else if (qName.equalsIgnoreCase("publisher")) { publication.setPublisher(value); } else if (qName.equalsIgnoreCase("isbn")) { publication.setIsbn(value); } else if (qName.equalsIgnoreCase("booktitle")) { publication.setBooktitle(value); } else if (qName.equalsIgnoreCase("editor")) { publication.setEditor(value); } else if (qName.equalsIgnoreCase("pages")) { String pageStr = value; parsePages(pageStr); } } }
From source file:de.micromata.genome.gwiki.model.GWikiStandardEmailProvider.java
protected void evaluateMailTemplate(String mailTemplate, Map<String, String> ctx) { GWikiStandaloneContext wikiContext = GWikiStandaloneContext.create(); wikiContext.setRequestAttribute("mailContext", ctx); for (Map.Entry<String, String> me : ctx.entrySet()) { wikiContext.setRequestAttribute(me.getKey(), me.getValue()); }/*w ww .j a v a2 s . c o m*/ GWikiElement el = wikiContext.getWikiWeb().getElement(mailTemplate); el.serve(wikiContext); wikiContext.flush(); String text = wikiContext.getOutString(); for (Map.Entry<String, Object> me : wikiContext.getRequestAttributes().entrySet()) { if (me.getValue() instanceof String) { ctx.put(me.getKey(), (String) me.getValue()); } } text = StringUtils.trimToEmpty(text); if (StringUtils.isNotBlank(text) == true) { ctx.put(TEXT, text); } }
From source file:com.xpn.xwiki.plugin.calendar.CalendarEvent.java
public void setUser(String user) { this.user = StringUtils.trimToEmpty(user); }
From source file:net.gplatform.sudoor.server.social.model.SimpleSignInAdapter.java
@Override public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) { SSAuth.signin(localUserId, null);//from w w w . j ava 2 s.c o m HttpServletRequest nativeReq = request.getNativeRequest(HttpServletRequest.class); HttpSession session = nativeReq.getSession(); session.setAttribute(CONNECTION_KEY, connection); String providerId = connection.getKey().getProviderId(); String parameter = "?entryPoint=oauth_" + providerId; String targetUrl = "/"; String originalUrl = extractOriginalUrl(request); if (StringUtils.isNotEmpty(originalUrl)) { targetUrl = StringUtils.trimToEmpty(originalUrl); } return targetUrl + parameter; }
From source file:com.omertron.slackbot.utils.GitRepositoryState.java
private static Boolean asBoolean(final String valueToConvert) { if (StringUtils.isNotBlank(valueToConvert)) { return Boolean.parseBoolean(StringUtils.trimToEmpty(valueToConvert)); }/* w ww . j a v a 2s .c o m*/ // Default to false return Boolean.FALSE; }
From source file:hu.bme.mit.sette.common.descriptors.eclipse.EclipseProjectDescriptor.java
/** * Sets the comment for the project./* w w w . j a va 2 s .c om*/ * * @param pComment * The comment for the project. */ public void setComment(final String pComment) { comment = StringUtils.trimToEmpty(pComment); }
From source file:com.mirth.connect.util.CodeTemplateUtil.java
public static String updateCode(String code) { if (StringUtils.isNotBlank(code)) { code = StringUtils.trim(code);// w ww .j a va 2s . c o m int endIndex = 0; Matcher matcher = COMMENT_PATTERN.matcher(code); if (matcher.find()) { endIndex = matcher.end(); } CodeTemplateDocumentation documentation = getDocumentation(code); String description = documentation.getDescription(); CodeTemplateFunctionDefinition functionDefinition = documentation.getFunctionDefinition(); if (StringUtils.isBlank(description)) { description = "Modify the description here. Modify the function name and parameters as needed. One function per template is recommended; create a new code template for each new function."; } StringBuilder builder = new StringBuilder("/**"); for (String descriptionLine : description.split("\r\n|\r|\n")) { builder.append("\n\t").append(WordUtils.wrap(descriptionLine, 100, "\n\t", false)); } if (functionDefinition != null) { builder.append('\n'); if (CollectionUtils.isNotEmpty(functionDefinition.getParameters())) { for (Parameter parameter : functionDefinition.getParameters()) { StringBuilder parameterBuilder = new StringBuilder("\n\t@param {"); parameterBuilder.append(StringUtils.defaultString(parameter.getType(), "Any")); parameterBuilder.append("} ").append(parameter.getName()).append(" - ") .append(StringUtils.trimToEmpty(parameter.getDescription())); builder.append(WordUtils.wrap(parameterBuilder.toString(), 100, "\n\t\t", false)); } } StringBuilder returnBuilder = new StringBuilder("\n\t@return {") .append(StringUtils.defaultString(functionDefinition.getReturnType(), "Any")).append("} ") .append(StringUtils.trimToEmpty(functionDefinition.getReturnDescription())); builder.append(WordUtils.wrap(returnBuilder.toString(), 100, "\n\t\t", false)); } builder.append("\n*/\n"); return builder.toString() + code.substring(endIndex); } return code; }