Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.togethersoft.openapi.sci
Interface SciReference

All Known Subinterfaces:
  SciInheritance, SciReferenceExpression, SciThrowSpecifier, SciType, SciTypeExpression

public interface SciReference
extends SciObject

`SciReference` interface provides methods for working with references.

In SCI model references are:

- Any usage of element's name in a source code except it's declaration or definition
- Special form of comments

Primitive datatypes are not considered as references.

For example, in the following Java source code fragment the references are `MyType1`, `someObject`, `someMethod` and `iTotal` (in the line with `iTotal=1;`):

       MyType1 myFirstAttribute=null;
       MyType2 mySecondAttribure=null;
       int iTotal=0;             //  it is not a reference!
       someObject.someMethod();
       iTotal=1;

The referenced element can be obtained using `getReferencedElement` method.

It is possible to change referenced element using `setReferencedElement` method. For the example described above , if the `refToMyType2` is a reference to `MyType2`, and the `elementMyType1` is an SCI element representing `MyType1`, the code:

       refToType2.setReferencedElement(elementMyType1)

will make the following changes in the source code:

       MyType1 myFirstAttribute=null;
       MyType1 mySecondAttribure=null;
       ...

Author:
  TogetherSoft

Method Summary
`boolean` | `canSetReferencedElement(SciElement element)` Checks whether the specified element can be set as a target for this reference.
`boolean` | `canSetReferenceText(String text)` Checks whether the specified text can be set as the text for this reference.
`SciElement` | `getReferencedElement()` Returns an `SciElement` this reference points to.
`String` | `getReferenceText()` Returns a string containing this reference text in a source code.
`void` | `setReferencedElement(SciElement element)` Sets another `SciElement` for this reference to point to.
`void` | `setReferenceText(String text)` Sets this reference text to the specified value.

Methods inherited from interface com.togethersoft.openapi.sci.SciObject
`canCut, canDelete, canReplace, copy, cut, delete, getContainingFile, getContainingScope, getLanguage, getPositions, getText, getUserProperty, isReadOnly, replace, setUserProperty`

Method Detail

### canSetReferencedElement

    public boolean canSetReferencedElement(SciElement element)

  Checks whether the specified element can be set as a target for this reference.
  Parameters:
    element - the `SciElement` which needs to be set as a target for this reference
  Returns: `true` if the specified element can be set as a target for this reference, `false` otherwise

### canSetReferenceText

    public boolean canSetReferenceText(String text)

  Checks whether the specified text can be set as the text for this reference.
  Parameters:
    text - the string which needs to be set as the text for this reference
  Returns: `true` if the specified text can be set as the text for this reference, `false` otherwise

### getReferencedElement

    public SciElement getReferencedElement()

  Returns an `SciElement` this reference points to. If Together cannot find such an element (for example, file is not in the classpath), then returns `null`.
  Returns: an `SciElement` this reference points to

### getReferenceText

    public String getReferenceText()

  Returns a string containing this reference text in a source code. This method returns the string exactly as it was typed in the source code.
  Returns: a string containing this reference text in the source code
  See Also:
    SciType.getCanonicalText()

### setReferencedElement

    public void setReferencedElement(SciElement element)

  Sets another `SciElement` for this reference to point to.
  Parameters:
    element - the `SciElement` which needs to be set as a target for this reference

### setReferenceText

    public void setReferenceText(String text)

  Sets this reference text to the specified value. Sometimes it is needed just to change the the text for this reference. This method is called automatically from `setReferencedElement` method.

  Note the difference with `SciType.setText` method when working with the `SciType` objects (`SciType` is a special kind of a reference - a reference to a type).

  Parameters:
    text - the string which needs to be set as the text for this reference
  See Also:
    setReferencedElement(com.togethersoft.openapi.sci.SciElement), SciType.setText(java.lang.String)

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD