Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.5.0)

E13403-06


oracle.javatools.editor.language
Class LanguageModule

java.lang.Object
  extended by oracle.javatools.editor.language.LanguageModule


public abstract class LanguageModule
extends java.lang.Object

The 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.

See Also:
LanguageSupport

Field Summary
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_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.

 

Constructor Summary
protected LanguageModule()
          Construct a new LanguageModule.

 

Method Summary
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.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

FILETYPE_TXT

public static final java.lang.String FILETYPE_TXT
The file suffix *.txt.
See Also:
Constant Field Values

FILETYPE_TEXT

public static final java.lang.String FILETYPE_TEXT
The file suffix *.text.
See Also:
Constant Field Values

FILETYPE_LOG

public static final java.lang.String FILETYPE_LOG
The file suffix *.log.
See Also:
Constant Field Values

FILETYPE_JAVA

public static final java.lang.String FILETYPE_JAVA
The file suffix *.java.
See Also:
Constant Field Values

FILETYPE_JSP

public static final java.lang.String FILETYPE_JSP
The file suffix *.jsp.
See Also:
Constant Field Values

FILETYPE_PHP

public static final java.lang.String FILETYPE_PHP
The file suffix *.php
See Also:
Constant Field Values

FILETYPE_PHP3

public static final java.lang.String FILETYPE_PHP3
The file suffix *.php3
See Also:
Constant Field Values

FILETYPE_PHP4

public static final java.lang.String FILETYPE_PHP4
The file suffix *.php4
See Also:
Constant Field Values

FILETYPE_HTML

public static final java.lang.String FILETYPE_HTML
The file suffix *.html.
See Also:
Constant Field Values

FILETYPE_HTM

public static final java.lang.String FILETYPE_HTM
The file suffix *.htm.
See Also:
Constant Field Values

FILETYPE_SQLJ

public static final java.lang.String FILETYPE_SQLJ
The file suffix *.sqlj.
See Also:
Constant Field Values

FILETYPE_SQL

public static final java.lang.String FILETYPE_SQL
The file suffix *.sql.
See Also:
Constant Field Values

FILETYPE_PLS

public static final java.lang.String FILETYPE_PLS
The file suffix *.pls.
See Also:
Constant Field Values

FILETYPE_PLSQL

public static final java.lang.String FILETYPE_PLSQL
The file suffix *.plsql.
See Also:
Constant Field Values

FILETYPE_PROPERTIES

public static final java.lang.String FILETYPE_PROPERTIES
The file suffix *.properties.
See Also:
Constant Field Values

FILETYPE_RTS

public static final java.lang.String FILETYPE_RTS
The file suffix *.rts.
See Also:
Constant Field Values

FILETYPE_XML

public static final java.lang.String FILETYPE_XML
The file suffix *.xml.
See Also:
Constant Field Values

FILETYPE_DTD

public static final java.lang.String FILETYPE_DTD
The file suffix *.dtd.
See Also:
Constant Field Values

FILETYPE_XSL

public static final java.lang.String FILETYPE_XSL
The file suffix *.xsl.
See Also:
Constant Field Values

FILETYPE_IDL

public static final java.lang.String FILETYPE_IDL
The file suffix *.idl.
See Also:
Constant Field Values

FILETYPE_C

public static final java.lang.String FILETYPE_C
The file suffix *.c.
See Also:
Constant Field Values

FILETYPE_CPP2

public static final java.lang.String FILETYPE_CPP2
The file suffix *.c++.
See Also:
Constant Field Values

FILETYPE_CPP

public static final java.lang.String FILETYPE_CPP
The file suffix *.cpp.
See Also:
Constant Field Values

FILETYPE_CPLUSPLUS

public static final java.lang.String FILETYPE_CPLUSPLUS
The file suffix *.cplusplus.
See Also:
Constant Field Values

FILETYPE_CSS

public static final java.lang.String FILETYPE_CSS
The file suffix *.css.
See Also:
Constant Field Values

FILETYPE_H

public static final java.lang.String FILETYPE_H
The file suffix *.h.
See Also:
Constant Field Values

FILETYPE_JS

public static final java.lang.String FILETYPE_JS
The file suffix *.js.
See Also:
Constant Field Values

FILETYPE_DIFF

public static final java.lang.String FILETYPE_DIFF
The file suffix *.diff.
See Also:
Constant Field Values

FILETYPE_PATCH

public static final java.lang.String FILETYPE_PATCH
The file suffix *.patch.
See Also:
Constant Field Values

Constructor Detail

LanguageModule

protected LanguageModule()
Construct a new LanguageModule. This will automatically register this language module class.

