Package org.graffiti.util
Class GeneralUtils
java.lang.Object
org.graffiti.util.GeneralUtils
- All Implemented Interfaces:
HelperClass
public class GeneralUtils extends Object implements HelperClass
-
Constructor Summary
Constructors Constructor Description GeneralUtils()
-
Method Summary
Modifier and Type Method Description boolean
existsEdge(Node n1, Node n2)
True iff any edge betweenn1
(source) andn2
(target) exists.static Collection<Edge>
getEdges(Node n1, Node n2)
Returns aCollection
of edges betweenn1
(source) andn2
(target).static String
getNewLineString()
DOCUMENT ME!static int[]
getPositionOfOnes(String s)
DOCUMENT ME!static boolean
isPowerOf(int a, int base)
Returnstrue
iff first parameter is a power of second, i.e.static double
log(double a, double base)
Returns the logarithm ofa
with respect to basebase
.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 attributesList)
Searches for all attributes that have the given class type.static String
XMLify(String inStr)
DOCUMENT ME!
-
Constructor Details
-
GeneralUtils
public GeneralUtils()
-
-
Method Details
-
getEdges
Returns aCollection
of edges betweenn1
(source) andn2
(target).If no edge exists, returns an empty instance of
Collection
.n1==n2
allowed.- Parameters:
n1
-n2
-- Returns:
- Collection
-
getNewLineString
DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getPositionOfOnes
DOCUMENT ME!- Parameters:
s
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
isPowerOf
public static final boolean isPowerOf(int a, int base)Returnstrue
iff first parameter is a power of second, i.e. returns true iffbase^a
is a natural number.- Parameters:
a
- number to checkbase
-- Returns:
- DOCUMENT ME!
-
XMLify
DOCUMENT ME!- Parameters:
inStr
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
existsEdge
True iff any edge betweenn1
(source) andn2
(target) exists.n1==n2
allowed.- Parameters:
n1
-n2
-- Returns:
- boolean
-
log
public static final double log(double a, double base)Returns the logarithm ofa
with respect to basebase
.- 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
Returns the number of "1"s within the string s.- Parameters:
s
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
searchForAttribute
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 eithersearchForAttributes(Attribute, Class, List)
.- Parameters:
attr
- the root attribute for the searchattributeType
- class to match- Returns:
- first child (depth first) of attr that matches class type attributeType.
-
searchForAttributes
Searches for all attributes that have the given class type.- Parameters:
attr
- the root attribute for the searchattributeType
- class to matchattributesList
- list which will be filled with found attributes.
-