Class Constructor

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Constructor>

    public class Constructor
    extends Callable
    implements java.io.Serializable, java.lang.Comparable<Constructor>, java.lang.Cloneable
    Java Parser Bridge: Holds all information extracted from '.java' Source Files about Constructor's identified in that file.

    The purpose of this bridge is provide a pared down, easier-to-use (but-with less-features) version of the publicly available "JavaParser" package. This class Field allows for storing the name, definition, modifiers list, etc... of a constructor.

    There is a Java-Parser Library that is required to use this Package. The Java Doc Upgrader Package / Tool will not work without this '.jar'file being placed in your CLASSPATH environment-variable. That '.jar'is available here:

    http://developer.torello.directory/ralphsReference/jars/javaparser-core-3.16.2.jar

    There is a book available and an internet "Gitter" support web-site chat-room with some of the people involved in writing this library. There are quite a number of available jars in the "Master Jar Distribution" - but the core library jar is fully sufficient for running the tasks needed by this Java-Doc Upgrade Tool's logic.

    Class Inheritance Diagram for Reflection Classes


    Class Declaration
     
    intid
    Entityentity
     
    Stringname
    Stringsignature
    StringjdComment
     
    String[]modifiers
    String[]annotations
     
    intsignatureLineNumber
    intjdStartLineNumber
    intjdEndLineNumber
     
     
     
     
     
    Class Callable
     
    Stringbody
     
    String[]parameterNames
    String[]parameterTypes
    String[]parameterTypesJOW
    String[][]parameterAnnotations
     
    String[]exceptions
     
     
     
     
     
    Class Method
     
    StringreturnType
    StringreturnTypeJOW
     
     
     
     
     
    Class Constructor
    Inherits Class Callable
    No Additional Fields
    Java Parser Bridge
    Inheritance Diagram


    Class Field
     
    Stringdefinition
    Stringtype
    StringtypeJOW
     
     
     
     
     
    Class EnumConstant
     
    String[]paramExpressions
     
     
     
     
     
    Class AnnotationElem
     
    StringdefaultValue
    Stringtype
    StringtypeJOW
     
     
     
     
     
    Class NestedType
     
    CIETciet
    intnumFields
    intnumMethods
     
    StringfullyQualifiedName
    StringnameWithContainer
    StringpackageName
     
    String[]extendedTypesJOW
    String[]implementedTypesJOW
    String[]genericTypeParameters
     
     
     
     
     




    IMPORTANT:
    All reflection classes above, also contain an additional (transient, non-Serializable) field that hooks into the native Java-Parser Library classes, providing an option for a more in-depth or complete analysis using that Library's features & extensive utilities.
    See Also:
    Serialized Form


    • Field Detail

      • serialVersionUID

        🡇    
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
        public static final long serialVersionUID = 1;
        
      • constructorDeclaration

        🡅  🡇    
        public final transient com.github.javaparser.ast.body.ConstructorDeclaration constructorDeclaration
        If a user decides to make use of the Java-Parser ConstructorDeclaration instance that was used to build this Constructor, it may be retrieved from this transient field.
        Code:
        Exact Field Declaration Expression:
        public final transient ConstructorDeclaration constructorDeclaration;
        
    • Constructor Detail

      • Constructor

        🡅  🡇    
        public Constructor​
                    (com.github.javaparser.ast.body.ConstructorDeclaration cd,
                     boolean isSignatureOnly)
        
        Builds an instance of this class
        Parameters:
        cd - This can be retrieved in any number of ways from the JavaParser package. The instantiation process will convert a Java-Parser form of a ConstructorDeclaration, into this Bridge form class Method.
        isSignatureOnly - This constructor may be used to build an instance of Constructor using only the signature of the constructor. If you have built / received a 'ConstructorDeclaration' without a constructor-body definition, set this parameter to TRUE; the value of the public final String body field will be null.

        NOTE: If this Java-Parser ConstructorDeclaration does have a body-defined, but this parameter is set to TRUE, the body String-field will still be null.
        Code:
        Exact Constructor Body:
         super(
             // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
             // Declaration-Constructor Parameters
             // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        
             cd.getAnnotations(),                    // annotations
             cd.getModifiers(),                      // modifiers
             cd.getNameAsString(),                   // name
             cd.getDeclarationAsString(),            // signature
             cd.getJavadocComment(),                 // java-doc comment
             Entity.CONSTRUCTOR,                     // Simple ENUM, instead of 'getClass()'
             cd.getBegin(),                          // The signature line number
        
        
             // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
             // Callable-Constructor Parameters
             // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        
             cd.getParameters(),                     // Parameters
             isSignatureOnly ? null : cd.getBody(),  // Constructor Body
             cd.getThrownExceptions()                // Exceptions
         );
        
         // Save this Java Parser reference in a transient field.
         this.constructorDeclaration = cd;
        
    • Method Detail

      • toString

        🡅  🡇    
        public java.lang.String toString()
        Generates a string of this constructor, with most information included.

        NOTE: This will not return every piece of information contained by this class. For example, both the constructor body, and any possible JavaDoc Comments are not included. For a more enhanced toString() version, call the one that accepts flags.
        Overrides:
        toString in class Callable
        Returns:
        A printable string of this field.
        See Also:
        PF, toString(int), StrCSV.toCSV(String[], boolean, boolean, Integer)
        Code:
        Exact Method Body:
         return
             "Name:            [" + name + "]\n" +
             "Signature:       [" + StringParse.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" +
             "Modifiers:       [" + StrCSV.toCSV(modifiers, true, true, null) + "]\n" +
             printedParameterNamesTS() +
             printedParameterTypesTS() +
             printedExceptionsTS() +
             "Line Numbers:    [sig=" + signatureLineNumber + ", jdStart=" + jdStartLineNumber +
                 ", jdEnd=" + jdEndLineNumber + "]";
        
      • toString

        🡅  🡇    
        public java.lang.String toString​(int flags)
        This class expects a flags that has been masked using the constant (public, static, final int) fields of class PF. Please view this class for more information about the flags available for modifying the return-value of this toString() method.
        Overrides:
        toString in class Callable
        Parameters:
        flags - These are the toString flags from class PF ("Print Flags"). View available flags listed in class PF.
        Returns:
        A printable String of this Constructor, with comment information included as well.
        See Also:
        toString(), StrCSV.toCSV(String[], boolean, boolean, Integer), PF
        Code:
        Exact Method Body:
         boolean color = (flags & UNIX_COLORS) > 0;
        
         return
             printedName("Constructor", 20, color) + 
             printedSignature(20, color) +
             printedModifiers(20) +
             printedParamNames() + 
             printedParamTypes(jowFlags(flags)) +
             printedExceptions() +
             printedLineNumbers(20, color) +
        
             // These are optional, they add a '\n' AT THE BEGINNING if they are included
             printedComments(20, color, (flags & JAVADOC_COMMENTS) > 0) +
             printedCallableBody(flags);
        
      • clone

        🡅  🡇    
        public Constructor clone()
        Java's interface Cloneable requirements. This instantiates a new Constructor with identical fields.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new Constructor whose internal fields are identical to this one. A deep copy on all internal arrays is performed. New arrays are instantiated.
        Code:
        Exact Method Body:
         return new Constructor(this);
        
      • compareTo

        🡅  🡇    
        public int compareTo​(Constructor c)
        Java's interface Comparable<T> requirements. This looks at the number of parameters, and parameter types in making a sort-decision.
        Specified by:
        compareTo in interface java.lang.Comparable<Constructor>
        Parameters:
        c - Any other Constructor to be compared to 'this' Constructor
        Returns:
        An integer that fulfils Java's interface Comparable<Constructor> public boolean compareTo(Constructor c) method requirements.
        Code:
        Exact Method Body:
         if (this == c) return 0;
        
         int ret = this.numParameters() - c.numParameters();
         if (ret != 0) return ret;
        
         if (this.parameterTypesJOW != null)
             for (int i=0; i < this.parameterTypesJOW.length; i++)
                 if ((ret = this.parameterTypesJOW[i].compareTo(c.parameterTypesJOW[i])) != 0)
                     return ret;
        
         return 0;
        
      • equals

        🡅    
        public boolean equals​(Constructor other)
        This should be called an "atypical version" of the usual equals(Object other) constructor. This version of equals merely compares the name and parameters-list of the constructor. The presumption here is that the definition of a 'constructor' only has meaning - at all - inside the context of a class or enumerated-type where that constructor is defined. Since inside any '.java' source-code file, there may only be one constructor with a given parameter-list, this shall return TRUE whenever the constructor being compared has the same parameter types as 'this' does.
        Parameters:
        other - This may be any other constructor. It is strongly suggested that this be a constructor defined in the same '.java' source-code file as 'this' constructor.
        Returns:
        This method returns TRUE when 'this' instance of Constructor has the same parameter-list as 'other'.
        Code:
        Exact Method Body:
         // If the number of parameters in the 'other' instance of Constructor differ from the
         // number of parameters in 'this' Constructor, then return FALSE immediately.  It cannot be
         // a match
        
         if (this.numParameters() != other.numParameters()) return false;
        
         // If there are no parameters (for either of them), then return true immediately
         if (this.numParameters() == 0) return true;
        
         // If any of the parameter-names are different, break immediately and return false;
         for (int i=0; i < this.parameterNames.length; i++)
             if (! this.parameterNames[i].equals(other.parameterNames[i]))
                 return false;
        
         // If the parameter-types listed by the javadoc '.html' file differ from parameter-types
         // listed in the original '.java' source-code file, then break immediately.
         //
         // NOTE: The "package-information" for the FULL CLASS OR INTERFACE NAME is not always
         // available.
        
         for (int i=0; i < this.parameterTypes.length; i++)
             if (! this.parameterTypesJOW[i].equals(other.parameterTypesJOW[i]))
                 return false;
        
         // ALL TESTS PASSED
         return true;