### *** This class provides Binary Compatibility only, not Source Compatibility ***

Package com.sas.services.webdav

# Class Utils

java.lang.Object
com.sas.services.webdav.Utils

@SASScope("ALL") @BinaryCompatibilityOnly public class Utils extends Object
A convenience class to bring together a number of utilities.

Since:
  1.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `PATH_KEY`
  `static final int`
  `URL_KEY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Utils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `addSegment(String path, String segment)`
  Append a segment to a path.
  `static String`
  `bytesToHex(byte[] chars)`
  Convert a byte array to a hex representation that is easy to visualize.
  `static String`
  `byteStreamToHex(InputStream byteStream)`
  Convert a stream of bytes to hex.
  `static String`
  `CDATA(String text)`
  Encapsulate the text in a CDATA section in case there is any markup in text.
  `static PropertyMap`
  `convertDavPropertyArray(List<DavPropertyItem> davPropertyItems)`
  `static String`
  `getHostPort(DAVResource r)`
  `static String`
  `getRelativePath(String urlString)`
  Get the relative path for a given URL.
  `static String`
  `intToHex(int number, int width)`
  Convert an int to printable hex format (e.g. 33 = x'21') padding if necessary.
  `static boolean`
  `isCollection(Map properties)`
  A utility method to check through a set of properties and determine if it is a collection or not.
  `static boolean`
  `isParentUrl(String url1, String url2)`
  Compare two URL strings.
  `static boolean`
  `isSameUrl(String url1, String url2)`
  Compare two URL strings.
  `static void`
  `print(String a)`
  `static String`
  `stringToHex(String chars)`
  Convert a set of characters to hex.
  `static String`
  `stripLeadingSlashes(String buffer)`
  Strip off leading forward slash characters
  `static Map`
  `transformDavProperties(String url, List<DavPropertyItem> davPropertyItems, int key)`
  `static String`
  `transformURL(String targetUrl, String originUrl)`
  `static String`
  `URIDecode(String uriString)`
  Decodes a URI and produces a Java string user version of the URI.
  `static String`
  `URIDecode(String uriString, boolean forcePort)`
  Decodes a URI and produces a Java string user version of the URI.
  `static String`
  `XMLESCAPE(String text)`
  Escape the characters '<', '&', '>' and '"', which shouldn't appear in literal form except as markup (unless they are in a CDATA section).

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

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

- ## Field Details

  - ### PATH_KEY

    public static final int PATH_KEY
    See Also:
      - Constant Field Values

  - ### URL_KEY

    public static final int URL_KEY
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Utils

    public Utils()

- ## Method Details

  - ### bytesToHex

    public static String bytesToHex(byte[] chars)
    Convert a byte array to a hex representation that is easy to visualize.
    Parameters:
      `chars` - The byte array to convert to hex display
    Returns:
      String A string with the multiple line hex display output.

  - ### byteStreamToHex

    public static String byteStreamToHex(InputStream byteStream)
    Convert a stream of bytes to hex.
    Parameters:
      `byteStream` - A stream containing the bytes to convert
    Returns:
      String Hex representation of chars

  - ### stringToHex

    public static String stringToHex(String chars)
    Convert a set of characters to hex.
    Parameters:
      `chars` - A string containing the characters to convert
    Returns:
      String Hex representation of chars

  - ### intToHex

    public static String intToHex(int number, int width)
    Convert an int to printable hex format (e.g. 33 = x'21') padding if necessary.
    Parameters:
      `number` - The number to be converted
      `width` - The width of the resulting string
    Returns:
      String A string of width "width" containing the hex representation of the number "number"

  - ### isSameUrl

    public static boolean isSameUrl(String url1, String url2)
    Compare two URL strings. A trailing slash is not significant and so this method checks to see whether the two URLs are equal with trailing slashes.
    Parameters:
      `url1` - The first URL string
      `url2` - The second URL string
    Returns:
      boolean true if the URLs represent the same resource, false otherwise

  - ### isParentUrl

    public static boolean isParentUrl(String url1, String url2)
    Compare two URL strings. A trailing slash is not significant and so this method checks to see whether the first URL is the parent of the second.
    Parameters:
      `url1` - The first URL string
      `url2` - The second URL string
    Returns:
      boolean true if the second URL contains the first, false otherwise

  - ### isCollection

    public static boolean isCollection(Map properties)
    A utility method to check through a set of properties and determine if it is a collection or not. When using depth=1 or depth=infinity, it is possible to get this information without having to bind to the resource itself. Use the value for the "{DAV:}resourcetype" property to determine whether this is a collection or not.
    Parameters:
      `properties` - The property map for this resource.
    Returns:
      boolean True if properties describe a collection, false otherwise.

  - ### convertDavPropertyArray

    public static PropertyMap convertDavPropertyArray(List<DavPropertyItem> davPropertyItems) throws ParserConfigurationException
    Throws:
      `ParserConfigurationException`

  - ### getRelativePath

    public static String getRelativePath(String urlString)
    Get the relative path for a given URL. This is the last segment of the name after the last forward slash, unless there is a forward slash at the end of the URL. In this case it is the name in between the two slashes.
    Parameters:
      `urlString` - A string representing a URL
    Returns:
      String The relative path, or last segment in the URL

  - ### addSegment

    public static String addSegment(String path, String segment)
    Append a segment to a path.

    Concatenate the segment to the path with a slash in between. This routine takes into account all the nasties, including blanks before or after the slashes, empty segment or path, multiple slashes, and missing slashes.

    Parameters:
      `path` - The path (or URL)
      `segment` - The segment to be added to the path
    Returns:
      String The correctly created new path

  - ### CDATA

    public static String CDATA(String text)
    Encapsulate the text in a CDATA section in case there is any markup in text. If text already a CDATA section then just return it.
    Parameters:
      `text` - The text to be encapsulated
    Returns:
      The CDATA section encapsulating the text

  - ### XMLESCAPE

    public static String XMLESCAPE(String text)
    Escape the characters '<', '&', '>' and '"', which shouldn't appear in literal form except as markup (unless they are in a CDATA section).
    Parameters:
      `text` - The text to be escaped
    Returns:
      The escaped text

  - ### stripLeadingSlashes

    public static String stripLeadingSlashes(String buffer)
    Strip off leading forward slash characters
    Parameters:
      `buffer` - Initial string from which to remove leading slashes
    Returns:
      String The input string with leading slashes removed

  - ### print

    public static void print(String a)

  - ### URIDecode

    public static String URIDecode(String uriString)
    Decodes a URI and produces a Java string user version of the URI. This includes the original unicode chars that would have produced this URI.
    Parameters:
      `uriString` - The actual URI (absolute or relative)
    Returns:
      String User Java string that will produce this URI

  - ### URIDecode

    public static String URIDecode(String uriString, boolean forcePort)
    Decodes a URI and produces a Java string user version of the URI. This includes the original unicode chars that would have produced this URI.
    Parameters:
      `uriString` - The actual URI (absolute or relative)
    Returns:
      String User Java string that will produce this URI

  - ### getHostPort

    public static String getHostPort(DAVResource r)

  - ### transformDavProperties

    public static Map transformDavProperties(String url, List<DavPropertyItem> davPropertyItems, int key) throws DAVException, RemoteException, ParserConfigurationException
    Throws:
      `DAVException`
      `RemoteException`
      `ParserConfigurationException`

  - ### transformURL

    public static String transformURL(String targetUrl, String originUrl) throws DAVException
    Throws:
      `DAVException`