uk.org.ogsadai.common
Class NetUtilities

java.lang.Object
  |
  +--uk.org.ogsadai.common.NetUtilities

public class NetUtilities
extends java.lang.Object

Contains helper methods relating to the java.net package, such as methods to read data from URLs.

Author:
The OGSA-DAI Project Team

Constructor Summary
NetUtilities()
           
 
Method Summary
static org.w3c.dom.Document readToDocument(java.lang.String url, boolean validate)
          Returns a Document containing the XML data read from a specified URL String.
static java.lang.String readToString(java.lang.String url)
          Returns a String containing the data read from a specified URL String.
static java.lang.String readToString(java.net.URL url)
          Returns a String containing the data read from a specified URL.
static boolean sameFile(java.net.URL url1, java.net.URL url2)
          Returns true if both URLs point to the same file, otherwise returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetUtilities

public NetUtilities()
Method Detail

readToDocument

public static org.w3c.dom.Document readToDocument(java.lang.String url,
                                                  boolean validate)
                                           throws CommonUserException
Returns a Document containing the XML data read from a specified URL String. Note that special care is needed when expressing file URLs. The following forms are acceptable: file:/C:/hello.txt or file:///C:/hello.txt but not file://C:/hello.txt.

Parameters:
url - the URL String to read data from
validate - indicates whether or not to perform schema validation when parsing the data and creating the document
Returns:
a Document containing the data read from the URL
Throws:
CommonUserException - if there is a problem reading data from the specified URL or constructing the document

readToString

public static java.lang.String readToString(java.lang.String url)
                                     throws CommonUserException
Returns a String containing the data read from a specified URL String. Note that special care is needed when expressing file URLs. The following forms are acceptable: file:/C:/hello.txt or file:///C:/hello.txt but not file://C:/hello.txt.

Parameters:
url - the URL String to read data from
Returns:
a String containing the data read from the URL
Throws:
CommonUserException - if there is a problem reading data from the specified URL

readToString

public static java.lang.String readToString(java.net.URL url)
                                     throws CommonUserException
Returns a String containing the data read from a specified URL.

Parameters:
url - the URL to read data from
Returns:
a String containing the data read from the URL
Throws:
CommonUserException - if there is a problem reading data from the specified URL

sameFile

public static boolean sameFile(java.net.URL url1,
                               java.net.URL url2)
Returns true if both URLs point to the same file, otherwise returns false.