/** * Decodes URL elements. This method may be used for all * parts of URL, except for the query parts, since it does * not decode the '+' character. * @see #decodeQuery(String, String) */ public static String decode(final String source, final String encoding) { return decode(source, encoding, false); }
/** * Encodes the given URI query parameter with the given encoding. */ public static String encodeQueryParam(final String queryParam, final String encoding) { return encodeUriComponent(queryParam, encoding, URIPart.QUERY_PARAM); } public static String encodeQueryParam(final String queryParam) {
/** * Sets HTML text, but decodes it first. */ public void setTextValue(final String text) { encodedText = text; nodeValue = HtmlDecoder.decode(text); }
/** * Creates URL builder for user-friendly way of building URLs. * Provided path is parsed and {@link #encodeUri(String) encoded}. * @see #build(String, boolean) */ public static Builder build(final String path) { return build(path, true); }
/** * Returns the corresponding MIME type to the given extension. * If no MIME type was found it returns <code>application/octet-stream</code> type. */ public static String getMimeType(final String ext) { String mimeType = lookupMimeType(ext); if (mimeType == null) { mimeType = MIME_APPLICATION_OCTET_STREAM; } return mimeType; }
/** * Encodes attribute value that will be double quoted. * In this case, only these entities are encoded: * <ul> * <li><code>&</code> with <code>&amp;</code></li> * <li><code>"</code> with <code>&quot;</code></li> * <li><code>& </code></li> * </ul> */ public static String attributeDoubleQuoted(final CharSequence value) { return encode(value, ATTR_DQ, LEN); }
public static HttpStatus409 error409() { return new HttpStatus409(); } public static HttpStatus500 error500() {
public TextResult status(final HttpStatus httpStatus) { this.status = httpStatus.status(); return this; }
/** * Decodes query name or value. */ public static String decodeQuery(final String source, final String encoding) { return decode(source, encoding, true); }
/** * Encodes the given URI user info with the given encoding. */ public static String encodeUserInfo(final String userInfo, final String encoding) { return encodeUriComponent(userInfo, encoding, URIPart.USER_INFO); } public static String encodeUserInfo(final String userInfo) {
/** * Encodes a string to HTML-safe text. The following characters are replaced: * <ul> * <li><code>&</code> with <code>&amp;</code></li> * <li><code><</code> with <code>&lt;</code></li> * <li><code>></code> with <code>&gt;</code></li> * <li><code>\u00A0</code> with <code> </code></li> * </ul> */ public static String text(final CharSequence text) { return encode(text, TEXT, LEN); }
/** * Decodes URL elements. */ public static String decode(final String url) { return decode(url, JoddCore.encoding, false); }
/** * Encodes the given URI path with the given encoding. */ public static String encodePath(final String path, final String encoding) { return encodeUriComponent(path, encoding, URIPart.PATH); } public static String encodePath(final String path) {
/** * Encodes XML string. In XML there are only 5 predefined character entities. */ public static String xml(final CharSequence text) { return encode(text, TEXT_XML, LEN_XML); }
/** * Decodes query name or value. */ public static String decodeQuery(final String source) { return decode(source, JoddCore.encoding, true); }
/** * Encodes the given URI path segment with the given encoding. */ public static String encodePathSegment(final String segment, final String encoding) { return encodeUriComponent(segment, encoding, URIPart.PATH_SEGMENT); } public static String encodePathSegment(final String segment) {
/** * Encodes attribute value that will be single quoted. * In this case, only two entities are encoded: * <ul> * <li><code>&</code> with <code>&amp;</code></li> * <li><code>'</code> with <code>&#39;</code></li> * <li><code>& </code></li> * </ul> */ public static String attributeSingleQuoted(final CharSequence value) { return encode(value, ATTR_SQ, LEN); }
/** * Encodes the given URI scheme with the given encoding. */ public static String encodeScheme(final String scheme, final String encoding) { return encodeUriComponent(scheme, encoding, URIPart.SCHEME); } public static String encodeScheme(final String scheme) {
/** * Encodes the given URI port with the given encoding. */ public static String encodePort(final String port, final String encoding) { return encodeUriComponent(port, encoding, URIPart.PORT); } public static String encodePort(final String port) {
/** * Encodes the given URI query with the given encoding. */ public static String encodeQuery(final String query, final String encoding) { return encodeUriComponent(query, encoding, URIPart.QUERY); } public static String encodeQuery(final String query) {