net.fenyo.gnetwatch
Class GenericTools

java.lang.Object
  extended by net.fenyo.gnetwatch.GenericTools

public class GenericTools
extends java.lang.Object

General methods not dedicated to a particular application.

Version:
$Id: GenericTools.java,v 1.16 2008/04/20 14:40:37 fenyo Exp $
Author:
Alexandre Fenyo

Field Summary
private static Log log
           
 
Constructor Summary
GenericTools()
           
 
Method Summary
static java.lang.String formatNumericString(Config config, java.lang.String value)
           
static java.lang.String getFullExceptionStackTrace(java.lang.Throwable ex)
          Returns the full stack trace.
static java.lang.String getNetFromAddress(java.lang.String addr_str)
          Returns the class A/B/C network address containing an IP address.
static java.lang.String inet4AddressToString(java.net.Inet4Address addr)
          Converts an IP address to its string representation.
static java.lang.String inet6AddressToString(java.net.Inet6Address addr)
          Converts an IP address to its string representation.
static void initLogEngine(Config config)
          Configure the global logging rules.
static java.net.Inet4Address stringToInet4Address(java.lang.String str)
          Converts a string to an Inet4Address.
static java.net.Inet6Address stringToInet6Address(java.lang.String str)
          Converts a string to an Inet6Address.
static void substractGraph(java.util.List<Pair<VisualElement,VisualElement>> g1, java.util.List<Pair<VisualElement,VisualElement>> g2)
          Removes the part of a graph that is covered by another graph.
static short unsignedByteToShort(byte ub)
          Converts a unsigned byte (encoded into a java signed byte) to a positive signed short.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static Log log
Constructor Detail

GenericTools

public GenericTools()
Method Detail

initLogEngine

public static void initLogEngine(Config config)
Configure the global logging rules.

Parameters:
config - Reference to the general configuration instance.

stringToInet4Address

public static java.net.Inet4Address stringToInet4Address(java.lang.String str)
                                                  throws java.net.UnknownHostException
Converts a string to an Inet4Address.

Parameters:
str - source string.
Returns:
Inet4Address address representing this string.
Throws:
java.net.UnknownHostException

stringToInet6Address

public static java.net.Inet6Address stringToInet6Address(java.lang.String str)
                                                  throws java.net.UnknownHostException
Converts a string to an Inet6Address.

Parameters:
str - source string.
Returns:
Inet6Address address representing this string.
Throws:
java.net.UnknownHostException

unsignedByteToShort

public static short unsignedByteToShort(byte ub)
Converts a unsigned byte (encoded into a java signed byte) to a positive signed short.

Parameters:
ub - unsigned byte encoded into a java signed byte.
Returns:
short positive signed short.

inet4AddressToString

public static java.lang.String inet4AddressToString(java.net.Inet4Address addr)
Converts an IP address to its string representation.

Parameters:
addr - ipv4 address.
Returns:
String ascii representation.

inet6AddressToString

public static java.lang.String inet6AddressToString(java.net.Inet6Address addr)
Converts an IP address to its string representation.

Parameters:
addr - ipv6 address.
Returns:
String ascii representation.

getNetFromAddress

public static java.lang.String getNetFromAddress(java.lang.String addr_str)
Returns the class A/B/C network address containing an IP address.

Parameters:
addr_str - IPv4 address.
Returns:
String network address.

substractGraph

public static void substractGraph(java.util.List<Pair<VisualElement,VisualElement>> g1,
                                  java.util.List<Pair<VisualElement,VisualElement>> g2)
Removes the part of a graph that is covered by another graph. Note that the second graph need not to be a subgraph of the first one.

Parameters:
addr - g1 initial graph.
addr - g2 graph defining links to remove to the initial graph.

getFullExceptionStackTrace

public static java.lang.String getFullExceptionStackTrace(java.lang.Throwable ex)
Returns the full stack trace. This function is a replacement to Throwable.getStackTrace() that writes "... XX [lines] more" when there are too many entries in the stack trace.

Parameters:
ex - exception.
Returns:
String exception description with full stack trace.

formatNumericString

public static java.lang.String formatNumericString(Config config,
                                                   java.lang.String value)