// Path: src/main/java/java/util/Date.java
// public class Date {
// 
//     private Object nativeDate;
//     
//     public Date() {
//         ScriptHelper.eval("this.nativeDate = new Date()");
//     }
// 
//     public Date(long millis) {
//         ScriptHelper.put("millis", millis);
//         ScriptHelper.eval("this.nativeDate = new Date(millis)");
//     }
// 
//     public long getTime() {
//         return ScriptHelper.evalLong("this.nativeDate.getTime()");
//     }
// 
//     public void setTime(long millis) {
//         ScriptHelper.put("millis", millis);
//         ScriptHelper.eval("this.nativeDate.setTime(millis)");
//     }
// 
//     public boolean equals(Object obj) {
//         Date other = (Date) obj;
//         return getTime() == other.getTime();
//     }
// 
//     public int hashCode() {
//         long time = getTime();
//         return (int) (time^(time >>> 32));
//     }
// 
//     public String toString() {
//         return (String) ScriptHelper.eval("this.nativeDate.toGMTString()");   
//     }
// }
// 
// Path: src/main/java/javascript/ScriptHelper.java
// public final class ScriptHelper {
//     
//     /**
//      * Sets a key/value pair of <code>Object</type> type.
//      */
//     public static native void put(String s, Object value);
//     
//     /**
//      * Sets a key/value pair of <code>boolean</code> type.
//      */
//     public static native void put(String s, boolean value);
//     
//     /**
//      * Sets a key/value pair of <code>primitive</code> type,
//      * except of type <code>boolean</code>.
//      */
//     public static native void put(String s, double value);
//     
//     //public static native Object get(String s);
// 
//     /**
//      * Executes the specified script.
//      * <b>Important</b>: In the current version the script must be a string literal.
//      * 
//      * @return the object returned by the JavaScript code
//      */
//     public static native Object eval(String script);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns an int.
//      */
//     public static native int evalInt(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a long.
//      */
//     public static native long evalLong(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns float.
//      */
//     public static native float evalFloat(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a double.
//      */
//     public static native double evalDouble(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a char.
//      */
//     public static native char evalChar(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a boolean.
//      */
//     public static native boolean evalBoolean(String jsCode);
// }


import javascript.ScriptHelper;
import java.util.Calendar;
import java.util.Date;
        ScriptHelper.put("d", d);
        return (String) ScriptHelper.eval("String(d)");
    }
    
    /**
     *    Splits this string around matches of the given regular expression.
     */
    public String[] split(String regex) {
        ScriptHelper.put("regex", regex);
        // String.prototype.split(separator, limit) accepts both a string and a regular expression as separator.
        // However, the string is not converted to a regular expression, so we have to do it.
        return (String[]) ScriptHelper.eval("this.split(new RegExp(regex))");
    }
    
    /**
     * Tells whether or not this string matches the given regular expression.
     */
    public boolean matches(String regex) {
        ScriptHelper.put("regex", "^" + regex + "$");
        return ScriptHelper.evalBoolean("this.match(new RegExp(regex))!=null");
    }
 
    private String replace(String regex, String flags, String replacement) {
        // \a -> a
        // \\ -> \
        // \" -> "
        // \n -> newline
        // \newline -> newline
        
        ScriptHelper.put("regex", regex);
// Path: src/main/java/java/util/Date.java
// public class Date {
// 
//     private Object nativeDate;
//     
//     public Date() {
//         ScriptHelper.eval("this.nativeDate = new Date()");
//     }
// 
//     public Date(long millis) {
//         ScriptHelper.put("millis", millis);
//         ScriptHelper.eval("this.nativeDate = new Date(millis)");
//     }
// 
//     public long getTime() {
//         return ScriptHelper.evalLong("this.nativeDate.getTime()");
//     }
// 
//     public void setTime(long millis) {
//         ScriptHelper.put("millis", millis);
//         ScriptHelper.eval("this.nativeDate.setTime(millis)");
//     }
// 
//     public boolean equals(Object obj) {
//         Date other = (Date) obj;
//         return getTime() == other.getTime();
//     }
// 
//     public int hashCode() {
//         long time = getTime();
//         return (int) (time^(time >>> 32));
//     }
// 
//     public String toString() {
//         return (String) ScriptHelper.eval("this.nativeDate.toGMTString()");   
//     }
// }
// 
// Path: src/main/java/javascript/ScriptHelper.java
// public final class ScriptHelper {
//     
//     /**
//      * Sets a key/value pair of <code>Object</type> type.
//      */
//     public static native void put(String s, Object value);
//     
//     /**
//      * Sets a key/value pair of <code>boolean</code> type.
//      */
//     public static native void put(String s, boolean value);
//     
//     /**
//      * Sets a key/value pair of <code>primitive</code> type,
//      * except of type <code>boolean</code>.
//      */
//     public static native void put(String s, double value);
//     
//     //public static native Object get(String s);
// 
//     /**
//      * Executes the specified script.
//      * <b>Important</b>: In the current version the script must be a string literal.
//      * 
//      * @return the object returned by the JavaScript code
//      */
//     public static native Object eval(String script);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns an int.
//      */
//     public static native int evalInt(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a long.
//      */
//     public static native long evalLong(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns float.
//      */
//     public static native float evalFloat(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a double.
//      */
//     public static native double evalDouble(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a char.
//      */
//     public static native char evalChar(String jsCode);
//     
//     /**
//      * Same as {@link ScriptHelper#eval(String)}, but returns a boolean.
//      */
//     public static native boolean evalBoolean(String jsCode);
// }


// Path: src/main/java/java/lang/String.java
import javascript.ScriptHelper;
import java.util.Calendar;
import java.util.Date;

        ScriptHelper.put("d", d);
        return (String) ScriptHelper.eval("String(d)");
    }
    
    /**
     *    Splits this string around matches of the given regular expression.
     */
    public String[] split(String regex) {
        ScriptHelper.put("regex", regex);
        // String.prototype.split(separator, limit) accepts both a string and a regular expression as separator.
        // However, the string is not converted to a regular expression, so we have to do it.
        return (String[]) ScriptHelper.eval("this.split(new RegExp(regex))");
    }
    
    /**
     * Tells whether or not this string matches the given regular expression.
     */
    public boolean matches(String regex) {
        ScriptHelper.put("regex", "^" + regex + "$");
        return ScriptHelper.evalBoolean("this.match(new RegExp(regex))!=null");
    }
 
    private String replace(String regex, String flags, String replacement) {
        // \a -> a
        // \\ -> \
        // \" -> "
        // \n -> newline
        // \newline -> newline
        
        ScriptHelper.put("regex", regex);
        ScriptHelper.put("flags", flags);