org.mozilla.javascript.WrapFactory.wrap()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 JavaScript  
字(6.7k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中org.mozilla.javascript.WrapFactory.wrap()方法的一些代码示例,展示了WrapFactory.wrap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WrapFactory.wrap()方法的具体详情如下:
包路径:org.mozilla.javascript.WrapFactory
类名称:WrapFactory
方法名:wrap

WrapFactory.wrap介绍

[英]Wrap the object.

The value returned must be one of

  • java.lang.Boolean
  • java.lang.String
  • java.lang.Number
  • org.mozilla.javascript.Scriptable objects
  • The value returned by Context.getUndefinedValue()
  • null
    [中]把物体包起来。
    返回的值必须是以下值之一:
    *爪哇。朗布尔
    *爪哇。串
    *爪哇。朗:号码
    *组织。mozilla。javascript。可编写脚本的对象
    *上下文返回的值。getUndefinedValue()
    *空的

代码示例

代码示例来源:origin: rhq-project/rhq

/**
   * This behaves exactly the same as the super class' method except the fact that
   * the ConsString is considered "primitive" and is not wrapped in any manner.
   * <p>
   * This is then consistent with the rest of Rhino that expects ConsString as a possible
   * implementation of the string.
   */
  @Override
  public Object wrap(Context cx, Scriptable scope, Object obj, Class<?> staticType) {
    if (obj instanceof ConsString) {
      return obj;
    }
    
    return super.wrap(cx, scope, obj, staticType);
  }
}

代码示例来源:origin: RPTools/maptool

@SuppressWarnings("rawtypes")
  @Override
  public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
    if (obj instanceof String || obj instanceof Number || obj instanceof Boolean) {
      return obj;
    } else if (obj instanceof Character) {
      char[] a = { ((Character) obj).charValue() };
      return new String(a);
    }
    return super.wrap(cx, scope, obj, staticType);
  }
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

public Object wrap(Context ctx, Scriptable scope,
            Object obj, Class staticType) {
    if (obj instanceof EventTarget) {
      return interpreter.buildEventTargetWrapper((EventTarget)obj);
    }
    return super.wrap(ctx, scope, obj, staticType);
  }
}

代码示例来源:origin: org.apache.xmlgraphics/batik-bridge

public Object wrap(Context ctx, Scriptable scope,
            Object obj, Class staticType) {
    if (obj instanceof EventTarget) {
      return interpreter.buildEventTargetWrapper((EventTarget)obj);
    }
    return super.wrap(ctx, scope, obj, staticType);
  }
}

代码示例来源:origin: apache/batik

public Object wrap(Context ctx, Scriptable scope,
            Object obj, Class staticType) {
    if (obj instanceof EventTarget) {
      return interpreter.buildEventTargetWrapper((EventTarget)obj);
    }
    return super.wrap(ctx, scope, obj, staticType);
  }
}

代码示例来源:origin: rhino/js

@Override
public Object get(int index, Scriptable start) {
  if (0 <= index && index < length) {
    Context cx = Context.getContext();
    Object obj = Array.get(array, index);
    return cx.getWrapFactory().wrap(cx, this, obj, cls);
  }
  return Undefined.instance;
}

代码示例来源:origin: geogebra/geogebra

/**
 * @deprecated Use {@link Context#getWrapFactory()} together with calling {@link
 * WrapFactory#wrap(Context, Scriptable, Object, Class)}
 */
