Class EncodeOrCheck


  • @Deprecated
    public class EncodeOrCheck
    extends java.lang.Object
    Deprecated.
    Will be removed in next minor release.
    Utility class to encode or check data.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String FRAGMENT_FORBIDDEN
      Deprecated.
      the characters forbidden in a fragment.
      static java.lang.String GEN_DELIMITERS
      Deprecated.
      the gen-delimiter characters in URIs
      private static char[] HEX_DIGITS
      Deprecated.
      A table of hex digits
      static java.lang.String RESERVED
      Deprecated.
      the reserved characters in URIs
      static java.lang.String SUB_DELIMITERS
      Deprecated.
      the sub-delimiter characters in URIs
      static java.lang.String TEMPL_PARAMS
      Deprecated.
      the additional allowed characters for template parameters in URIs.
      static java.lang.String UNRESERVED
      Deprecated.
      the unreserved characters in URIs
    • Constructor Summary

      Constructors 
      Constructor Description
      EncodeOrCheck()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.String all​(java.lang.CharSequence string, boolean encode)
      Deprecated.
      Checks / encodes all chars of the given char sequence.
      static void checkForInvalidUriChars​(java.lang.CharSequence uriPart, int indexForErrMessage, java.lang.String errMessName)
      Deprecated.
      Checks, if the string contains characters that are reserved in URIs.
      (package private) static int encode​(char toEncode, java.lang.StringBuilder stb)
      Deprecated.
      Appends the given character encoded (if not unreserved) to the StringBuilder.
      private static java.lang.String encodeNotBraces​(java.lang.CharSequence uriPart, boolean allowSemicolon, boolean encodeSlash)
      Deprecated.
      This methods encodes the given String, but doesn't encode braces.
      static java.lang.CharSequence fragment​(java.lang.CharSequence fragment)
      Deprecated.
       
      static java.lang.CharSequence fullMatrix​(java.lang.CharSequence matrix)
      Deprecated.
      encodes respectively checks a full matrix parameter list.
      static java.lang.CharSequence fullQuery​(java.lang.CharSequence query, boolean encode)
      Deprecated.
      encodes respectively checks a full query.
      private static java.lang.CharSequence fullQueryOrMatrix​(java.lang.CharSequence string, char delimiter, java.lang.String spaceReplace, boolean encode)
      Deprecated.
       
      static java.lang.String host​(java.lang.String host)
      Deprecated.
      Checks, if the host String contains is valid.
      static java.lang.String nameOrValue​(java.lang.Object nameOrValue, boolean encode, java.lang.String nameForMessage)
      Deprecated.
      Encodes the given string, if encoding is enabled.
      static java.lang.CharSequence pathSegmentsWithMatrix​(java.lang.CharSequence path, boolean encode)
      Deprecated.
       
      static java.lang.CharSequence pathSegmentWithMatrix​(java.lang.CharSequence pathSegments, boolean encode)
      Deprecated.
       
      private static java.lang.CharSequence pathSegmentWithMatrix​(java.lang.CharSequence pathSegments, boolean encode, boolean encodeSlash)
      Deprecated.
       
      static java.lang.CharSequence pathWithoutMatrix​(java.lang.CharSequence path)
      Deprecated.
      This methods encodes the given path, but doesn't encode braces.
      (package private) static void processPercent​(int i, boolean encode, java.lang.CharSequence uriPart, java.lang.StringBuilder stb)
      Deprecated.
      appends the '%' at the given position i to the given StringBuilder.
      private static int processTemplVarname​(java.lang.CharSequence uriPart, int braceIndex, java.lang.StringBuilder stb)
      Deprecated.
      Reads and checks the template variable name.
      static java.lang.String scheme​(java.lang.String scheme)
      Deprecated.
      Checks, if the String is a valid URI scheme
      private static java.lang.IllegalArgumentException throwIllegalArgExc​(int index, java.lang.String errMessName, java.lang.Object illegalString, java.lang.String messageEnd)
      Deprecated.
       
      static void toHex​(char toEncode, java.lang.StringBuilder stb)
      Deprecated.
      Appends the given character precent-encoded to the StringBuilder.
      private static void toHexOrReject​(char c, java.lang.StringBuilder stb, boolean encode)
      Deprecated.
      if encode is true, the given char is appended as hex string to the StringBuilder.
      static java.lang.CharSequence userInfo​(java.lang.CharSequence userInfo, boolean encode)
      Deprecated.
       
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FRAGMENT_FORBIDDEN

        public static final java.lang.String FRAGMENT_FORBIDDEN
        Deprecated.
        the characters forbidden in a fragment.
      • GEN_DELIMITERS

        public static final java.lang.String GEN_DELIMITERS
        Deprecated.
        the gen-delimiter characters in URIs
        See Also:
        Constant Field Values
      • HEX_DIGITS

        private static final char[] HEX_DIGITS
        Deprecated.
        A table of hex digits
      • SUB_DELIMITERS

        public static final java.lang.String SUB_DELIMITERS
        Deprecated.
        the sub-delimiter characters in URIs
        See Also:
        Constant Field Values
      • TEMPL_PARAMS

        public static final java.lang.String TEMPL_PARAMS
        Deprecated.
        the additional allowed characters for template parameters in URIs.
        See Also:
        Constant Field Values
      • RESERVED

        public static final java.lang.String RESERVED
        Deprecated.
        the reserved characters in URIs
        See Also:
        Constant Field Values
      • UNRESERVED

        public static final java.lang.String UNRESERVED
        Deprecated.
        the unreserved characters in URIs
        See Also:
        Constant Field Values
    • Constructor Detail

      • EncodeOrCheck

        public EncodeOrCheck()
        Deprecated.
    • Method Detail

      • all

        public static java.lang.String all​(java.lang.CharSequence string,
                                           boolean encode)
                                    throws java.lang.IllegalArgumentException
        Deprecated.
        Checks / encodes all chars of the given char sequence.
        Parameters:
        string -
        encode - true, if the value should be encoded, or false if not.
        Returns:
        the enoced string (if it should be encoded)
        Throws:
        java.lang.IllegalArgumentException - if encode is false and at least one character of the CharSequence is invalid.
      • checkForInvalidUriChars

        public static void checkForInvalidUriChars​(java.lang.CharSequence uriPart,
                                                   int indexForErrMessage,
                                                   java.lang.String errMessName)
                                            throws java.lang.IllegalArgumentException
        Deprecated.
        Checks, if the string contains characters that are reserved in URIs.
        Parameters:
        uriPart -
        indexForErrMessage -
        errMessName -
        Throws:
        java.lang.IllegalArgumentException - if the CharSequence to test contains illegal characters.
        See Also:
        RFC 3986, Section 2.2
      • encode

        static int encode​(char toEncode,
                          java.lang.StringBuilder stb)
        Deprecated.
        Appends the given character encoded (if not unreserved) to the StringBuilder.
        Parameters:
        toEncode - the character to encode.
        stb - the StringBuilder to append.
        Returns:
        the number of added chars
        See Also:
        RFC 3986, section 2.2
      • encodeNotBraces

        private static java.lang.String encodeNotBraces​(java.lang.CharSequence uriPart,
                                                        boolean allowSemicolon,
                                                        boolean encodeSlash)
                                                 throws java.lang.IllegalArgumentException
        Deprecated.
        This methods encodes the given String, but doesn't encode braces.
        Parameters:
        uriPart - the String to encode
        allowSemicolon - if true, a ';' is encoded, otherwise an IllegalArgumentException is thrown.
        encodeSlash - if encodeSlash is true, than slashes are also converted, otherwise not.
        Returns:
        the encoded String
        Throws:
        java.lang.IllegalArgumentException
      • fragment

        public static java.lang.CharSequence fragment​(java.lang.CharSequence fragment)
                                               throws java.lang.IllegalArgumentException
        Deprecated.
        Parameters:
        fragment - the fragment, may contain URI template parameters. Must not be null.
        Returns:
        the encoced character sequence (if it should be encoded)
        Throws:
        java.lang.IllegalArgumentException - if encode is false and the fragment contains at least one invalid character.
      • fullMatrix

        public static java.lang.CharSequence fullMatrix​(java.lang.CharSequence matrix)
                                                 throws java.lang.IllegalArgumentException
        Deprecated.
        encodes respectively checks a full matrix parameter list.
        Parameters:
        matrix - matrix parameters to convert or check, may contain URI template parameters. Must not be null.
        Returns:
        the encoced character sequence (if it should be encoded)
        Throws:
        java.lang.IllegalArgumentException - if encode is false and at least one character is invalid.
      • fullQuery

        public static java.lang.CharSequence fullQuery​(java.lang.CharSequence query,
                                                       boolean encode)
        Deprecated.
        encodes respectively checks a full query.
        Parameters:
        query - query to convert or check, may contain URI template parameters. Must not be null.
        encode -
        Returns:
        the encoced character sequence (if it should be encoded)
      • fullQueryOrMatrix

        private static java.lang.CharSequence fullQueryOrMatrix​(java.lang.CharSequence string,
                                                                char delimiter,
                                                                java.lang.String spaceReplace,
                                                                boolean encode)
                                                         throws java.lang.IllegalArgumentException
        Deprecated.
        Parameters:
        string -
        delimiter -
        spaceReplace - The String to replace a space with ("+" or "%20")
        encode -
        Returns:
        Throws:
        java.lang.IllegalArgumentException
      • host

        public static java.lang.String host​(java.lang.String host)
                                     throws java.lang.IllegalArgumentException
        Deprecated.
        Checks, if the host String contains is valid.
        Parameters:
        host - Could include template variable names. Must not be null, will throw a NullPointerException.
        Returns:
        the valid host.
        Throws:
        java.lang.IllegalArgumentException - if the host contains an invalid character.
      • nameOrValue

        public static java.lang.String nameOrValue​(java.lang.Object nameOrValue,
                                                   boolean encode,
                                                   java.lang.String nameForMessage)
                                            throws java.lang.IllegalArgumentException
        Deprecated.
        Encodes the given string, if encoding is enabled. If encoding is disabled, the methods checks the validaty of the containing characters.
        Parameters:
        nameOrValue - the string to encode or check. Must not be null; result are not defined. May contain URI template parameters.
        encode - if true, the String is encoded, if false it is checked, if all chars are valid.
        nameForMessage - The name for the message
        Returns:
        the encoced character sequence (if it should be encoded)
        Throws:
        java.lang.IllegalArgumentException - if the given String is null, or at least one char is invalid.
      • pathSegmentsWithMatrix

        public static java.lang.CharSequence pathSegmentsWithMatrix​(java.lang.CharSequence path,
                                                                    boolean encode)
        Deprecated.
        Parameters:
        path -
        encode -
        Returns:
        the encoced character sequence (if it should be encoded)
      • pathSegmentWithMatrix

        public static java.lang.CharSequence pathSegmentWithMatrix​(java.lang.CharSequence pathSegments,
                                                                   boolean encode)
                                                            throws java.lang.IllegalArgumentException
        Deprecated.
        Parameters:
        pathSegments - the path to check; must not be null.
        encode -
        Returns:
        the encoced character sequence (if it should be encoded)
        Throws:
        java.lang.IllegalArgumentException - id encode is false and the path contains an invalid character.
      • pathSegmentWithMatrix

        private static java.lang.CharSequence pathSegmentWithMatrix​(java.lang.CharSequence pathSegments,
                                                                    boolean encode,
                                                                    boolean encodeSlash)
                                                             throws java.lang.IllegalArgumentException
        Deprecated.
        Parameters:
        pathSegments - the path to check; must not be null.
        encode -
        Returns:
        Throws:
        java.lang.IllegalArgumentException - id encode is false and the path contains an invalid character.
      • pathWithoutMatrix

        public static java.lang.CharSequence pathWithoutMatrix​(java.lang.CharSequence path)
                                                        throws java.lang.IllegalArgumentException
        Deprecated.
        This methods encodes the given path, but doesn't encode braces.
        Parameters:
        path - the path to encode
        Returns:
        the encoded String
        Throws:
        java.lang.IllegalArgumentException - if the path is not valid
      • processPercent

        static void processPercent​(int i,
                                   boolean encode,
                                   java.lang.CharSequence uriPart,
                                   java.lang.StringBuilder stb)
        Deprecated.
        appends the '%' at the given position i to the given StringBuilder.
        Preconditions (not checked !!):
        • i > 0
        • at position i is a '%'.
        Parameters:
        i - the index in the uriPart
        encode -
        uriPart -
        stb -
      • processTemplVarname

        private static int processTemplVarname​(java.lang.CharSequence uriPart,
                                               int braceIndex,
                                               java.lang.StringBuilder stb)
                                        throws java.lang.IllegalArgumentException
        Deprecated.
        Reads and checks the template variable name. The starting "{" is at given position i.
        Parameters:
        uriPart - the processed part of the uri
        braceIndex - the current for variable value (position of "{"). The method do not check, if this is the position of the '{'.
        stb - the StringBuilder to append the variable name with "{" and "}" to. Will be changed, also if an error occurs. May be null; then nothing is appended.
        Returns:
        the position of the corresponding "}" to assign to the for variable.
        Throws:
        java.lang.IllegalArgumentException - if the rest of the uriPart contains a '{' or no '}'.
      • scheme

        public static java.lang.String scheme​(java.lang.String scheme)
                                       throws java.lang.IllegalArgumentException
        Deprecated.
        Checks, if the String is a valid URI scheme
        Parameters:
        scheme - the String to check. May contain template variables.
        Returns:
        the valid scheme
        Throws:
        java.lang.IllegalArgumentException - If the string is not a valid URI scheme.
      • throwIllegalArgExc

        private static java.lang.IllegalArgumentException throwIllegalArgExc​(int index,
                                                                             java.lang.String errMessName,
                                                                             java.lang.Object illegalString,
                                                                             java.lang.String messageEnd)
        Deprecated.
        Parameters:
        index - index, starting with zero.
        errMessName - the name of the string with illegal characters
        illegalString - the illegal String
        messageEnd -
        Returns:
      • toHex

        public static void toHex​(char toEncode,
                                 java.lang.StringBuilder stb)
        Deprecated.
        Appends the given character precent-encoded to the StringBuilder. Example: ' ' -> "%20%
        Parameters:
        toEncode -
        stb -
      • toHexOrReject

        private static void toHexOrReject​(char c,
                                          java.lang.StringBuilder stb,
                                          boolean encode)
                                   throws java.lang.IllegalArgumentException
        Deprecated.
        if encode is true, the given char is appended as hex string to the StringBuilder. If encode is false, an IllegalArgumentException is thrown.
        Parameters:
        c -
        stb -
        encode - true, if the value should be encoded, or false if not.
        Throws:
        java.lang.IllegalArgumentException
      • userInfo

        public static java.lang.CharSequence userInfo​(java.lang.CharSequence userInfo,
                                                      boolean encode)
                                               throws java.lang.IllegalArgumentException
        Deprecated.
        Parameters:
        userInfo - the URI user-info, may contain URI template parameters
        encode -
        Returns:
        the encoced character sequence (if it should be encoded)
        Throws:
        java.lang.IllegalArgumentException - if automatic encoding is disabled and the userInfo contains illegal characters, or if the userInfo is null.