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

com.sas.services.webdav
Class Utils

java.lang.Object
  |
  +--com.sas.services.webdav.Utils

public class Utils
extends Object

A convenience class to bring together a number of utilties.


Constructor Summary
Utils()
           
 
Method Summary
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 visualise.
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 convertPropertyArray(org.apache.webdav.lib.Property[] props)
          A utility method to convert an array of WebDAV Property objects to a property map.
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 (eg 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 isSameUrl(String url1, String url2)
          Compare two url strings.
static String stringToHex(String chars)
          Convert a set of characters to hex.
static String stripLeadingSlashes(String buffer)
          Strip off leading forward slash characters
static String XMLESCAPE(String text)
          Escape the three characters "<", "&", ">", which cannot 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
 

Constructor Detail

Utils

public Utils()
Method Detail

bytesToHex

public static String bytesToHex(byte[] chars)
Convert a byte array to a hex representation that is easy to visualise.
Parameters:
chars - The byte array to convert to hex display
Returns:
String A string with the multiline 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 (eg 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

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.

convertPropertyArray

public static PropertyMap convertPropertyArray(org.apache.webdav.lib.Property[] props)
A utility method to convert an array of WebDAV Property objects to a property map.
Parameters:
props - An array of Property objects
Returns:
PropertyMap (maps property names to values). The property names in this case use the format "{namespace}propertyname".

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 inbetween 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 inbetween. This routine takes into account all the nasties, including blanks before or after the slashes, empty segment or path, muliple 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 three characters "<", "&", ">", which cannot 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

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




Copyright © 2006 SAS Institute Inc. All Rights Reserved.
javadoc generated Fri, 10 Feb 2006 17:29:04