org.sourcejammer.util
Class CounterFactory

java.lang.Object
  |
  +--org.sourcejammer.util.CounterFactory

public class CounterFactory
extends java.lang.Object

Title: $FileName: CounterFactory.java$

Version:
$VerNum: 2$
Author:
$AuthorName: Rob MacGrogan$

$Description: $
$KeyWordsOff: $

Field Summary
private  java.io.File counterFile
           
private static java.util.Hashtable counters
          A cache of counter objects.
private  long value
           
 
Constructor Summary
private CounterFactory(java.io.File counterFile)
          Constructs the CounterFactory from the specified file.

If the file is not found, this method attempts to create it.

If the file found is a Counter object, this method attempts to read the Counter object and convert it to a CounterFactory.
 
Method Summary
private  long getNextValue()
           
static long getNextValue(java.io.File counterFile)
          Returns the next id of the counter stored at the specified location.
static void main(java.lang.String[] args)
           
private static long oldCounterNextID(java.io.File fl)
           
private  long readLongValue()
          Reads the value from the file.
private  void saveValue()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counters

private static java.util.Hashtable counters
A cache of counter objects.


counterFile

private java.io.File counterFile

value

private long value
Constructor Detail

CounterFactory

private CounterFactory(java.io.File counterFile)
                throws java.io.IOException
Constructs the CounterFactory from the specified file.

If the file is not found, this method attempts to create it.

If the file found is a Counter object, this method attempts to read the Counter object and convert it to a CounterFactory.

Method Detail

getNextValue

private long getNextValue()
                   throws java.io.IOException
java.io.IOException

saveValue

private void saveValue()
                throws java.io.IOException
java.io.IOException

readLongValue

private long readLongValue()
                    throws java.io.FileNotFoundException,
                           java.io.IOException,
                           java.lang.ClassNotFoundException
Reads the value from the file.

java.io.FileNotFoundException
java.io.IOException
java.lang.ClassNotFoundException

getNextValue

public static long getNextValue(java.io.File counterFile)
                         throws java.io.IOException
Returns the next id of the counter stored at the specified location. If the counter does not exist, this method will attempt to create it and return the initial value (0).

java.io.IOException

main

public static void main(java.lang.String[] args)

oldCounterNextID

private static long oldCounterNextID(java.io.File fl)
                              throws java.io.IOException
java.io.IOException


Copyright 2003 Soucejammer project.