Class JrpcgenEnum

All Implemented Interfaces:
JrpcgenItem, JrpcgenTypeMapping

public class JrpcgenEnum extends JrpcgenComplexType
The JrpcgenEnum class represents a single enumeration from an rpcgen "x"-file. It is a "container" for the elements (constants) belonging to this enumeration.
Version:
$Revision: 1.1 $ $Date: 2003/08/13 12:03:45 $ $State: Exp $ $Locker: $
Author:
Harald Albrecht
  • Constructor Details

    • JrpcgenEnum

      public JrpcgenEnum(JrpcgenContext context, String identifier, JrpcgenConst.Table elements)
      Constructs a JrpcgenEnum and sets the identifier and all its enumeration elements.
      Parameters:
      context - The context the new enumeration belongs to.
      identifier - Identifier to be declared.
      enums - Vector of enumeration elements of class JrpcgenConst.
  • Method Details

    • getElements

      public final JrpcgenConst.Table getElements()
    • generateJavaFile

      public void generateJavaFile()
      Description copied from class: JrpcgenComplexType
      Concrete implementations are asked to generate a Java file containing an implementation of the Java class mapping the complex type.
      Specified by:
      generateJavaFile in class JrpcgenComplexType
    • writeXdrVectorCodingMethods

      public void writeXdrVectorCodingMethods(JrpcgenJavaFile javaFile, JrpcgenContext context)
      Description copied from class: JrpcgenComplexType
      Writes static encoding and decoding methods for fixed and dynamic vectors of the mapping to the passed Java file. A call to this method is intended during the generation of the class file of the mapping type.

      However, the static encoding and decoding methods for fixed and dynamic vectors of the mapping type will be written only if they are required as a result of the foregoing parsing process. During the parsing phase vector uses of the mapping type are recognized and stored in maps for types in fixed and dynamic vector uses, respectively. The rules of generation are as follows:

      • Nothing will be written, if the mapping type is neither listed in the map of types in fixed vector use nor listed in the map of the types in dynamic vector use.
      • The static encoding and decoding methods for dynamic vectors of the mapping type will be written, if the mapping type is used at least in one of the both fixed or dynamic vectors.
      • The static encoding methods for fixed and dynamic vectors of the mapping type will be written, if the mapping type is used at least in a fixed vector.
      Overrides:
      writeXdrVectorCodingMethods in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the static methods are going to be placed.
      context - The context of the current jrpcgen run.
    • getJavaName

      public String getJavaName()
      Description copied from class: JrpcgenComplexType
      The Java name is equal to the definition name and therefore equal to the identifier of the complex type.
      Specified by:
      getJavaName in interface JrpcgenTypeMapping
      Overrides:
      getJavaName in class JrpcgenComplexType
      Returns:
      The identifier of the complex type.
    • getJavaClass

      public String getJavaClass()
      Description copied from class: JrpcgenComplexType
      The complex type is mapped by a Java class. The name of the class is equal to teh definition name of the complex type and therefore equal to the identifier of the complex type.
      Specified by:
      getJavaClass in interface JrpcgenTypeMapping
      Overrides:
      getJavaClass in class JrpcgenComplexType
      Returns:
      The identifier of the complex type.
    • getXdrClass

      public String getXdrClass()
      Description copied from class: JrpcgenComplexType
      The Java class mapping the complex type usually implements the interface
      invalid reference
      XdrAble
      . Therefore the name of the XDR class is equal to the definition name and the identifier of the complex type, respectively.
      Specified by:
      getXdrClass in interface JrpcgenTypeMapping
      Overrides:
      getXdrClass in class JrpcgenComplexType
      Returns:
      The identifier of the complex type.
    • writeXdrConstructorCall

      public void writeXdrConstructorCall(JrpcgenJavaFile javaFile, String constructorParameter)
      Description copied from class: JrpcgenComplexType
      Writes a default constructor call or a constructor call with one parameter with the XDR class provided by this mapping. Passing null as value of the parameter parameter will result in a default constructor call written to the passed Java file. Otherwise the value of the parameter parameter will be written as parameter to the constuctor call.
      Specified by:
      writeXdrConstructorCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrConstructorCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the constructor call is going to be placed.
      constructorParameter - null to generate a default constructor call, a parameter name to generate a constructor call with one parameter.
    • writeJavaToXdr

      public void writeJavaToXdr(JrpcgenJavaFile javaFile, String variable)
      Description copied from class: JrpcgenComplexType
      At this level of a complex type the passed variable represents both the Java as well as the XDR representation and will be written as is to the passed Java file. No conversion will take place.
      Specified by:
      writeJavaToXdr in interface JrpcgenTypeMapping
      Overrides:
      writeJavaToXdr in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the variable is going to be placed.
      variable - The name of a variable in Java representation.
    • writeJavaToXdr

      public void writeJavaToXdr(JrpcgenJavaFile javaFile, JrpcgenJavaFile.Expression expression)
      Description copied from class: JrpcgenComplexType
      Wirtes the passed expression to the passed Java file. At this level of a complex type no conversion takes place and therefore the passed expression will be written as is. The expression is expected to result in a value of the mapped type.
      Specified by:
      writeJavaToXdr in interface JrpcgenTypeMapping
      Overrides:
      writeJavaToXdr in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the passed expression is going to be placed.
      expression - An expression to be called with the passed Java file.
    • writeXdrToJava

      public void writeXdrToJava(JrpcgenJavaFile javaFile, String result)
      Description copied from class: JrpcgenComplexType
      At this level of a complex type the passed variable represents both the Java as well as the XDR representation and will be written as is to the passed Java file. No conversion will take place.
      Specified by:
      writeXdrToJava in interface JrpcgenTypeMapping
      Overrides:
      writeXdrToJava in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the result is going to be placed.
      result - The name of a variable in XDR representation.
    • writeXdrEncodingCall

      public void writeXdrEncodingCall(JrpcgenJavaFile javaFile, String xdrStream, String variable)
      Description copied from class: JrpcgenComplexType
      Writes an XDR encoding call on the passed variable with the passed name of an XDR encoding stream to the passed Java file. At this level of complex types the mapping type implements the interface
      invalid reference
      XdrAble
      and therefore the XDR encoding call will be similar to variable.xdrEncode(xdrStream).
      Specified by:
      writeXdrEncodingCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrEncodingCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the XDR encoding call is going to be placed.
      xdrStream - The name of the XDR encoding stream instance to be used in the statement.
      variable - The name of the variable to be used in the statement.
    • writeXdrFixedVectorEncodingCall

      public void writeXdrFixedVectorEncodingCall(JrpcgenJavaFile javaFile, String xdrStream, String variable, String size)
      Description copied from class: JrpcgenComplexType
      Writes an XDR encoding call for a fixed vector of the mapping type to the passed Java file. The passed name of an XDR encoding stream, the passed name of the vector variable and the passed size string indicating the size of the fixed vector are used to form the XDR encoding call. This method expects the existence of the static method xdrEncodeFixedVector(XdrEncodingStream, MappingType, int) in the generated code of the mapping type MappingType as done by a call to the method JrpcgenComplexType.writeXdrVectorCodingMethods(JrpcgenJavaFile, JrpcgenContext) within the implementation of the method JrpcgenComplexType.generateJavaFile(). Thereby MappingType is a placeholder for the name of concrete mapping type at this point.
      Specified by:
      writeXdrFixedVectorEncodingCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrFixedVectorEncodingCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the XDR encoding call is going to be placed.
      xdrStream - The name of the XDR encoding instance to be used in the statement.
      variable - The name of the variable to be used in the statement.
      size - A string specifying the size of the fixed vector.
    • writeXdrDynamicVectorEncodingCall

      public void writeXdrDynamicVectorEncodingCall(JrpcgenJavaFile javaFile, String xdrStream, String variable)
      Description copied from class: JrpcgenComplexType
      Writes an XDR encoding call for a dynamic vector of the mapping type to the passed Java file. The passed name of an XDR encoding stream and the passed name of the vector variable are used to form the XDR encoding call. This method expects the existence of the static method xdrEncodeDynamicVector(XdrEncodingStream, MappingType) in the generated code of the mapping type as done by a call to the method
      invalid reference
      #wirteXdrVectorCodingMethods(JrpcgenJavaFile, JrpcgenContext)
      within the implementation of the method JrpcgenComplexType.generateJavaFile(). Thereby MappingType is a placeholder for the name of the concrete mapping type at this point.
      Specified by:
      writeXdrDynamicVectorEncodingCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrDynamicVectorEncodingCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the XDR encoding call is going to be placed.
      xdrStream - The name of the XDR encoding instance to be used in the statement.
      variable - The name of the variable to be used in the statement.
    • writeXdrDecodingCall

      public void writeXdrDecodingCall(JrpcgenJavaFile javaFile, String xdrStream)
      Description copied from class: JrpcgenComplexType
      Writes an XDR encoding call on the result of the passed expression with the passed name of an XDR decoding stream to the passed Java file. At this level of complex types the mapping type implements the interface
      invalid reference
      XdrAble
      and therefore the XDR decoding call will be similar to an constructor call with the name of the XDR decoding stream as parameter.
      Specified by:
      writeXdrDecodingCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrDecodingCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the XDR decoding call is going to be placed.
      xdrStream - The name of the XDR decoding stream instance to be used in the statement.
    • writeXdrFixedVectorDecodingCall

      public void writeXdrFixedVectorDecodingCall(JrpcgenJavaFile javaFile, String xdrStream, String size)
      Description copied from class: JrpcgenComplexType
      Writes an XDR decoding call for a fixed vector of the mapping type to the passed Java file. The passed name of an XDR decoding stream and the passed size string indicating the size of fixed vector are used to form the XDR decoding call. This method expects the existence of the static method xdrDecodeFixedVector(XdrDecodingStream, int) within the implementation of the generated code of the mapping type MappingType as done by a call to the method JrpcgenComplexType.writeXdrVectorCodingMethods(JrpcgenJavaFile, JrpcgenContext) within the implementation of the method JrpcgenComplexType.generateJavaFile(). Thereby MappingType is a placeholder for the name of the concrete mapping type at this point.
      Specified by:
      writeXdrFixedVectorDecodingCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrFixedVectorDecodingCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the XDR decoding call is going to be placed.
      xdrStream - The name of the XDR decoding stream instance to be used in the statement.
      size - A string specifying the size of the fixed vector.
    • writeXdrDynamicVectorDecodingCall

      public void writeXdrDynamicVectorDecodingCall(JrpcgenJavaFile javaFile, String xdrStream)
      Description copied from class: JrpcgenComplexType
      Writes an XDR decoding call for a dynamic vector of the mapping type to the passed Java file. The passed name of an XDR decoding stream is used to to form the XDR decoding call. This method expects the existence of the static method xdrDecodeDynamicVector(XdrDecodingStream) in the generated code of the mapping type as done by a call to method JrpcgenComplexType.writeXdrVectorCodingMethods(JrpcgenJavaFile, JrpcgenContext) within the implementation of the method JrpcgenComplexType.generateJavaFile().
      Specified by:
      writeXdrDynamicVectorDecodingCall in interface JrpcgenTypeMapping
      Overrides:
      writeXdrDynamicVectorDecodingCall in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the XDR decoding call is going to be placed.
      xdrStream - The name of the XDR decoding stream instance to be used in the statement.
    • writeEqualsExpression

      public void writeEqualsExpression(JrpcgenJavaFile javaFile, String variableLeft, String variableRight, boolean negate)
      Description copied from class: JrpcgenComplexType
      Writes an equals expression to the passed Java file using the passed names of the left hand side and the right hand side variable. The negate parameter controls whether the statement evaluates to true on equality or on inequality. At this level of complex types the generated code will be similar to
       java.utils.Objects.equals(variableLeft, variableRight)
       
      for negate=false and
       ! java.utils.Objects.equals(variableLeft, variableRight)
       
      for negate=true.
      Specified by:
      writeEqualsExpression in interface JrpcgenTypeMapping
      Overrides:
      writeEqualsExpression in class JrpcgenComplexType
      Parameters:
      javaFile - The Java file, where the equality expression is going to be placed.
      variableLeft - The name of the variable to be used as the left hand side in the statement.
      variableRight - The name of the variable to be used as the right hand side in the statement.
      negate - false to let the resulting statement return true on equality, true to let the resulting statement return true on inequality.
    • toString

      public String toString()
      Returns the fully qualified identifier. return fully qualified identifier.
      Overrides:
      toString in class Object
    • dump

      public void dump()
      Dumps the enumeration together with its elements to System.out.
    • dump

      public <T extends Appendable> T dump(T appendable)