|
|||||||||
| Home >> All >> allensoft >> javacvs >> [ client overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
allensoft.javacvs.client
Class TextFileFormatter

java.lang.Objectallensoft.javacvs.client.TextFileFormatter
- public final class TextFileFormatter
- extends java.lang.Object
Defines a text file formatter. This converts from one text format to another. This could be used to change the indentation of a source file, for example. The user can configure any number of these. The RepositoryDetails class can then be used to associate various formatters for a repository location. This is quite powerful and allows one to, for example, always ensure that C files in one repository location are indented so as to conform to coding standards. It also allows the user to check the file out in their preffered style. This allows individual developers to have different indentation styles while the repository remains consistent and uses only one style. The command of the formatter can use the %in and %out macros, which get substituted with the absolute path of the input and output files respectively. For example the command:
indent -gnu %in -o %out
could be used to indent a C file into the GNU coding standards for indentation.
| Nested Class Summary | |
static class |
TextFileFormatter.InvalidTextFileFormatterException
Excpetion thrown for when repository details are added using the add method. |
| Field Summary | |
private static java.util.List |
g_Formatters
|
private boolean |
m_bRunOnConflicts
|
private int |
m_nSuccessfulExitCode
|
private java.lang.String |
m_sCommand
|
private java.lang.String |
m_sName
|
private java.lang.String |
m_sPatterns
|
private static java.util.prefs.Preferences |
prefs
|
private static allensoft.util.ResourceLoader |
res
|
| Constructor Summary | |
private |
TextFileFormatter(java.lang.String name,
java.lang.String pattern,
java.lang.String command,
boolean runOnConflicts)
|
| Method Summary | |
static TextFileFormatter |
add(java.lang.String name,
java.lang.String patterns,
java.lang.String command,
boolean runOnConflicts)
Adds a new text file formatter to the database of available formatters. |
void |
formatTextFile(java.io.File in,
java.io.File out)
Using the settings in this formatter formats in and writes result to out. |
static TextFileFormatter |
get(int i)
Gets the text formatter at the specified index. |
static TextFileFormatter |
get(java.lang.String name)
Gets the text file formatter with the specified user name. |
java.lang.String |
getCommand()
Gets the command to be executed to format the text file. |
static int |
getCount()
Gets the number of text formatters defined by the user. |
static TextFileFormatter |
getFormatterForReceivingText(java.io.File file)
Gets the formatter that would be used when sending the supplied file to a server. |
static TextFileFormatter |
getFormatterForSendingText(java.io.File file)
Gets the formatter that would be used when sending the supplied file to a server. |
java.lang.String |
getName()
Gets the user assigned name for this formatter. |
java.lang.String |
getPatterns()
Gets the patterns that describe the files that this formatter can work on. |
boolean |
getRunOnConflicts()
Determines if this formatter can run on files that are marked as having conflicts. |
int |
getSuccessfulExitCode()
Gets the exit code that should be returned by the command to indicate success. |
private boolean |
matchesFileName(java.lang.String sName)
Returns true if this text file formatter's pattern matches the supplied file name. |
private static void |
save()
|
void |
setCommand(java.lang.String s)
Sets the command to be executed to format the text file. |
void |
setPatterns(java.lang.String s)
Sets the patterns that describe the files that this formatter can work on. |
void |
setRunOnConflicts(boolean b)
Sets whether this formatter can run on files that are marked as having conflicts. |
void |
setSuccessfulExitCode(int n)
Sets the exit code that should be returned by the command to indicate success. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
prefs
private static final java.util.prefs.Preferences prefs
res
private static final allensoft.util.ResourceLoader res
g_Formatters
private static java.util.List g_Formatters
m_sName
private java.lang.String m_sName
m_sPatterns
private java.lang.String m_sPatterns
m_sCommand
private java.lang.String m_sCommand
m_bRunOnConflicts
private boolean m_bRunOnConflicts
m_nSuccessfulExitCode
private int m_nSuccessfulExitCode
| Constructor Detail |
TextFileFormatter
private TextFileFormatter(java.lang.String name, java.lang.String pattern, java.lang.String command, boolean runOnConflicts)
| Method Detail |
save
private static void save()
add
public static TextFileFormatter add(java.lang.String name, java.lang.String patterns, java.lang.String command, boolean runOnConflicts) throws TextFileFormatter.InvalidTextFileFormatterException
- Adds a new text file formatter to the database of available formatters.
getCount
public static int getCount()
- Gets the number of text formatters defined by the user.
get
public static TextFileFormatter get(int i)
- Gets the text formatter at the specified index.
get
public static TextFileFormatter get(java.lang.String name)
- Gets the text file formatter with the specified user name.
getFormatterForSendingText
public static TextFileFormatter getFormatterForSendingText(java.io.File file)
- Gets the formatter that would be used when sending the supplied file to
a server. This method first checks if the file is under CVS control.
If it is then it checks to make sure the file is not a binary file
(-kb). It then tries to find the RepositoryDetails for the location where
the file will be sent. From this it will check the repository details to see
if the user has configured a formatter for sending text to this repository.
getFormatterForReceivingText
public static TextFileFormatter getFormatterForReceivingText(java.io.File file)
- Gets the formatter that would be used when sending the supplied file to
a server. This method first checks if the file is under CVS control.
If it is then it checks to make sure the file is not a binary file
(-kb). It then tries to find the RepositoryDetails for the location where
the file will be sent. From this it will check the repository details to see
if the user has configured a formatter for sending text to this repository.
getName
public java.lang.String getName()
- Gets the user assigned name for this formatter.
getPatterns
public java.lang.String getPatterns()
- Gets the patterns that describe the files that this formatter can work on.
Patterns are separated by space.
setPatterns
public void setPatterns(java.lang.String s)
- Sets the patterns that describe the files that this formatter can work on.
Patterns are separated by space.
getCommand
public java.lang.String getCommand()
- Gets the command to be executed to format the text file. The commmand
can contain %in and %out to refer to the input and output files.
setCommand
public void setCommand(java.lang.String s)
- Sets the command to be executed to format the text file. The commmand
can contain %in and %out to refer to the input and output files.
getRunOnConflicts
public boolean getRunOnConflicts()
- Determines if this formatter can run on files that are marked as having
conflicts. Some formatters may change the notation that CVS uses to identify
conflicts and so shouldn't be run. This defaults to false.
setRunOnConflicts
public void setRunOnConflicts(boolean b)
- Sets whether this formatter can run on files that are marked as having
conflicts. Some formatters may change the notation that CVS uses to identify
conflicts and so shouldn't be run. This defaults to false.
getSuccessfulExitCode
public int getSuccessfulExitCode()
- Gets the exit code that should be returned by the command to indicate success.
Bt default this is 0.
setSuccessfulExitCode
public void setSuccessfulExitCode(int n)
- Sets the exit code that should be returned by the command to indicate success.
Bt default this is 0.
matchesFileName
private boolean matchesFileName(java.lang.String sName)
- Returns true if this text file formatter's pattern matches the supplied file name.
formatTextFile
public void formatTextFile(java.io.File in, java.io.File out) throws java.io.IOException
- Using the settings in this formatter formats in and writes result to out.
|
|||||||||
| Home >> All >> allensoft >> javacvs >> [ client overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
allensoft.javacvs.client.TextFileFormatter