Class AnnotationElem

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

    public class AnnotationElem
    extends Declaration
    implements java.io.Serializable, java.lang.Comparable<AnnotationElem>, java.lang.Cloneable
    Java Parser Bridge: Holds all information extracted from '.java' Annotation (@interface) Source Files about all Elements identified in that file.

    Instances of this Class are Obtained From: ReflHTML & SummaryTableHTML

    Use of the Reflection-HTML API is *NOT REQUIRED* to perform a standard Java Doc HTML File Upgrade. This "extra API" allows for programmatic modification of Java Doc HTML. This class contains quite a bit of reflected information, and furthermore, here there is a hook to the Native Java Parser Reflection Class.
    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 AnnotationElem allows for storing the name, definition, default-value, etc... of an Annotation Element. Note that an 'Annotation Element' is not the same as a Java 'Annotation' (@interface). An 'Annotation Element' is merely the (optional) element / parameter which may (if used) help specify the contents of a Java Annotation.

    For Instance: With the commonly-used annotation named @SuppressWarnings(...), the value-parameters that are passed inside the parenthesis are the 'value' Annotation-Element. This 'value' may be assigned several Java String's such as: 'rawtypes', 'unchecked', etc...

    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;
        
      • type

        🡅  🡇    
        public final java.lang.String type
        An Annotation-Element may only assume one of several types, as per the Java Sun / Oracle Documentation. The type must be one of the following, or a compile-time error occurs:

        • a primitive type
        • String
        • Class or an invocation of Class
        • An enum type
        • An annotation type
        • An (1 dimensional) array type whose component type is one of the preceding types
        Code:
        Exact Field Declaration Expression:
        public final String type;
        
      • typeJOW

        🡅  🡇    
        public final java.lang.String typeJOW


        JOW: Just One Word

        The Just One Word convention in the upgrader tool elminates package-name information from type-String's.
        Code:
        Exact Field Declaration Expression:
        public final String typeJOW;
        
      • defaultValue

        🡅  🡇    
        public final java.lang.String defaultValue
        The default value assigned to this element. This may be null if there is no assigned default value.
        Code:
        Exact Field Declaration Expression:
        public final String defaultValue;
        
      • annotationMemberDeclaration

        🡅  🡇    
        public final transient com.github.javaparser.ast.body.AnnotationMemberDeclaration annotationMemberDeclaration

        Hook Reference to Java-Parser Refletion Class

        Though this class offers a streamlined set of reflection features, the Native Java-Parser Library Reflection-Classes offer a near-complete set of analysis tools for just about any kind of code-analysis neccessary. If you would like your Java Doc Pages to include more analytical-information, this field is provided as a convenience for such purposes.
        If a user decides to make use of the Java-Parser AnnotationMemberDeclaration instance that was used to build this AnnotationEleme, it may be retrieved from this transient field.
        Code:
        Exact Field Declaration Expression:
        public final transient AnnotationMemberDeclaration annotationMemberDeclaration;
        
    • Constructor Detail

      • AnnotationElem

        🡅  🡇    
        public AnnotationElem​
                    (com.github.javaparser.ast.body.AnnotationMemberDeclaration amd)
        
        Instantiates a AnnotationElem, and peels out the String's from a JavaParser AnnotationMemberDeclaration

        EXCEPTIONS NOTE: The underlying parser code can throw exceptions, and the exception chain, and exception tree in the package is quite dense. Suffice it to say, they are all unchecked exceptions.
        Parameters:
        amd - This can be retrieved in any number of ways from the JavaParser package. The instantiation process will convert a Java-Parser from of an AnnotationMemberDeclaration, into this Bridge form class AnnotationElem.

        Yes, this is redundant, but that's what a bridge is - a wrapper class to make the programmer's life easier. All the salient information a programmer would need when improving JavaDoc Documentation HTML Files is easily and simply encapsulated as lists of String's in the class AnnotationElem.
    • Method Detail

      • toString

        🡅  🡇    
        public java.lang.String toString()
        Generates a String of this Annotation Element, with all information included.
        Overrides:
        toString in class Declaration
        Returns:
        A printable string of this AnnotationElem.
        See Also:
        StrCSV.toCSV(String[], boolean, boolean, Integer), toString(int)
        Code:
        Exact Method Body:
         String def = (defaultValue != null)
             ? ("Default:      [" + StringParse.abbrevEndRDSF(defaultValue, MAX_STR_LEN, true) +
                 "]\n") 
             : "";
            
         return
             "Name:         [" + name + "]\n" +
             "Declaration:  [" + StringParse.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" +
             "Type:         [" + typeJOW + "]\n" +
             "Modifiers:    [" + StrCSV.toCSV(modifiers, true, true, null) + "]\n" +
             def +
             "Line Numbers: [sig=" + signatureLineNumber + ", jdStart=" + jdStartLineNumber +
                                     ", jdEnd=" + jdEndLineNumber + "]";
        
      • toString

        🡅  🡇    
        public java.lang.String toString​(int flags)
        Generates a String of this Annotation Element, with all information included. This will also included any content requested by the 'flags' parameter. For this class (class AnnotationElem), the only additional information printed by this 'toString' method is the Java-Doc Comment String.

        This String may also have UNIX color codes added.
        Overrides:
        toString in class Declaration
        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 AnnotationElem.
        See Also:
        PF, StrCSV.toCSV(String[], boolean, boolean, Integer), toString()
        Code:
        Exact Method Body:
         boolean color = (flags & UNIX_COLORS) > 0;
        
         return
             printedName("Element", 14, color) + 
             printedDeclaration(14, color) +
             "Type-JOW:     [" + typeJOW + "]\n" + 
             printedModifiers(14) +
             printedLineNumbers(14, color) +
        
             // These are optional, they adds a '\n' AT THE BEGINNING if they are included
             printedDefault(color) +
             printedComments(14, color, (flags & JAVADOC_COMMENTS) > 0);
        
      • clone

        🡅  🡇    
        public AnnotationElem clone()
        Java's interface Cloneable requirements. This instantiates a new AnnotationElem with identical fields.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new AnnotationElem 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 AnnotationElem(this);
        
      • compareTo

        🡅  🡇    
        public int compareTo​(AnnotationElem ae)
        Java's interface Comparable<T> requirements. This does a very simple comparison using the two elements' 'name' field.
        Specified by:
        compareTo in interface java.lang.Comparable<AnnotationElem>
        Parameters:
        ae - Any other AnnotationElem to be compared to 'this' AnnotationElem
        Returns:
        An integer that fulfills Java's interface Comparable<AnnotationElem> public boolean compareTo(AnnotationElem ae) method requirements.
        Code:
        Exact Method Body:
         return (this == ae) ? 0 : this.name.compareTo(ae.name);
        
      • equals

        🡅    
        public boolean equals​(AnnotationElem other)
        This should be called an "atypical version" of the usual equals(Object other) method. This version of equals merely compares the name of the element defined. The presumption here is that the definition of an 'element' only has meaning - at all - inside the context of an Annotation where that element has been defined. Since inside any '.java' Annotation, there may only be one element with a given name, this method shall return TRUE whenever the element being compared also has the same name.
        Parameters:
        other - This may be any other Annotation-Element. It is strongly suggested that 'other' be an element defined in the same '.java' source-code file as 'this' element.
        Returns:
        This method returns TRUE when 'this' instance of AnnotationElem has the same 'name' as the name of input-parameter 'other'
        Code:
        Exact Method Body:
         return this.name.equals(other.name);