public void setSrc(String src) { this.src = StringUtils.trim(src); }
public void setDest(String dest) { this.dest = StringUtils.trim(dest); }
public void setName(String name) { this.name = StringUtils.trim(name); }
public void setSource(String source) { this.source = StringUtils.trim(source); }
public void setEmail(String email) { this.email = StringUtils.trim(email); }
public void setDestination(String destination) { if (StringUtils.isNotBlank(destination)) { this.destination = StringUtils.trim(destination); } }
/** * <p>Removes control characters (char <= 32) from both * ends of this String returning {@code null} if the String is * empty ("") after the trim or if it is {@code null}. * * <p>The String is trimmed using {@link String#trim()}. * Trim removes start and end characters <= 32. * To strip whitespace use {@link #stripToNull(String)}.</p> * * <pre> * StringUtils.trimToNull(null) = null * StringUtils.trimToNull("") = null * StringUtils.trimToNull(" ") = null * StringUtils.trimToNull("abc") = "abc" * StringUtils.trimToNull(" abc ") = "abc" * </pre> * * @param str the String to be trimmed, may be null * @return the trimmed String, * {@code null} if only chars <= 32, empty or null String input * @since 2.0 */ public static String trimToNull(final String str) { final String ts = trim(str); return isEmpty(ts) ? null : ts; }
/** * @return A map that contains default charset for a specific content-type. It will have precedence over {@link #defaultContentCharset()}. */ public boolean hasDefaultCharsetForContentType(String contentType) { return !StringUtils.isBlank(contentType) && contentTypeToDefaultCharset.containsKey(trim(contentType).toLowerCase()); }
/** * @return A map that contains default charset for a specific content-type. It will have precedence over {@link #defaultContentCharset()}. */ public boolean hasDefaultCharsetForContentType(String contentType) { return !StringUtils.isBlank(contentType) && contentTypeToDefaultCharset.containsKey(trim(contentType).toLowerCase()); }
@JSONField(serialize = false) public Map<String, String> getCustomHeaders() { if (StringUtils.isBlank(headers)) { return Collections.emptyMap(); } Map<String, String> headerMap = new HashMap<String, String>(16); for (String s : headers.split(Constants.NAMING_HTTP_HEADER_SPILIER)) { String[] splits = s.split(":"); if (splits.length != 2) { continue; } headerMap.put(StringUtils.trim(splits[0]), StringUtils.trim(splits[1])); } return headerMap; }
/** * Specify a charset for this content-type * * @param charset The charset * @return The content-type with the given charset. */ public String withCharset(String charset) { if (StringUtils.isBlank(charset)) { throw new IllegalArgumentException("charset cannot be empty"); } return format("%s; charset=%s", this.toString(), trim(charset)); }
/** * Specify the default charset to use for the specific content-type if it's not specified in the content-type header explicitly * * @param charset The charset to use as default (unless specified explicitly) * @param contentType The content-type * @return A new instance of {@link DecoderConfig} */ public DecoderConfig defaultCharsetForContentType(String charset, String contentType) { notNull(charset, "Charset"); notNull(contentType, "ContentType"); Map<String, String> map = new HashMap<String, String>(contentTypeToDefaultCharset); map.put(trim(contentType).toLowerCase(), trim(charset)); return new DecoderConfig(charset, useNoWrapForInflateDecoding, true, contentDecoders, map); }
/** * Specify the default charset to use for the specific content-type if it's not specified in the content-type header explicitly * * @param charset The charset to use as default (unless specified explicitly) * @param contentType The content-type * @return A new instance of {@link EncoderConfig} */ public EncoderConfig defaultCharsetForContentType(String charset, String contentType) { notNull(charset, "Charset"); notNull(contentType, "ContentType"); Map<String, String> map = new HashMap<String, String>(contentTypeToDefaultCharset); map.put(trim(contentType).toLowerCase(), trim(charset)); return new EncoderConfig(charset, defaultQueryParameterCharset, shouldAppendDefaultContentCharsetToContentTypeIfUndefined, contentEncoders, map, true); }
/** * @return The default charset for a specific content-type. It will have precedence over {@link #defaultContentCharset()}. */ public String defaultCharsetForContentType(String contentType) { if (StringUtils.isEmpty(contentType)) { return defaultContentCharset(); } String charset = contentTypeToDefaultCharset.get(trim(contentType).toLowerCase()); if (charset == null) { return defaultContentCharset(); } return charset; }
/** * @return The default charset for a specific content-type. It will have precedence over {@link #defaultContentCharset()}. */ public String defaultCharsetForContentType(String contentType) { if (StringUtils.isEmpty(contentType)) { return defaultContentCharset(); } String charset = contentTypeToDefaultCharset.get(trim(contentType).toLowerCase()); if (charset == null) { return defaultContentCharset(); } return charset; }
public CustomHttpMethod(String methodName, final URI uri) { AssertParameter.notNull(methodName, "Method"); this.methodName = StringUtils.trim(methodName).toUpperCase(); setURI(uri); }
@Test public void testTrim() { assertEquals(FOO, StringUtils.trim(FOO + " ")); assertEquals(FOO, StringUtils.trim(" " + FOO + " ")); assertEquals(FOO, StringUtils.trim(" " + FOO)); assertEquals(FOO, StringUtils.trim(FOO + "")); assertEquals("", StringUtils.trim(" \t\r\n\b ")); assertEquals("", StringUtils.trim(StringUtilsTest.TRIMMABLE)); assertEquals(StringUtilsTest.NON_TRIMMABLE, StringUtils.trim(StringUtilsTest.NON_TRIMMABLE)); assertEquals("", StringUtils.trim("")); assertNull(StringUtils.trim(null)); }
/** * Specify the default charset to use for the specific content-type if it's not specified in the content-type header explicitly * * @param charset The charset to use as default (unless specified explicitly) * @param contentType The content-type * @return A new instance of {@link EncoderConfig} */ public EncoderConfig defaultCharsetForContentType(String charset, ContentType contentType) { notNull(charset, "Charset"); notNull(contentType, ContentType.class); Map<String, String> map = new HashMap<String, String>(contentTypeToDefaultCharset); for (String ct : contentType.getContentTypeStrings()) { map.put(ct.toLowerCase(), trim(charset)); } return new EncoderConfig(charset, defaultQueryParameterCharset, shouldAppendDefaultContentCharsetToContentTypeIfUndefined, contentEncoders, map, true); }
/** * Specify the default charset to use for the specific content-type if it's not specified in the content-type header explicitly * * @param charset The charset to use as default (unless specified explicitly) * @param contentType The content-type * @return A new instance of {@link DecoderConfig} */ public DecoderConfig defaultCharsetForContentType(String charset, ContentType contentType) { notNull(charset, "Charset"); notNull(contentType, ContentType.class); Map<String, String> map = new HashMap<String, String>(contentTypeToDefaultCharset); for (String ct : contentType.getContentTypeStrings()) { map.put(ct.toLowerCase(), trim(charset)); } return new DecoderConfig(charset, useNoWrapForInflateDecoding, true, contentDecoders, map); }
/** * Set a specific header * * @return The builder */ public ResponseBuilder setHeader(String name, String value) { notNull(name, "Header name"); notNull(value, "Header value"); List<Header> newHeaders = new ArrayList<Header>(restAssuredResponse.headers().asList()); newHeaders.add(new Header(name, value)); restAssuredResponse.setResponseHeaders(new Headers(newHeaders)); if (trim(name).equalsIgnoreCase(CONTENT_TYPE)) { restAssuredResponse.setContentType(value); } return this; }