List of usage examples for org.apache.commons.lang StringUtils trimToNull
public static String trimToNull(String str)
Removes control characters (char <= 32) from both ends of this String returning null
if the String is empty ("") after the trim or if it is null
.
From source file:net.hillsdon.reviki.wiki.renderer.creole.CreoleLinkContentsSplitter.java
/** * Splits links of the form target or text|target where target is * /*from w w w .j av a 2 s.c om*/ * PageName wiki:PageName PageName#fragment wiki:PageName#fragment * A String representing an absolute URI scheme://valid/absolute/uri * Any character not in the `unreserved`, `punct`, `escaped`, or `other` categories (RFC 2396), * and not equal '/' or '@', is %-encoded. * * @param in The String to split * @return The split LinkParts */ LinkParts split(final String in) { String target = StringUtils.trimToEmpty(StringUtils.substringBefore(in, "|")); String text = StringUtils.trimToNull(StringUtils.substringAfter(in, "|")); if (target == null) { target = ""; } if (text == null) { text = target; } // Link target can be PageName, wiki:PageName or a URL. URI uri = null; try { URL url = new URL(target); uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); if (uri.getPath() == null || !uri.isAbsolute()) { uri = null; } } catch (URISyntaxException e) { // uri remains null } catch (MalformedURLException e) { // uri remains null } if (uri != null) { return new LinkParts(text, uri); } else { // Split into wiki:pageName String[] parts = target.split(":", 2); String wiki = null; String pageName = target; if (parts.length == 2) { wiki = parts[0]; pageName = parts[1]; } // Split into pageName#fragment parts = pageName.split("#", 2); String fragment = null; if (parts.length == 2) { pageName = parts[0]; fragment = parts[1]; } // Split into pageName/attachment parts = pageName.split("/", 2); String attachment = null; if (parts.length == 2) { pageName = parts[0]; attachment = parts[1]; } return new LinkParts(text, wiki, pageName, fragment, attachment); } }
From source file:com.mmj.app.common.cookie.parser.CookieParser.java
/** * CookieName???Cookievalue. ?CookieNameCookieKey * /*from w w w .j av a2s . c o m*/ * @return ?null */ public static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) { String value = StringUtils.trimToNull(cookieValue); if (value == null || StringUtils.equalsIgnoreCase("null", value)) return null; // ? if (cookieNameConfig.isEncrypt()) { value = EncryptBuilder.getInstance().decrypt(value); } CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(), cookieNameConfig); // ??Key??,? if (cookieNameConfig.isSimpleValue()) { cookieNameHelper.parserValue(value); } else { // ??Value?? Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig); // CookieNameHelper cookieNameHelper = null; if (kv != null && !kv.isEmpty()) cookieNameHelper.parserAllValues(kv); } return cookieNameHelper; }
From source file:com.egt.core.aplicacion.OrdenConjuntoResultados.java
@Override public String toString() { String order = StringUtils.EMPTY; String token = StringUtils.EMPTY; for (CriterioOrden criterio : criterios) { token = criterio.toString();//from www . j a v a 2s. c o m order += StringUtils.isBlank(token) ? "" : COMA + token; } order = StringUtils.removeStart(order, COMA); return StringUtils.trimToNull(order); }
From source file:com.alibaba.dubbo.governance.web.governance.module.screen.Weights.java
public void index(Map<String, Object> context) { final String service = StringUtils.trimToNull((String) context.get("service")); String address = (String) context.get("address"); address = Tool.getIP(address); List<Weight> weights;/*from w ww . j a v a 2s . c om*/ if (service != null && service.length() > 0) { weights = OverrideUtils.overridesToWeights(overrideService.findByService(service)); } else if (address != null && address.length() > 0) { weights = OverrideUtils.overridesToWeights(overrideService.findByAddress(address)); } else { weights = OverrideUtils.overridesToWeights(overrideService.findAll()); } context.put("weights", weights); }
From source file:com.opengamma.web.portfolio.WebPortfolioNodePositionsResource.java
@POST @Produces(MediaType.TEXT_HTML)/*from ww w . j a v a 2 s. c o m*/ @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response postHTML(@FormParam("positionurl") String positionUrlStr) { PortfolioDocument doc = data().getPortfolio(); if (doc.isLatest() == false) { return Response.status(Status.FORBIDDEN).entity(new WebPortfolioNodeResource(this).getHTML()).build(); } positionUrlStr = StringUtils.trimToNull(positionUrlStr); if (positionUrlStr == null) { FlexiBean out = createRootData(); out.put("err_positionUrlMissing", true); String html = getFreemarker().build(HTML_DIR + "portfolionodepositions-add.ftl", out); return Response.ok(html).build(); } UniqueId positionId = null; try { new URI(positionUrlStr); // validates whole URI String uniqueIdStr = StringUtils.substringAfterLast(positionUrlStr, "/positions/"); uniqueIdStr = StringUtils.substringBefore(uniqueIdStr, "/"); positionId = UniqueId.parse(uniqueIdStr); data().getPositionMaster().get(positionId); // validate position exists } catch (Exception ex) { FlexiBean out = createRootData(); out.put("err_positionUrlInvalid", true); String html = getFreemarker().build(HTML_DIR + "portfolionodepositions-add.ftl", out); return Response.ok(html).build(); } URI uri = addPosition(doc, positionId); return Response.seeOther(uri).build(); }
From source file:ch.entwine.weblounge.common.impl.content.page.ComposerImpl.java
/** * Creates a new composer with the given identifier. * //from ww w .j a v a 2 s .c o m * @param identifier * the composer identifier */ public ComposerImpl(String identifier) { if (StringUtils.trimToNull(identifier) == null) throw new IllegalArgumentException("Composer identifier cannot be null"); this.identifier = identifier; this.pagelets = new ArrayList<Pagelet>(); }
From source file:jenkins.plugins.livingdoc.mapping.LivingDocProjectConfigPage.java
public String getTestResultsPattern() { return StringUtils.trimToNull(testResultsPattern().getText()); }
From source file:com.thistech.spotlink.model.Ad.java
public Ad addTrackingEventUrl(String event, String url) { if (StringUtils.isNotEmpty(event) && StringUtils.isNotEmpty(url)) { getTrackingEvents().getEventUrls().put(StringUtils.trimToNull(event), StringUtils.trimToNull(url)); }// w w w . j a v a 2 s. c om return this; }
From source file:com.enonic.vertical.VerticalProperties.java
public String getProperty(final String key) { final String systemProperty = StringUtils.trimToNull(System.getProperty(key)); if (systemProperty != null) { return systemProperty; }// w w w . j a v a2 s . com return StringUtils.trimToNull(properties.getProperty(key)); }
From source file:com.novartis.pcs.ontology.rest.servlet.GraphServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String pathInfo = StringUtils.trimToNull(request.getPathInfo()); String orientation = StringUtils.trimToNull(request.getParameter("orientation")); String callback = StringUtils.trimToNull(request.getParameter("callback")); String mediaType = getExpectedMediaType(request); if (pathInfo != null && pathInfo.length() > 1) { String termRefId = pathInfo.substring(1); graph(termRefId, mediaType, orientation, callback, response); } else {/* www .ja va2 s. c om*/ response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.setContentLength(0); } }