org.apache.synapse.commons.util

## Class MiscellaneousUtil

- java.lang.Object
- - org.apache.synapse.commons.util.MiscellaneousUtil

-     public class MiscellaneousUtil
      extends java.lang.Object

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `asBytes(java.io.InputStream in)`
    `static java.lang.String` | `getMessageProcessorName(java.lang.String taskName)` Provides the name of the corresponding message processor of a task
    `static java.lang.String` | `getProperty(java.util.Properties properties, java.lang.String name, java.lang.String defaultValue)` Helper method to get the value of the property from a given property bag
    `static <T> T` | `getProperty(java.util.Properties properties, java.lang.String name, T defaultValue, java.lang.Class<? extends T> type)` Helper method to get the value of the property from a given property bag This method will return a value with the type equal to the type given by the Class type parameter.
    `static boolean` | `isTaskOfMessageProcessor(java.lang.String taskName)` Checks if the task belongs to a message processor
    `static java.util.Properties` | `loadProperties(java.lang.String filePath)` Loads the properties from a given property file path
    `static org.apache.axiom.om.OMElement` | `loadXMLConfig(java.lang.String filePath)` Load xml config
    `static org.apache.axiom.om.OMElement` | `loadXMLConfig(java.lang.String filePath, boolean isMandatory)` Load a xml configuration file
    `static byte[]` | `serialize(java.lang.Object data)` Helper method to serialize object into a byte array

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getProperty

          public static java.lang.String getProperty(java.util.Properties properties,
                                                     java.lang.String name,
                                                     java.lang.String defaultValue)

      Helper method to get the value of the property from a given property bag
      Parameters:
        `properties` - The property collection
        `name` - The name of the property
        `defaultValue` - The default value for the property
      Returns:
        The value of the property if it is found , otherwise , default value

    - #### getProperty

          public static <T> T getProperty(java.util.Properties properties,
                                          java.lang.String name,
                                          T defaultValue,
                                          java.lang.Class<? extends T> type)

      Helper method to get the value of the property from a given property bag This method will return a value with the type equal to the type given by the Class type parameter. Therefore, The user of this method can ensure that he is get what he request
      Parameters:
        `properties` - Properties bag
        `name` - Name of the property
        `defaultValue` - Default value
        `type` - Expected Type using Class
      Returns:
        Value corresponding to the given property name

    - #### loadProperties

          public static java.util.Properties loadProperties(java.lang.String filePath)

      Loads the properties from a given property file path
      Parameters:
        `filePath` - Path of the property file
      Returns:
        Properties loaded from given file

    - #### loadXMLConfig

          public static org.apache.axiom.om.OMElement loadXMLConfig(java.lang.String filePath)

      Load xml config
      Parameters:
        `filePath` - file path
      Returns:
        OMElement of build from the config file

    - #### loadXMLConfig

          public static org.apache.axiom.om.OMElement loadXMLConfig(java.lang.String filePath,
                                                                    boolean isMandatory)

      Load a xml configuration file
      Parameters:
        `filePath` - file path
        `isMandatory` - whether this is a mandatory config
      Returns:
        OMElement of build from the config file

    - #### serialize

          public static byte[] serialize(java.lang.Object data)

      Helper method to serialize object into a byte array
      Parameters:
        `data` - The object to be serialized
      Returns:
        The byte array representation of the provided object

    - #### asBytes

          public static byte[] asBytes(java.io.InputStream in)

    - #### isTaskOfMessageProcessor

          public static boolean isTaskOfMessageProcessor(java.lang.String taskName)

      Checks if the task belongs to a message processor
      Parameters:
        `taskName` - task name
      Returns:
        true if task belongs to a message processor

    - #### getMessageProcessorName

          public static java.lang.String getMessageProcessorName(java.lang.String taskName)

      Provides the name of the corresponding message processor of a task
      Parameters:
        `taskName` - task name
      Returns:
        message processor name

Copyright © 2005-2021 Apache Software Foundation. All Rights Reserved.