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

com.sas.services.webdav
Class Utils

com.sas.services.webdav.Utils

@SASScope(value="ALL")
@BinaryCompatibilityOnly
public class Utils

A convenience class to bring together a number of utilities.

Since:
1.0

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

Field Detail

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 Detail

Utils

public Utils()
Method Detail

bytesToHex

public static java.lang.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 java.lang.String byteStreamToHex(java.io.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 java.lang.String stringToHex(java.lang.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 java.lang.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(java.lang.String url1,
                                java.lang.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

isCollection

public static boolean isCollection(java.util.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(java.util.List<DavPropertyItem> davPropertyItems)
                                           throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

getRelativePath

public static java.lang.String getRelativePath(java.lang.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 java.lang.String addSegment(java.lang.String path,
                                          java.lang.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 java.lang.String CDATA(java.lang.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 java.lang.String XMLESCAPE(java.lang.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 java.lang.String stripLeadingSlashes(java.lang.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(java.lang.String a)

URIDecode

public static java.lang.String URIDecode(java.lang.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 java.lang.String URIDecode(java.lang.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 java.lang.String getHostPort(DAVResource r)

transformDavProperties

public static java.util.Map transformDavProperties(java.lang.String url,
                                                   java.util.List<DavPropertyItem> davPropertyItems,
                                                   int key)
                                            throws DAVException,
                                                   java.rmi.RemoteException,
                                                   javax.xml.parsers.ParserConfigurationException
Throws:
DAVException
java.rmi.RemoteException
javax.xml.parsers.ParserConfigurationException

transformURL

public static java.lang.String transformURL(java.lang.String targetUrl,
                                            java.lang.String originUrl)
                                     throws DAVException
Throws:
DAVException

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




Copyright © 2009 SAS Institute Inc. All Rights Reserved.