dojo/_base/_loader/hostenv_rhino.js

  • Provides:

    • dojo
  • dojo.byId

    • type
      Function
    • parameters:
      • id: (typeof )
      • doc: (typeof )
    • source: [view]
        if(id && (typeof id == "string" || id instanceof String)){
         if(!doc){ doc = document; }
         return doc.getElementById(id);
        }
        return id; // assume it's a node
    • returns
      assume it's a node
    • summary
  • dojo._isLocalUrl

    • type
      Function
    • parameters:
      • uri: (typeof String)
    • source: [view]
       var local = (new java.io.File(uri)).exists();
       if(!local){
        var stream;
        //Try remote URL. Allow this method to throw,
        //but still do cleanup.
        try{
         // try it as a file first, URL second
         stream = (new java.net.URL(uri)).openStream();
         // close the stream so we don't leak resources
         stream.close();
        }finally{
         if(stream && stream.close){
          stream.close();
         }
        }
       }
       return local;
    • summary
      determines if URI is local or not.
  • dojo._loadUri

    • type
      Function
    • parameters:
      • uri: (typeof )
      • cb: (typeof )
    • source: [view]
       if(dojo._loadedUrls[uri]){
        return true; // Boolean
       }
       try{
        var local;
        try{
         local = dojo._isLocalUrl(uri);
        }catch(e){
         // no debug output; this failure just means the uri was not found.
         return false;
        }


        dojo._loadedUrls[uri] = true;
        //FIXME: Use Rhino 1.6 native readFile/readUrl if available?
        if(cb){
         var contents = (local ? readText : readUri)(uri, "UTF-8");


         // patch up the input to eval until https://bugzilla.mozilla.org/show_bug.cgi?id=471005 is fixed.
         if(!eval("'\u200f'").length){
          contents = String(contents).replace(/[\u200E\u200F\u202A-\u202E]/g, function(match){
           return "\\u" + match.charCodeAt(0).toString(16);
          })
         }
         contents = /^define\(/.test(contents) ? contents : '('+contents+')';
         cb(eval(contents));
        }else{
         load(uri);
        }
        dojo._loadedUrls.push(uri);
        return true;
       }catch(e){
        dojo._loadedUrls[uri] = false;
        console.debug("rhino load('" + uri + "') failed. Exception: " + e);
        return false;
       }
    • returns
      Boolean
    • summary
  • dojo.exit

    • type
      Function
    • parameters:
      • exitcode: (typeof )
    • source: [view]
       quit(exitcode);
    • summary
  • readText

    • type
      Function
    • parameters:
      • path: (typeof )
      • encoding: (typeof )
    • source: [view]
       encoding = encoding || "utf-8";
       // NOTE: we intentionally avoid handling exceptions, since the caller will
       // want to know
       var jf = new java.io.File(path);
       var is = new java.io.FileInputStream(jf);
       return dj_readInputStream(is, encoding);
    • summary
  • readUri

    • type
      Function
    • parameters:
      • uri: (typeof )
      • encoding: (typeof )
    • source: [view]
       var conn = (new java.net.URL(uri)).openConnection();
       encoding = encoding || conn.getContentEncoding() || "utf-8";
       var is = conn.getInputStream();
       return dj_readInputStream(is, encoding);
    • summary
  • dj_readInputStream

    • type
      Function
    • parameters:
      • is: (typeof )
      • encoding: (typeof )
    • source: [view]
       var input = new java.io.BufferedReader(new java.io.InputStreamReader(is, encoding));
       try {
        var sb = new java.lang.StringBuffer();
        var line = "";
        while((line = input.readLine()) !== null){
         sb.append(line);
         sb.append(java.lang.System.getProperty("line.separator"));
        }
        return sb.toString();
       } finally {
        input.close();
       }
    • summary
  • dojo._getText

    • type
      Function
    • parameters:
      • uri: (typeof URI)
        A relative or absolute uri.
      • fail_ok: (typeof Boolean)
        Default false. If fail_ok and loading fails, return null
        instead of throwing.
    • source: [view]
       try{
        var local = dojo._isLocalUrl(uri);
        var text = (local ? readText : readUri)(uri, "UTF-8");
        if(text !== null){
         //Force JavaScript string.
         text += "";
        }
        return text;
       }catch(e){
        if(fail_ok){
         return null;
        }else{
         throw e;
        }
       }
    • summary
      Read the contents of the specified uri and return those contents.
    • return_summary
      The response text. null is returned when there is a
      failure and failure is okay (an exception otherwise)
  • dojo.body

    • type
      Function
    • source: [view]
       return document.body;
    • summary
  • clearTimeout

    • type
      Function
    • parameters:
      • idx: (typeof )
    • source: [view]
        if(!dojo._timeouts[idx]){ return; }
        dojo._timeouts[idx].stop();
    • summary
  • setTimeout

    • type
      Function
    • parameters:
      • func: (typeof )
      • delay: (typeof )
    • source: [view]
        var def={
         sleepTime:delay,
         hasSlept:false,

        
         run:function(){
          if(!this.hasSlept){
           this.hasSlept=true;
           java.lang.Thread.currentThread().sleep(this.sleepTime);
          }
          try{
           func();
          }catch(e){
           console.debug("Error running setTimeout thread:" + e);
          }
         }
        };

       
        var runnable = new java.lang.Runnable(def);
        var thread = new java.lang.Thread(runnable);
        thread.start();
        return dojo._timeouts.push(thread)-1;
    • summary
      provides timed callbacks using Java threads
  • setTimeout.hasSlept

    • summary
  • dojo.baseUrl

    • summary
  • dojo.locale

    • summary
  • dojo._name

    • summary
  • dojo.isRhino

    • summary
  • console.debug

    • summary
  • dojo.doc

    • summary
  • dojo._timeouts

    • summary
  • dojo

    • type
      Object
    • summary