Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.editor.codetemplates/1 1.2.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.netbeans.lib.editor.codetemplates.spi
Class CodeTemplateInsertRequest

    java.lang.Object
      org.netbeans.lib.editor.codetemplates.spi.CodeTemplateInsertRequest

    public final class CodeTemplateInsertRequest

extends Object

Code template insert request parses the code template's text to gather the data necessary to insert the particular code template into the document (such as the template's parameters).

### State

The insert request can be in three states:

- It is not inserted into the document yet. Both `isInserted()` and `isReleased()` return false. Registered `CodeTemplateProcessor`s will be asked to fill in the default values into the parameters.
- It is inserted and the user modifies the parameters' values in the document. `isInserted()` returns true and `isReleased()` returns false.
- It is released. `isReleased()` returns true. There is no more work to do. Code templates processor(s) servicing the request will be released.

### Parameters

The code template's text is first parsed to find the parameters. Each first occurrence of a parameter with particular name define a master parameter. All the other occurrences of a parameter with the same name define slave parameters (of the previously defined master).

See Also:
  `CodeTemplateParameter`

Method Summary
`List` | `getAllParameters()` Get all the parameters (masters and slaves) present in the code template text in the order as they occur in the parametrized text.
`CodeTemplate` | `getCodeTemplate()` Get code template associated with this insert request.
`JTextComponent` | `getComponent()` Get the text component into which the template should be inserted at the current caret position.
`String` | `getInsertText()` Get the text where all the parameters are replaced by their present values.
`CodeTemplateParameter` | `getMasterParameter(String name)` Get master parameter with the given name.
`List` | `getMasterParameters()` Get list of master parameters in the order they are located in the code template text.
`String` | `getParametrizedText()` Get the present parametrized text handled by this request.
`boolean` | `isInserted()` Check whether the code template that this request represents was already inserted into the document.
`boolean` | `isReleased()` Check whether this request is already released which means that the code template was inserted and values of all the parameters were modified by the user so there is no more work to be done.
`void` | `setParametrizedText(String parametrizedText)` Set the parametrized text to a new value.

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

Method Detail

### getCodeTemplate

    public CodeTemplate getCodeTemplate()

  Get code template associated with this insert request.

### getComponent

    public JTextComponent getComponent()

  Get the text component into which the template should be inserted at the current caret position.

### getMasterParameters

    public List getMasterParameters()

  Get list of master parameters in the order they are located in the code template text.
  The master parameters can be explored by the code template processor and their default values can be changed as necessary.

  Returns:
    non-null unmodifiable list of master parameters.

### getMasterParameter

    public CodeTemplateParameter getMasterParameter(String name)

  Get master parameter with the given name.

  Parameters:
    `name` - non-null name of the master parameter to be searched.
  Returns:
    master parameter with the given name or null if no such parameter exists.

### getAllParameters

    public List getAllParameters()

  Get all the parameters (masters and slaves) present in the code template text in the order as they occur in the parametrized text.

  Returns:
    non-null unmodifiable list of all parameters.
  See Also:
    `getMasterParameters()`

### isInserted

    public boolean isInserted()

  Check whether the code template that this request represents was already inserted into the document.

  Returns:
    true if the code template was already inserted into the document and the inserted default values are being modified by the user which can result into `CodeTemplateProcessor.parameterValueChanged(CodeTemplateParameter, boolean)`.

    Returns false if the code template was not yet inserted into the document i.e. the `CodeTemplateProcessor.updateDefaultValues()` is currently being called on the registered processors.
  See Also:
    `isReleased()`

### isReleased

    public boolean isReleased()

  Check whether this request is already released which means that the code template was inserted and values of all the parameters were modified by the user so there is no more work to be done.

  Returns:
    whether this request is already released or not. If the request was not yet released then `isInserted()` gives additional info whether request is inserted into the document or not.
  See Also:
    `isInserted()`

### getParametrizedText

    public String getParametrizedText()

  Get the present parametrized text handled by this request.
  By default the code template's parametrized text obtained by `CodeTemplate.getParametrizedText()` is used.
  The parametrized text can be modified by `setParametrizedText(String)`.

### setParametrizedText

    public void setParametrizedText(String parametrizedText)

  Set the parametrized text to a new value.
  This may be necessary if some parameters are just artificial and should be expanded by a particular code template processor before the regular processing.
  Once this method is called the new parametrized text will be parsed and a fresh new list of parameters will be created.

  Parameters:
    `parametrizedText` - new parametrized text to be used.

### getInsertText

    public String getInsertText()

  Get the text where all the parameters are replaced by their present values.
  Unless any parameter's value gets changed this text would be inserted into the document once all the code template processors finish their processing.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.editor.codetemplates/1 1.2.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.