coins.driver
Class SuffixFactory

java.lang.Object
  extended bycoins.driver.SuffixFactory

public class SuffixFactory
extends java.lang.Object

A factory of Suffix object.
SuffixFactory reads a suffix database file and creates Suffix objects representing each suffix appeared in the file. The file consists of any number of record lines following a header line. Format of a header line is as following:

#SRD, 2, any string
``#SRD'' represents that this file is a suffix database file. ``2'' means the format version number (i.e., version 2). You can supply any string to explain the contents. Format of a record line is as following:
suffixspec, language name, description, afterpreprocess, aftercompile, afterassemble
Where suffixspecs is a suffixspec, or '/' separated suffixspecs to show more than one suffix represent a same kind of file. A suffixspec is a suffix string may be followed by a (option). The option is called as a suffix option. More than one record can specify a same suffix as long as a suffix option is supplied to all record lines but one. The suffix options for a same suffix must differ each other. If a suffix option is given when getting a Suffix object from the SuffixFactory, an object corresponding the record which has the suffix option is returned. A suffixspec without a suffix option is a default record of the suffix. language name is a name of a programming language in which the file of the suffix is written. The language name can be used to distinguish the programming language in compilation process when more than one programming language is used to build a program. description is a description of this suffix. Do not include commas in the description. afterpreprocess, aftercompile and afterassemble are suffix strings of output files of preprocessing, compilation and assemble. A `-' can be specified when corresponding pass is not required for files with this suffix. Following is a sample suffix database file:
 #SRD, 2, Suffix rule DB file, format version 2
 c,		C,		C source,				i,s,o
 i,		C,		preprocessed C source,			-,s,o
 cc/cpp/cxx/C,C++,		C++ source,				ii,s,o
 ii,		C++,		preprocessed C++ source,		-,s,o
 java,	Java,		Java source,				-,class,-
 java(native),Java,		Java source (native compile),		-,s,o
 f,		FORTRAN,	FORTRAN source,				-,s,o
 S,		Assembler,	assembly source (need preprocess),	s,-,o
 s,		Assembler,	assembly source,			-,-,o
 
The third record line tells that there are four different suffixes which represent C++ source file and preprocess, compilation and assemble are required to process it. The sixth record line tells that when native option is given, a .java file is compiled into an assembler source file.


Field Summary
static java.lang.String DEFAULT_SUFFIX_FILE
          A default suffix database file name.
 
Constructor Summary
SuffixFactory()
           
 
Method Summary
(package private) static void defaultInitialize(CompileSpecification pSpec)
           
static Suffix getSuffix(java.io.File file)
          Returns a Suffix object representing a suffix of a specified file name.
static Suffix getSuffix(java.io.File file, java.lang.String option)
          Returns a Suffix object representing a suffix of a specified file name.
static Suffix getSuffix(java.lang.String suffixString)
          Returns a Suffix object representing a specified suffix string.
static Suffix getSuffix(java.lang.String suffixString, java.lang.String option)
          Returns a Suffix object representing a specified suffix string.
(package private) static void initialize()
           
(package private) static boolean initialize(java.io.BufferedReader pReader, java.lang.String pFile, CompileSpecification pSpec)
           
(package private) static void initialize(CompileSpecification pSpec)
           
(package private) static void initialize(java.io.File pFile, CompileSpecification pSpec)
           
(package private) static void initialize(java.io.InputStream pIn, java.lang.String pFile, CompileSpecification pSpec)
           
(package private) static void initialize(java.lang.String pString, CompileSpecification pSpec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SUFFIX_FILE

public static final java.lang.String DEFAULT_SUFFIX_FILE
A default suffix database file name.

See Also:
Constant Field Values
Constructor Detail

SuffixFactory

public SuffixFactory()
Method Detail

defaultInitialize

static void defaultInitialize(CompileSpecification pSpec)

initialize

static void initialize(CompileSpecification pSpec)

initialize

static void initialize()

initialize

static boolean initialize(java.io.BufferedReader pReader,
                          java.lang.String pFile,
                          CompileSpecification pSpec)
                   throws java.io.IOException
Throws:
java.io.IOException

initialize

static void initialize(java.io.File pFile,
                       CompileSpecification pSpec)

initialize

static void initialize(java.lang.String pString,
                       CompileSpecification pSpec)

initialize

static void initialize(java.io.InputStream pIn,
                       java.lang.String pFile,
                       CompileSpecification pSpec)

getSuffix

public static Suffix getSuffix(java.io.File file)
Returns a Suffix object representing a suffix of a specified file name. Uses the default record when more than one record is found in the database file. If no record matches to the suffix of the specified file name, it is treated as an object file name and a Suffix object representing an object file suffix is returned.

Parameters:
file - a file name.
Returns:
a Suffix object.

getSuffix

public static Suffix getSuffix(java.io.File file,
                               java.lang.String option)
Returns a Suffix object representing a suffix of a specified file name. If a non-null option is specified, a record with that option is searched first, and if not found, the default record is searched. If no record matches to the suffix of the specified file name, it is treated as an object file name and a Suffix object representing an object file suffix is returned.

Parameters:
file - a file name.
Returns:
a Suffix object.

getSuffix

public static Suffix getSuffix(java.lang.String suffixString)
Returns a Suffix object representing a specified suffix string. Uses the default record when more than one record is found in the data base file. If no record matches to the specified suffix string, it is treated as an object file suffix and a Suffix object representing an object file suffix is returned.

Parameters:
suffixString - a suffix string.
Returns:
a Suffix object.

getSuffix

public static Suffix getSuffix(java.lang.String suffixString,
                               java.lang.String option)
Returns a Suffix object representing a specified suffix string. If a non-null option is specified, a record with that option is searched first, and if not found, the default record is searched. If no record matches to the specified suffix string, it is treated as an object file suffix and a Suffix object representing an object file suffix is returned.

Parameters:
suffixString - a suffix string.
option - a suffix option string.
Returns:
a Suffix object.