[13522 views]

[]

The lib_odi Library

What is lib_odi?

lib_odi is a library that contains some useful classes. Other Java applications on this website make liberal use of it.

Download

Download Package lib_odi.jar (19 KB)
Download Source lib_odi_src.jar (17 KB)

Packages

See the API Doc for details.
com.ch.odi.io Streams with limited bandwidth. Specify a bandwidth limit and the bandwith limiting streams will keep to it. This provides a possibility to do traffic shaping.
com.ch.odi.net Networking helper classes for servers. Servers can listen on a port and handle incoming connections in separate threads.
com.ch.odi.parallel Some applications repeatedly perform many similar tasks. To speed up the application those tasks could be performed at the same time. This is called parallel processing or multithreading.

Consider a sample application: The computation of the Mandelbrot Set.
The same calculation is made for every pixel on the screen. Normally an application does one pixel at a time. Fair enough because most computers only have one CPU. So the processor is completely busy all the time. What about Dual Processor machines or even computers with a higher number of CPUs? Several processors could work on individual pixels.

Consider another sample: Portscanning - the newly discovered sports on the Internet.
You scan a remote host's ports by trying to establish a connection to it. If the connection is successful the port is considered as open. A typical port scanner would scan all TCP ports from 1 through 1024 one by one. But most of the time the computer will be waiting for the data packets beeing returned or timeout. So it would be better to perform other port scans meanwhile.

This Package enables the programmer to easily create a constant number of threads. The classes handle thread synchronization properly.
com.ch.odi.common Other useful classes:
- Find and replace for strings
- an object cache
- Hashtable utility
com.ch.odi.common.graphs What is a graph?
A graph consists of interconnected nodes. A node must be connected to at least one other node (neighbour). All nodes in a graph are connected so that there are no islands. A single node without any connections is a valid graph. A graph without nodes is a valid graph.

Graphs are useful for state diagrams and game analysis or representation of web-like structures.
The package supports graph data structures and finding the shortest path between nodes.

How to use

Include the package in your classpath. At compile time this is accomplished either from within your IDE or on the console: javac -cp lib_odi.jar MyClass.java
At runtime this is accomplished either from within your IDE or on the console: java -cp lib_odi.jar MyClass