1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package Torello.Browser.JsonAST;

/**
 * This method is used to convert a CDP "domain" (which essentially the same as a Java "Package"),
 * that is represented as a {@code String}, and convert it into a reference to one of the 
 * {@link Domain} object references.  Just as a reminder, inside of a Web Browser, a "domain" seems
 * to be extremely similar to the concept of a Java "Package".  CDP calls them "domains" instead of
 * packages, and they just group together methods, classes & event classes which are related.
 * 
 * <BR /><BR />
 * Essentially this performs:
 * 
 * <DIV CLASS=EXAMPLE>{@code
 * // The following code would print the string representation of the CDP Domain whose 
 * // ==> domain.name.equals("Target");
 * 
 * final Domain d = Helper$FindDomain.find("Target");
 * System.out.println(d.toString());
 * }</DIV>
 */
@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="LINKER_JDHBI")
public class Helper$FindDomain
{
    private Helper$FindDomain() { }

    private static API browser, js;

    static void initialize(final API browser, final API js)
    {
        Helper$FindDomain.browser   = browser;
        Helper$FindDomain.js        = js;
    }


    // And here it all is!  In all its glory and its majesty.
    // You give me a "Domain Name" (as a String),
    // I convert that into a Pointer / Reference to an actual AST Node from the Tree whose name
    // actually is "domainName" - the String you just gave me
    // 
    // Remember, search both the JavaScript API, and the Browser API
    // Pretend they are basically part of the same thing (the two, together, comprise the CDP API)

    static Domain find(final String domainName)
    {
        Domain ret = Helper$FindDomain.js.findDomain(domainName);
        if (ret != null) return ret;

        ret = Helper$FindDomain.browser.findDomain(domainName);
        if (ret != null) return ret;

        throw new LinkingStateError("Cannot find the domain: " + domainName);
    }
}