Java 类org.mozilla.javascript.Kit 实例源码

项目:whackpad    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:whackpad    文件:Main.java   
public Object run(Context cx)
{
    if (modulePath != null || mainModule != null) {
        require = global.installRequire(cx, modulePath, sandboxed);
    }
    if (type == PROCESS_FILES) {
        processFiles(cx, args);
    } else if (type == EVAL_INLINE_SCRIPT) {
        Script script = loadScriptFromSource(cx, scriptText,
                                             "<command>", 1, null);
        if (script != null) {
            evaluateScript(script, cx, getGlobal());
        }
    } else {
        throw Kit.codeBug();
    }
    return null;
}
项目:pizzascript    文件:MainWindow.java   
public FilePanel openFile(String filePath, boolean showDebugPane) {
    String source;
    try {
        Reader r = new FileReader(filePath);
        try {
            source = Kit.readReader(r);
        } finally {
            r.close();
        }
        SourceFile sourceFile = codeModel.newFile(source, filePath);
        sourceFile.setNewFile(false);
        sourceFile.setIsModified(false);
        return createFilePanel(sourceFile, showDebugPane);
    } catch (IOException ex) {
        MessageDialog.show(MainWindow.this,
                ex.getMessage(),
                "Error reading " + filePath,
                JOptionPane.ERROR_MESSAGE);
        return null;
    }
}
项目:code404    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:S3F    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:rhino-jscover    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:rhino-jscover    文件:ShellConsole.java   
private static JLineShellConsoleV1 getJLineShellConsoleV1(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompletor(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.Completor");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompletor", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV1(reader, cs);
}
项目:rhino-jscover    文件:ShellConsole.java   
private static JLineShellConsoleV2 getJLineShellConsoleV2(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompleter(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.console.completer.Completer");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompleter", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV2(reader, cs);
}
项目:astor    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:astor    文件:ShellConsole.java   
private static JLineShellConsoleV1 getJLineShellConsoleV1(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompletor(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.Completor");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompletor", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV1(reader, cs);
}
项目:astor    文件:ShellConsole.java   
private static JLineShellConsoleV2 getJLineShellConsoleV2(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompleter(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.console.completer.Completer");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompleter", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV2(reader, cs);
}
项目:Rhino-Prov-Mod    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:Rhino-Prov-Mod    文件:ShellConsole.java   
private static JLineShellConsoleV1 getJLineShellConsoleV1(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompletor(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.Completor");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompletor", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV1(reader, cs);
}
项目:Rhino-Prov-Mod    文件:ShellConsole.java   
private static JLineShellConsoleV2 getJLineShellConsoleV2(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompleter(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.console.completer.Completer");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompleter", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV2(reader, cs);
}
项目:closure-compiler-old    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:closure-compiler-old    文件:ShellConsole.java   
private static JLineShellConsoleV1 getJLineShellConsoleV1(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompletor(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.Completor");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompletor", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV1(reader, cs);
}
项目:closure-compiler-old    文件:ShellConsole.java   
private static JLineShellConsoleV2 getJLineShellConsoleV2(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompleter(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.console.completer.Completer");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompleter", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV2(reader, cs);
}
项目:closure-compiler-copy    文件:SwingGui.java   
/**
 * Reads the file with the given name and returns its contents as a String.
 */
private String readFile(String fileName) {
    String text;
    try {
        Reader r = new FileReader(fileName);
        try {
            text = Kit.readReader(r);
        } finally {
            r.close();
        }
    } catch (IOException ex) {
        MessageDialogWrapper.showMessageDialog(this,
                                               ex.getMessage(),
                                               "Error reading "+fileName,
                                               JOptionPane.ERROR_MESSAGE);
        text = null;
    }
    return text;
}
项目:closure-compiler-copy    文件:ShellConsole.java   
private static JLineShellConsoleV1 getJLineShellConsoleV1(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompletor(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.Completor");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompletor", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV1(reader, cs);
}
项目:closure-compiler-copy    文件:ShellConsole.java   
private static JLineShellConsoleV2 getJLineShellConsoleV2(
        ClassLoader classLoader, Class<?> readerClass, Scriptable scope,
        Charset cs) throws NoSuchMethodException, InstantiationException,
        IllegalAccessException, InvocationTargetException {
    // ConsoleReader reader = new ConsoleReader();
    Constructor<?> c = readerClass.getConstructor();
    Object reader = c.newInstance();

    // reader.setBellEnabled(false);
    tryInvoke(reader, "setBellEnabled", BOOLEAN_ARG, Boolean.FALSE);

    // reader.addCompleter(new FlexibleCompletor(prefixes));
    Class<?> completorClass = Kit.classOrNull(classLoader,
            "jline.console.completer.Completer");
    Object completor = Proxy.newProxyInstance(classLoader,
            new Class[] { completorClass },
            new FlexibleCompletor(completorClass, scope));
    tryInvoke(reader, "addCompleter", new Class[] {completorClass}, completor);

    return new JLineShellConsoleV2(reader, cs);
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:Main.java   
public Object run(Context cx) {
    if (useRequire) {
        require = global.installRequire(cx, modulePath, sandboxed);
    }
    if (type == PROCESS_FILES) {
        processFiles(cx, args);
    } else if (type == EVAL_INLINE_SCRIPT) {
        evalInlineScript(cx, scriptText);
    } else {
        throw Kit.codeBug();
    }
    return null;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:Main.java   
public void quit(Context cx, int exitCode) {
    if (type == SYSTEM_EXIT) {
        System.exit(exitCode);
        return;
    }
    throw Kit.codeBug();
}
项目:HL4A    文件:NativeRegExp.java   
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}
项目:Auto.js    文件:Main.java   
public Object run(Context cx) {
    if (useRequire) {
        require = global.installRequire(cx, modulePath, sandboxed);
    }
    if (type == PROCESS_FILES) {
        processFiles(cx, args);
    } else if (type == EVAL_INLINE_SCRIPT) {
        evalInlineScript(cx, scriptText);
    } else {
        throw Kit.codeBug();
    }
    return null;
}
项目:Auto.js    文件:Main.java   
public void quit(Context cx, int exitCode) {
    if (type == SYSTEM_EXIT) {
        System.exit(exitCode);
        return;
    }
    throw Kit.codeBug();
}
项目:whackpad    文件:Main.java   
public void quit(Context cx, int exitCode)
{
    if (type == SYSTEM_EXIT) {
        System.exit(exitCode);
        return;
    }
    throw Kit.codeBug();
}
项目:whackpad    文件:NativeRegExp.java   
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}
项目:whackpad    文件:XMLName.java   
public Object set(Context cx, Object value)
{
    if (xmlObject == null) {
        throw ScriptRuntime.undefWriteError(Undefined.instance,
                                            toString(),
                                            value);
    }
    // Assignment to descendants causes parse error on bad reference
    // and this should not be called
    if (isDescendants) throw Kit.codeBug();
    xmlObject.putXMLProperty(this, value);
    return value;
}
项目:TaleCraft    文件:NativeRegExp.java   
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}
项目:code404    文件:Main.java   
public Object run(Context cx)
{
    if (useRequire) {
        require = global.installRequire(cx, modulePath, sandboxed);
    }
    if (type == PROCESS_FILES) {
        processFiles(cx, args);
    } else if (type == EVAL_INLINE_SCRIPT) {
        evalInlineScript(cx, scriptText);
    } else {
        throw Kit.codeBug();
    }
    return null;
}
项目:code404    文件:Main.java   
public void quit(Context cx, int exitCode)
{
    if (type == SYSTEM_EXIT) {
        System.exit(exitCode);
        return;
    }
    throw Kit.codeBug();
}
项目:code404    文件:NativeRegExp.java   
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}
项目:code404    文件:XMLName.java   
public Object set(Context cx, Object value)
{
    if (xmlObject == null) {
        throw ScriptRuntime.undefWriteError(Undefined.instance,
                                            toString(),
                                            value);
    }
    // Assignment to descendants causes parse error on bad reference
    // and this should not be called
    if (isDescendants) throw Kit.codeBug();
    xmlObject.putXMLProperty(this, value);
    return value;
}
项目:S3F    文件:Main.java   
public Object run(Context cx)
{
    if (useRequire) {
        require = global.installRequire(cx, modulePath, sandboxed);
    }
    if (type == PROCESS_FILES) {
        processFiles(cx, args);
    } else if (type == EVAL_INLINE_SCRIPT) {
        evalInlineScript(cx, scriptText);
    } else {
        throw Kit.codeBug();
    }
    return null;
}
项目:S3F    文件:Main.java   
public void quit(Context cx, int exitCode)
{
    if (type == SYSTEM_EXIT) {
        System.exit(exitCode);
        return;
    }
    throw Kit.codeBug();
}
项目:rhino-jscover    文件:Main.java   
public Object run(Context cx)
{
    if (useRequire) {
        require = global.installRequire(cx, modulePath, sandboxed);
    }
    if (type == PROCESS_FILES) {
        processFiles(cx, args);
    } else if (type == EVAL_INLINE_SCRIPT) {
        evalInlineScript(cx, scriptText);
    } else {
        throw Kit.codeBug();
    }
    return null;
}
项目:rhino-jscover    文件:Main.java   
public void quit(Context cx, int exitCode)
{
    if (type == SYSTEM_EXIT) {
        System.exit(exitCode);
        return;
    }
    throw Kit.codeBug();
}
项目:rhino-jscover    文件:NativeRegExp.java   
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}
项目:rhino-jscover    文件:XMLName.java   
public Object set(Context cx, Object value)
{
    if (xmlObject == null) {
        throw ScriptRuntime.undefWriteError(Undefined.instance,
                                            toString(),
                                            value);
    }
    // Assignment to descendants causes parse error on bad reference
    // and this should not be called
    if (isDescendants) throw Kit.codeBug();
    xmlObject.putXMLProperty(this, value);
    return value;
}
项目:LoboEvolution    文件:NativeRegExp.java   
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}