Class Util


  • public class Util
    extends Object
    Utilities class. Extended by ResourceUtil and ProviderUtil utilities. Used by resource and providers.
    Author:
    Rajeshwar Patil
    • Method Detail

      • logTimingMessage

        public static void logTimingMessage​(String msg)
      • getResourceName

        public static String getResourceName​(jakarta.ws.rs.core.UriInfo uriInfo)
        Returns name of the resource from UriInfo.
      • getParentName

        public static String getParentName​(jakarta.ws.rs.core.UriInfo uriInfo)
        Returns name of the resource parent from UriInfo.
      • getGrandparentName

        public static String getGrandparentName​(jakarta.ws.rs.core.UriInfo uriInfo)
      • getName

        public static String getName​(String typeName)
        Returns just the name of the given fully qualified name.
      • getName

        public static String getName​(String typeName,
                                     char delimiter)
        Returns just the name of the given fully qualified name.
      • getParentName

        public static String getParentName​(String url)
        returns just the parent name of the resource from the resource url.
      • getGrandparentName

        public static String getGrandparentName​(String url)
      • eleminateHypen

        public static String eleminateHypen​(String string)
        Removes any hypens ( - ) from the given string. When it removes a hypen, it converts next immediate character, if any, to an Uppercase.(schema2beans convention)
        Parameters:
        string - the input string
        Returns:
        a String resulted after removing the hypens
      • decode

        public static String decode​(String string)
        Decodes an encoded URL using UTF-8
        Parameters:
        string - string to decode
        Returns:
        decoded string, or the original string if decoding failed
      • upperCaseFirstLetter

        public static String upperCaseFirstLetter​(String string)
        Converts the first letter of the given string to Uppercase.
        Parameters:
        string - the input string
        Returns:
        the string with the Uppercase first letter
      • lowerCaseFirstLetter

        public static String lowerCaseFirstLetter​(String string)
        Converts the first letter of the given string to lower case.
        Parameters:
        string - the input string
        Returns:
        the string with the lower case first letter
      • getHtml

        protected static String getHtml​(String message,
                                        jakarta.ws.rs.core.UriInfo uriInfo,
                                        boolean delete)
        Returns the html for the given message.
        Parameters:
        uriInfo - the uriInfo context of the request
        Returns:
        String the html representation of the given message
      • methodNameFromDtdName

        public static String methodNameFromDtdName​(String elementName,
                                                   String prefix)
        Constructs a method name from element's dtd name name for a given prefix.(schema2beans convention)
        Parameters:
        elementName - the given element name
        prefix - the given prefix
        Returns:
        a method name formed from the given name and the prefix
      • methodNameFromBeanName

        public static String methodNameFromBeanName​(String elementName,
                                                    String prefix)
        Constructs a method name from element's bean name for a given prefix.(schema2beans convention)
        Parameters:
        elementName - the given element name
        prefix - the given prefix
        Returns:
        a method name formed from the given name and the prefix
      • getJerseyClient

        public static jakarta.ws.rs.client.Client getJerseyClient()
      • applyChanges

        public static RestActionReporter applyChanges​(Map<String,​String> data,
                                                      jakarta.ws.rs.core.UriInfo uriInfo,
                                                      Subject subject)
        Apply changes passed in data using CLI "set".
        Parameters:
        data - The set of changes to be applied
        Returns:
        ActionReporter containing result of "set" execution
      • getCurrentValues

        public static Map<String,​String> getCurrentValues​(String basePath,
                                                                org.glassfish.hk2.api.ServiceLocator habitat,
                                                                Subject subject)
      • getKeyAttributeName

        public static String getKeyAttributeName​(ConfigModel model)
        Parameters:
        model -
        Returns:
        name of the key attribute for the given model.
      • getBeanName

        public static String getBeanName​(String elementName)
      • createTempDirectory

        public static File createTempDirectory()
      • deleteDirectory

        public static void deleteDirectory​(File dir)
      • getMethodParameterList

        public static String getMethodParameterList​(CommandModel cm,
                                                    boolean withType,
                                                    boolean includeOptional)
      • isGenericType

        public static boolean isGenericType​(Type type)
      • getFirstGenericType

        public static Class<?> getFirstGenericType​(Type genericType)
        This method takes a Type argument that represents a generic class (e.g., List<String>) and returns the Class for the first generic type. If the Class is not a generic type, null is returned. The primary intended usage for this is in the MessageBodyReaders to help return a more accurate result from isReadable, though it may also be helpful in other, more general situations.
        Parameters:
        genericType -
        Returns:
      • getFormattingIndentLevel

        public static int getFormattingIndentLevel()
        Get the current configured indenting value for the REST layer
        Returns:
      • useLegacyResponseFormat

        public static boolean useLegacyResponseFormat​(jakarta.ws.rs.core.HttpHeaders requestHeaders)
      • parameterMap

        public static ParameterMap parameterMap()
        Convenience wrapper around ParameterMap constructor to make it easier to use its fluent API
        Returns:
        ParameterMap