public class Utilities
extends java.lang.Object
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static void |
bufferToFile(java.lang.String fileName,
java.nio.ByteBuffer buf,
boolean overWriteOK)
This method takes a byte buffer and saves it to the specified file,
overwriting whatever is there.
|
static int |
generateBaseFileName(java.lang.String baseName,
java.lang.String runType,
java.lang.StringBuilder newNameBuilder)
This method generates part of a file name given a base file name as an argument.
|
static java.lang.String |
generateFileName(java.lang.String baseFileName,
int specifierCount,
int runNumber,
long split,
int splitNumber)
This method generates a complete file name from the previously determined baseFileName
obtained from calling
generateBaseFileName(String, String, StringBuilder) . |
public static int generateBaseFileName(java.lang.String baseName, java.lang.String runType, java.lang.StringBuilder newNameBuilder) throws EvioException
The base file name may contain up to 2, C-style integer format specifiers
(such as %03d, or %x). If more than 2 are found, an exception
will be thrown.
If no "0" precedes any integer between the "%" and the "d" or "x" of the format specifier,
it will be added automatically in order to avoid spaces in the returned string.
In the generateFileName(String, int, int, long, int)
method, the first
occurrence will be substituted with the given runNumber value.
If the file is being split, the second will be substituted with the split number.
The base file name may contain characters of the form $(ENV_VAR) which will be substituted with the value of the associated environmental variable or a blank string if none is found.
Finally, the base file name may contain occurrences of the string "%s" which will be substituted with the value of the runType arg or nothing if the runType is null.
baseName
- file name to start withrunType
- run type/configuration namenewNameBuilder
- object which contains generated base file nameEvioException
- if baseName arg is improperly formatted;
if baseName or newNameBuilder arg is nullpublic static java.lang.String generateFileName(java.lang.String baseFileName, int specifierCount, int runNumber, long split, int splitNumber) throws java.util.IllegalFormatException
generateBaseFileName(String, String, StringBuilder)
.
If evio data is to be split up into multiple files (split > 0), numbers are used to
distinguish between the split files with splitNumber.
If baseFileName contains C-style int format specifiers (specifierCount > 0), then
the first occurrence will be substituted with the given runNumber value.
If the file is being split, the second will be substituted with the splitNumber.
If 2 specifiers exist and the file is not being split, no substitutions are made.
If no specifier for the splitNumber exists, it is tacked onto the end of the file name.baseFileName
- file name to use as a basis for the generated file namespecifierCount
- number of C-style int format specifiers in baseFileName argrunNumber
- CODA run numbersplit
- number of bytes at which to split off evio filesplitNumber
- number of the split filejava.util.IllegalFormatException
- if the baseFileName arg contains printing format
specifiers which are not compatible with integers
and interfere with formattingpublic static void bufferToFile(java.lang.String fileName, java.nio.ByteBuffer buf, boolean overWriteOK) throws java.io.IOException, EvioException
fileName
- name of file to writebuf
- buffer to write to fileoverWriteOK
- if true
, OK to overwrite previously existing filejava.io.IOException
- if trouble writing to fileEvioException
- if file exists but overwriting is not permitted;
if null arg(s)