Class BaseUnit

    • Constructor Detail

      • BaseUnit

        public BaseUnit​(NamedObj container,
                        java.lang.String name)
                 throws IllegalActionException,
                        NameDuplicationException
        Construct a base unit with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.
        Parameters:
        container - The container.
        name - The name of this attribute.
        Throws:
        IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
        NameDuplicationException - If the name coincides with an attribute already in the container.
    • Method Detail

      • getToken

        public Token getToken()
                       throws IllegalActionException
        Get the token contained by this base unit. The token contains the unit information specified by the unit category property. Calling this method will trigger evaluation of the expression, if the value has been given by setExpression(). Notice the evaluation of the expression can trigger an exception if the expression is not valid, or if the result of the expression violates type constraints specified by setTypeEquals() or setTypeAtMost(), or if the result of the expression is null and there are other variables that depend on this one. The returned value will be null if neither an expression nor a token has been set, or either has been set to null.
        Overrides:
        getToken in class Variable
        Returns:
        The token contained by this variable converted to the type of this variable, or null if there is none.
        Throws:
        IllegalActionException - If the expression cannot be parsed or cannot be evaluated, or if the result of evaluation violates type constraints, or if the result of evaluation is null and there are variables that depend on this one.
        See Also:
        Variable.setToken(String), Variable.setToken(ptolemy.data.Token)