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 SciElement

All Known Subinterfaces:
  SciAttribute, SciClass, SciFunction, SciInheritance, SciInitializer, SciMember, SciOperation, SciParameter, SciThrowSpecifier, SciVariable

public interface SciElement
extends SciObject

A generic element of a program (class, function, variable etc). Every SCI element has a set of characteristics which define its behavior and structure:

Properties
  Properties contain element's modifier-like information. For example, an element can have a property which indicates whether this element is private. An element can have several properties.
Unique Name
  Every SCI element has a string of a special content called unique name. This string is totally unique within the SCI model, and every element can be found or identified by its unique name.
Qualified Name
  Qualified name has a sense only for `SciClass`es and `SciMember`s, and contains the full name of the element. For example, the qualified name for a java class will look like a standard Java language fully qualified class name: "java.lang.String".

  You can identify a class by its qualified name if you now its language. For example: ``

         SciClass justFoundClass = mySciModel.findClass(SciLanguage.JAVA,"com.togethersoft.openapi.sci.SciElement");

Name
  A string containing a short name of the element. For example, the short name of "java.lang.String" will be "String".

Every `SciElement`'s derivative inherits the `accept(SciElementVisitor)` method which runs visitor's `visitXXX` method corresponding to the kind of this element.

`visitReferences(SciReferenceVisitor)` and `visitReferences(SciReferenceVisitor, SciElement)` methods are used to perform actions upon references contained in this element.

This interfaces contains very useful method `getTagList`, which gives an access to the SciTag objects representing RWI properties of this element, written in the JavaDoc manner in the comment field.

The `isDeleted` method is used for checking whether this `SciElement` represents the existing element of the model.

Author:
  TogetherSoft
See Also: SciProperty, SciTag, SciElementVisitor, SciReferenceVisitor

Method Summary
`Object` | `accept(SciElementVisitor visitor)` "Accepts" a visitor, calling up its `visitXXX` method corresponding to the kind of this element.
`boolean` | `canSetName(String name)` Checks whether the specified name can be set for this element.
`boolean` | `canSetProperty(int property, boolean value)` Checks if the value is valid for this property, or can be assigned to it at this time.
`String` | `getDeclarationText()` Returns a string with a text of this element's declaration.
`String` | `getName()` Returns a string containing the name for this element.
`String` | `getQualifiedName()` Returns a string with the qualified name of this element.
`SciTagList` | `getTagList()` Returns `SciTagList` object containing all `SciTag`s for this element.
`String` | `getUniqueName()` Returns a string with the unique name of this element.
`boolean` | `hasProperty(int property)` Checks whether this element has the specified property.
`boolean` | `isDeleted()` Checks whether this `SciElement` represents existing model's data.
`boolean` | `isPropertyReadable(int property)` Checks whether the property is readable (used to check whether the property has a sense for this element).
`boolean` | `isPropertyWritable(int property)` Checks whether the property is writable for this element.
`void` | `setName(String name)` Sets the name for this element.
`void` | `setProperty(int property, boolean value)` Sets the value for the property.
`void` | `visitReferences(SciReferenceVisitor visitor)` In this element, makes a specified visitor perform certain actions upon all references.
`void` | `visitReferences(SciReferenceVisitor visitor, SciElement referencedElement)` In this element, makes a specified visitor perform certain actions upon all references to the specified element.

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

### accept

    public Object accept(SciElementVisitor visitor)

  "Accepts" a visitor, calling up its `visitXXX` method corresponding to the kind of this element.
  Parameters:
    visitor - the `SciElementVisitor` type visitor
  Returns: visitor-specific result.
  See Also:
    SciElementVisitor, com.togethersoft.openapi.sci.visitor

### canSetName

    public boolean canSetName(String name)

  Checks whether the specified name can be set for this element.
  Parameters:
    name - the string which needs to be assigned as a name fot this element
  Returns: `true` if the specified name can be set for this element, `false` otherwise

### canSetProperty

    public boolean canSetProperty(int property, boolean value)

  Checks if the value is valid for this property, or can be assigned to it at this time.
  Parameters:
    property - The integer value which represents a kind of a property. See `SciProperty` interface for a predefined kinds of properties.
    value - the boolean value for the property
  Returns: `true` if the value can be assigned to the property, `false` otherwise
  See Also:
    SciProperty

### getDeclarationText

    public String getDeclarationText()

  Returns a string with a text of this element's declaration. For example, for the `SciMember` representing this Java operation:

       /**
       * @author TogetherSoft Corporation
       */
       public void someOperation(String str){
          System.out.println(str);
       }

  this method will return `"public void someOperation(String str)"`.
  Returns: a string

### getName

    public String getName()

  Returns a string containing the name for this element.
  Returns: a string containing the name for this element

