Class TypeDeclarationFactory


  • public class TypeDeclarationFactory
    extends java.lang.Object
    TypeDeclarationFactory contains cache of TypeDeclarations for to make the lookup of JavaScript types as efficient as possible.
    • Constructor Detail

      • TypeDeclarationFactory

        public TypeDeclarationFactory()
    • Method Detail

      • setTypeDeclarationVersion

        public java.util.List<java.lang.String> setTypeDeclarationVersion​(java.lang.String ecmaVersion,
                                                                          boolean xmlSupported,
                                                                          boolean client)
      • getDefaultECMAVersion

        protected java.lang.String getDefaultECMAVersion()
        Returns:
        Default base ECMA implementation
      • getAllJavaScriptTypes

        public java.util.List<TypeDeclaration> getAllJavaScriptTypes()
      • removeType

        public void removeType​(java.lang.String name)
        Removes declaration type from type cache
        Parameters:
        name - name of type declaration
      • isJavaScriptType

        public boolean isJavaScriptType​(TypeDeclaration td)
        Returns whether the qualified name is a built-in JavaScript type
        Parameters:
        td - The type declaration to check.
        Returns:
        Whether it is a built-in JS type.
      • getTypeDeclaration

        public TypeDeclaration getTypeDeclaration​(java.lang.String name)
        Parameters:
        name -
        Returns:
        Lookup type declaration from name. If the TypeDeclaration cannot be found, then lookup using reserve lookup
      • getJSTypeDeclarationAsString

        private java.lang.String getJSTypeDeclarationAsString​(java.lang.String name)
        Parameters:
        name - of TypeDeclaration to lookup
        Returns:
        lookup TypeDeclaration and return the JavaScript name
      • convertJavaScriptType

        public java.lang.String convertJavaScriptType​(java.lang.String lookupName,
                                                      boolean qualified)
        The API may have its own types, so these need converting back to JavaScript types e.g. JSString == String, JSNumber == Number
      • getDefaultTypeDeclaration

        public TypeDeclaration getDefaultTypeDeclaration()
        Returns:
        default type declaration - ANY
      • addType

        public void addType​(java.lang.String name,
                            TypeDeclaration dec)
      • getClassName

        public java.lang.String getClassName​(java.lang.String lookup)
                                      throws java.lang.RuntimeException
        Throws:
        java.lang.RuntimeException
      • canJavaScriptBeInstantiated

        public boolean canJavaScriptBeInstantiated​(java.lang.String name)
        Answers the question whether an object can be instantiated (i.e. has a constructor)
        Parameters:
        name - name of class to test