Package Torello.Browser.JsonAST
Class API
- java.lang.Object
-
- Torello.Browser.JsonAST.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 theJsonAST-Package. It is easy to load the Abstract Syntax Tree's from disk by invoking thedeserializeFromJAR()method inside of classSERIALIZED_AST. Remember that the entire packageTorello.Browser.JsonASTis 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 aReadOnlyListthat 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 JSONandJavaScript 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 intoReadOnlyList'sfrom theReadOnly 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.
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 sixJsonObjectproperties are mapped to the followingEntitysubclasses:Json Object Type AST Node Java Conversion "Target" Type TypeNodeConverted into Java Inner Classes / Nested Types of the Primary Domain Java-Classes Command CommandNodeConverted into Java Methods within the Primary Domain Java-Classes Event EventNodeAlso Converted into Inner Classes / Nested Types of the Primary Domain Java-Classes Property PPRConverted into typical Java Fields within the Inner Types / Nested Classes.
(See note †† below.)Parameter PPRFor 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 PPRThese are converted (for Commands), into Return-Values for the Methods. Using the "Multi-Return Tuples" RetNdefined in theJava.Additionalpackage, it is possible (and quite common, actually) to return multiple values from a single method invocation.
(See note †† below.)
†† UnlikeTCE, Properties, Parameters, and Return-Values do not have their own dedicated AST nodes, because their content is always identical to that in base classPPR.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Browser/JsonAST/API.java
- Open New Browser-Tab: Torello/Browser/JsonAST/API.java
File Size: 6,721 Bytes Line Count: 166 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field Description protected static longserialVersionUIDCore Identity: Fundamental Details about this API Modifier and Type Field Description intidStringinFileNameContains the Json Specifiction File's nameStringnameThis will either contain theString "BrowserAPI"or the"JavaScriptAPI"Complete list of CDP Domains that comprise in this API Modifier and Type Field Description ReadOnlyList<Domain>domainsThe 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 DomainfindDomain(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 anIteratorthat iterates the contents of thedomainslist.Methods: interface java.lang.Comparable Modifier and Type Method Description intcompareTo(API other)Checksnamefields, using the standardString.compareToto produce a comparison value.Methods: class java.lang.Object Modifier and Type Method Description booleanequals(Object other)Checksthis.idagainstother.idfor equality.inthashCode()Utilizesthis.idas a hash; it is a unique value across the AST Tree.StringtoString()Generates a fullStringrepresentation ofthisinstance.
-
-
-
Field Detail
-
serialVersionUID
protected static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation 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 theString "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 ajava.lang.String- Returns:
- The domain whose
Domain.namematches'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;
-
iterator
-
equals
-
hashCode
-
toString
public java.lang.String toString()
Generates a fullStringrepresentation ofthisinstance.- Overrides:
toStringin classjava.lang.Object- Code:
- Exact Method Body:
return StringAPI.get(this);
-
-