Class Script

    • Constructor Detail

      • Script

        Script()
        Constructor for serializer.
      • Script

        public Script​(java.lang.String name)
        Constructor for a script without parent, parameters or advices and with the default type registry.
        Parameters:
        name - Name of the project.
      • Script

        public Script​(java.lang.String name,
                      TypeRegistry registry)
        Constructor for a script without parent, parameters or advices.
        Parameters:
        name - Name of the project.
        registry - the responsible registry
      • Script

        public Script​(java.lang.String name,
                      VariableDeclaration[] parameters)
        Constructor for a script with parameters and default type registry.
        Parameters:
        name - Name of the project.
        parameters - the formal parameters of this script
      • Script

        public Script​(java.lang.String name,
                      VariableDeclaration[] parameters,
                      TypeRegistry registry)
        Constructor for a script with parameters.
        Parameters:
        name - Name of the project.
        parameters - the formal parameters of this script
        registry - the responsible registry
      • Script

        public Script​(java.lang.String name,
                      ModelImport<Script> parent,
                      Script.ScriptDescriptor<Script> descriptor,
                      TypeRegistry registry)
        Constructor for a script.
        Parameters:
        name - Name of the project.
        parent - the super script to inherit from (as a script import, may be null, shall be member of imports or also null)
        descriptor - the descriptor carrying parameters, advices and imports (may be null)
        registry - the responsible type registry
    • Method Detail

      • adjustParents

        private void adjustParents()
        Adjusts the parents of contained elements.
      • createDefaultParameter

        public static VariableDeclaration[] createDefaultParameter()
        Creates the default parameter for a VIL script.
        Returns:
        the default parameter
      • addLoadProperties

        public void addLoadProperties​(LoadProperties propFile)
        Add a properties file to this project.
        Parameters:
        propFile - The properties to be added.
      • addRule

        public void addRule​(AbstractRule rule)
        Adds a rule instance.
        Parameters:
        rule - the rule instance
      • removeRule

        public void removeRule​(Rule rule)
        Removes a rule instance.
        Parameters:
        rule - the rule instance
      • getName

        public java.lang.String getName()
        Get the name of this project.
        Specified by:
        getName in interface IMetaType
        Specified by:
        getName in interface IModel
        Specified by:
        getName in interface IModelData
        Returns:
        The name of this project.
      • getQualifiedName

        public java.lang.String getQualifiedName()
        Description copied from interface: IMetaType
        Returns the qualified name of this type.
        Specified by:
        getQualifiedName in interface IMetaType
        Returns:
        the qualified name
      • getVersion

        public Version getVersion()
        Get the version of this project.
        Specified by:
        getVersion in interface IModel
        Specified by:
        getVersion in interface IModelData
        Returns:
        The version of this project or null if no version is defined for this project.
      • setVersion

        public void setVersion​(Version version)
        Description copied from interface: IModel
        Changes the version of this model.
        Specified by:
        setVersion in interface IModel
        Parameters:
        version - Version to set
      • getRuleCount

        public int getRuleCount()
        Get the number of rules in this project.
        Returns:
        The number of rules in this project.
      • getRule

        public AbstractRule getRule​(int index)
        Get the rule in this project at the specified index.
        Parameters:
        index - The 0-based index of the rule to be returned.
        Returns:
        The rule at the given index.
      • indexOf

        public int indexOf​(Rule rule)
        Returns the index of the specified rule.
        Parameters:
        rule - the rule to search for
        Returns:
        -1 if rule was not found, , the index of rule else
      • getVariableDeclaration

        public VariableDeclaration getVariableDeclaration​(java.lang.String name)
        Returns the variable declaration with the specified name.
        Parameters:
        name - the name of the variable declaration
        Returns:
        the matching variable declaration, null else
      • getPropertiesCount

        public int getPropertiesCount()
        Get the number of properties to be loaded for this project.
        Returns:
        The number of properties to be loaded for this project.
      • getProperties

        public LoadProperties getProperties​(int index)
        Get the properties file of this project at the specified index.
        Parameters:
        index - The 0-based index of the properties file to be returned.
        Returns:
        The properties file at the given index.
      • accept

        public java.lang.Object accept​(IVisitor visitor)
                                throws VilException
        Description copied from interface: IBuildlangElement
        Accepts the visitor for visiting.
        Specified by:
        accept in interface IBuildlangElement
        Parameters:
        visitor - the visitor to be used
        Returns:
        the result of visiting this instance (may be null)
        Throws:
        VilException - in case that visiting fails (e.g., execution)
      • getOperationsCount

        public int getOperationsCount()
        Description copied from interface: IMetaType
        Returns the number of operations provided by this type.
        Specified by:
        getOperationsCount in interface IMetaType
        Returns:
        the number of operations
      • getOperation

        public IMetaOperation getOperation​(int index)
        Description copied from interface: IMetaType
        Returns the specified operation.
        Specified by:
        getOperation in interface IMetaType
        Parameters:
        index - the 0-based index of the operation to be returned
        Returns:
        the specified operation
      • isAssignableFrom

        public boolean isAssignableFrom​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type is the same or a super class of type.
        Specified by:
        isAssignableFrom in interface IMetaType
        Parameters:
        type - the descriptor to be tested
        Returns:
        true if both types are assignment compatible, false else
      • findConversion

        public IMetaOperation findConversion​(IMetaType sourceType,
                                             IMetaType targetType)
        Description copied from interface: IMetaType
        Returns the conversion operation from this type to target type (if there is any).
        Specified by:
        findConversion in interface IMetaType
        Parameters:
        sourceType - the source type to convert from
        targetType - the target type to convert to
        Returns:
        the conversion operation as defined in the underlying implementation class, null if no matching can be found
      • getSuper

        public ModelImport<Script> getSuper()
        Description copied from interface: IModel
        Returns the reference to the super model (if it exists).
        Specified by:
        getSuper in interface IModel
        Returns:
        the super model (in terms of a model import/reference, may be null)
      • getIndentationConfiguration

        public IndentationConfiguration getIndentationConfiguration()
        Description copied from interface: IModel
        Returns the indentation configuration for this model. The indentation configuration is considered to be immutable.
        Specified by:
        getIndentationConfiguration in interface IModel
        Returns:
        the indentation configuration (disabled if null)
      • determineStartRule

        public AbstractRule determineStartRule​(java.lang.String startRuleName)
                                        throws VilException
        Determines the start rule for script involving imported scripts.
        Parameters:
        startRuleName - the start rule name (typically "main")
        Returns:
        the start rule
        Throws:
        VilException - in case that the start rule cannot be determined (uniquely)
      • collectRoots

        private void collectRoots​(java.util.Set<Script> processed,
                                  java.util.Set<java.lang.String> knownSignatures,
                                  java.util.List<AbstractRule> roots)
        Finds the root rules.
        Parameters:
        processed - already processed scripts (to be modified as a side effect)
        knownSignatures - the known signatures of already included rules (to be modified as a side effect)
        roots - the actual root rules (to be modified as a side effect)
      • getContainingFolder

        java.io.File getContainingFolder()
        Returns the folder containing the physical model file.
        Returns:
        the folder or null if this cannot be accessed
      • getMainRule

        public AbstractRule getMainRule​(boolean createIfAbsent)
        Returns the default main rule of this script, i.e., a rule with name DEFAULT_START_RULE_NAME complying to the parameters of this script.
        Parameters:
        createIfAbsent - if true create the rule if it does not exist, false just return null if the rule does not exist
        Returns:
        the main rule or null
      • getMainRule

        public AbstractRule getMainRule​(java.lang.String name,
                                        boolean createIfAbsent)
        Returns the main rule of this script, i.e., a rule with name complying to the parameters of this script.
        Parameters:
        createIfAbsent - if true create the rule if it does not exist, false just return null if the rule does not exist
        name - the name of the rule
        Returns:
        the main rule or null
      • isBasicType

        public boolean isBasicType()
        Description copied from interface: IMetaType
        Returns whether this instance represents a basic type.
        Specified by:
        isBasicType in interface IMetaType
        Returns:
        true if this instance represents a basic type, false else
      • enableDynamicDispatch

        public boolean enableDynamicDispatch()
        Description copied from interface: IMetaType
        Returns whether this type enables dynamic dispatch of operations.
        Specified by:
        enableDynamicDispatch in interface IMetaType
        Returns:
        true if it enables dynamic dispatch, false else
      • getVtlRestrictionsCount

        public int getVtlRestrictionsCount()
        Returns the number of VTL restrictions.
        Returns:
        the number of VTL restrictions
      • getVtlRestriction

        public ModelImport<Template> getVtlRestriction​(int index)
        Returns the specified VTL restriction.
        Parameters:
        index - the 0-based index of the VTL restriction
        Returns:
        the specified model import
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >=getVtlRestrictionsCount()
      • isPlaceholder

        public boolean isPlaceholder()
        Description copied from interface: IMetaType
        Returns whether this type is valid or whether it is a placeholder type in case that the original type cannot be resolved but the script shall remain executable.
        Specified by:
        isPlaceholder in interface IMetaType
        Returns:
        true if this type is a placeholder, false else
      • addPlaceholderOperation

        public IMetaOperation addPlaceholderOperation​(java.lang.String name,
                                                      int parameterCount,
                                                      boolean acceptsNamedParameters)
        Description copied from interface: IMetaType
        Adds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.
        Specified by:
        addPlaceholderOperation in interface IMetaType
        Parameters:
        name - the name of the operation
        parameterCount - the number of parameters of the operation
        acceptsNamedParameters - whether the operation shall accept named parameters
        Returns:
        the added operation, null if this type is not a placeholder
      • isActualTypeOf

        public boolean isActualTypeOf​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type can act as an actual type of type.
        Specified by:
        isActualTypeOf in interface IMetaType
        Parameters:
        type - the type to be checked
        Returns:
        true if this type can act as an actual type of type, false else
        See Also:
        IActualTypeProvider
      • getRestrictionEvaluationContext

        public IRestrictionEvaluationContext getRestrictionEvaluationContext()
        Description copied from interface: IModel
        Returns the context for evaluating import / conflict restrictions. This context shall only contain the information that is necessary to evaluate restriction information.
        Specified by:
        getRestrictionEvaluationContext in interface IModel
        Returns:
        the evaluation context
      • getBaseType

        public IMetaType getBaseType()
        Description copied from interface: IMetaType
        Returns the base type (in case of IVML derived types).
        Specified by:
        getBaseType in interface IMetaType
        Returns:
        the base type or null
      • getFieldCount

        public int getFieldCount()
        Description copied from interface: IMetaType
        Returns the number of fields provided by this type.
        Specified by:
        getFieldCount in interface IMetaType
        Returns:
        the number of fields
      • getField

        public IMetaField getField​(int index)
        Description copied from interface: IMetaType
        Returns the specified field.
        Specified by:
        getField in interface IMetaType
        Parameters:
        index - the 0-based index of the field to be returned
        Returns:
        the specified field
      • isInternal

        public boolean isInternal()
        Description copied from interface: IMetaType
        Returns whether this type is internal and shall not be visible to the user.
        Specified by:
        isInternal in interface IMetaType
        Returns:
        true if this type is internal, false else
      • getSuperType

        public IMetaType getSuperType()
        Description copied from interface: IMetaType
        Returns the type this type is refined from.
        Specified by:
        getSuperType in interface IMetaType
        Returns:
        the super type or null if there is none
      • getGenericParameterCount

        public int getGenericParameterCount()
        Description copied from interface: IMetaType
        Returns the number of generic type parameters.
        Specified by:
        getGenericParameterCount in interface IMetaType
        Returns:
        the number of generic type parameters
      • getGenericParameterType

        public TypeDescriptor<?> getGenericParameterType​(int index)
        Description copied from interface: IMetaType
        Returns the specified generic parameter type.
        Specified by:
        getGenericParameterType in interface IMetaType
        Parameters:
        index - the index of the parameter type to return
        Returns:
        the specified parameter type
      • checkConversion

        public boolean checkConversion​(IMetaType param,
                                       IMetaOperation conversion)
        Description copied from interface: IMetaType
        Checks a conversion from this type to param via the given conversion.
        Specified by:
        checkConversion in interface IMetaType
        Parameters:
        param - the original parameter value
        conversion - the conversion function
        Returns:
        true if ok, false else
      • getCandidates

        public java.util.List<IMetaOperation> getCandidates​(java.lang.String name,
                                                            int unnamedArgsCount)
        Description copied from interface: IMetaType
        Returns operation candidates matching the given name and number of unnamed (required) arguments.
        Specified by:
        getCandidates in interface IMetaType
        Parameters:
        name - the name of the operation
        unnamedArgsCount - the number of unnamed arguments
        Returns:
        the operation candidates
      • getLanguageName

        public java.lang.String getLanguageName()
        Returns the name of the language represented.
        Returns:
        the name of the language