java.lang.Object
org.sourcejammer.util.CounterFactory
- public class CounterFactory
- extends java.lang.Object
Title: $FileName: CounterFactory.java$
- Version:
- $VerNum: 2$
|
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. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
counters
private static java.util.Hashtable counters
- A cache of counter objects.
counterFile
private java.io.File counterFile
value
private long value
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.
getNextValue
private long getNextValue()
throws java.io.IOException
saveValue
private void saveValue()
throws java.io.IOException
readLongValue
private long readLongValue()
throws java.io.FileNotFoundException,
java.io.IOException,
java.lang.ClassNotFoundException
- Reads the value from the file.
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).
main
public static void main(java.lang.String[] args)
oldCounterNextID
private static long oldCounterNextID(java.io.File fl)
throws java.io.IOException