Package Torello.Browser.JsonAST
Class InfoData
- java.lang.Object
-
- Torello.Browser.JsonAST.InfoData
-
- All Implemented Interfaces:
java.io.Serializable
public class InfoData extends java.lang.Object implements java.io.Serializable
The contents of theJsonAST-Package are, in general, provided strictly for informational & reference purposes. If further research & investigation of Google's CDP API are necessary, one may deserialize theBrowser-APIand / or theJavaScript-APIfrom the Java-HTML'.jar'file, and review the AST's programmatically. The AST Node Java-Classes have been meticulously documented exactly for that purpose.
Generally, though, there really is very little need to review, understand, or programmatically analyze the CDP API. And the contents of this entire package, again, are largely here for reference only.
This particular class falls under the Package "Sub-Category" of"Data Serializers". These classes actually just store some (extremely uninteresting) data which is eventually utilized by the Code Generator to convert the two AST's from Java Memory into actual, reified Java POJO's / Classes.
It might be somewhat important to recognize that though the Java-HTML Library makes theJsonASTPackage source files public in the documentation files for this library, the CDP API Code Generator is not in the public docs, nor are its included in the'.jar'file, either. Generally, what there is to know, is that if you think this JsonAST stuff is actually kind of boring, and not that useful as a reference tool, wait until you get a load of what "Code Generator" code actually looks like. Keeping your eyes open is quite difficult!This is used by the AST Building Class (AST_BUILD) to collect and store some pivotal facts, details & information about the various types and events that are extracted frp, the CDP JSON spec files. These cute little "facts" are essentailly nothing more than some of the "tests" or "if statements" that are used by the proprietary Code Generator that utilizes these two AST's to generate the Browser API and Java-Script API classes.
This stuff serves next to no purpose at all outside of the Code Generator's methods, and all that they really do is help make the code a little nicer and cleaner when you read. it. Furthermore (and most importantly), the actual Code Generator is not part of the Java-HTML public API. You may review the AST, but the actual generator (which isn't very complicated) is not being exposed, either in the Java-HTML'.jar'-File, nor in the Java-HTML documentation.
The reason for this is simply to prevent abuse of this jar, and much more importantly, there is nothing very interesting about the Json ➜ Web-Socket ➜ Browser ➜ WebSocket ➜ Json ➜ Java "loop" that is going on. It is extremely boring and uninteresting. What is (hopefully) useful, challenging, fun, etc... is trying to use Google's API that is created.
Attempting to make Browser Automation actually do something interesting is at least one order of magnitude more useful than playing with a Code Generator that is generating the Java Stubs that are communicating with the browser.
Anyway, there are severalReadOnlyList'sthat are produced and created by the constructors of this class. The make several of the "if" statements inside of the Code Generator much easier to use. Rather than explaining how / why / when, you need to just accept, that inside of larger applications, not everything can be part of the "Public Facing API."
Below is an example of how to print out the contents of this class, using this class'toString()method. At the bottom of this example, the output produced by this example by clicking on the link provided.
Example:
import Torello.Browser.JsonAST.SERIALIZED_AST; import Torello.Browser.JsonAST.API; import Torello.Java.FileRW; import Torello.Java.C; import static Torello.Java.StringParse.nChars; import static Torello.Java.StringParse.rightSpacePad; import static Torello.Java.C.BRED_BKGND; import static Torello.Java.C.BYELLOW; import static Torello.Java.C.RESET; import java.io.IOException; public class InfoDataToString { public static void main(String[] argv) throws IOException { final SERIALIZED_AST sa = SERIALIZED_AST.deserializeFromJAR(); final String output = title(sa.jsAPI) + sa.jsDat.toString() + "\n" + title(sa.browserAPI) + sa.browserDat.toString() + '\n'; // Print the output to terminal System.out.println(output); // Also save this output to disk System.out.println("Writing File to Disk: " + BYELLOW + "InfoDataToString.html" + RESET); FileRW.writeFile( C.toHTML(output, "InfoData.toString()"), "../../doc-files/InfoDataToString.html" ); } private static String title(final API api) { final String titleStr = rightSpacePad(" " + api.name + " InfoData Contents", 38); return LINE + BRED_BKGND + " " + RESET + titleStr + BRED_BKGND + " " + RESET + '\n' + LINE + '\n' + "Total Number of Domains: " + api.domains.size() + '\n'; } private static final String LINE = BRED_BKGND + nChars(' ', 40) + RESET + '\n'; }
Above Example's Output:
InfoDataToString Output
Hi-Lited Source-Code:- View Here: Torello/Browser/JsonAST/InfoData.java
- Open New Browser-Tab: Torello/Browser/JsonAST/InfoData.java
File Size: 14,612 Bytes Line Count: 345 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field Description protected static longserialVersionUIDList of Types exhibiting a particular characteristic Modifier and Type Field Description ReadOnlyList<TypeNode>eliminatedTypeNodesReadOnlyList<TypeNode>enumValTypeNodesReadOnlyList<EventNode>markerEventNodesReadOnlyList<TypeNode>simpleTypeNodesList of Domains exhibiting a particular characteristic Modifier and Type Field Description ReadOnlySet<Domain>hasEnumStrListsReadOnlySet<Domain>hasMarkerEventsReadOnlySet<Domain>hasReifiedEventsThe set of all domains which have actual nested java inner classes defined within them.ReadOnlySet<Domain>hasReifiedReturnTypesThis should list all domains that have commands which return more than one value as a result of their invocation.ReadOnlySet<Domain>hasReifiedTypesThe set of all domains which have actual nested java inner classes defined within them.ReadOnlySet<Domain>hasSimpleTypesThe list of domains which have at least one zero-property type (and were eliminated during the code generation step).
-
Method Summary
Methods: class java.lang.Object Modifier and Type Method Description StringtoString()Generates aStringrepresentation of the contents of this'InfoData'instance.
-
-
-
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;
-
eliminatedTypeNodes
public final ReadOnlyList<TypeNode> eliminatedTypeNodes
This list contains the names of all "types" from the CDP API which are never actually converted into actual Java POJO's by the code generator.
Eliminated Types, essentially, subsumes the set of "Simple Types" (which are just a renaming of a Java Type), along with "Enumerated String Constant Types" as well. In fact, the contents of this list should just be the concatenation of these two lists:- See Also:
simpleTypeNodes,enumValTypeNodes- Code:
- Exact Field Declaration Expression:
public final ReadOnlyList<TypeNode> eliminatedTypeNodes;
-
simpleTypeNodes
public final ReadOnlyList<TypeNode> simpleTypeNodes
Simple Types are types defined in the CDP API'.json'-files that do not actually contain anyfields. Instead, such types are just a "renaming" of a standard Java Type, such as'String'or'int'. These types are, essentially, eliminated by the code generator, during the code generation stage as no actual Java Class is produced to represent them.
Instead, such types are converted into aString-field within the domain's POJO, rather than a dedicated Nested Class within that domain's definition.
The list below contains a few links to CDP API types which are elimminated as per being nothing more than a "renaming" of a standard Java Type. Such types are, instead, converted into aString-field within theDomain'sPOJO, so that the user may read any documentation which Google may (or may not) have provided.
- Code:
- Exact Field Declaration Expression:
public final ReadOnlyList<TypeNode> simpleTypeNodes;
-
enumValTypeNodes
public final ReadOnlyList<TypeNode> enumValTypeNodes
The lion's share of types defined in the CDP API contain lists of fields for a type. These lists are easily converted into Java Classes. The properties contained by these type definitions are easily converted by the Java-HTML proprietary code generator into fields of those classes.
Within the CDP API, there are several types which are defined that are, essentially, identical to a Java'enum'type. These special types defined by the API, instead of providing a list of properties (READ: "fields"), provide a list of enumerated constants. These constants are stored within the API's'.json'definition file merely as a list ofString's.
The field'enumValTypeNodes'simply contains the names of all such CDP types which are intended to mimic Java'enum'types. It is important to note that the enumerated constant list types are not actually converted into Javaenum'sby the code generator, but instead intoReadOnlyList<String>. There is little actual value to creating even more'.class'files for this API.
The list below contains a few links to CDP API "String Enum Types" that have been converted into read-onlyStringlists.
- Code:
- Exact Field Declaration Expression:
public final ReadOnlyList<TypeNode> enumValTypeNodes;
-
markerEventNodes
public final ReadOnlyList<EventNode> markerEventNodes
"Marker Events" is a term that is used to describe Chrome Browser Events which fire, but do not have any parameters ascribed to them when they fire. They are "stateless" events whose firing is the only actual information that is conveyed from the browser to the user.
The vast majority of events which are listed by the CDP API contain at least one data field with their event type definition. This list here contains the names of all events which have precisely zero parameters when they are fired.
The "See Also" section below contains a few links to CDP API Events that contain zero properties within their definitions. Instead, these are converted into a simpleString-field within theDomain'sPOJO, so that the user may read any documentation which Google may (or may not) have provided.
- Code:
- Exact Field Declaration Expression:
public final ReadOnlyList<EventNode> markerEventNodes;
-
hasEnumStrLists
public final ReadOnlySet<Domain> hasEnumStrLists
This contains the complete list of domains which have at least one "Enum Type". Below, there is a list containing a few Chrome Domains that define Enumerated Constants. Again, Chrome Enum Val Strings are just lists of string tokens, which are nearly identical to Javaenum's.
The complete list of "Enumerated String Constant Types" may be reviewed by inspectingenumValTypeNodes. Note that the set of domains which comprise this fieldhasEnumStrLists(this field) is simply and precisely the set of domains that form the union of domains built out of all'i'inInfoData.enumValTypeNodes.get(.).ownerDomain
Click on any one of the domain links provided in the list below, and scroll to the "Fields Summary Section" to look for the "Enumerated Strings" sub-category of fields.
- See Also:
Entity.ownerDomain,enumValTypeNodes- Code:
- Exact Field Declaration Expression:
public final ReadOnlySet<Domain> hasEnumStrLists;
-
hasSimpleTypes
public final ReadOnlySet<Domain> hasSimpleTypes
The list of domains which have at least one zero-property type (and were eliminated during the code generation step).- Code:
- Exact Field Declaration Expression:
public final ReadOnlySet<Domain> hasSimpleTypes;
-
hasMarkerEvents
public final ReadOnlySet<Domain> hasMarkerEvents
This contains the complete list of domains which have at least one "Marker Event." Remember that not all Chrome Domains have an event actually defined within them. Fewer domains have an actual zero-parameter marker event defined.
This set is formed by nothing more than "the union" of all domains formed out of the list ofownerDomain'sfor each event in themarkerEventNodes. In plain English, all Marker Events within themarkerEventNodeslist have their "Owner Domain" added to this set, before it is constructed by this class' constructor.
Click on any one of the domain links provided in the list below, and scroll to the "Fields Summary Section" to look for the "Marker Events" sub-category of fields.
- See Also:
Entity.ownerDomain,markerEventNodes- Code:
- Exact Field Declaration Expression:
public final ReadOnlySet<Domain> hasMarkerEvents;
-
hasReifiedTypes
public final ReadOnlySet<Domain> hasReifiedTypes
The set of all domains which have actual nested java inner classes defined within them. There are relatively few domains in the CDP API that do not actually define any types, though there are some.
In the most recent parsing and generation of the "Browser API" from CDP, 41 out of the 47 Domains have actual, reified, events. You may see thetoString Outputfor this class by clicking the link.- Code:
- Exact Field Declaration Expression:
public final ReadOnlySet<Domain> hasReifiedTypes;
-
hasReifiedReturnTypes
public final ReadOnlySet<Domain> hasReifiedReturnTypes
This should list all domains that have commands which return more than one value as a result of their invocation. Rather than return tuples of results, a dedicated nested-inner type is created for any CDP command that needs to actually return more than one value.- Code:
- Exact Field Declaration Expression:
public final ReadOnlySet<Domain> hasReifiedReturnTypes;
-
hasReifiedEvents
public final ReadOnlySet<Domain> hasReifiedEvents
The set of all domains which have actual nested java inner classes defined within them. Event inner classes are not actually defined in any way that is different from standard inner types. Instead, they are just listed on their respective Java-Doc Pages as "Event Classes" which are only generated when the CDP API actually fires an event for them.
In the most recent parsing and generation of the "Browser API" from CDP, 33 out of the 47 Domains have actual, reified, events. You may see thetoString Outputfor this class by clicking the link.- Code:
- Exact Field Declaration Expression:
public final ReadOnlySet<Domain> hasReifiedEvents;
-
-
Method Detail
-
toString
public java.lang.String toString()
Generates aStringrepresentation of the contents of this'InfoData'instance. The only two instances of'InfoData'which are generated are the one for the "Browser API" along with the instance which represents Google's "JavaScript API"
The "See Also" link below provides a direct link to the two fields within the classSERIALIZED_ASTwhich contains a reference / pointer to an instance of this class.- Overrides:
toStringin classjava.lang.Object- Returns:
- A
Stringrepresentation / summary of one of the two API's. - See Also:
SERIALIZED_AST.browserDat,SERIALIZED_AST.jsDat- Code:
- Exact Method Body:
return "{\n" + " this.hasEnumStrLists:" + list(this.hasEnumStrLists) + " this.hasSimpleTypes:" + list(this.hasSimpleTypes) + " this.hasMarkerEvents:" + list(this.hasMarkerEvents) + " this.hasReifiedTypes:" + list(this.hasReifiedTypes) + " this.hasReifiedEvents:" + list(this.hasReifiedEvents) + '\n' + " this.eliminatedTypeNodes.size(): " + this.eliminatedTypeNodes.size() + '\n' + " this.simpleTypeNodes.size(): " + this.simpleTypeNodes.size() + '\n' + " this.enumValTypeNodes.size(): " + this.enumValTypeNodes.size() + '\n' + " this.markerEventNodes.size(): " + this.markerEventNodes.size() + '\n' + '\n' + " this.hasEnumStrLists.size(): " + this.hasEnumStrLists.size() + '\n' + " this.hasSimpleTypes.size(): " + this.hasSimpleTypes.size() + '\n' + " this.hasMarkerEvents.size(): " + this.hasMarkerEvents.size() + '\n' + 'n' + " this.hasReifiedTypes.size(): " + this.hasReifiedTypes.size() + '\n' + " this.hasReifiedReturnTypes.size(): " + this.hasReifiedReturnTypes.size() + '\n' + " this.hasReifiedEvents.size(): " + this.hasReifiedEvents.size() + '\n' + "}\n";
-
-