public final class CodeStylePreferences extends Object
java.util.prefs.Prefernces instance.
Typical usecase: This class is typically called from an implementation
of IndentTask or ReformatTask, which needs to know formatting
setting in order to do its job. The implementation is given a context object
with a javax.swing.text.Document instance where the formatting is
taking place. The implementation should call get(javax.swing.text.Document)
and getPreferences() in order to get Preferences with
formatting settings.
The infrastructure will take care of providing the right Preferences
instance from either MimeLookup or a project depending on the formatted
document and user's choice. It is important not to cache the Preferences
instance, because a different instance may be provided in the future if a user
changes his mind in using global or per-project formatting settings.
| Modifier and Type | Class and Description |
|---|---|
static interface |
CodeStylePreferences.Provider
Code style preferences provider.
|
| Modifier and Type | Method and Description |
|---|---|
static CodeStylePreferences |
get(Document doc)
Gets
CodeStylePreferences for a document. |
static CodeStylePreferences |
get(Document doc,
String mimeType)
Gets
CodeStylePreferences for a document and an embedding mimeType. |
static CodeStylePreferences |
get(FileObject file)
Gets
CodeStylePreferences for a file. |
static CodeStylePreferences |
get(FileObject file,
String mimeType)
Gets
CodeStylePreferences for a file. |
Preferences |
getPreferences() |
public static CodeStylePreferences get(Document doc)
CodeStylePreferences for a document. This is the prefered
method to use. Whenever you have both Document and its
FileObject always use this method and provide the Document
instance.doc - The document to get CodeStylePreferences for,
can be null. If null, the method will return
global preferences for 'all languages'.CodeStylePreferences, never null.public static CodeStylePreferences get(Document doc, String mimeType)
CodeStylePreferences for a document and an embedding mimeType.
This is the prefered method to use. Whenever you have both Document and its
FileObject always use this method and provide the Document
instance.doc - The document to get CodeStylePreferences for,
can be null. If null, the method will return
global preferences for 'all languages'.CodeStylePreferences, never null.public static CodeStylePreferences get(FileObject file)
CodeStylePreferences for a file. If you also have a
Document instance you should use the get(javax.swing.text.Document)
method.file - The file to get CodeStylePreferences for,
can be null. If null, the method will return
global preferences for 'all languages'.CodeStylePreferences, never null.public static CodeStylePreferences get(FileObject file, String mimeType)
CodeStylePreferences for a file. If you also have a
Document instance you should use the get(javax.swing.text.Document)
method.file - The file to get CodeStylePreferences for,
can be null. If null, the method will return
global preferences for 'all languages'.CodeStylePreferences, never null.public Preferences getPreferences()
Built on June 18 2013. | Portions Copyright 1997-2013 Oracle. All rights reserved.