ecologylab.net
Class NetTools

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.net.NetTools

public class NetTools
extends Debug

Reusable static methods that do nifty network stuff.

Author:
andruid, blake, eunyee

Constructor Summary
NetTools()
           
 
Method Summary
static void disconnect(java.net.URLConnection urlConnection)
          Free resources as possible on the URLConnection passed in.
static java.net.InetAddress[] getAllInetAddressesForLocalhost()
           
static java.lang.String isCharsetSupported(java.lang.String mimeType)
          Seek a charset specification in the MimeType header of the HTTP request.
static java.lang.String localHost()
          local host address (parse out only IP address)
static java.net.InetAddress[] wrapSingleAddress(java.net.InetAddress address)
          Convienence method for getting a single-element array of InetAddresses for servers that normally take an array, but when only one is available.
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetTools

public NetTools()
Method Detail

isCharsetSupported

public static java.lang.String isCharsetSupported(java.lang.String mimeType)
Seek a charset specification in the MimeType header of the HTTP request. The return values are strange, in order to enable reporting an error to happen conveniently around the call site.

Parameters:
mimeType - The Mime Type header.
Returns:
Null if the charset is supported (including if there is no specificaton of it in the header). The charset that is unsupported, if that is the case.

disconnect

public static void disconnect(java.net.URLConnection urlConnection)
Free resources as possible on the URLConnection passed in. This is accomplished by calling disconnect() if it turns out to be an instance of HttpURLConnection.

Parameters:
urlConnection - a reference to a URLConnection.

localHost

public static java.lang.String localHost()
local host address (parse out only IP address)

Returns:

getAllInetAddressesForLocalhost

public static java.net.InetAddress[] getAllInetAddressesForLocalhost()

wrapSingleAddress

public static final java.net.InetAddress[] wrapSingleAddress(java.net.InetAddress address)
Convienence method for getting a single-element array of InetAddresses for servers that normally take an array, but when only one is available.

Parameters:
address - the address to wrap.
Returns:
a single-element array containing address.