com.togethersoft.openapi.sci
Interface SciFactory


public interface SciFactory

A creator of new source code parts of the model with default contents/properties.


Automatically set properties for created objects
are dictated by the language standards and common sense (for example, attributes are made private).


After creation (see example), a newly created element can be pasted into SciContainer using the
paste method.


An instance of SciFactory for a specific language can be obtained using
SciModel.getFactory(String lagnuage) method.


There is a similar interface called SciGenericFactory
which also creates new source code parts of the model,
but it creates them based on the string with the text of the member you want to create.

Author:
TogetherSoft
Since: Together 3.0
See Also: SciModel.getFactory(java.lang.String), SciGenericFactory

Method Summary
 SciAttributenewAttribute()
          Creates a new SciAttribute with a set of default properties (private, int).
 SciClassnewClass()
          Creates a new SciClass with a set of default properties.
 SciCodeBlocknewCodeBlock()
          Creates a new empty SciCodeBlock.
 SciFilenewFile()
          Creates a new empty SciFile with a set of default properties.
 SciInheritancenewInheritance()
          Creates a new SciInheritance.
 SciJavaImportnewJavaImport()
          Creates a new SciJavaImport.
 SciMemberDefinitionnewMemberDefinition(SciMember sciMember)
          Creates a new SciMemberDefinition for a given SciMember.
 SciOperationnewOperation()
          Creates a new SciOperation with a set of default properties (public, void, no parameters).
 SciPackagenewPackage()
          Creates a new SciPackage.
 SciParameternewParameter()
          Creates a new SciParameter with a set of default properties.
 SciTagnewTag()
          Creates a new SciTag.
 SciThrowSpecifiernewThrowSpecifier()
          Creates a new SciThrowSpecifier.

Method Detail

newAttribute

public SciAttribute newAttribute()
Creates a new SciAttribute with a set of default properties (private, int). For example:

SciAttribute newAttribute = SciModelAccess.getModel().getFactory(SciLanguage.JAVA).newAttribute(); //creating a new attribute with default name and type
newAttribute.setName("myLastName"); //setting the name
newAttribute.getType().setText("String"); //setting the type
newAttribute.setProperty(SciProperty.PUBLIC, true); //setting the public modifier
someSciClass.paste(newAttribute, null, false); //pasting it into someSciClass

This code will create a new attribute "public String myLastName" and insert it into someSciClass
Returns: a new SciAttribute with a set of default properties
See Also:
SciGenericFactory.newMember(java.lang.String,com.togethersoft.openapi.sci.SciClass), newOperation()

newClass

public SciClass newClass()
Creates a new SciClass with a set of default properties.
Returns: a new SciClass with a set of default properties
See Also:
SciGenericFactory.newClass(java.lang.String), newOperation(), newAttribute()

newCodeBlock

public SciCodeBlock newCodeBlock()
Creates a new empty SciCodeBlock.
Returns: a new empty SciCodeBlock
See Also:
SciFunction.setBody(com.togethersoft.openapi.sci.SciCodeBlock)

newFile

public SciFile newFile()
Creates a new empty SciFile with a set of default properties.

SciFile f = SciModelAccess.getModel().getFactory(SciLanguage.JAVA).newFile();
f.setName("R.java"); //setting the name
someSciPackage.paste(f,null,false);
Returns: a new SciFile with a set of default properties
See Also:
SciGenericFactory.newFile(java.lang.String)

newInheritance

public SciInheritance newInheritance()
Creates a new SciInheritance.
Returns: a new SciInheritance

newJavaImport

public SciJavaImport newJavaImport()
Creates a new SciJavaImport. For Java language only.
Returns: a new SciJavaImport

newMemberDefinition

public SciMemberDefinition newMemberDefinition(SciMember sciMember)
Creates a new SciMemberDefinition for a given SciMember. For C++ language only.
Returns: a new SciMemberDefinition

newOperation

public SciOperation newOperation()
Creates a new SciOperation with a set of default properties (public, void, no parameters).

SciOperation newOperation = SciModelAccess.getModel().getFactory(SciLanguage.JAVA).newOperation(); //creating a new operation with default name, parameters and return type
newOperation.setName("getSalary"); //setting the name
newOperation.getReturnType().setText("int"); //setting the return type
newOperation.getParameterList().setText("String lastName, int year"); //setting the parameters
newOperation.setProperty(SciProperty.PROTECTED, true); //setting the protected modifier
someSciClass.paste(newOperation, null, false); //pasting it into someSciClass

This code will create a new operation

protected int getSalary(String lastName, int year){}

and insert into someSciClass.
The body for the operation can be created and set using the methods newCodeBlock,
SciGenericFactory.newCodeBlock and
SciFunction.setBody methods respectively.
Returns: a new SciOperation with a set of default properties
See Also:
SciGenericFactory.newMember(java.lang.String,com.togethersoft.openapi.sci.SciClass), newAttribute()

newPackage

public SciPackage newPackage()
Creates a new SciPackage.
Returns: the newly created package

newParameter

public SciParameter newParameter()
Creates a new SciParameter with a set of default properties.
Returns: a new SciParameter with a set of default properties
See Also:
SciGenericFactory.newParameter(java.lang.String)

newTag

public SciTag newTag()
Creates a new SciTag.
Returns: a new SciTag
See Also:
SciTagList.setTagValue(java.lang.String,java.lang.String)

newThrowSpecifier

public SciThrowSpecifier newThrowSpecifier()
Creates a new SciThrowSpecifier.
Returns: a new SciThrowSpecifier