Class GeneralUtils

java.lang.Object
org.graffiti.util.GeneralUtils
All Implemented Interfaces:
HelperClass

public class GeneralUtils
extends Object
implements HelperClass
  • Constructor Details

    • GeneralUtils

      public GeneralUtils()
  • Method Details

    • 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 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.