List of usage examples for org.apache.commons.lang3 StringUtils length
public static int length(final CharSequence cs)
From source file:io.knotx.adapter.common.placeholders.SlingUriInfoHelper.java
private static SlingUriInfo generateSlingUriInfo(String uri) { final Matcher matcher = URI_PATTERN.matcher(uri); SlingUriInfo uriInfo = null;/* ww w . ja v a 2s.c o m*/ if (matcher.matches()) { String path = matcher.group(1); String[] pathParts = StringUtils.length(path) > 1 ? path.substring(1).split("/") : new String[] { path }; String selectorString = matcher.group(3); String[] selectors = selectorString != null ? selectorString.split("\\.") : new String[0]; String extension = matcher.group(5); String suffix = matcher.group(6); uriInfo = new SlingUriInfo(path, pathParts, selectorString, selectors, extension, suffix); } return uriInfo; }
From source file:kenh.expl.functions.Length.java
public int process(Object obj) { if (obj instanceof String) { return StringUtils.length((String) obj); } else if (obj.getClass().isArray()) { return java.lang.reflect.Array.getLength(obj); } else if (obj instanceof Collection) { return ((Collection) obj).size(); }//from w ww.j a va 2 s. c o m return -1; }
From source file:minor.stockQuote.stockQuote.java
@Override public void validate() { if (StringUtils.isEmpty(getStockQuote())) { addFieldError("StockQuote", "Stock Quote cannot be blank"); }//from w ww . j a v a 2 s.c o m if (StringUtils.isNumeric(getStockQuote())) { addFieldError("StockQuote", "Stock Quote cannot be numeric"); } if (StringUtils.length(getStockQuote()) > 6) { addFieldError("StockQuote", "Invalid Ticker length"); } }
From source file:com.ync365.px.web.account.LoginController.java
@RequestMapping(method = RequestMethod.POST) public String fail(HttpServletRequest request, HttpServletResponse response) { String msg = (String) request.getAttribute("shiroLoginFailure"); if (StringUtils.length(msg) >= 15) {//????? request.setAttribute("errorMsg", "???"); } else {/*from ww w.j av a 2s. co m*/ request.setAttribute("errorMsg", msg); } if (!SecurityUtils.getSubject().isAuthenticated()) { response.setStatus(901); return "account/login_soft"; } return "redirect:/tohomepage"; }
From source file:gov.nih.nci.caintegrator.application.study.SubjectAnnotationHandler.java
/** * {@inheritDoc}//from www .ja va 2s .c o m */ @Override void handleIdentifier(String identifier) throws ValidationException { if (StringUtils.length(identifier) > MAX_IDENTIFIER_LENGTH) { throw new ValidationException( "Identifiers can only be up to " + MAX_IDENTIFIER_LENGTH + " characters in length."); } currentSubjectAssignment = sourceConfiguration.getStudyConfiguration() .getOrCreateSubjectAssignment(identifier); }
From source file:alfio.manager.EuVatChecker.java
static BiFunction<ConfigurationManager, OkHttpClient, Optional<VatDetail>> performCheck(String vatNr, String countryCode, int organizationId) { return (configurationManager, client) -> { if (StringUtils.isNotEmpty(vatNr) && StringUtils.length(countryCode) == 2 && checkingEnabled(configurationManager, organizationId)) { Request request = new Request.Builder().url(apiAddress(configurationManager) + "?country=" + countryCode.toUpperCase() + "&number=" + vatNr).get().build(); try (Response resp = client.newCall(request).execute()) { if (resp.isSuccessful()) { return Optional.of(getVatDetail(resp, vatNr, countryCode, organizerCountry(configurationManager, organizationId))); } else { return Optional.empty(); }/*from w ww . j av a2 s . co m*/ } catch (IOException e) { e.printStackTrace(); } } return Optional.empty(); }; }
From source file:com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperUtils.java
public static String bindingPathAndNode(String path, String zNodeName, String pathSeparator) { StringBuilder fullPath = new StringBuilder(StringUtils.length(path) + StringUtils.length(zNodeName) + 1); fullPath.append(path);//from www . j av a2 s .c o m if (!path.endsWith(pathSeparator)) { fullPath.append(pathSeparator); } fullPath.append(zNodeName); return fullPath.toString(); }
From source file:ch.cyberduck.core.ftp.LoggingProtocolCommandListener.java
@Override public void protocolCommandSent(final ProtocolCommandEvent event) { final String message = StringUtils.chomp(event.getMessage()); if (message.startsWith(FTPCmd.PASS.name())) { this.log(Type.request, String.format("%s %s", FTPCmd.PASS.name(), StringUtils.repeat("*", StringUtils.length(StringUtils.removeStart(message, FTPCmd.PASS.name()))))); } else {//from ww w.j a va 2 s . c o m this.log(Type.request, message); } }
From source file:com.adguard.android.filtering.api.HttpServiceClient.java
/** * Posts request with specified parameters to url. * * @param uploadUrl URL to send POST request to * @param data POST body/*from w w w . j a va 2 s. co m*/ * @return Response string * @throws IOException */ protected static String postData(String uploadUrl, String data) throws IOException { LOG.debug("Sending HTTP POST request to {}. Length={}", uploadUrl, StringUtils.length(data)); final String response = UrlUtils.postRequest(new URL(uploadUrl), data, "utf-8", "application/x-www-form-urlencoded", true, READ_TIMEOUT, CONNECTION_TIMEOUT); if (StringUtils.isEmpty(response)) { LOG.error("Response for {} is empty", uploadUrl); throw new IOException("Response is empty."); } LOG.debug("Got response: {}", response); return response; }
From source file:ch.cyberduck.core.PermissionOverwrite.java
public PermissionOverwrite fromOctal(final String input) { if (StringUtils.isBlank(input)) { return null; }//w w w. j a v a2s .c o m if (StringUtils.length(input) != 3) { return null; } if (!StringUtils.isNumeric(input)) { return null; } this.user.parse(input.charAt(0)); this.group.parse(input.charAt(1)); this.other.parse(input.charAt(2)); return this; }