List of usage examples for org.apache.commons.lang StringUtils stripToEmpty
public static String stripToEmpty(String str)
Strips whitespace from the start and end of a String returning an empty String if null
input.
From source file:com.adobe.acs.commons.errorpagehandler.impl.ErrorPageHandlerImpl.java
/** * Add extension as configured via OSGi Component Property. * <p>// w w w. j a va 2 s . c o m * Defaults to .html * * @param path * @return */ private String applyExtension(String path) { if (path == null) { return null; } if (StringUtils.isBlank(errorPageExtension)) { return path; } return StringUtils.stripToEmpty(path).concat(".").concat(errorPageExtension); }
From source file:nl.knaw.huygens.timbuctoo.model.PersonNameComponent.java
public void setValue(String value) { this.value = StringUtils.stripToEmpty(value); }
From source file:nl.knaw.huygens.timbuctoo.model.util.Link.java
public void setUrl(String url) { this.url = StringUtils.stripToEmpty(url); }
From source file:nl.knaw.huygens.timbuctoo.model.util.Link.java
public void setLabel(String label) { this.label = StringUtils.stripToEmpty(label); }
From source file:nl.knaw.huygens.timbuctoo.tools.importer.neww.WomenWritersImporter.java
private String preprocessJson(String line) { line = StringUtils.stripToEmpty(line); if (line.startsWith("{")) { line = line.replaceAll("\"_id\"", "\"tempid\""); line = line.replaceAll("ObjectId\\(\\s*(\\S+)\\s*\\)", "$1"); return line; } else {//from w w w . j a v a2 s .c o m System.out.println("## Skipping line: " + line); return ""; } }
From source file:org.ambraproject.action.user.UserActionSupport.java
private String makeValidUrl(final String url) throws MalformedURLException { final String newUrl = StringUtils.stripToEmpty(url); if (StringUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase(HTTP_PREFIX)) { return StringUtils.EMPTY; }//from w ww. j a va 2s. c o m return TextUtils.makeValidUrl(newUrl); }
From source file:org.apache.ivory.entity.FeedHelper.java
public static String normalizePartitionExpression(String part1, String part2) { String partExp = StringUtils.stripToEmpty(part1) + "/" + StringUtils.stripToEmpty(part2); partExp = partExp.replaceAll("//+", "/"); partExp = StringUtils.stripStart(partExp, "/"); partExp = StringUtils.stripEnd(partExp, "/"); return partExp; }
From source file:org.archive.modules.fetcher.FetchHTTP.java
/** * Set the transfer, content encodings based on headers (if necessary). * //from ww w. j av a 2 s .com * @param rec * Recorder for this request. * @param response * Method used for the request. */ protected void setOtherCodings(CrawlURI uri, final Recorder rec, final HttpResponse response) { if (response.getEntity() != null) { rec.setInputIsChunked(response.getEntity().isChunked()); Header contentEncodingHeader = response.getEntity().getContentEncoding(); if (contentEncodingHeader != null) { String ce = contentEncodingHeader.getValue().trim(); try { rec.setContentEncoding(ce); } catch (IllegalArgumentException e) { uri.getAnnotations().add("unsatisfiableContentEncoding:" + StringUtils.stripToEmpty(ce)); } } } }
From source file:org.archive.modules.fetcher.FetchHTTP.java
/** * Set the character encoding based on the result headers or default. * //from w w w.j a v a 2 s . com * The HttpClient returns its own default encoding ("ISO-8859-1") if one * isn't specified in the Content-Type response header. We give the user the * option of overriding this, so we need to detect the case where the * default is returned. * * Now, it may well be the case that the default returned by HttpClient and * the default defined by the user are the same. * * TODO:FIXME?: This method does not do the "detect the case where the * [HttpClient] default is returned" mentioned above! Why not? * * @param rec * Recorder for this request. * @param response * Method used for the request. */ protected void setCharacterEncoding(CrawlURI curi, final Recorder rec, final HttpResponse response) { rec.setCharset(getDefaultCharset()); try { Charset charset = ContentType.getOrDefault(response.getEntity()).getCharset(); if (charset != null) { rec.setCharset(charset); } } catch (IllegalArgumentException e) { // exception could be UnsupportedCharsetException or IllegalCharsetNameException String unsatisfiableCharset; try { unsatisfiableCharset = response.getFirstHeader("content-type").getElements()[0] .getParameterByName("charset").getValue(); } catch (Exception f) { unsatisfiableCharset = "<failed-to-parse>"; } curi.getAnnotations() .add("unsatisfiableCharsetInHeader:" + StringUtils.stripToEmpty(unsatisfiableCharset)); } }
From source file:org.dishevelled.commandline.argument.BooleanListArgument.java
/** {@inheritDoc} */ protected List<Boolean> convert(final String s) throws Exception { List<Boolean> list = new ArrayList<Boolean>(); StringTokenizer st = new StringTokenizer(s, ","); while (st.hasMoreTokens()) { String token = StringUtils.stripToEmpty(st.nextToken()); if ("true".equalsIgnoreCase(token)) { list.add(Boolean.TRUE); } else if ("false".equalsIgnoreCase(token)) { list.add(Boolean.FALSE); } else if ("t".equalsIgnoreCase(token)) { list.add(Boolean.TRUE); } else if ("f".equalsIgnoreCase(token)) { list.add(Boolean.FALSE); } else if ("1".equalsIgnoreCase(token)) { list.add(Boolean.TRUE); } else if ("0".equalsIgnoreCase(token)) { list.add(Boolean.FALSE); } else {/*from w w w . j ava 2 s .co m*/ throw new Exception("could not parse " + token + " into a Boolean"); } } return list; }