org.erights.e.develop.trace
Class TraceVersionNamer

java.lang.Object
  |
  +--org.erights.e.develop.trace.TraceVersionNamer
All Implemented Interfaces:
TraceConstants
Direct Known Subclasses:
TraceTxtVersionNamer

class TraceVersionNamer
extends Object
implements TraceConstants

This class and its subclasses know how to construct backup version Files for given Files.

This class constructs backup names by appending sequence numbers to the original name.


Field Summary
static String[] acceptorNames
           
static int ADD
           
static int DEBUG
           
static String DEFAULT_NAME
           
static int ERROR
          The different trace thresholds.
static int EVENT
           
static int FOR_SUBSYSTEM
           
static int FROM_DEFAULT
          When referring to thresholds, are we talking about those from the default thresholds, or ones specific to a subsystem? XXX These could be interned strings, but interning didn't work right in 1.0.4.
static int IRRELEVANT
           
static int LOG
          This identifies the TraceMessageAcceptor used for the on-disk log.
static String LOG_EXTENSION
           
static int MAX_THRESHOLD
           
(package private)  String myBasename
          The basename is that part of the file that precedes a sequence number.
(package private)  String myDir
          A directory that contains the given file.
private  File myFile
          The file for which a version number is being created.
(package private)  String myName
          The 'filename' part of the given file, sans directory.
static int NUM_ACCEPTORS
          The number of different types of TraceMessageAcceptors.
static int OVERWRITE
           
static String[] reasonNames
           
static long SMALLEST_LOG_SIZE_THRESHOLD
           
static int STARTING_LOG_BACKUP_ACTION
           
static File STARTING_LOG_DIR
           
static long STARTING_LOG_SIZE_THRESHOLD
           
static String STARTING_LOG_TAG
           
static int STARTING_LOG_THRESHOLD
           
static boolean STARTING_LOG_WRITE
           
static int STARTING_TRACE_BUFFER_SIZE
           
static int STARTING_TRACE_THRESHOLD
           
static int TIMING
          As a late addition, there's a "timing" boolean that can be set orthogonally from the thresholds.
static int TRACE
          This identifies the TraceMessageAcceptor used for the in-core trace and its associated window.
static String UNLIMITED_NAME
           
static int USAGE
           
static int VERBOSE
           
static String version
           
static int WARNING
           
static int WORLD
           
 
Constructor Summary
(package private) TraceVersionNamer(File aFile)
          Create a TraceVersionNamer from the given file.
 
Method Summary
(package private)  File constructVersion(int sequence)
          Create a backup file name, given a sequence number.
(package private) static TraceVersionNamer factory(File file)
          Return a TraceTxtVersionNamer if the file ends with ".txt"; otherwise, return a TraceVersionNamer.
(package private)  String fetchBasename()
          The basename of a backup version, including any trailing '.' separating the basename from the sequence number.
(package private)  File firstVersion()
          The backup file with sequence number 0.
(package private)  int getSeq(String filename)
          Return a sequence number, if the given file contains one.
static void main(String[] args)
           
(package private)  boolean mightHaveSeq(String filename)
          True iff the filename is of a format that could be a backup version of the original file.
(package private)  File nextAvailableVersion()
          Return the next file in the sequence , .0, .1, etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myFile

private final File myFile
The file for which a version number is being created.


myName

final String myName
The 'filename' part of the given file, sans directory.


myDir

final String myDir
A directory that contains the given file.


myBasename

final String myBasename
The basename is that part of the file that precedes a sequence number.


version

public static final String version

LOG

public static final int LOG
This identifies the TraceMessageAcceptor used for the on-disk log.


TRACE

public static final int TRACE
This identifies the TraceMessageAcceptor used for the in-core trace and its associated window.


NUM_ACCEPTORS

public static final int NUM_ACCEPTORS
The number of different types of TraceMessageAcceptors.


acceptorNames