@Deprecated
public static Object wrap(Scriptable scope, Object obj, Class<?> staticType) {
  Context cx = Context.getContext();
  return cx.getWrapFactory().wrap(cx, scope, obj, staticType);
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

public Object get(int index, Scriptable start) {
  if (0 <= index && index < length) {
    Context cx = Context.getContext();
    Object obj = Array.get(array, index);
    return cx.getWrapFactory().wrap(cx, this, obj, cls);
  }
  return Undefined.instance;
}

代码示例来源:origin: com.github.tntim96/rhino

@Override
public Object get(int index, Scriptable start) {
  if (0 <= index && index < length) {
    Context cx = Context.getContext();
    Object obj = Array.get(array, index);
    return cx.getWrapFactory().wrap(cx, this, obj, cls);
  }
  return Undefined.instance;
}

代码示例来源:origin: geogebra/geogebra

@Override
public Object get(int index, Scriptable start) {
  if (0 <= index && index < length) {
    Context cx = Context.getContext();
    Object obj = Array.get(array, index);
    return cx.getWrapFactory().wrap(cx, this, obj, cls);
  }
  return Undefined.instance;
}

代码示例来源:origin: io.apigee/rhino

@Override
public Object get(int index, Scriptable start) {
  if (0 <= index && index < length) {
    Context cx = Context.getContext();
    Object obj = Array.get(array, index);
    return cx.getWrapFactory().wrap(cx, this, obj, cls);
  }
  return Undefined.instance;
}

代码示例来源:origin: ro.isdc.wro4j/rhino

@Override
public Object get(int index, Scriptable start) {
  if (0 <= index && index < length) {
    Context cx = Context.getContext();
    Object obj = Array.get(array, index);
    return cx.getWrapFactory().wrap(cx, this, obj, cls);
  }
  return Undefined.instance;
}

代码示例来源:origin: rhino/js

/**
@deprecated Use {@link Context#getWrapFactory()} together with calling {@link
WrapFactory#wrap(Context, Scriptable, Object, Class)}
*/
  public static Object wrap(Scriptable scope, Object obj, Class<?> staticType) {

    Context cx = Context.getContext();
    return cx.getWrapFactory().wrap(cx, scope, obj, staticType);
  }

代码示例来源:origin: io.apigee/rhino

/**
@deprecated Use {@link Context#getWrapFactory()} together with calling {@link
WrapFactory#wrap(Context, Scriptable, Object, Class)}
*/
  public static Object wrap(Scriptable scope, Object obj, Class<?> staticType) {

    Context cx = Context.getContext();
    return cx.getWrapFactory().wrap(cx, scope, obj, staticType);
  }

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
@deprecated Use {@link Context#getWrapFactory()} together with calling {@link
WrapFactory#wrap(Context, Scriptable, Object, Class)}
*/
  public static Object wrap(Scriptable scope, Object obj, Class<?> staticType) {

    Context cx = Context.getContext();
    return cx.getWrapFactory().wrap(cx, scope, obj, staticType);
  }

代码示例来源:origin: com.sun.phobos/phobos-rhino

/**
@deprecated Use {@link Context#getWrapFactory()} together with calling {@link
WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)}
*/
  public static Object wrap(Scriptable scope, Object obj, Class staticType) {

    Context cx = Context.getContext();
    return cx.getWrapFactory().wrap(cx, scope, obj, staticType);
  }

代码示例来源:origin: com.github.tntim96/rhino

/**
@deprecated Use {@link Context#getWrapFactory()} together with calling {@link
WrapFactory#wrap(Context, Scriptable, Object, Class)}
*/
  public static Object wrap(Scriptable scope, Object obj, Class<?> staticType) {

    Context cx = Context.getContext();
    return cx.getWrapFactory().wrap(cx, scope, obj, staticType);
  }

代码示例来源:origin: rhino/js

private static Object doCall(Context cx, Scriptable scope,
               Scriptable thisObj, Function f,
               Object[] args, long argsToWrap)
{
  // Wrap the rest of objects
  for (int i = 0; i != args.length; ++i) {
    if (0 != (argsToWrap & (1 << i))) {
      Object arg = args[i];
      if (!(arg instanceof Scriptable)) {
        args[i] = cx.getWrapFactory().wrap(cx, scope, arg,
                          null);
      }
    }
  }
  return f.call(cx, scope, thisObj, args);
}

代码示例来源:origin: geogebra/geogebra

private static Object doCall(Context cx, Scriptable scope,
               Scriptable thisObj, Function f,
               Object[] args, long argsToWrap)
{
  // Wrap the rest of objects
  for (int i = 0; i != args.length; ++i) {
    if (0 != (argsToWrap & (1 << i))) {
      Object arg = args[i];
      if (!(arg instanceof Scriptable)) {
        args[i] = cx.getWrapFactory().wrap(cx, scope, arg,
                          null);
      }
    }
  }
  return f.call(cx, scope, thisObj, args);
}

代码示例来源:origin: io.apigee/rhino

private static Object doCall(Context cx, Scriptable scope,
               Scriptable thisObj, Function f,
               Object[] args, long argsToWrap)
{
  // Wrap the rest of objects
  for (int i = 0; i != args.length; ++i) {
    if (0 != (argsToWrap & (1 << i))) {
      Object arg = args[i];
      if (!(arg instanceof Scriptable)) {
        args[i] = cx.getWrapFactory().wrap(cx, scope, arg,
                          null);
      }
    }
  }
  return f.call(cx, scope, thisObj, args);
}

相关文章