public abstract class LanguageModule
extends java.lang.Object
LanguageModule
interface acts as a registration
vehicle and factory for the services used for editing a particular
language. It takes care of registering the file types supported by
this language, and the styles (language features) used for
rendering. It is also the factory for creating a LanguageSupport
instance for this language.
LanguageModule
implementations are automatically
registered in the framework when a new instance of that
implementation is instantiated. During this registration process,
the styles for the module are initialized, and the supported file
types registered. Because of this auto-registration,
LanguageModule
instances are intended to be singleton
instances.
This class provides a number of predefined file type constants.
These may be returned in getSupportedFileTypes()
. If
you wish your implementation to override one of the default ones in
supporting a particular file type, simply return that file type in
your implementation of getSupportedFileTypes()
.
Pre-defined LanguageModules
are loaded using
Class.forName() and instantiated so that the base editor does not
have a direct dependency on various supports except for the
default, built-in one for plain text. This allows clients to drop
supports which they do not need.
LanguageSupport
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FILETYPE_C
The file suffix *.c.
|
static java.lang.String |
FILETYPE_CPLUSPLUS
The file suffix *.cplusplus.
|
static java.lang.String |
FILETYPE_CPP
The file suffix *.cpp.
|
static java.lang.String |
FILETYPE_CPP2
The file suffix *.c++.
|
static java.lang.String |
FILETYPE_CSS
The file suffix *.css.
|
static java.lang.String |
FILETYPE_DIFF
The file suffix *.diff.
|
static java.lang.String |
FILETYPE_DTD
The file suffix *.dtd.
|
static java.lang.String |
FILETYPE_H
The file suffix *.h.
|
static java.lang.String |
FILETYPE_HTM
The file suffix *.htm.
|
static java.lang.String |
FILETYPE_HTML
The file suffix *.html.
|
static java.lang.String |
FILETYPE_IDL
The file suffix *.idl.
|
static java.lang.String |
FILETYPE_JAVA
The file suffix *.java.
|
static java.lang.String |
FILETYPE_JS
The file suffix *.js.
|
static java.lang.String |
FILETYPE_JSP
The file suffix *.jsp.
|
static java.lang.String |
FILETYPE_LOG
The file suffix *.log.
|
static java.lang.String |
FILETYPE_MF
The file suffix *.MF
|
static java.lang.String |
FILETYPE_PATCH
The file suffix *.patch.
|
static java.lang.String |
FILETYPE_PHP
The file suffix *.php
|
static java.lang.String |
FILETYPE_PHP3
The file suffix *.php3
|
static java.lang.String |
FILETYPE_PHP4
The file suffix *.php4
|
static java.lang.String |
FILETYPE_PLS
The file suffix *.pls.
|
static java.lang.String |
FILETYPE_PLSQL
The file suffix *.plsql.
|
static java.lang.String |
FILETYPE_PROPERTIES
The file suffix *.properties.
|
static java.lang.String |
FILETYPE_RTS
The file suffix *.rts.
|
static java.lang.String |
FILETYPE_SQL
The file suffix *.sql.
|
static java.lang.String |
FILETYPE_SQLJ
The file suffix *.sqlj.
|
static java.lang.String |
FILETYPE_TEXT
The file suffix *.text.
|
static java.lang.String |
FILETYPE_TXT
The file suffix *.txt.
|
static java.lang.String |
FILETYPE_XML
The file suffix *.xml.
|
static java.lang.String |
FILETYPE_XSL
The file suffix *.xsl.
|
Modifier | Constructor and Description |
---|---|
protected |
LanguageModule()
Construct a new
LanguageModule . |
Modifier and Type | Method and Description |
---|---|
abstract BlockRenderer |
createBlockRenderer(TextBuffer buffer)
Creates a new BlockRenderer instance for editing this
specific language.
|
static BlockRenderer |
createBlockRendererForFileType(java.lang.String fileType,
TextBuffer textBuffer) |
static LanguageSupport |
createDefaultSupport()
Static factory routine to create a default
LanguageSupport
for editing plain text. |
abstract LanguageSupport |
createLanguageSupport()
Creates a new LanguageSupport instance for editing this
specific language.
|
static LanguageSupport |
createSupportForFileType(java.lang.Class supportClass)
Static factory routine to create a
LanguageSupport
based on the currently registered LanguageModules . |
static LanguageSupport |
createSupportForFileType(java.lang.String fileName)
Static factory routine to create a
LanguageSupport
for the given filename based on the currently registered
LanguageModules . |
abstract java.lang.String |
getContentSample()
Fetches a sample of the content that can be edited by this
language module.
|
static LanguageModule |
getDefaultModule()
Static utility routine to fetch the default language module used
for plain content.
|
static java.lang.String |
getFileType(java.lang.String fileName)
Retrieve the file type based on the given filename.
|
static StyleRegistry |
getGlobalStyleRegistry()
Convenience routine to fetch the global style registry.
|
static java.util.Iterator |
getLanguageIterator()
Fetch an
Iterator for all the language modules. |
static LanguageModule |
getModuleForFileType(java.lang.String fileName)
Utility routine to fetch the
LanguageModule registered
for the given filetype. |
java.lang.String |
getName()
Fetches the name of this language module.
|
abstract java.lang.String |
getPresentationName()
Fetch the visible or presentation name of this language module.
|
abstract java.lang.String[] |
getStyleNames()
Fetches an array of style names for the
BaseStyles
specific to this language. |
abstract java.lang.String[] |
getSupportedFileTypes()
Fetches an array of supported file suffixes.
|
protected void |
initializeModule()
Initialize the language module.
|
void |
registerModule(LanguageModule module)
Registers this language module with the framework.
|
static void |
registerModuleForFileType(LanguageModule module,
java.lang.String fileName)
Utility routine to register the
LanguageModule for
the given file type. |
abstract void |
registerStyles(StyleRegistry registry)
Register the styles used by the highlighter in this language.
|
java.lang.String |
toString()
Fetches the human-readable name of the module.
|
public static final java.lang.String FILETYPE_TXT
public static final java.lang.String FILETYPE_TEXT
public static final java.lang.String FILETYPE_LOG
public static final java.lang.String FILETYPE_JAVA
public static final java.lang.String FILETYPE_JSP
public static final java.lang.String FILETYPE_PHP
public static final java.lang.String FILETYPE_PHP3
public static final java.lang.String FILETYPE_PHP4
public static final java.lang.String FILETYPE_HTML
public static final java.lang.String FILETYPE_HTM
public static final java.lang.String FILETYPE_SQLJ
public static final java.lang.String FILETYPE_SQL
public static final java.lang.String FILETYPE_PLS
public static final java.lang.String FILETYPE_PLSQL
public static final java.lang.String FILETYPE_PROPERTIES
public static final java.lang.String FILETYPE_RTS
public static final java.lang.String FILETYPE_MF
public static final java.lang.String FILETYPE_XML
public static final java.lang.String FILETYPE_DTD
public static final java.lang.String FILETYPE_XSL
public static final java.lang.String FILETYPE_IDL
public static final java.lang.String FILETYPE_C
public static final java.lang.String FILETYPE_CPP2
public static final java.lang.String FILETYPE_CPP
public static final java.lang.String FILETYPE_CPLUSPLUS
public static final java.lang.String FILETYPE_CSS
public static final java.lang.String FILETYPE_H
public static final java.lang.String FILETYPE_JS
public static final java.lang.String FILETYPE_DIFF
public static final java.lang.String FILETYPE_PATCH
protected LanguageModule()
LanguageModule
. This will
automatically register this language module class.public static LanguageSupport createDefaultSupport()
LanguageSupport
for editing plain text.public static LanguageModule getDefaultModule()
public static LanguageSupport createSupportForFileType(java.lang.String fileName)
LanguageSupport
for the given filename based on the currently registered
LanguageModules
. The file type is based on the
trailing suffix of the filename.fileName
- the name of the file from which the file type is derivedpublic static LanguageSupport createSupportForFileType(java.lang.Class supportClass)
LanguageSupport
based on the currently registered LanguageModules
.
The file type is based on the type of an existing
LanguageSupport
class.supportClass
- the language support instance to bepublic static BlockRenderer createBlockRendererForFileType(java.lang.String fileType, TextBuffer textBuffer)
public static LanguageModule getModuleForFileType(java.lang.String fileName)
LanguageModule
registered
for the given filetype. The file type is based on the trailing
suffix of the filename.fileName
- the name of the file from which the file type is derivedpublic static void registerModuleForFileType(LanguageModule module, java.lang.String fileName)
LanguageModule
for
the given file type. The file type is based on the trailing
suffix of the filenamemodule
- the language module to register to support this file typefileName
- the name of the file from which the file type is derivedpublic static java.lang.String getFileType(java.lang.String fileName)
fileName
- the file name to get the type forpublic static StyleRegistry getGlobalStyleRegistry()
public void registerModule(LanguageModule module)
module
- the language module to registerpublic static java.util.Iterator getLanguageIterator()
Iterator
for all the language modules.
that have been registered.protected void initializeModule()
public java.lang.String getName()
public abstract java.lang.String getPresentationName()
public java.lang.String toString()
toString
in class java.lang.Object
public abstract java.lang.String[] getSupportedFileTypes()
public abstract java.lang.String[] getStyleNames()
BaseStyles
specific to this language. This can be used for example, for a
syntax highlighting options panel that displays styles by
language category. Note that the internal names, not the
presentation names of the styles should be returned here.public abstract java.lang.String getContentSample()
public abstract void registerStyles(StyleRegistry registry)
registry
- the StyleRegistry (for lookups of derived styles)public abstract LanguageSupport createLanguageSupport()
public abstract BlockRenderer createBlockRenderer(TextBuffer buffer)