Class PMA

java.lang.Object
com.pathomation.PMA

public class PMA extends Object
Helper class
  • Field Details

    • debug

      public static boolean debug
    • logger

      public static Logger logger
      for logging purposes
  • Constructor Details

    • PMA

      public PMA()
  • Method Details

    • join

      public static String join(String... varargs)
      This method is used to concatenate a couple of Strings while replacing "\\" by "/"
      Parameters:
      varargs - Array of String optional arguments, each argument is a string to be concatenated
      Returns:
      Concatenation of a couple of String while making sure the first string always ends with "/"
    • pmaQ

      public static String pmaQ(String arg)
      This method is used to encode a String to be compatible as a url
      Parameters:
      arg - string to be encoded
      Returns:
      Encoded String to be compatible as a url
    • httpGet

      public static String httpGet(String url, String property)
      This method is used to cache results from requested URLs (GET method)
      Parameters:
      url - URL to request
      property - Header value
      Returns:
      Data returned following a request to a specific URL
    • clearURLCache

      public static void clearURLCache()
      This method is used to clear the URLs cache
    • setDebugFlag

      public static void setDebugFlag(Boolean flag)
      This method is used to determine whether the Java SDK runs in debugging mode or not. When in debugging mode (flag = true), extra output is produced when certain conditions in the code are not met
      Parameters:
      flag - Debugging mode (activated or deactivated)
    • urlReader

      public static String urlReader(String url)
      This method is used to retrieve HTML Code from URL
      Parameters:
      url - to get HTML code from
      Returns:
      HTML code generated from the url argument
    • domParser

      public static Document domParser(String s)
      This method is used to parse a XML content
      Parameters:
      s - XML content to parse
      Returns:
      Document parsed XML
    • xmlToStringArray

      public static List<String> xmlToStringArray(Document root, Integer... varargs)
      This method is used to get a list of the values of "String" tags of a XML document
      Parameters:
      root - XML document
      varargs - Array of optional arguments

      limit : First optional argument(int), default value(0), defines a limit

      Returns:
      Values' list of tags named "string" in a XML document
    • xmlToStringArray

      public static List<String> xmlToStringArray(Element root, Integer... varargs)
      This method is an overload of method xmlToStringArray to cope with "root" argument as an "Element" instead of a "Document"
      Parameters:
      root - XML document
      varargs - Array of optional arguments

      limit : First optional argument(int), default value(0), defines a limit

      Returns:
      Values' list of tags named "string" in a XML document
    • getJSONAsStringBuffer

      public static StringBuffer getJSONAsStringBuffer(HttpURLConnection con)
      This method is used to create a StringBuffer from a connection URL
      Parameters:
      con - http connection URL to retrieve JSON from
      Returns:
      string buffer created from the connection URL
    • isJSONObject

      public static Boolean isJSONObject(String value)
      This method is used to check if a json returned is an object
      Parameters:
      value - json in String format
      Returns:
      True if it's a JSONObject, false otherwise
    • isJSONArray

      public static Boolean isJSONArray(String value)
      This method is used to check if a json returned is an array
      Parameters:
      value - json in String format
      Returns:
      True if it's a JSONObject, false otherwise
    • getJSONObjectResponse

      public static org.json.JSONObject getJSONObjectResponse(String value)
      This method is used to create a json Object out of a string
      Parameters:
      value - json in String format
      Returns:
      Creates a Json object from a string
    • getJSONArrayResponse

      public static org.json.JSONArray getJSONArrayResponse(String value)
      This method is used to creates a json Array out of a string
      Parameters:
      value - json in String format
      Returns:
      Creates a Json array from a string
    • removeDriveName

      public static List<String> removeDriveName(List<String> lst)
      This method is used to remove the drive name from a path returned by pma_java SDK why is this needed : for PMA.core(.lite) the path sent should include the drive name (if not blank) and the paths returned also include the drive name e.g. "Primary Disk (C:)/samples" it's necessary to remove drive name from the path's root to be able to use these paths in file system
      Parameters:
      lst - List of paths (directories, root directories, slides...)
      Returns:
      List of paths formatted to remove the Disk label if it exists
    • createPathWithLabel

      public static String createPathWithLabel(String value)
      This method is used to add the drive name to a path before sending it to pma_java SDK why is this needed? : for PMA.core(.lite) the path sent should include the drive name (if not blank) and the paths returned also include the drive name e.g. "Primary Disk (C:)/samples" it's necessary to add drive name to the path's root to be able to make a valid request to PMA.core(.lite)
      Parameters:
      value - path to be formatted
      Returns:
      Path formatted to include the Disk label if it doesn't exist