当前位置: 首页>>代码示例>>Java>>正文


Java ScriptRuntime.toBoolean方法代码示例

本文整理汇总了Java中org.mozilla.javascript.ScriptRuntime.toBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.toBoolean方法的具体用法?Java ScriptRuntime.toBoolean怎么用?Java ScriptRuntime.toBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mozilla.javascript.ScriptRuntime的用法示例。


在下文中一共展示了ScriptRuntime.toBoolean方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: js_getInt

import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private Object js_getInt(int bytes, boolean signed, Object[] args)
{
    checkOffset(args, 0);

    int pos = ScriptRuntime.toInt32(args[0]);
    rangeCheck(pos, bytes);

    boolean littleEndian =
        (isArg(args, 1) && (bytes > 1) && ScriptRuntime.toBoolean(args[1]));

    switch (bytes) {
    case 1:
        return (signed ? ByteIo.readInt8(arrayBuffer.buffer, offset + pos) :
                         ByteIo.readUint8(arrayBuffer.buffer, offset + pos));
    case 2:
        return (signed ? ByteIo.readInt16(arrayBuffer.buffer, offset + pos, littleEndian) :
                         ByteIo.readUint16(arrayBuffer.buffer, offset + pos, littleEndian));
    case 4:
        return (signed ? ByteIo.readInt32(arrayBuffer.buffer, offset + pos, littleEndian) :
                         ByteIo.readUint32(arrayBuffer.buffer, offset + pos, littleEndian));
    default:
        throw new AssertionError();
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:25,代码来源:NativeDataView.java

示例2: js_getFloat

import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private Object js_getFloat(int bytes, Object[] args)
{
    checkOffset(args, 0);

    int pos = ScriptRuntime.toInt32(args[0]);
    rangeCheck(pos, bytes);

    boolean littleEndian =
        (isArg(args, 1) && (bytes > 1) && ScriptRuntime.toBoolean(args[1]));

    switch (bytes) {
    case 4:
        return ByteIo.readFloat32(arrayBuffer.buffer, offset + pos, littleEndian);
    case 8:
        return ByteIo.readFloat64(arrayBuffer.buffer, offset + pos, littleEndian);
    default:
        throw new AssertionError();
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:20,代码来源:NativeDataView.java

示例3: js_setFloat

import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void js_setFloat(int bytes, Object[] args)
{
    checkOffset(args, 0);
    checkValue(args, 1);

    int pos = ScriptRuntime.toInt32(args[0]);
    rangeCheck(pos, bytes);

    boolean littleEndian =
        (isArg(args, 2) && (bytes > 1) && ScriptRuntime.toBoolean(args[2]));
    double val = ScriptRuntime.toNumber(args[1]);

    switch (bytes) {
    case 4:
        ByteIo.writeFloat32(arrayBuffer.buffer, offset + pos, val, littleEndian);
        break;
    case 8:
        ByteIo.writeFloat64(arrayBuffer.buffer, offset + pos, val, littleEndian);
        break;
    default:
        throw new AssertionError();
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:24,代码来源:NativeDataView.java

示例4: js_setInt

import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private void js_setInt(int bytes, boolean signed, Object[] args)
{
    checkOffset(args, 0);
    checkValue(args, 1);

    int pos = ScriptRuntime.toInt32(args[0]);
    rangeCheck(pos, bytes);

    boolean littleEndian =
        (isArg(args, 2) && (bytes > 1) && ScriptRuntime.toBoolean(args[2]));

    switch (bytes) {
    case 1:
        if (signed) {
            ByteIo.writeInt8(arrayBuffer.buffer, offset + pos, Conversions.toInt8(args[1]));
        } else {
            ByteIo.writeUint8(arrayBuffer.buffer, offset + pos, Conversions.toUint8(args[1]));
        }
        break;
    case 2:
        if (signed) {
            ByteIo.writeInt16(arrayBuffer.buffer, offset + pos, Conversions.toInt16(args[1]), littleEndian);
        } else {
            ByteIo.writeUint16(arrayBuffer.buffer, offset + pos, Conversions.toUint16(args[1]), littleEndian);
        }
        break;
    case 4:
        if (signed) {
            ByteIo.writeInt32(arrayBuffer.buffer, offset + pos, Conversions.toInt32(args[1]), littleEndian);
        } else {
            ByteIo.writeUint32(arrayBuffer.buffer, offset + pos, Conversions.toUint32(args[1]), littleEndian);
        }
        break;
    default:
        throw new AssertionError();
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:38,代码来源:NativeDataView.java

示例5: valueIsTruthy

import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public boolean valueIsTruthy(Object value) {
    if(value instanceof Scriptable) {
        if(isArrayLikeScriptableObject(value) == 0) {
            return false;   // empty array
        }
        return ScriptRuntime.toBoolean(value);
    } else {
        return super.valueIsTruthy(value);
    }
}
 
开发者ID:haplo-org,项目名称:haplo-safe-view-templates,代码行数:11,代码来源:RhinoJavaScriptDriver.java


注:本文中的org.mozilla.javascript.ScriptRuntime.toBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。