Package Torello.Browser.JsonAST
Class EventNode
- java.lang.Object
-
- Torello.Browser.JsonAST.Entity
-
- Torello.Browser.JsonAST.TCE
-
- Torello.Browser.JsonAST.EventNode
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Entity>
public class EventNode extends TCE implements java.io.Serializable
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.An Java Object used within AST to symbolize or encapsulate the data present in any of theJsonObject'sfound within aDomain's"events"array.
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/EventNode.java
- Open New Browser-Tab: Torello/Browser/JsonAST/EventNode.java
File Size: 5,512 Bytes Line Count: 127 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field Description protected static longserialVersionUIDStatic Field: Internally Used String List. EventNode Specific JsonObject Property-Names Modifier and Type Field Description protected static ReadOnlySet<String>EVENT_JSON_PROPERTIES_SETThe list of additionalJsonObjectproperties that the parser should expect when parsingEventNodeobjects from the JSON CDP specification files.Instance Fields: List of PPR (Parameter) instances which Will Generate into Event-Class Fields Modifier and Type Field Description ReadOnlyList<PPR>parametersCollection of PPR (Parameter) instances that will be materialized as Java Event-Class fieldsInstance Fields: Fundamental Details about this EventNode Modifier and Type Field Description booleanisReifiedInnerClassFlag indicating whether this EventNode represents a reified inner class in the CDP model.-
Fields inherited from class Torello.Browser.JsonAST.Entity
arrItemsTypeProp, deprecated, description, enumVals, enumValsStr, experimental, id, index, name, optional, ownerDomain, propNames, typeProp, whichEntity
-
-
Method Summary
Methods: interface java.lang.Iterable Modifier and Type Method Description Iterator<PPR>iterator()Returns anIteratorthat iterates the contents of theparameterslist.Methods: class java.lang.Object Modifier and Type Method Description StringtoString()Returns aStringrepresentation of'this'instance.-
Methods inherited from class Torello.Browser.JsonAST.TCE
toStringShort
-
Methods inherited from class Torello.Browser.JsonAST.Entity
compareTo, equals, exceptionLocationSummary, hashCode
-
-
-
-
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;
-
EVENT_JSON_PROPERTIES_SET
protected static final ReadOnlySet<java.lang.String> EVENT_JSON_PROPERTIES_SET
The list of additionalJsonObjectproperties that the parser should expect when parsingEventNodeobjects from the JSON CDP specification files.- Code:
- Exact Field Declaration Expression:
protected static final ReadOnlySet<String> EVENT_JSON_PROPERTIES_SET = new ReadOnlyTreeSet<>(String::compareTo, "name", "parameters");
-
parameters
public final ReadOnlyList<PPR> parameters
Collection of PPR (Parameter) instances that will be materialized as Java Event-Class fields
The CDP JSON Specification Files allocate a"parameters"array for mostJsonObject"event"elements in the specs. Each of the objects in the"parameters"array are, themselves, constructed & instantiated into instances of classPPR.
And each and everyPPRwill eventually be converted in a Java Field which is a member of the container"event"(astaticnested class) in which they were specified.- Code:
- Exact Field Declaration Expression:
public final ReadOnlyList<PPR> parameters;
-
isReifiedInnerClass
public final boolean isReifiedInnerClass
Flag indicating whether this EventNode represents a reified inner class in the CDP model.
A "Reified Class" is an instance of aEventNodefor which the Code Generator shall emit astaticJava nested type as astaticmember of theownerDomainclass. In short, if anEventNode's 'isReifiedInnerClass' booleanhas been assignedTRUE, then you should be able to count on finding a nested type in the Generated Java Class for the domain in which thatEventNoderesides.
As an example, in theBrowserAPI, the first domain which is listed is theAccessibilitydomain. Inside that domain, the first nested type / inner class listed is one namedAccessibility.loadComplete. The inner classloadCompleteis, indeed, astaticnested inner class; and if you were to traverse or "search" the AST tree for the following nodes:
BrowserAPI(APINode) ➜Accessibility(Domain) ➜loadComplete(EventNode)
and check the value of itsisReifiedInnerClassflag, you would see instantly that it had been assignedTRUE, precisely because the Code Generator intentionally generated that nested class to represent this particularEventNodeWhat is important to know is that within the CDP JSON Specifications, not all"events"have been declared or created equal. Any type which has at least onePPRproperty in itsparametersarray will be reified into its own, dedicated, Java Nested Class.
Some events, simply called "Marker Events" by the docs in this library (although they are not likely known by that name elsewhere), are events which do not possess any state whatsoever. And when they are fired by the browser, since there is nothing to relay to the user, other than the fact that the event did fire, they are not "reified" into actual Java Classes. In english this means that the internal Java-HTML Code Generator will not produce an actual Java Class for that event.
Instead, when they are fired a genericBrowserEventis transmitted to the programmer's Event Listener, with theBrowserEvent'sfieldsnameanddomainbeing sent to the domain and event name that have been fired.- Code:
- Exact Field Declaration Expression:
public final boolean isReifiedInnerClass;
-
-
Method Detail
-
iterator
public java.util.Iterator<PPR> iterator()
Returns anIteratorthat iterates the contents of theparameterslist.- See Also:
parameters,RemoveUnsupportedIterator- Code:
- Exact Method Body:
return this.parameters.iterator();
-
toString
public java.lang.String toString()
Returns aStringrepresentation of'this'instance.- Overrides:
toStringin classjava.lang.Object- Code:
- Exact Method Body:
return StringTCE.get(this);
-
-