Class TypeConversion


public final class TypeConversion extends Expression

Type Conversion.

Link to GitHub: Source File.

  • Field Details

    • expression

      public Expression expression
      The expression.
  • Constructor Details

    • TypeConversion

      public TypeConversion(Type type, Expression expression)
      Create a new TypeConversion.
      Parameters:
      type - the new type
      expression - the expression
    • TypeConversion

      private TypeConversion()
      Default constructor used by Attribute File I/O
  • Method Details

    • mayBeConvert

      public static String mayBeConvert(Type fromType, Type toType, String expr)
      Java Coding utility: Test if a TypeConversion is necessary and then create it.
      Parameters:
      fromType - convert from this type
      toType - convert to this type
      expr - the expression
      Returns:
      piece of Java source code
    • buildMayBeConvert

      public static void buildMayBeConvert(Type fromType, Type toType, CodeBuilder codeBuilder)
      ClassFile coding utility: Test if a TypeConversion is necessary and then create it.
      Parameters:
      fromType - convert from this type
      toType - convert to this type
      codeBuilder - the codeBuilder to use.
    • testAndCreate

      public static Expression testAndCreate(Type toType, Expression expression)
      Java Coding utility: Test if a TypeConversion is necessary and then create it.
      Parameters:
      toType - convert to toType
      expression - the expression
      Returns:
      the resulting expression
    • testCastNeccessary

      private static boolean testCastNeccessary(Type toType, Expression expression)
      Java coding utility: Test if a Type Cast is necessary.
      Parameters:
      toType - the desired type
      expression - the expression
      Returns:
      piece of Java source code
    • getWriteableVariable

      public VariableExpression getWriteableVariable()
      Description copied from class: Expression

      Get a writeable variable.

      This method is redefined in Variable, RemoteVariable and TypeConversion.

      Overrides:
      getWriteableVariable in class Expression
      Returns:
      a writeable variable or null
    • doChecking

      public void doChecking()
      Description copied from class: SyntaxClass

      Perform semantic checking.

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • maybeStatement

      public boolean maybeStatement()
      Description copied from class: Expression
      Returns true if this expression may be used as a statement.
      Specified by:
      maybeStatement in class Expression
      Returns:
      true if this expression may be used as a statement
    • toJavaCode

      public String toJavaCode()
      Description copied from class: SyntaxClass
      Generate Java code for this Syntax Class.
      Overrides:
      toJavaCode in class SyntaxClass
      Returns:
      Java code
    • buildEvaluation

      public void buildEvaluation(Expression rightPart, CodeBuilder codeBuilder)
      Description copied from class: Expression
      ClassFile coding utility: Build Evaluation Code.
      Specified by:
      buildEvaluation in class Expression
      Parameters:
      rightPart - expression
      codeBuilder - the codeBuilder used.
    • toString

      public String toString()
      Overrides:
      toString in class Expression
    • writeObject

      public void writeObject(AttributeOutputStream oupt) throws IOException
      Description copied from class: SyntaxClass
      Write a SyntaxClass object to a AttributeOutputStream.
      Overrides:
      writeObject in class SyntaxClass
      Parameters:
      oupt - the AttributeOutputStream to write to.
      Throws:
      IOException - if something went wrong.
    • readObject

      public static TypeConversion readObject(AttributeInputStream inpt) throws IOException
      Read and return a TypeConversion object.
      Parameters:
      inpt - the AttributeInputStream to read from
      Returns:
      the TypeConversion object read from the stream.
      Throws:
      IOException - if something went wrong.