org.graffiti.util
Class GeneralUtils

java.lang.Object
  extended by org.graffiti.util.GeneralUtils

public class GeneralUtils
extends Object


Constructor Summary
GeneralUtils()
           
 
Method Summary
 boolean existsEdge(Node n1, Node n2)
          True iff any edge between n1 (source) and n2 (target) exists.
static Collection<Edge> getEdges(Node n1, Node n2)
          Returns a Collection of edges between n1 (source) and n2 (target).
static String getNewLineString()
          DOCUMENT ME!
static int[] getPositionOfOnes(String s)
          DOCUMENT ME!
static boolean isPowerOf(int a, int base)
          Returns true iff first parameter is a power of second, i.e.
static double log(double a, double base)
          Returns the logarithm of a with respect to base base.
static boolean nan(double d)
          DOCUMENT ME!
static int numberOfOnes(String s)
          Returns the number of "1"s within the string s.
static Attribute searchForAttribute(Attribute attr, Class<?> attributeType)
          Returns the first attribute it finds that has the given class type.
static void searchForAttributes(Attribute attr, Class<?> attributeType, List<Attribute> attributesList)
          Searches for all attributes that have the given class type.
static String XMLify(String inStr)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralUtils

public GeneralUtils()
Method Detail

getEdges

public static final Collection<Edge> getEdges(Node n1,
                                              Node n2)
Returns a Collection of edges between n1 (source) and n2 (target).

If no edge exists, returns an empty instance of Collection. n1==n2 allowed.

Parameters:
n1 -
n2 -
Returns:
Collection

getNewLineString

public static final String getNewLineString()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getPositionOfOnes

public static final int[] getPositionOfOnes(String s)
DOCUMENT ME!

Parameters:
s - DOCUMENT ME!
Returns:
DOCUMENT ME!

isPowerOf

public static final boolean isPowerOf(int a,
                                      int base)
Returns true iff first parameter is a power of second, i.e. returns true iff base^a is a natural number.

Parameters:
a - number to check
base -
Returns:
DOCUMENT ME!

XMLify

public static final String XMLify(String inStr)
DOCUMENT ME!

Parameters:
inStr - DOCUMENT ME!
Returns:
DOCUMENT ME!

existsEdge

public boolean existsEdge(Node n1,
                          Node n2)
True iff any edge between n1 (source) and n2 (target) exists.

n1==n2 allowed.

Parameters:
n1 -
n2 -
Returns:
boolean

log

public static final double log(double a,
                               double base)
Returns the logarithm of a with respect to base base.

Parameters:
a - DOCUMENT ME!
base - DOCUMENT ME!
Returns:
DOCUMENT ME!

nan

public static final boolean nan(double d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!
Returns:
DOCUMENT ME!

numberOfOnes

public static final int numberOfOnes(String s)
Returns the number of "1"s within the string s.

Parameters:
s - DOCUMENT ME!
Returns:
DOCUMENT ME!

searchForAttribute

public static final Attribute searchForAttribute(Attribute attr,
                                                 Class<?> attributeType)
Returns the first attribute it finds that has the given class type. Warning: this method delivers only one contained attribute of the given type. If there are more than one attibute of that type and you expect all that attributes you should better use either searchForAttributes(Attribute, Class, List).

Parameters:
attr - the root attribute for the search
attributeType - class to match
Returns:
first child (depth first) of attr that matches class type attributeType.

searchForAttributes

public static void searchForAttributes(Attribute attr,
                                       Class<?> attributeType,
                                       List<Attribute> attributesList)
Searches for all attributes that have the given class type.

Parameters:
attr - the root attribute for the search
attributeType - class to match
attributesList - list which will be filled with found attributes.


Generated at 2012-05-30 11:00:14 PM CEST