001package Torello.Browser.JsonAST; 002 003import java.io.File; 004import Torello.Java.LFEC; 005 006/** 007 * This class is the primary User-Interaction API class. This class will load the "already parsed" 008 * a.k.a. the "already generated" AST Object Instances from the Java-HTML {@code '.jar'} File into 009 * memory from disk. This class uses the standard JDK Object serialization and de-serialization 010 * techniques. 011 * 012 * <EMBED CLASS='external-html' DATA-FILE-ID=SERIALIZED_AST> 013 */ 014public class SERIALIZED_AST implements java.io.Serializable 015{ 016 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 017 protected static final long serialVersionUID = 1; 018 019 /** 020 * The Java-HTML {@code '.jar'} File contains a data-file by this name. Using standard Java 021 * Serialization, both Google's "JavaScript API" and Google's "Browser API" have had their 022 * Abstract Syntax Tree's serialized (saved) to disk. 023 * 024 * <BR /><BR /> 025 * If you don't remember how to load a serialized data-file into memory, there is a simple 026 * method in this class which does just that. (See {@link #deserializeFromJAR()}) 027 * 028 */ 029 public static final String FILE_NAME_JAR = "SerializedAST.dat"; 030 031 /** 032 * This is an instance field, and after the AST's have been loaded from the {@code '.jar'} 033 * file, this field will contain the Abstract Syntax Tree for Google's "Browser API" suite of 034 * methods, types and events. 035 * 036 * <BR /><BR /> 037 * Remember that all of the public-facing methods & fields in the AST nodes are declared 038 * {@code 'final'}. Any lists or sets present in these nodes have been built with classes from 039 * Java-HTML's "Read Only" Package. It is impossible to break, ruin or screw-up these trees. 040 * <B STYLE='color: red;'><I>They, and their contents, are perfectly immutable!</I></B> 041 * 042 * @see #deserializeFromJAR() 043 */ 044 public final API browserAPI; 045 046 /** 047 * This is an instance field, and after the AST's have been loaded from the {@code '.jar'} 048 * file, this field will contain the Abstract Syntax Tree for Google's "JavaScript API" suite 049 * of methods, types and events. 050 * 051 * <BR /><BR /> 052 * Remember that all of the public-facing methods & fields in the AST nodes are declared 053 * {@code 'final'}. Any lists or sets present in these nodes have been built with classes from 054 * Java-HTML's "Read Only" Package. It is impossible to break, ruin or screw-up these trees. 055 * <B STYLE='color: red;'><I>They, and their contents, are perfectly immutable!</I></B> 056 * 057 * @see #deserializeFromJAR() 058 */ 059 public final API jsAPI; 060 061 /** 062 * This is some rather boring "facts" about the classes and methods in the AST ("the tree"). 063 * This data-field and group of Read-Only "sets" and "lists" exists solely to make the actual 064 * code written for the (proprietary, and non-visible) Java-HTML Browser Package Code Generator 065 * look a little nicer and a little bit easier to read. 066 * 067 * <BR /><BR /> 068 * You may review these lists; they aren't that interesting. The contents of the 069 * {@link InfoData} are all declared {@code 'final'} and typed using "Read Only" data-types. 070 * They are perfectly immutable, and you cannot "screw them up" or anything like that. 😀😀 071 */ 072 public final InfoData browserDat; 073 074 /** 075 * This is some rather boring "facts" about the classes and methods in the AST ("the tree"). 076 * This data-field and group of Read-Only "sets" and "lists" exists solely to make the actual 077 * code written for the (proprietary, and non-visible) Java-HTML Browser Package Code Generator 078 * look a little nicer and a little bit easier to read. 079 * 080 * <BR /><BR /> 081 * You may review these lists; they aren't that interesting. The contents of the 082 * {@link InfoData} are all declared {@code 'final'} and typed using "Read Only" data-types. 083 * They are perfectly immutable, and you cannot "screw them up" or anything like that. 😀😀 084 */ 085 public final InfoData jsDat; 086 087 SERIALIZED_AST( 088 final API browserAPI, 089 final API jsAPI, 090 final InfoData browserDat, 091 final InfoData jsDat 092 ) 093 { 094 this.browserAPI = browserAPI; 095 this.jsAPI = jsAPI; 096 this.browserDat = browserDat; 097 this.jsDat = jsDat; 098 } 099 100 /** 101 * Reads both {@link API API's} (the "Browser API" and the "JavaScript API") from disk, and 102 * into Java Memory. The {@code 'API'} class is the root node of an Abstract Syntax Treee, 103 * or AST. It is just the "Java-ized" variant of the Protocol-API which Google has specified 104 * using the two {@code '.json'} files: 105 * 106 * <BR /><BR /><UL CLASS=JDUL> 107 * <LI><B><CODE><A HREF='../doc-files/protocol_as_json/browser_protocol.json'> 108 * browser_protocol.json</A></CODE></B></LI> 109 * 110 * <LI><B><CODE><A HREF='../doc-files/protocol_as_json/js_protocol.json'> 111 * js_protocol.json</A></CODE></B></LI> 112 * </UL> 113 * 114 * @return An instance of this class, with all four data-fields properly initialized. 115 * @see LFEC#readObjectFromFile_JAR(Class, String, boolean, Class) 116 */ 117 public static SERIALIZED_AST deserializeFromJAR() 118 { 119 // readObjectFromFile_JAR 120 // ( 121 // Class<?> classLoaderClass, 122 // String f, 123 // boolean zip, 124 // Class<T> returnClass 125 // ) 126 127 return LFEC.readObjectFromFile_JAR( 128 SERIALIZED_AST.class, 129 "data-files" + File.separator + FILE_NAME_JAR, 130 true, 131 SERIALIZED_AST.class 132 ); 133 } 134}