Packages

  • package root
    Definition Classes
    root
  • package de
    Definition Classes
    root
  • package h2b
    Definition Classes
    de
  • package scala
    Definition Classes
    h2b
  • package lib
    Definition Classes
    scala
  • package io
    Definition Classes
    lib
  • package math
    Definition Classes
    lib
  • package phys
    Definition Classes
    lib
  • package util

    This is a Scala library of programming utilities.

    This is a Scala library of programming utilities. It is not intended to comprise a systematic collection but contains some tools that may be useful for some applications.

    Some highlights are a number of probability distributions, a command-line interface, a configuration package, an RSS utility, a class to handle temporary directories, control structures, a logger trait and a timer.

    Definition Classes
    lib
  • package cli

    Define the parameters of your command line as instances of

    Define the parameters of your command line as instances of

    - FlagParameter: no specific value, just signals that it is there,

    - HelpParameter: signals that the user needs some help (if given as a command-line argument, other parameters are not computed and no parse exceptions are thrown),

    - ValueParameter[V]: has exactly one value of type V,

    - ListParameter[V]: has a number of values of type V and

    - MainParameter: has a number of String values.

    ValueParameter[V] and ListParameter[V] need a converter to convert a string to the value type V. You might want to import the object Converter that provides converters for standard data types implicitly by:

    import de.h2b.scala.lib.util.cli.Converter._

    Then create a new instance of CommandLine with a set of parameters. The resulting object then can parse a string sequence or an array of strings for parameters and their values. If something goes wrong, either a ParameterException (some argument does not obey to the format specified by its parameter) or a CommandLineException (something is wrong with the arguments as a whole) is thrown.

    Finally query the original parameter instances for its value or values field.

    The usage method of CommandLine constructs a string suitable for a usage message.

    Example:
    1. import de.h2b.scala.lib.util.cli._
      import de.h2b.scala.lib.util.cli.Converter._
      val overwrite = FlagParameter(Set("-o", "--overwrite"), "overwrite target")
      val mode = ValueParameter(Set("-m"), "mode", default=Some(0))
      val main = MainParameter("source target", arity=2)
      CommandLine(Set(overwrite, mode, main)).parse("-o -m 1 from to".split(' '))
      println(overwrite.value) //> Some(true)
      println(mode.value) //> Some(1)
      println(main.values) //> Some(WrappedArray(from, to))
  • package config

    This package provides various configuration sources under a common trait Config, which is basically an immutable map.

    This package provides various configuration sources under a common trait Config, which is basically an immutable map. The following implementations are available:

    - ArgsConfig loads key/value pairs from an array of strings: array elements that contain a separator char (defined by ArgsConfig.SeparatorChar) are considered as key/value pairs, while elements not consumed by this rule can be retrieved by the remaining array (makes it suitable to scan a command line for such key/value pairs and parsing the rest with tools like described in [U1 Command-Line Interface](#u1-command-line-interface).

    - FileConfig loads key/value pairs from a specified resource file which must conform to the java.util.Properties#load(InputStream) method; there is also a factory method where the resource is looked up under the modified package name of a specified class.

    - BundleConfig loads key/value pairs from a resource bundle (according to the java.util.ResourceBundle class) of a specified base name using a locale option; there is also a factory method where the resource bundle is looked up under the modified package name of a specified class.

    * SystemPropertiesConfig is a Config object that represents the system properties of the JVM.

    * SystemEnvironmentConfig is a Config object that represents the system environment; note that the system may not support environment variables -- in this case, this object is empty.

    Multiple Configs can be combined using the standard map ++ operators, yielding an overall Config.

    Example:
    1. import de.h2b.scala.lib.util.config._
      val argsConfig = ArgsConfig("-x key1=val1 /y key2=val2 abc".split(' '))
      val sysConfig = SystemPropertiesConfig
      val otherConfig = Config("one"->1, "two"->2, "three"->3)
      val config = argsConfig ++ sysConfig ++ otherConfig
      println(config.get("key1")) //> Some(val1)
      println(config.get("java.version")) //> Some(1.8.0_121)
      println(config.get("two")) //> Some(2)
      println(argsConfig.remaining.mkString(" ")) //> -x /y abc
  • Builder
  • ConsoleLogger
  • Control
  • JavaCollectionConverters
  • Level
  • Logger
  • MsTimer
  • NsTimer
  • PerformanceMeter
  • StringCompare
  • StringCompareIgnoreSet
  • StringConv
  • StringOps
  • Timer
  • package web
    Definition Classes
    lib

package util

This is a Scala library of programming utilities. It is not intended to comprise a systematic collection but contains some tools that may be useful for some applications.

Some highlights are a number of probability distributions, a command-line interface, a configuration package, an RSS utility, a class to handle temporary directories, control structures, a logger trait and a timer.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. util
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package cli

    Define the parameters of your command line as instances of

    Define the parameters of your command line as instances of

    - FlagParameter: no specific value, just signals that it is there,

    - HelpParameter: signals that the user needs some help (if given as a command-line argument, other parameters are not computed and no parse exceptions are thrown),

    - ValueParameter[V]: has exactly one value of type V,

    - ListParameter[V]: has a number of values of type V and

    - MainParameter: has a number of String values.

    ValueParameter[V] and ListParameter[V] need a converter to convert a string to the value type V. You might want to import the object Converter that provides converters for standard data types implicitly by:

    import de.h2b.scala.lib.util.cli.Converter._

    Then create a new instance of CommandLine with a set of parameters. The resulting object then can parse a string sequence or an array of strings for parameters and their values. If something goes wrong, either a ParameterException (some argument does not obey to the format specified by its parameter) or a CommandLineException (something is wrong with the arguments as a whole) is thrown.

    Finally query the original parameter instances for its value or values field.

    The usage method of CommandLine constructs a string suitable for a usage message.

    Example:
    1. import de.h2b.scala.lib.util.cli._
      import de.h2b.scala.lib.util.cli.Converter._
      val overwrite = FlagParameter(Set("-o", "--overwrite"), "overwrite target")
      val mode = ValueParameter(Set("-m"), "mode", default=Some(0))
      val main = MainParameter("source target", arity=2)
      CommandLine(Set(overwrite, mode, main)).parse("-o -m 1 from to".split(' '))
      println(overwrite.value) //> Some(true)
      println(mode.value) //> Some(1)
      println(main.values) //> Some(WrappedArray(from, to))
  2. package config

    This package provides various configuration sources under a common trait Config, which is basically an immutable map.

    This package provides various configuration sources under a common trait Config, which is basically an immutable map. The following implementations are available:

    - ArgsConfig loads key/value pairs from an array of strings: array elements that contain a separator char (defined by ArgsConfig.SeparatorChar) are considered as key/value pairs, while elements not consumed by this rule can be retrieved by the remaining array (makes it suitable to scan a command line for such key/value pairs and parsing the rest with tools like described in [U1 Command-Line Interface](#u1-command-line-interface).

    - FileConfig loads key/value pairs from a specified resource file which must conform to the java.util.Properties#load(InputStream) method; there is also a factory method where the resource is looked up under the modified package name of a specified class.

    - BundleConfig loads key/value pairs from a resource bundle (according to the java.util.ResourceBundle class) of a specified base name using a locale option; there is also a factory method where the resource bundle is looked up under the modified package name of a specified class.

    * SystemPropertiesConfig is a Config object that represents the system properties of the JVM.

    * SystemEnvironmentConfig is a Config object that represents the system environment; note that the system may not support environment variables -- in this case, this object is empty.

    Multiple Configs can be combined using the standard map ++ operators, yielding an overall Config.

    Example:
    1. import de.h2b.scala.lib.util.config._
      val argsConfig = ArgsConfig("-x key1=val1 /y key2=val2 abc".split(' '))
      val sysConfig = SystemPropertiesConfig
      val otherConfig = Config("one"->1, "two"->2, "three"->3)
      val config = argsConfig ++ sysConfig ++ otherConfig
      println(config.get("key1")) //> Some(val1)
      println(config.get("java.version")) //> Some(1.8.0_121)
      println(config.get("two")) //> Some(2)
      println(argsConfig.remaining.mkString(" ")) //> -x /y abc

Type Members

  1. trait Builder[T] extends AnyRef

    A builder for objects of type T.

  2. class ConsoleLogger extends Logger

    Logger implementation that writes logging messages to the console.

  3. trait Logger extends AnyRef

    An interface for logging events.

    An interface for logging events.

    Copyright (C) 2008, 2015 Hans-Hermann Bode

  4. class MsTimer extends Timer
  5. class NsTimer extends Timer
  6. implicit class StringCompare extends AnyRef

    Provides string similarity-comparison ignoring implicitly specified characters.

    Provides string similarity-comparison ignoring implicitly specified characters.

    The implicit specification offered by this package object ignores whitespace.

  7. class StringCompareIgnoreSet extends AnyRef
  8. implicit class StringConv extends AnyRef

    Provides implicit string conversions.

  9. implicit class StringOps extends AnyRef

    Provides implicit additional string operations.

    Provides implicit additional string operations.

    Since

    0.4.2

  10. trait Timer extends AnyRef

    Provides timer functionality.

    Provides timer functionality.

    Based on my Java class Timer (as of 2006, has been nested in Clock class) that itself had a long history of Modula2 (1987-90) and C (1994) implementations.

    The timer will start immediately on construction, so it is not required to start or reset it explictely (although it does no harm). Arbitrary many start (implicit or explicit) and stop cycles can be passed through. The times measured on each cycle are cumulated and the result is returned by the reading method, while the lap method adds the time since the last stop to that result.

    Copyright (C) 1987, 1989, 1990, 1994, 2006, 2015 Hans-Hermann Bode

    Version

    3.0

Value Members

  1. implicit final val Whitespace: StringCompareIgnoreSet
  2. object Control
  3. object JavaCollectionConverters extends AsJavaExtensions with AsScalaExtensions

    An equivalent to scala.jdk.CollectionConverters.

    An equivalent to scala.jdk.CollectionConverters. To be used to import this object from a single package over different Scala versions in order to maintain source-code compatibilty.

    Note

    This variant of the source code is for Scala from version 2.13 on.

  4. object Level extends Enumeration

    An enumeration type for providing different logging levels.

    An enumeration type for providing different logging levels.

    The levels are prioritized in the order as they are declared. As a clue, dummy priority numbers are given below to show the ordering, but beware that these numbers are not part of the specification nor of the implementation.

    Copyright (C) 2008, 2015 Hans-Hermann Bode

    Version

    2.0

  5. object Logger extends ConsoleLogger

    Companion object that both serves as a global logger instance and provides factory methods to create individual instances.

  6. object PerformanceMeter
  7. object StringCompare
  8. object Timer

Inherited from AnyRef

Inherited from Any

Ungrouped