Class RemoteMethodInfo


  • public class RemoteMethodInfo
    extends java.lang.Object
    Holds information gathered by the Analyze annotation.

    The AnalyzeProcessor creates an info file in an apt run and wurblets pick up this information to generate code.

    Author:
    harald
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String INFO_FILE_EXTENSION
      all remote method info files end with .remote
      static java.lang.String INFO_FILE_VERSION
      Fileformat version
      static java.lang.String TYPE_CLASS
      Information type for a class.
      static java.lang.String TYPE_METHOD
      Information type for a method.
    • Constructor Summary

      Constructors 
      Constructor Description
      RemoteMethodInfo​(java.lang.String type)
      Creates an RemoteMethodInfo for a given type.
      RemoteMethodInfo​(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.element.ExecutableElement methodElement)
      Creates an RemoteMethodInfo from a method element.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addParameter​(RemoteMethodInfoParameter parameter)
      Adds a formal parameter
      java.lang.String cleanTypeString​(java.lang.String type)
      Simplifies some classnames by removing package names.
      Makes generated code better readable.
      java.lang.String getClassName()
      Gets the name of the class this analyze info is part of.
      java.lang.String getGenericReturnType()
      Gets the generic return type.
      java.lang.String getMethodName()
      Gets the method name the annotation belongs to.
      javax.lang.model.element.Modifier[] getModifiers()
      Gets the modifiers for the method
      java.lang.String getModifiersAsString()
      Gets the method's modifiers as a string
      java.lang.String getNameCollection()
      Gets the classname for a collection.
      java.lang.String getNameContext()
      Gets the classname for a domain context.
      java.lang.String getNameCursor()
      Gets the classname for a cursor.
      java.lang.String getNameDbObject()
      Gets the classname for a simple db object.
      java.lang.String getNamePdo()
      Gets the classname for a PDO.
      java.lang.String getNameSession()
      Gets the classname for a session.
      RemoteMethodInfoParameter[] getParameters()
      Gets the formal parameters of the method.
      java.lang.String getReturnType()
      Gets the return type of the method
      java.lang.String getSuperClassName()
      Gets the name of the superclass this analyze info is part of.
      java.lang.String getType()
      Gets the type of this analyze info.
      boolean isModifierSet​(javax.lang.model.element.Modifier modifier)
      Checks whether given modifier is set for the method
      boolean isReturningCursor()
      Checks whether the method is returning a cursor.
      boolean isReturningDbObject()
      Checks whether the method is returning a low-level db object.
      boolean isReturningDbObjectCollection()
      Checks whether the method is returning a collection of low-level db objects.
      boolean isReturningPdo()
      Checks whether the method is returning a PDO.
      boolean isReturningPdoCollection()
      Checks whether the method is returning a collection of PDOs.
      boolean isReturningPdoCursor()  
      boolean isVarArgsMethod()
      Returns whether the method has varargs.
      static RemoteMethodInfo readInfo​(java.io.File infoFile)
      Reads info from an file.
      static RemoteMethodInfo readInfo​(java.io.LineNumberReader reader)
      Reads info from an line reader.
      void setClassName​(java.lang.String className)
      Sets the classname and the packagename from a given classname.
      void setGenericReturnType​(java.lang.String genericReturnType)
      Sets the generic return type.
      void setMethodName​(java.lang.String methodName)
      Sets the method name the annotation belongs to.
      void setModifiers​(javax.lang.model.element.Modifier[] modifiers)
      Sets the modifiers for the method
      void setReturningCursor​(boolean returningCursor)
      Sets whether the method is returning a cursor.
      void setReturningDbObject​(boolean returningDbObject)
      Sets whether the method is returning a low-level db object.
      void setReturningDbObjectCollection​(boolean returningDbObjectCollection)
      Sets whether the method is returning a collection of low-level db objects.
      void setReturningPdo​(boolean returningPdo)
      Sets whether the method is returning a PDO.
      void setReturningPdoCollection​(boolean returningPdoCollection)
      Sets whether the method is returning a collection of PDOs.
      void setReturningPdoCursor​(boolean returningPdoCursor)  
      void setReturnType​(java.lang.String returnType)
      Sets the return type of the method
      void setSuperClassName​(java.lang.String superClassName)
      Sets the classname of the superclass.
      void setVarArgsMethod​(boolean varArgsMethod)
      Sets whether the method has varargs.
      java.lang.String toString()
      Gets the declaration string.
      void write​(java.io.PrintWriter writer)
      Writes this object to an info file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • INFO_FILE_VERSION

        public static final java.lang.String INFO_FILE_VERSION
        Fileformat version
        See Also:
        Constant Field Values
      • INFO_FILE_EXTENSION

        public static final java.lang.String INFO_FILE_EXTENSION
        all remote method info files end with .remote
        See Also:
        Constant Field Values
      • TYPE_METHOD

        public static final java.lang.String TYPE_METHOD
        Information type for a method.
        See Also:
        Constant Field Values
      • TYPE_CLASS

        public static final java.lang.String TYPE_CLASS
        Information type for a class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RemoteMethodInfo

        public RemoteMethodInfo​(java.lang.String type)
                         throws java.io.IOException
        Creates an RemoteMethodInfo for a given type. Used when reading from infofile.
        Parameters:
        type - one of TYPE_...
        Throws:
        java.io.IOException - if unsupported TYPE_...
      • RemoteMethodInfo

        public RemoteMethodInfo​(javax.annotation.processing.ProcessingEnvironment processingEnv,
                                javax.lang.model.element.ExecutableElement methodElement)
                         throws java.io.IOException
        Creates an RemoteMethodInfo from a method element. Used during apt processing.
        Parameters:
        processingEnv - the annotation processor's environment
        methodElement - the ExecutableElement to create an info from
        Throws:
        java.io.IOException - if some I/O error occurs
    • Method Detail

      • readInfo

        public static RemoteMethodInfo readInfo​(java.io.File infoFile)
                                         throws java.io.IOException
        Reads info from an file.
        Parameters:
        infoFile - the file to read from
        Returns:
        an RemoteMethodInfo object, null if file is empty or does not contain an RemoteMethodInfo-text
        Throws:
        java.io.IOException - if reading failed
      • readInfo

        public static RemoteMethodInfo readInfo​(java.io.LineNumberReader reader)
                                         throws java.io.IOException
        Reads info from an line reader.
        Parameters:
        reader - is the LineNumberReader
        Returns:
        an RemoteMethodInfo object, null if file is empty or does not contain an RemoteMethodInfo-text
        Throws:
        java.io.IOException - if reading failed
      • getNameCollection

        public java.lang.String getNameCollection()
        Gets the classname for a collection.
        Returns:
        the classname
      • getNameSession

        public java.lang.String getNameSession()
        Gets the classname for a session.
        Returns:
        the classname
      • getNameDbObject

        public java.lang.String getNameDbObject()
        Gets the classname for a simple db object.
        Returns:
        the classname
      • getNameCursor

        public java.lang.String getNameCursor()
        Gets the classname for a cursor.
        Returns:
        the classname
      • getNameContext

        public java.lang.String getNameContext()
        Gets the classname for a domain context.
        Returns:
        the classname
      • getNamePdo

        public java.lang.String getNamePdo()
        Gets the classname for a PDO.
        Returns:
        the classname
      • getType

        public java.lang.String getType()
        Gets the type of this analyze info.
        Returns:
        the type
      • getClassName

        public java.lang.String getClassName()
        Gets the name of the class this analyze info is part of.
        Returns:
        the classname
      • setClassName

        public void setClassName​(java.lang.String className)
        Sets the classname and the packagename from a given classname.
        Parameters:
        className - the full class name
      • getSuperClassName

        public java.lang.String getSuperClassName()
        Gets the name of the superclass this analyze info is part of.
        Returns:
        the classname
      • setSuperClassName

        public void setSuperClassName​(java.lang.String superClassName)
        Sets the classname of the superclass.
        Parameters:
        superClassName - the full class name
      • getMethodName

        public java.lang.String getMethodName()
        Gets the method name the annotation belongs to.
        Returns:
        the method name
      • setMethodName

        public void setMethodName​(java.lang.String methodName)
        Sets the method name the annotation belongs to.
        Parameters:
        methodName - the method name
      • getReturnType

        public java.lang.String getReturnType()
        Gets the return type of the method
        Returns:
        the return type
      • setReturnType

        public void setReturnType​(java.lang.String returnType)
        Sets the return type of the method
        Parameters:
        returnType - the return type
      • getGenericReturnType

        public java.lang.String getGenericReturnType()
        Gets the generic return type.
        Returns:
        the generic type, null or empty if none
      • setGenericReturnType

        public void setGenericReturnType​(java.lang.String genericReturnType)
        Sets the generic return type.
        Parameters:
        genericReturnType - the generic type, null or empty if none
      • getParameters

        public RemoteMethodInfoParameter[] getParameters()
        Gets the formal parameters of the method.
        Returns:
        the array of parameters
      • addParameter

        public void addParameter​(RemoteMethodInfoParameter parameter)
        Adds a formal parameter
        Parameters:
        parameter - the formal parameter to add
      • isVarArgsMethod

        public boolean isVarArgsMethod()
        Returns whether the method has varargs.
        Returns:
        true if varargs method
      • setVarArgsMethod

        public void setVarArgsMethod​(boolean varArgsMethod)
        Sets whether the method has varargs.
        Parameters:
        varArgsMethod - true if varargs method
      • getModifiers

        public javax.lang.model.element.Modifier[] getModifiers()
        Gets the modifiers for the method
        Returns:
        the array of modifiers
      • getModifiersAsString

        public java.lang.String getModifiersAsString()
        Gets the method's modifiers as a string
        Returns:
        the modifiers as a string
      • isModifierSet

        public boolean isModifierSet​(javax.lang.model.element.Modifier modifier)
        Checks whether given modifier is set for the method
        Parameters:
        modifier - the modifier to test
        Returns:
        true if modifier set
      • setModifiers

        public void setModifiers​(javax.lang.model.element.Modifier[] modifiers)
        Sets the modifiers for the method
        Parameters:
        modifiers - for the method
      • isReturningDbObject

        public boolean isReturningDbObject()
        Checks whether the method is returning a low-level db object.
        Returns:
        true if method returns a DbObject.
      • setReturningDbObject

        public void setReturningDbObject​(boolean returningDbObject)
        Sets whether the method is returning a low-level db object.
        Parameters:
        returningDbObject - true if method returns a DbObject.
      • isReturningDbObjectCollection

        public boolean isReturningDbObjectCollection()
        Checks whether the method is returning a collection of low-level db objects.
        Returns:
        true if method returns a collection of DbObjects.
      • setReturningDbObjectCollection

        public void setReturningDbObjectCollection​(boolean returningDbObjectCollection)
        Sets whether the method is returning a collection of low-level db objects.
        Parameters:
        returningDbObjectCollection - true if method returns a collection of DbObjects.
      • isReturningCursor

        public boolean isReturningCursor()
        Checks whether the method is returning a cursor.
        Returns:
        true if method returns a cursor
      • setReturningCursor

        public void setReturningCursor​(boolean returningCursor)
        Sets whether the method is returning a cursor.
        Parameters:
        returningCursor - true if method returns a cursor
      • isReturningPdoCursor

        public boolean isReturningPdoCursor()
      • setReturningPdoCursor

        public void setReturningPdoCursor​(boolean returningPdoCursor)
      • isReturningPdo

        public boolean isReturningPdo()
        Checks whether the method is returning a PDO.
        Returns:
        true if method returns a PDO.
      • setReturningPdo

        public void setReturningPdo​(boolean returningPdo)
        Sets whether the method is returning a PDO.
        Parameters:
        returningPdo - true if method returns a PDO
      • isReturningPdoCollection

        public boolean isReturningPdoCollection()
        Checks whether the method is returning a collection of PDOs.
        Returns:
        true if method returns a collection of PDOs.
      • setReturningPdoCollection

        public void setReturningPdoCollection​(boolean returningPdoCollection)
        Sets whether the method is returning a collection of PDOs.
        Parameters:
        returningPdoCollection - true if method returns a collection of PDOs.
      • toString

        public java.lang.String toString()
        Gets the declaration string.

        Overrides:
        toString in class java.lang.Object
      • write

        public void write​(java.io.PrintWriter writer)
                   throws java.io.IOException
        Writes this object to an info file.
        Parameters:
        writer - is the PrintWriter object
        Throws:
        java.io.IOException - if write failed
      • cleanTypeString

        public java.lang.String cleanTypeString​(java.lang.String type)
        Simplifies some classnames by removing package names.
        Makes generated code better readable. Can be used by wurblets.
        Parameters:
        type - the full type
        Returns:
        the shortened type