Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.openide.text 6.9.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.openide.text
Class IndentEngine

    java.lang.Object
      org.openide.ServiceType
          org.openide.text.IndentEngine

All Implemented Interfaces:
  Serializable, HelpCtx.Provider

    public abstract class IndentEngine

extends ServiceType

Indentation engine for formating text in documents. Provides mapping between MIME types and engines, so anybody can find appropriate type of engine for type of document.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.openide.ServiceType
`ServiceType.Handle, ServiceType.Registry`

Field Summary

Fields inherited from class org.openide.ServiceType
`PROP_NAME`

Constructor Summary
`IndentEngine()`

Method Summary
`protected boolean` | `acceptMimeType(String mime)` Allow subclasses to decide whether they are suitable for the given mime-type or not.
`abstract Writer` | `createWriter(Document doc, int offset, Writer writer)` Creates writer that formats text that is inserted into it.
`static IndentEngine` | `find(Document doc)` Finds engine associated with given document.
`static IndentEngine` | `find(String mime)` Finds engine associated with given mime type.
`static IndentEngine` | `getDefault()` Returns a simple indentation engine that does no formatting.
`HelpCtx` | `getHelpCtx()`
`static Enumeration` | `indentEngines()` Returns enumeration of all registered indentation engines.
`abstract int` | `indentLine(Document doc, int offset)` Indents the current line.
`abstract int` | `indentNewLine(Document doc, int offset)` Inserts new line at given position and indents the new line with spaces.
`static void` | `register(String mime, IndentEngine eng)` Deprecated. IndentEngine now is a ServiceType

Methods inherited from class org.openide.ServiceType
`addPropertyChangeListener, clone, createClone, displayName, firePropertyChange, getName, removePropertyChangeListener, setName`

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

Constructor Detail

### IndentEngine

    public IndentEngine()

Method Detail

### getHelpCtx

    public HelpCtx getHelpCtx()

  Specified by:
    `getHelpCtx` in interface `HelpCtx.Provider`
  Specified by:
    `getHelpCtx` in class `ServiceType`

### indentLine

    public abstract int indentLine(Document doc,
                                   int offset)

  Indents the current line. Should not effect any other lines.

  Parameters:
    `doc` - the document to work on
    `offset` - the offset of a character on the line
  Returns:
    new offset of the original character

### indentNewLine

    public abstract int indentNewLine(Document doc,
                                      int offset)

  Inserts new line at given position and indents the new line with spaces.

  Parameters:
    `doc` - the document to work on
    `offset` - the offset of a character on the line
  Returns:
    new offset to place cursor to

### createWriter

    public abstract Writer createWriter(Document doc,
                                        int offset,
                                        Writer writer)

  Creates writer that formats text that is inserted into it. The writer should not modify the document but use the provided writer to write to. Usually the underlaying writer will modify the document itself and optionally it can remember the current position in document. That is why the newly created writer should do no buffering.

  The provided document and offset are only informational, should not be modified but only used to find correct indentation strategy.

  Parameters:
    `doc` - document
    `offset` - position to begin inserts at
    `writer` - writer to write to
  Returns:
    new writer that will format written text and pass it into the writer

### acceptMimeType

    protected boolean acceptMimeType(String mime)

  Allow subclasses to decide whether they are suitable for the given mime-type or not.

  Parameters:
    `mime` - mime-type string
  Returns:
    true if this engine is suitable for the given mime-type.

### register

    public static void register(String mime,
                                IndentEngine eng)

  Deprecated. IndentEngine now is a ServiceType

### indentEngines

    public static Enumeration indentEngines()

  Returns enumeration of all registered indentation engines.

  Returns:
    enumeration of IndentEngine

### find

    public static IndentEngine find(String mime)

  Finds engine associated with given mime type. If no engine is associated returns default one.

### find

    public static IndentEngine find(Document doc)

  Finds engine associated with given document. If no engine is associated returns default one.

### getDefault

    public static IndentEngine getDefault()

  Returns a simple indentation engine that does no formatting.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.openide.text 6.9.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.