| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
php.java.script.URLReader
public class URLReader
This class can be used to connect to a HTTP server to allocate and to invoke php scripts. Example:
 
 ScriptEngine e = new ScriptEngineManager().getEngineByName("php-invocable");
 e.eval(new URLReader(new URL("http://localhost:80/JavaProxy.php"));
 System.out.println(((Invocable)e).invoke("java_get_server_name", new Object[]{}));
 ((Closeable)e).close();
 
| Field Summary | 
|---|
| Fields inherited from interface php.java.script.IScriptReader | 
|---|
| HEADER | 
| Constructor Summary | |
|---|---|
| URLReader(java.net.HttpURLConnection conn)Create a special reader which can be used to read data from a URL. | |
| 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,
     HeaderParser headerParser)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 | 
|---|
public URLReader(java.net.URL url)
          throws java.net.UnknownHostException,
                 java.io.IOException
url - 
java.io.IOException
java.net.UnknownHostExceptionpublic URLReader(java.net.HttpURLConnection conn)
 
 URL url = new URL("http://....");
 HttpURLConnection conn = (HttpURLConnection)url.openConnection();
 conn.setDoInput(true);
 conn.setRequestMethod("GET");
 conn.setRequestProperty ("SOME_VAR", SOME_VAL);
 scriptEngine.eval(new URLReader(conn));
 ((Invocable)scriptEngine).invokeFunction(...);
 ((Closeable)scriptEngine).close();
 
 
conn - the URL connection| Method Detail | 
|---|
public java.net.URL getURL()
public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
read in class java.io.Readerjava.io.IOException
public void read(java.util.Map env,
                 java.io.OutputStream out,
                 HeaderParser headerParser)
          throws java.io.IOException
IScriptReader
read in interface IScriptReaderenv - The environment, must contain values for X_JAVABRIDGE_CONTEXT. It may contain X_JAVABRIDGE_OVERRIDE_HOSTS.out - The OutputStream.headerParser - The header parser
java.io.IOException
public void close()
           throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.Readerjava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||