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 booleanexistsEdge(Node n1, Node n2)True iff any edge betweenn1(source) andn2(target) exists.static Collection<Edge>getEdges(Node n1, Node n2)Returns aCollectionof edges betweenn1(source) andn2(target).static StringgetNewLineString()DOCUMENT ME!static int[]getPositionOfOnes(String s)DOCUMENT ME!static booleanisPowerOf(int a, int base)Returnstrueiff first parameter is a power of second, i.e.static doublelog(double a, double base)Returns the logarithm ofawith respect to basebase.static booleannan(double d)DOCUMENT ME!static intnumberOfOnes(String s)Returns the number of "1"s within the string s.static AttributesearchForAttribute(Attribute attr, Class attributeType)Returns the first attribute it finds that has the given class type.static voidsearchForAttributes(Attribute attr, Class attributeType, List attributesList)Searches for all attributes that have the given class type.static StringXMLify(String inStr)DOCUMENT ME!
-
Constructor Details
-
GeneralUtils
public GeneralUtils()
-
-
Method Details
-
getEdges
Returns aCollectionof edges betweenn1(source) andn2(target).If no edge exists, returns an empty instance of
Collection.n1==n2allowed.- 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)Returnstrueiff first parameter is a power of second, i.e. returns true iffbase^ais 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==n2allowed.- Parameters:
n1-n2-- Returns:
- boolean
-
log
public static final double log(double a, double base)Returns the logarithm ofawith 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.
-