Class Field

  • All Implemented Interfaces:, java.lang.Cloneable, java.lang.Comparable<Field>

    public class Field
    extends Declaration
    implements, java.lang.Comparable<Field>, java.lang.Cloneable
    Extension of Package java.lang.reflect
    This class operates as a slightly more advanced version of the basic Java Reflection Class java.lang.reflect.Field. This class provides a hook into the native Java Parser JAR Library classes FieldDeclaration and VariableDeclarator.

    This class is heavily used internally, and can be used (if needed) to modify Java Doc Web-Pages, programmatically.

    HTML Processors that sort the Web-Page "Summary-Tables" will provide instances of this class to your Summary-Sorter Handler methods. Summary-Sorter handlers usually implement the SummarySorterHelper interface; please review that class for more about sorting Java-Doc Page Summary Tables.

    The HTML Processors that upgrade Web-Page "Detail Elements" also rely heavily on this class. Please review the class: ReflHTML for more information about Java-Doc Web-Page Detail Sections.
    Java Parser Bridge: Holds all information extracted from '.java' Source-Files about Field's 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 Field allows for storing the name, definition and modifiers list of a field.

    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:

    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.

    Reflection-Classes Inheritance-Diagram

    Class Declaration
    Class Callable
    Class Method
    Class Constructor
    Also Inherits Class Callable
    No Additional Fields
    Reflection Class
    Inheritance Diagram

    Class Field
    Class EnumConstant
    Class AnnotationElem
    Class NestedType

    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

        protected static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface 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
        Exact Field Declaration Expression:
         protected static final long serialVersionUID = 1;
      • definition

        public final java.lang.String definition
        The definition of this field, as a String.
        Exact Field Declaration Expression:
         public final String definition;
      • type

        public final java.lang.String type
        The type / class of this field, as a String.
        Exact Field Declaration Expression:
         public final String type;
      • typeJOW

        public final java.lang.String typeJOW
        The type / class of this field, as a String.

        JOW: Just One Word

        If the String's in a type-as-String contain complicated or intricate detailed information, and all you need is a simple identifier, the JOW-String stores the type-as-String with all package-name and generic-parameters (if they were present / included) stripped from the String. Furthermore, if the type was originally an inner-class, even the containing class-name is removed from the JOW-String.

        If a parameter to a Method, or the type of a Field had the (fully-qualified) type-name:<String>, the JOW-String would simply have the word "Builder".

        NOTE: If the type, itself, is an array of any kind, the array-brackets will be included in this String-name.
        Output Single-Word, Type-StringInput Type
        "Entry" "java.util.Map.Entry<K, V>"
        "Vector" "java.util.Vector<E>"
        "Vector" "Vector<TagNode>"
        "Vector" "Vector<Vector<TagNode>>"
        "Vector" "java.util.Vector<Vector<TagNode>>"
        "String" "String"
        "String" "java.lang.String"
        "String[]" "java.lang.String[]"
        "Integer" "Integer"
        "Integer[]" "java.lang.Integer[]"

        NOTE: You may view the StringParse class' methods removeGeneric, and typeToJavaIdentifier for more information.
        Exact Field Declaration Expression:
         public final String typeJOW;
      • variableDeclarator

        public final transient com.github.javaparser.ast.body.VariableDeclarator variableDeclarator

        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 VariableDeclarator instance that was used to build this Field, it may be retrieved from this transient field.
        Exact Field Declaration Expression:
         public final transient VariableDeclarator variableDeclarator;
      • variableTree

        public final transient com.sun.source.tree.VariableTree variableTree

        Hook Reference to Sun/Oracle Parser-Refletion Class

        Though this class offers a streamlined set of reflection features, the Native Oracle Library Reflection-Classes offer a detailed AST interface into the standard Java Compiler. If you would like to use these Tree's to provide further code analysis on your Java-Doc Pages, this field is provided as a convenience for such purposes.
        If a user decides to make use of the native Sun/Oracle VariableTree instance that was used to build this Field instance, it may be retrieved from this transient field.
        Exact Field Declaration Expression:
         public final transient VariableTree variableTree;
    • Constructor Detail

      • Field

        public Field​(com.sun.source.tree.VariableTree vt,
                     TreeUtils util)
        Constructs an instance of this class, Field. A parsed AST node that has been compiled by Java's Source-Parser, and the exact instance of TreeUtils that generated the parsed node must be passed by parameter to this constructor.
        vt - Any instance of a Java AST Field Node. It is required that this member / entity AST-Node is one which the Java-Compiler generated using the exact same TreeUtils instance also being passed by parameter here.

        Any time that the Java-Compiler parses a 'Field' Member / Entity, that member is converted into an instance of the AST-Node VariableTree.
        util - This utility class will contain references to all of the most important instances that are used when compiling a standard Java Souce-Code ('.java' File). In this Java-Doc Web-Page 'Upgrade' Package, whenever any '.java' file is compiled and converted into an Abstract Syntax Tree, a new instance of TreeUtils will be created / generated.

        Each source-file in a Java-Project will be compiled once, and converted into an instance of TreeUtils. Note that it is imperative that the TreeUtils instance being passed to this method is the same instance that was used to generate the Field-Node instance with this constructor-invocation.

        An instance of TreeUtils. is always available as a member-field of the top-level class JavaDocHTMLFile.treeUtils.
    • Method Detail

      • toString

        public java.lang.String toString()
        Generates a String of this field, with all information included.
        toString in class Declaration
        A printable String of this field.
        See Also:
        StrCSV.toCSV(String[], boolean, boolean, Integer), toString(int)
        Exact Method Body:
         String defStr = (definition == null)
             ? "null" 
             : StrPrint.abbrevEndRDSF(definition, MAX_STR_LEN, true);
             "Name:         [" + name + "]\n" +
             "Declaration:  [" + StrPrint.abbrevEndRDSF(signature, MAX_STR_LEN, true) + "]\n" +
             "Type:         [" + type + "]\n" + 
             "Definition:   [" + defStr + "]\n" +
             "Modifiers:    [" + StrCSV.toCSV(modifiers, true, true, null) + "]\n" +
             // This will **NEVER** be null - unless 'this' instance was built from an HTML File,
             // rather than a source-code file.  Instances like that are only used temporarily, and
             // are garbage collected instantly.  Do this check anyway (just in case).
             "Location:     " + ((this.location == null)
                 ? "null" 
                 : ('[' + this.location.quickSummary() + ']'));
      • toString

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

        This String may also have UNIX color codes added.
        toString in class Declaration
        flags - These are the toString(...) flags from class PF ("Print Flags"). View available flags listed in class PF.
        A printable String of this Field.
        See Also:
        PF, StrCSV.toCSV(String[], boolean, boolean, Integer), toString()
        Exact Method Body:
         boolean color = (flags & UNIX_COLORS) > 0;
             printedName("Field", 15, color) + 
             printedDeclaration(15, color) +
             printedType(jowFlags(flags)) +
             printedDefinition(color) +
             printedModifiers(15) +
             printedLocation(15, color, (flags & BRIEF_LOCATION) > 0) +
             // The previous method does not add a '\n' end to the end of the returned string
             // This is optional, it adds a '\n' AT THE BEGINNING if it is included
             printedComments(15, color, (flags & JAVADOC_COMMENTS) > 0);
      • clone

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

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

        public boolean equals​(Field 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 field defined. The presumption here is that the definition of a 'field' only has meaning - at all - inside the context of a class, interface, or enumerated-type where that field is defined. Since inside any '.java' source-code file, there may only be one field with a given name, this method shall return TRUE whenever the field being compared also has the same name.
        other - This may be any other field. It is strongly suggested that 'other' be a field defined in the same '.java' source-code file as 'this' field.
        This method returns TRUE when 'this' instance of Field has the same 'name' as the name-field of input-parameter 'other'
        Exact Method Body: