com.hammurapi.common

## Class ScriptURLStreamHandler

- java.lang.Object
- - java.net.URLStreamHandler
  - - com.hammurapi.common.ScriptURLStreamHandler

-     public class ScriptURLStreamHandler
      extends URLStreamHandler

  This class handles `script` protocol/schema and evaluates expressions using Java Scripting framework. Expression language extension is passed as authority and expression is passed as path, e.g. `script://java/myObject.toString()`. Evaluation result is converted to input stream in the following way: a) If it is input stream then it is returned as is. b) If it is Reader then it is wrapped into input stream. c) If it is null, then null is returned. d) Result is converted to String with toString() method and string bytes are returned as input stream.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SCRIPT_PROTOCOL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ScriptURLStreamHandler(ClassLoader classLoader, Map<String,Object> bindings)`
    `ScriptURLStreamHandler(Map<String,Object> bindings)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(String[] args)`
    `protected URLConnection` | `openConnection(URL u)`

    - ### Methods inherited from class java.net.URLStreamHandler

      `equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, parseURL, sameFile, setURL, setURL, toExternalForm`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SCRIPT_PROTOCOL

          public static final String SCRIPT_PROTOCOL

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ScriptURLStreamHandler

          public ScriptURLStreamHandler(ClassLoader classLoader,
                                Map<String,Object> bindings)

      Parameters:
        `classLoader` - ClassLoader to use to load script engines and other classes.
        `bindings` - Bindings for evaluating script expression.

    - #### ScriptURLStreamHandler

          public ScriptURLStreamHandler(Map<String,Object> bindings)

      Parameters:
        `bindings` - Bindings for evaluating script expression.

  - ### Method Detail

    - #### main

          public static void main(String[] args)
                           throws Exception

      Throws:
        `Exception`

    - #### openConnection

          protected URLConnection openConnection(URL u)
                                          throws IOException

      Specified by:
        `openConnection` in class `URLStreamHandler`
      Throws:
        `IOException`