org.fife.rtext
Class SyntaxFilters

java.lang.Object
  extended by org.fife.rtext.SyntaxFilters
All Implemented Interfaces:
SyntaxConstants

public class SyntaxFilters
extends java.lang.Object
implements SyntaxConstants

Manages a list of wildcard file filters and what syntax highlighting styles they map to.

Version:
0.1
Author:
Robert Futrell

Field Summary
 
Fields inherited from interface org.fife.ui.rsyntaxtextarea.SyntaxConstants
SYNTAX_STYLE_ACTIONSCRIPT, SYNTAX_STYLE_ASSEMBLER_X86, SYNTAX_STYLE_BBCODE, SYNTAX_STYLE_C, SYNTAX_STYLE_CLOJURE, SYNTAX_STYLE_CPLUSPLUS, SYNTAX_STYLE_CSHARP, SYNTAX_STYLE_CSS, SYNTAX_STYLE_DELPHI, SYNTAX_STYLE_DTD, SYNTAX_STYLE_FORTRAN, SYNTAX_STYLE_GROOVY, SYNTAX_STYLE_HTACCESS, SYNTAX_STYLE_HTML, SYNTAX_STYLE_JAVA, SYNTAX_STYLE_JAVASCRIPT, SYNTAX_STYLE_JSON, SYNTAX_STYLE_JSP, SYNTAX_STYLE_LATEX, SYNTAX_STYLE_LISP, SYNTAX_STYLE_LUA, SYNTAX_STYLE_MAKEFILE, SYNTAX_STYLE_MXML, SYNTAX_STYLE_NONE, SYNTAX_STYLE_NSIS, SYNTAX_STYLE_PERL, SYNTAX_STYLE_PHP, SYNTAX_STYLE_PROPERTIES_FILE, SYNTAX_STYLE_PYTHON, SYNTAX_STYLE_RUBY, SYNTAX_STYLE_SAS, SYNTAX_STYLE_SCALA, SYNTAX_STYLE_SQL, SYNTAX_STYLE_TCL, SYNTAX_STYLE_UNIX_SHELL, SYNTAX_STYLE_VISUAL_BASIC, SYNTAX_STYLE_WINDOWS_BATCH, SYNTAX_STYLE_XML
 
Constructor Summary
SyntaxFilters()
          Creates a new SyntaxFilters with default values for all filters.
SyntaxFilters(java.lang.String filterStr)
          Creates a new SyntaxFilters from the given string.
 
Method Summary
 void addFileFilter(java.lang.String style, java.lang.String filter)
          Adds a file filter for a given syntax style.
 java.lang.String getFilterString(java.lang.String style)
          Returns a list of all wildcard file filters associated with this syntax type, separated by spaces.
 java.lang.String getSyntaxStyleForFile(java.lang.String fileName, boolean ignoreBackupExtensions)
          Returns the type of syntax highlighting to use for the given text file based on its extension and the current filters.
static boolean isValidFileFilterString(java.lang.String fileFilterString)
          Returns true if and only if the file filter string passed in is "valid".
 void restoreDefaultFileFilters()
          Sets default values for syntax filters.
 void setFiltersForSyntaxStyle(java.lang.String style, java.lang.String filterString)
          Sets all file filters for a given syntax style.
 void setPreservingPluginAdded(SyntaxFilters filters)
          Sets values for all the filters not added by plugins.
 java.lang.String toString()
          Returns this object as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SyntaxFilters

public SyntaxFilters()
Creates a new SyntaxFilters with default values for all filters.


SyntaxFilters

public SyntaxFilters(java.lang.String filterStr)
Creates a new SyntaxFilters from the given string.

Parameters:
filterStr - Must be a String generated from SyntaxFilter.toString(). If its format is invalid, then default filter strings are used for all syntax styles.
Method Detail

addFileFilter

public void addFileFilter(java.lang.String style,
                          java.lang.String filter)
Adds a file filter for a given syntax style.

Parameters:
style - The syntax style to add a file filter to.
filter - The filter to add. If null, nothing will be done.
Throws:
java.lang.IllegalArgumentException - If style is invalid.

getFilterString

public java.lang.String getFilterString(java.lang.String style)
Returns a list of all wildcard file filters associated with this syntax type, separated by spaces. For example, if the C++ syntax style has filters *.cpp and *.h associated with it, then getFilterString(SYNTAX_STYLE_CPLUSPLUS) would return "*.cpp *.h".

Parameters:
style - The syntax style to check.
Throws:
java.lang.IllegalArgumentException - If style is invalid.

getSyntaxStyleForFile

public java.lang.String getSyntaxStyleForFile(java.lang.String fileName,
                                              boolean ignoreBackupExtensions)
Returns the type of syntax highlighting to use for the given text file based on its extension and the current filters.

Parameters:
fileName - The file to syntax highlight.
ignoreBackupExtensions - Whether to ignore ".bak", ".old" and ".orig" extensions, if they exist.
Returns:
The syntax highlighting scheme to use, for example, SYNTAX_STYLE_JAVA or SYNTAX_STYLE_CPLUSPLUS.
See Also:
RSyntaxTextArea, SyntaxConstants

isValidFileFilterString

public static boolean isValidFileFilterString(java.lang.String fileFilterString)
Returns true if and only if the file filter string passed in is "valid". Currently valid file filter strings contain only the following characters: A-Z, a-z, 0-9, '*', '?', '.', '-', '_', ' ', '$'.

Parameters:
fileFilterString - The file filter string to test.
Returns:
true if the file filter string is valid, false otherwise.

restoreDefaultFileFilters

public void restoreDefaultFileFilters()
Sets default values for syntax filters.


setFiltersForSyntaxStyle

public void setFiltersForSyntaxStyle(java.lang.String style,
                                     java.lang.String filterString)
Sets all file filters for a given syntax style.

Parameters:
style - The syntax style to add a file filter to.
filterString - A string representing the file filters separated by spaces. If null, nothing happens.
Throws:
java.lang.IllegalArgumentException - If style is invalid.

setPreservingPluginAdded

public void setPreservingPluginAdded(SyntaxFilters filters)
Sets values for all the filters not added by plugins.

Parameters:
filters - The new values for filters.

toString

public java.lang.String toString()
Returns this object as a string. Note that we currently do not save plugin-defined syntax filters.

Overrides:
toString in class java.lang.Object
Returns:
A string representing this SyntaxFilters.