php.java.script
Class URLReader

java.lang.Object
  extended by java.io.Reader
      extended by php.java.script.URLReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class URLReader
extends java.io.Reader

This class can be used to connect to a HTTP server to allocate and to invoke php scripts. Example:

PhpScriptEngine e = new PhpScriptEngine();
e.eval(new URLReader(new URL("http://localhost:80/foo.php"));
System.out.println(((Invocable)e).invoke("java_get_server_name", new Object[]{}));
e.release();

Author:
jostb

Constructor Summary
URLReader(java.net.URL url)
          Create a special reader which can be used to read data from a URL.
 
Method Summary
 void close()
           
 java.net.URL getURL()
          Returns the URL to which this reader connects.
 int read(char[] cbuf, int off, int len)
           
 void read(java.util.Map env, java.io.OutputStream out)
          Read from the URL and write the data to out.
 java.lang.String toString()
          
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLReader

public URLReader(java.net.URL url)
          throws java.net.UnknownHostException,
                 java.io.IOException
Create a special reader which can be used to read data from a URL.

Parameters:
url -
Throws:
java.io.IOException
java.net.UnknownHostException
Method Detail

getURL

public java.net.URL getURL()
Returns the URL to which this reader connects.

Returns:
the URL.

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
NotImplementedException
java.io.IOException
See Also:
read(Map, OutputStream)

read

public void read(java.util.Map env,
                 java.io.OutputStream out)
          throws java.io.IOException
Read from the URL and write the data to out.

Parameters:
env - The environment, must contain values for X_JAVABRIDGE_CONTEXT. It may contain X_JAVABRIDGE_OVERRIDE_HOSTS.
out - The OutputStream.
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
NotImplementedException
java.io.IOException
See Also:
read(Map, OutputStream)

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object