Class API

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<API>, java.lang.Iterable<Domain>

    public class API
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<API>, java.lang.Iterable<Domain>
    The class class comprises the intended public facing API for the JsonAST-Package. It is easy to load the Abstract Syntax Tree's from disk by invoking the deserializeFromJAR() method inside of class SERIALIZED_AST. Remember that the entire package Torello.Browser.JsonAST is used primarily by a proprietary, and yet unreleased code generator, and is only made public for informational & reference purposes.

    Loading the the serialized trees from the '.jar' file, perhaps, may elucidate some of Google's Browser CDP API. The nodes themselves have quite a bit of read only data available.
    Contains a ReadOnlyList that has each domain defined in the API. There are exactly two API's that Google has created in its CDP (Chrome DevTools Protocol) System: the "Browser API", and the "JavaScript API".

    The following two tree diagrams, with explanation, are repeated verbatim across all eight AST Node Classes.

    Object Inheritance for AST Nodes, and RunTime Tree Organization

    The Objects which are generated by the JSON Parser are converted into AST Node Object-Instances, all of which are listed here, below. An in depth study of the CDP Specification, a programmer must realize that there are actually three (possibly four) different trees functioning simultaneously. The Classes themselves have their own "Inheritance Tree." Then, additionally, by its very nature, the original JSON Spec Files are organized in a Tree Structure (as is all JSON, you may view these trees here: Browser API JSON and JavaScript API JSON

    Finally, and most importantly, at RunTime as Objects Instances, themselves, are created by the Parser; they are saved into the "Abstract Syntax Tree" (AST for short). These instances are placed into this AST, by saving them into ReadOnlyList's from the ReadOnly Collections Framework.


    Class Inheritance Tree:
    The diagram below shows the static class hierarchy: how the core JsonAST classes inherit from one another at the type level.

    API
    Domain
    
    Entity
    ├─ TCE  (abstract)
    │  ├─ TypeNode
    │  ├─ CommandNode
    │  └─ EventNode
    └─ PPR
    



    Runtime Object Instance Tree:
    In contrast, this diagram shows the dynamic structure at runtime: how reified instances of those same classes are organized into an AST, with parent–child container relationships.

    API
    └─ Domain
       ├─ TypeNode
       │  └─ PPR       ➜ [P]roperties     ➜ Generate to Java Class Fields
       ├─ CommandNode
       │  ├─ PPR       ➜ [P]arameters     ➜ Generate to Java Method Parameters
       │  └─ PPR       ➜ [R]eturn-Values  ➜ Generate to Java Method Return Values
       └─ EventNode
          └─ PPR       ➜ [P]arameters     ➜ Generate to Java "Event Class" Fields
    



    The following six JsonObject properties are mapped to the following Entity subclasses:
    Json Object Type AST Node Java Conversion "Target"
    Type TypeNode Converted into Java Inner Classes / Nested Types of the Primary Domain Java-Classes
    Command CommandNode Converted into Java Methods within the Primary Domain Java-Classes
    Event EventNode Also Converted into Inner Classes / Nested Types of the Primary Domain Java-Classes
    Property PPR Converted into typical Java Fields within the Inner Types / Nested Classes.
    (See note †† below.)
    Parameter PPR For Commands, these are Converted by the Code Generator into Method Parameters. For Events, these are actually also just converted into Fields of the Nested Event Class too.
    (See note †† below.)
    Return Value PPR These are converted (for Commands), into Return-Values for the Methods. Using the "Multi-Return Tuples" RetN defined in the Java.Additional package, it is possible (and quite common, actually) to return multiple values from a single method invocation.
    (See note †† below.)

    †† Unlike TCE, Properties, Parameters, and Return-Values do not have their own dedicated AST nodes, because their content is always identical to that in base class PPR.
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field Description
      protected static long serialVersionUID
       
      Core Identity: Fundamental Details about this API
      Modifier and Type Field Description
      int id  
      String inFileName
      Contains the Json Specifiction File's name
      String name
      This will either contain the String "BrowserAPI" or the "JavaScriptAPI"
       
      Complete list of CDP Domains that comprise in this API
      Modifier and Type Field Description
      ReadOnlyList<Domain> domains
      The complete list of domain's in the API, extracted & parsed from the Json File.
    • Method Summary

       
      Search for a Domain with a Specific Name
      Modifier and Type Method Description
      Domain findDomain​(String domainName)
      This method merely iterates the list of domain's contained by this API, to find and return the domain whose name matches 'domainName'.
       
      Methods: interface java.lang.Iterable
      Modifier and Type Method Description
      Iterator<Domain> iterator()
      Returns an Iterator that iterates the contents of the domains list.
       
      Methods: interface java.lang.Comparable
      Modifier and Type Method Description
      int compareTo​(API other)
      Checks name fields, using the standard String.compareTo to produce a comparison value.
       
      Methods: class java.lang.Object
      Modifier and Type Method Description
      boolean equals​(Object other)
      Checks this.id against other.id for equality.
      int hashCode()
      Utilizes this.id as a hash; it is a unique value across the AST Tree.
      String toString()
      Generates a full String representation of this instance.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        protected 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:
         protected static final long serialVersionUID = 1;
        
      • id

        🡅  🡇     🗕  🗗  🗖
        public final int id
        Code:
        Exact Field Declaration Expression:
         public final int id = IDManager.nextID();
        
      • inFileName

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String inFileName
        Contains the Json Specifiction File's name
        Code:
        Exact Field Declaration Expression:
         public final String inFileName;
        
      • name

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String name
        This will either contain the String "BrowserAPI" or the "JavaScriptAPI"
        Code:
        Exact Field Declaration Expression:
         public final String name;
        
      • domains

        🡅  🡇     🗕  🗗  🗖
        public final ReadOnlyList<Domain> domains
        The complete list of domain's in the API, extracted & parsed from the Json File.
        Code:
        Exact Field Declaration Expression:
         public final ReadOnlyList<Domain> domains;
        
    • Method Detail

      • findDomain

        🡅  🡇     🗕  🗗  🗖
        public Domain findDomain​(java.lang.String domainName)
        This method merely iterates the list of domain's contained by this API, to find and return the domain whose name matches 'domainName'.
        Parameters:
        domainName - the name of one of the domain's in this API, as a java.lang.String
        Returns:
        The domain whose Domain.name matches 'domainName', or null if no such domain exists.
        Code:
        Exact Method Body:
         for (Domain domain : domains) if (domain.name.equals(domainName)) return domain;
         return null;
        
      • compareTo

        🡅  🡇     🗕  🗗  🗖
        public int compareTo​(API other)
        Checks name fields, using the standard String.compareTo to produce a comparison value.
        Specified by:
        compareTo in interface java.lang.Comparable<API>
        Code:
        Exact Method Body:
         if (this == other) return 0;
         if (other == null) return 1;
        
         return this.name.compareTo(other.name);
        
      • equals

        🡅  🡇     🗕  🗗  🗖
        public boolean equals​(java.lang.Object other)
        Checks this.id against other.id for equality.
        Overrides:
        equals in class java.lang.Object
        Code:
        Exact Method Body:
         if (other == null)              return false;
         if (! (other instanceof API))   return false;
         return this.id == ((API) other).id;
        
      • hashCode

        🡅  🡇     🗕  🗗  🗖
        public int hashCode()
        Utilizes this.id as a hash; it is a unique value across the AST Tree.
        Overrides:
        hashCode in class java.lang.Object
        Code:
        Exact Method Body:
         return id;
        
      • toString

        🡅         External-Java:    🗕  🗗  🗖
        public java.lang.String toString()
        Generates a full String representation of this instance.
        Overrides:
        toString in class java.lang.Object
        Code:
        Exact Method Body:
         return StringAPI.get(this);