public static final String[] acceptorNames

ERROR

public static final int ERROR
The different trace thresholds. See the Trace class for documentation. There is space between the levels for expansion. If you add or delete a level, you must change Trace.java to add new methods and variables.


WARNING

public static final int WARNING

WORLD

public static final int WORLD

USAGE

public static final int USAGE

EVENT

public static final int EVENT

DEBUG

public static final int DEBUG

VERBOSE

public static final int VERBOSE

MAX_THRESHOLD

public static final int MAX_THRESHOLD

TIMING

public static final int TIMING
As a late addition, there's a "timing" boolean that can be set orthogonally from the thresholds. The above values are overloaded: thresholds, but also identifiers for the original message (was it sent with errorm(), etc.). The TIMING "level" is added for the latter purpose, but it has nothing to do with thresholds. To avoid confusion, it's set negative, thus below the minimum threshold.


FROM_DEFAULT

public static final int FROM_DEFAULT
When referring to thresholds, are we talking about those from the default thresholds, or ones specific to a subsystem? XXX These could be interned strings, but interning didn't work right in 1.0.4. That is, two "default" strings weren't eq.


FOR_SUBSYSTEM

public static final int FOR_SUBSYSTEM

reasonNames

public static final String[] reasonNames

STARTING_TRACE_BUFFER_SIZE

public static final int STARTING_TRACE_BUFFER_SIZE

STARTING_TRACE_THRESHOLD

public static final int STARTING_TRACE_THRESHOLD

STARTING_LOG_SIZE_THRESHOLD

public static final long STARTING_LOG_SIZE_THRESHOLD

SMALLEST_LOG_SIZE_THRESHOLD

public static final long SMALLEST_LOG_SIZE_THRESHOLD

STARTING_LOG_THRESHOLD

public static final int STARTING_LOG_THRESHOLD

STARTING_LOG_WRITE

public static final boolean STARTING_LOG_WRITE

IRRELEVANT

public static final int IRRELEVANT

ADD

public static final int ADD

OVERWRITE

public static final int OVERWRITE

STARTING_LOG_BACKUP_ACTION

public static final int STARTING_LOG_BACKUP_ACTION

STARTING_LOG_DIR

public static final File STARTING_LOG_DIR

STARTING_LOG_TAG

public static final String STARTING_LOG_TAG

LOG_EXTENSION

public static final String LOG_EXTENSION

DEFAULT_NAME

public static final String DEFAULT_NAME

UNLIMITED_NAME

public static final String UNLIMITED_NAME
Constructor Detail

TraceVersionNamer

TraceVersionNamer(File aFile)
Create a TraceVersionNamer from the given file. The file object must have a directory and name component. It may be absolute or relative.

Method Detail

constructVersion

File constructVersion(int sequence)
Create a backup file name, given a sequence number.


factory

static TraceVersionNamer factory(File file)
Return a TraceTxtVersionNamer if the file ends with ".txt"; otherwise, return a TraceVersionNamer.


fetchBasename

String fetchBasename()
The basename of a backup version, including any trailing '.' separating the basename from the sequence number.


firstVersion

File firstVersion()
The backup file with sequence number 0. Doesn't matter if it exists.


getSeq

int getSeq(String filename)
Return a sequence number, if the given file contains one. If it does not contain one, return -1. Do not call this method unless mightHaveSeq has approved the filename.


main

public static void main(String[] args)

mightHaveSeq

boolean mightHaveSeq(String filename)
True iff the filename is of a format that could be a backup version of the original file. It remains to be determined whether it truly contains a sequence number.

In a stunning display of write-once-run-everywhere, the check is case-insensitive. This obeys Windows conventions about what "same files" are, not Unix conventions.

Parameters:
filename - a filename, not including any directory part.

nextAvailableVersion

File nextAvailableVersion()
Return the next file in the sequence , .0, .1, etc. Subclasses will have their own name-construction rules.



comments?