Method Detail

createDefaultSupport

public static LanguageSupport createDefaultSupport()
Static factory routine to create a default LanguageSupport for editing plain text.
Returns:
a default language support instance

getDefaultModule

public static LanguageModule getDefaultModule()
Static utility routine to fetch the default language module used for plain content.
Returns:
the default language module

createSupportForFileType

public static LanguageSupport createSupportForFileType(java.lang.String fileName)
Static factory routine to create a LanguageSupport for the given filename based on the currently registered LanguageModules. The file type is based on the trailing suffix of the filename.
Parameters:
fileName - the name of the file from which the file type is derived
Returns:
a new language support instance for the given file type

createSupportForFileType

public static LanguageSupport createSupportForFileType(java.lang.Class supportClass)
Static factory routine to create a LanguageSupport based on the currently registered LanguageModules. The file type is based on the type of an existing LanguageSupport class.
Parameters:
supportClass - the language support instance to be
Returns:
a new language support instance for the given file type

createBlockRendererForFileType

public static BlockRenderer createBlockRendererForFileType(java.lang.String fileType,
                                                           TextBuffer textBuffer)

getModuleForFileType

public static LanguageModule getModuleForFileType(java.lang.String fileName)
Utility routine to fetch the LanguageModule registered for the given filetype. The file type is based on the trailing suffix of the filename.
Parameters:
fileName - the name of the file from which the file type is derived
Returns:
the language module registered to support this file type

registerModuleForFileType

public static void registerModuleForFileType(LanguageModule module,
                                             java.lang.String fileName)
Utility routine to register the LanguageModule for the given file type. The file type is based on the trailing suffix of the filename
Parameters:
module - the language module to register to support this file type
fileName - the name of the file from which the file type is derived

getFileType

public static java.lang.String getFileType(java.lang.String fileName)
Retrieve the file type based on the given filename. This is done by getting the trailing suffix without the dot "." character. If a dot is not found, it is just assumed that the file name is the suffix. Either way, it is converted to lowercase when returned to ensure that when we get or put from our map, that we can find the type correctly.
Parameters:
fileName - the file name to get the type for
Returns:
the file type found

getGlobalStyleRegistry

public static StyleRegistry getGlobalStyleRegistry()
Convenience routine to fetch the global style registry.
Returns:
the global style registry

registerModule

public void registerModule(LanguageModule module)
Registers this language module with the framework. This will instruct the module to register its styles, and will also register all of the file types that the module can support. If the module has been registered before, it will not be registered again.
Parameters:
module - the language module to register

getLanguageIterator

public static java.util.Iterator getLanguageIterator()
Fetch an Iterator for all the language modules. that have been registered.
Returns:
an iterator for all registered modules

initializeModule

protected void initializeModule()
Initialize the language module. Subclasses that have extra initialization to perform besides creating styles and registering file types may override this method.

getName

public java.lang.String getName()
Fetches the name of this language module. This may be used for registration or debugging purposes.
Returns:
name of this language module.

getPresentationName

public abstract java.lang.String getPresentationName()
Fetch the visible or presentation name of this language module. This is generally a translated name that can be used for UI purposes.
Returns:
the name of this module in human-readable (translated) form

toString

public java.lang.String toString()
Fetches the human-readable name of the module.
Overrides:
toString in class java.lang.Object
Returns:
the module name

getSupportedFileTypes

public abstract java.lang.String[] getSupportedFileTypes()
Fetches an array of supported file suffixes.
Returns:
a string array of the supported file suffixes.

getStyleNames

public abstract java.lang.String[] getStyleNames()
Fetches an array of style names for the 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.
Returns:
a string array of the language style names

getContentSample

public abstract java.lang.String getContentSample()
Fetches a sample of the content that can be edited by this language module. This may be used for UI purposes, such as being displayed in the editor of the syntax highlighting options panel that shows that the language styles look like.
Returns:
a sample of the type of document that this module can edit

registerStyles

public abstract void registerStyles(StyleRegistry registry)
Register the styles used by the highlighter in this language.
Parameters:
registry - the StyleRegistry (for lookups of derived styles)

createLanguageSupport

public abstract LanguageSupport createLanguageSupport()
Creates a new LanguageSupport instance for editing this specific language.
Returns:
a new LanguageSupport instance

createBlockRenderer

public abstract BlockRenderer createBlockRenderer(TextBuffer buffer)
Creates a new BlockRenderer instance for editing this specific language.
Returns:
a new BlockRenderer instance

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.5.0)

E13403-06


Copyright © 1997, 2011, Oracle. All rights reserved.