### getQualifiedName

    public String getQualifiedName()

  Returns a string with the qualified name of this element. For `SciClass` the qualified name is a fully qualified name of this class.

  For `SciMember`s this method returns a string written in Together's internal format. To obtain a normal string with the member's qualified name, method SciLanguageHelper.convertMemberQualifiedNameToPresentableForm can be used.

  Returns: a string with the qualified name of this element
  See Also:
    SciModel.findClass(java.lang.String,java.lang.String), SciModel.findMember(java.lang.String,java.lang.String)

### getTagList

    public SciTagList getTagList()

  Returns `SciTagList` object containing all `SciTag`s for this element.
  Returns: `SciTagList` object containing all `SciTag`s for this element
  See Also:
    SciTagList

### getUniqueName

    public String getUniqueName()

  Returns a string with the unique name of this element.
  Returns: a string with the unique name of this element
  See Also:
    SciModel.findElement(java.lang.String)

### hasProperty

    public boolean hasProperty(int property)

  Checks whether this element has the specified property. Returns `true` if it has, `false` otherwise.
  Parameters:
    property - The integer value which represents a kind of property. See `SciProperty` interface for a predefined kinds of properties.
  Returns: `true` if this element has the specified property, `false` otherwise.

  For example, suppose we have `SciClass`. `SciClass` might represent either a class or an interface. Here is how we can distinguish them: ``

       if (someSciClass.hasProperty(SciProperty.INTERFACE)){
         ... // it is an interface
       } else {
         ... // it is a class
       }

  Another example: suppose you have `SciOperation` and you need to know if it is a public abstract operation: ``

       if (someSciOperation.hasProperty(SciProperty.PUBLIC) && someSciOperation.hasProperty(SciProperty.ABSTRACT)){
         ... // it is an public abstract operation
       } else {
         ... // it is something else, not public abstract
       }

  See Also:
    SciProperty

### isDeleted

    public boolean isDeleted()

  Checks whether this `SciElement` represents existing model's data. For example, if you have gotten an `SciElement` representing an operation, and after that (while your script or pattern was passive) the user deleted this operation in the text editor (or your script deleted `SciObject` representing this operation via `SciObject.delete` method, or the user just closed the project), then your `SciElement` will refer to a non-existing element.

  If you try to use methods of a deleted `SciElement`, the result is unpredictable (you might get a `NullPointerException` etc.). You should always check whether `SciElement` is deleted, if you are not sure in it:

       if (!mySciElement.isDeleted()) {
         return mySciElement.getPositions();
       }

  The only exception is methods `equals` and `hashCode` which can be performed on deleted elements as well.

  Returns: `true` if this `SciElement` represents a non-existing model's element, and cannot be used any longer, `false` otherwise

### isPropertyReadable

    public boolean isPropertyReadable(int property)

  Checks whether the property is readable (used to check whether the property has a sense for this element).
  Parameters:
    property - The integer value which represents a kind of a property. See `SciProperty` interface for a predefined kinds of properties.
  Returns: `true` if the property is readable, `false` otherwise
  See Also:
    SciProperty

### isPropertyWritable

    public boolean isPropertyWritable(int property)

  Checks whether the property is writable for this element.
  Parameters:
    property - The integer value which represents a kind of a property. See `SciProperty` interface for a predefined kinds of properties.
  Returns: `true` if the property is writable, `false` otherwise
  See Also:
    SciProperty

### setName

    public void setName(String name)

  Sets the name for this element.
  Parameters:
    name - the string which needs to be assigned as a name to this element

### setProperty

    public void setProperty(int property, boolean value)

  Sets the value for the property.
  Parameters:
    property - The integer value which represents a kind of a property. See `SciProperty` interface for a predefined kinds of properties.
    value - the boolean value for the property

    For example, if you have `SciOperation` representing a public operation and you would like to make it private: ``

         if (someSciOperation.canSetProperty(SciProperty.PRIVATE, true)){
           someSciOperation.setProperty(SciProperty.PRIVATE, true); //do it
         }

  See Also:
    SciProperty

### visitReferences

    public void visitReferences(SciReferenceVisitor visitor)

  In this element, makes a specified visitor perform certain actions upon all references.
  Parameters:
    visitor - the `SciReferenceVisitor` which will perform certain actions upon all references in this element
  See Also:
    SciReferenceVisitor

### visitReferences

    public void visitReferences(SciReferenceVisitor visitor, SciElement referencedElement)

  In this element, makes a specified visitor perform certain actions upon all references to the specified element.
  Parameters:
    visitor - the `SciReferenceVisitor` which will perform certain actions upon all references to the specified element
    referencedElement - the `SciElement`, references to which are subject for the actions
  See Also:
    SciReferenceVisitor

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