Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ifs.util
Class ToolBox

    java.lang.Object
      ifs.util.ToolBox

    public class ToolBox

extends Object

Several auxiliary static methods.

Version:
  1.0
Author:
  Tomáš Müller

Constructor Summary
`ToolBox()`

Method Summary
`static String` | `col2string(Collection col, int tab)` Multiline representation of a colection
`static void` | `configureLogging()` Configurates log4j loging
`static void` | `configureLogging(String logDir, Properties properties)` Configurates log4j loging
`static void` | `configureLogging(String logDir, Properties properties, boolean timeInFileName)` Configurates log4j loging
`static String` | `dict2string(Dictionary dict, int tab)` Multiline representation of a dictionary
`static Random` | `getRandom()` Gets random number generator
`static long` | `getSeed()` Gets current seed
`static Vector` | `intersect(Collection source1, Collection source2)` Returns intersection of two collections
`static DataProperties` | `loadProperties(File propertyFile)` Loads data properties.
`static void` | `merge(Vector target, Collection source)` Merge source with target
`static double` | `random()` Generates random double number
`static Object` | `random(Collection set)` Returns random element from the given set of elements
`static int` | `random(int limit)` Returns random number (int) from the set 0 .. limit - 1
`static double` | `rms(int n, double x, double x2)` Root mean square
`static void` | `setSeed(long seed)` Sets seeds for `getRandom()` and `random()` methods.
`static Enumeration` | `sortEnumeration(Enumeration e)` Sort enumeration
`static Enumeration` | `sortEnumeration(Enumeration e, Comparator c)` Sort enumeration
`static Collection` | `subSet(Collection set, double part)` Returns a randomly generated subset of the given set
`static Collection` | `subSet(Collection set, double part, int minSize)` Returns a randomly generated subset of the given set
`static String` | `trim(String s, int length)` Trim a string to have given length

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ToolBox

    public ToolBox()

Method Detail

### random

    public static int random(int limit)

  Returns random number (int) from the set 0 .. limit - 1

### random

    public static Object random(Collection set)

  Returns random element from the given set of elements

### subSet

    public static Collection subSet(Collection set,
                                    double part)

  Returns a randomly generated subset of the given set

  Parameters:
    `set` - set
    `part` - probability of selection of an element into the resultant subset

### subSet

    public static Collection subSet(Collection set,
                                    double part,
                                    int minSize)

  Returns a randomly generated subset of the given set

  Parameters:
    `set` - set
    `part` - probability of selection of an element into the resultant subset
    `minSize` - minimal size of the returned subset

### trim

    public static String trim(String s,
                              int length)

  Trim a string to have given length

### col2string

    public static String col2string(Collection col,
                                    int tab)

  Multiline representation of a colection

### dict2string

    public static String dict2string(Dictionary dict,
                                     int tab)

  Multiline representation of a dictionary

### rms

    public static double rms(int n,
                             double x,
                             double x2)

  Root mean square

  Parameters:
    `n` - number of tests
    `x` - total value of all tests
    `x2` - total value^2 of all tests

### sortEnumeration

    public static Enumeration sortEnumeration(Enumeration e)

  Sort enumeration

  Parameters:
    `e` - an enumeration
  Returns:
    sorted enumeration

### sortEnumeration

    public static Enumeration sortEnumeration(Enumeration e,
                                              Comparator c)

  Sort enumeration

  Parameters:
    `e` - an enumeration
    `c` - comparator of two objects in enumeration e
  Returns:
    sorted enumeration

### merge

    public static void merge(Vector target,
                             Collection source)

  Merge source with target

### intersect

    public static Vector intersect(Collection source1,
                                   Collection source2)

  Returns intersection of two collections

### setSeed

    public static void setSeed(long seed)

  Sets seeds for `getRandom()` and `random()` methods.

### getSeed

    public static long getSeed()

  Gets current seed

### getRandom

    public static Random getRandom()

  Gets random number generator

### random

    public static double random()

  Generates random double number

### configureLogging

    public static void configureLogging()

  Configurates log4j loging

### configureLogging

    public static void configureLogging(String logDir,
                                        Properties properties)

  Configurates log4j loging

  Parameters:
    `logDir` - output folder
    `properties` - some other log4j properties

### configureLogging

    public static void configureLogging(String logDir,
                                        Properties properties,
                                        boolean timeInFileName)

  Configurates log4j loging

  Parameters:
    `logDir` - output folder
    `properties` - some other log4j properties
    `timeInFileName` - if true log file is named debug_yyyy-MM-dd_(HH.mm.ss).log, it is named debug.log otherwise

### loadProperties

    public static DataProperties loadProperties(File propertyFile)

  Loads data properties. If there is INCLUDE property available, it is interpreted as semi-colon separated list of porperty files which should be also loaded (works recursively).

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 Tomáš Müller