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


Java Undefined.instance方法代码示例

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


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

示例1: compile

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
Scriptable compile(Context cx, Scriptable scope, Object[] args)
{
    if (args.length > 0 && args[0] instanceof NativeRegExp) {
        if (args.length > 1 && args[1] != Undefined.instance) {
            // report error
            throw ScriptRuntime.typeError0("msg.bad.regexp.compile");
        }
        NativeRegExp thatObj = (NativeRegExp) args[0];
        this.re = thatObj.re;
        this.lastIndex = thatObj.lastIndex;
        return this;
    }
    String s = args.length == 0 ? "" : ScriptRuntime.toString(args[0]);
    String global = args.length > 1 && args[1] != Undefined.instance
        ? ScriptRuntime.toString(args[1])
        : null;
    this.re = (RECompiled)compileRE(cx, s, global, false);
    this.lastIndex = 0;
    return this;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:21,代码来源:NativeRegExp.java

示例2: compile

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
Scriptable compile(Context cx, Scriptable scope, Object[] args)
{
    if (args.length > 0 && args[0] instanceof NativeRegExp) {
        if (args.length > 1 && args[1] != Undefined.instance) {
            // report error
            throw ScriptRuntime.typeError0("msg.bad.regexp.compile");
        }
        NativeRegExp thatObj = (NativeRegExp) args[0];
        this.re = thatObj.re;
        this.lastIndex = thatObj.lastIndex;
        return this;
    }
    String s = args.length == 0 || args[0] instanceof Undefined ? "" : escapeRegExp(args[0]);
    String global = args.length > 1 && args[1] != Undefined.instance
        ? ScriptRuntime.toString(args[1])
        : null;
    this.re = compileRE(cx, s, global, false);
    this.lastIndex = 0d;
    return this;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:21,代码来源:NativeRegExp.java

示例3: compile

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
Scriptable compile(Context cx, Scriptable scope, Object[] args)
{
    if (args.length > 0 && args[0] instanceof NativeRegExp) {
        if (args.length > 1 && args[1] != Undefined.instance) {
            // report error
            throw ScriptRuntime.typeError0("msg.bad.regexp.compile");
        }
        NativeRegExp thatObj = (NativeRegExp) args[0];
        this.re = thatObj.re;
        this.lastIndex = thatObj.lastIndex;
        return this;
    }
    String s = args.length == 0 ? "" : escapeRegExp(args[0]);
    String global = args.length > 1 && args[1] != Undefined.instance
        ? ScriptRuntime.toString(args[1])
        : null;
    this.re = compileRE(cx, s, global, false);
    this.lastIndex = 0;
    return this;
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:21,代码来源:NativeRegExp.java

示例4: wrap

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
@Override
public Object wrap(Context cx, Scriptable scope, Object obj, Class<?> staticType) {
  if (obj == null || obj == Undefined.instance || obj instanceof Scriptable) {
    return obj;
  }
  if (staticType != null) {
    if (obj instanceof String || obj instanceof Number || obj instanceof Boolean
        || obj instanceof Character) {
      return Context.javaToJS(obj, scope);
    }
  }
  if (obj.getClass().isArray()) {
    if (obj.getClass().getComponentType() != Object.class) {
      Object[] array = new Object[Array.getLength(obj)];
      for (int i = 0; i < array.length; i++) {
        array[i] = Context.javaToJS(Array.get(obj, i), scope);
      }
      return cx.newArray(scope, array);
    }
  }
  return super.wrap(cx, scope, obj, staticType);
}
 
开发者ID:kohii,项目名称:smoothcsv,代码行数:23,代码来源:SCWrapFactory.java

示例5: call

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
	InvocableMember<?> nearestInvocable = getNearestObjectFunction(args, objectFunctions);

	if (nearestInvocable == null) {
		throw new FunctionException("Unable to match nearest function");
	}
	
	FunctionMember nearestFunctionObject = (FunctionMember)nearestInvocable;
	
	Method functionMethod = nearestFunctionObject.getMember();
	Class<?> returnType = functionMethod.getReturnType();
	
	Class<?> expectedTypes[] = functionMethod.getParameterTypes();
	Object[] castedArgs = castArgs(expectedTypes, args);
	
	try {
		 Object returned = functionMethod.invoke(object, castedArgs);
		 return (returnType == Void.class)? Undefined.instance : returned;
	} catch (Exception e) {
		throw new UnknownException("Unable to invoke function " + nearestFunctionObject.getName(), e);
	}
}
 
开发者ID:jutils,项目名称:jsen-js,代码行数:24,代码来源:HostedJavaMethod.java

示例6: setLocalFiles

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Java wrapper for {@link DistributedCache#setLocalFiles(Configuration, String)}.
 *
 * @param ctx the JavaScript context
 * @param thisObj the 'this' object
 * @param args the function arguments
 * @param func the function being called
 */
@JSStaticFunction
public static void setLocalFiles(final Context ctx, final Scriptable thisObj, final Object[] args,
                                 final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
    final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;

    if (args.length < 2) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!JavaScriptUtils.isDefined(arg1)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
    } else if (!(arg0 instanceof ConfigurationWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
    }

    DistributedCache.setLocalFiles(((ConfigurationWrap)arg0).getConf(), arg1.toString());
}
 
开发者ID:apigee,项目名称:lembos,代码行数:27,代码来源:DistributedCacheWrap.java

示例7: getNumLinesPerSplit

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Java wrapper for {@link NLineInputFormat#getNumLinesPerSplit(org.apache.hadoop.mapreduce.JobContext)}.
 *
 * @param ctx the JavaScript context
 * @param thisObj the 'this' object
 * @param args the function arguments
 * @param func the function being called
 *
 * @return the number of lines per split
 */
@JSStaticFunction
public static Object getNumLinesPerSplit(final Context ctx, final Scriptable thisObj, final Object[] args,
                                        final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;

    if (args.length < 1) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!(arg0 instanceof JobWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_JOB);
    }

    return NLineInputFormat.getNumLinesPerSplit(((JobWrap)arg0).getJob());
}
 
开发者ID:apigee,项目名称:lembos,代码行数:26,代码来源:NLineInputFormatWrap.java

示例8: setInt

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Wraps {@link Configuration#setInt(String, int)}.
 *
 * @param ctx the JavaScript context (unused)
 * @param thisObj the 'this' object of the caller
 * @param args the arguments for the call
 * @param func the function called (unused)
 *
 * @return this
 */
@JSFunction
public static Object setInt(final Context ctx, final Scriptable thisObj, final Object[] args,
                          final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
    final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;

    if (args.length < 2) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!JavaScriptUtils.isDefined(arg1)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
    } else if (!(arg1 instanceof Number)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_ARG_MUST_BE_NUM);
    }

    ((ConfigurationWrap)thisObj).conf.setInt(arg0.toString(),
                                             JavaScriptUtils.fromNumber(arg1).intValue());

    return thisObj;
}
 
开发者ID:apigee,项目名称:lembos,代码行数:32,代码来源:ConfigurationWrap.java

示例9: addArchiveToClassPath

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Java wrapper for {@link DistributedCache#addArchiveToClassPath(Path, Configuration)} and
 * {@link DistributedCache#addArchiveToClassPath(Path, Configuration, org.apache.hadoop.fs.FileSystem)}.
 *
 * @param ctx the JavaScript context
 * @param thisObj the 'this' object
 * @param args the function arguments
 * @param func the function being called
 */
@JSStaticFunction
public static void addArchiveToClassPath(final Context ctx, final Scriptable thisObj, final Object[] args,
                                         final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
    final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;

    if (args.length < 2) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!JavaScriptUtils.isDefined(arg1)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
    } else if (!(arg1 instanceof ConfigurationWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_MUST_BE_CONF);
    }

    final Configuration conf = ((ConfigurationWrap)arg1).getConf();
    final Path path = new Path(URI.create(arg0.toString()));

    try {
        DistributedCache.addArchiveToClassPath(path, conf, path.getFileSystem(conf));
    } catch (IOException e) {
        throw Utils.makeError(ctx, thisObj, e.getMessage());
    }
}
 
开发者ID:apigee,项目名称:lembos,代码行数:35,代码来源:DistributedCacheWrap.java

示例10: getArchiveTimestamps

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Java wrapper for {@link DistributedCache#getArchiveTimestamps(Configuration)}.
 *
 * @param ctx the JavaScript context
 * @param thisObj the 'this' object
 * @param args the function arguments
 * @param func the function being called
 *
 * @return array of archive timestamps
 */
@JSStaticFunction
public static Object getArchiveTimestamps(final Context ctx, final Scriptable thisObj, final Object[] args,
                                          final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;

    if (args.length < 1) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!(arg0 instanceof ConfigurationWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
    }

    return JavaScriptUtils.asArray(thisObj, DistributedCache.getArchiveTimestamps(
            ((ConfigurationWrap)arg0).getConf()));
}
 
开发者ID:apigee,项目名称:lembos,代码行数:27,代码来源:DistributedCacheWrap.java

示例11: setNumLinesPerSplit

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Java wrapper for {@link NLineInputFormat#setNumLinesPerSplit(org.apache.hadoop.mapreduce.Job, int)}.
 *
 * @param ctx the JavaScript context
 * @param thisObj the 'this' object
 * @param args the function arguments
 * @param func the function called (unused)
 */
@JSStaticFunction
public static void setNumLinesPerSplit(final Context ctx, final Scriptable thisObj, final Object[] args,
                                       final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
    final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;

    if (args.length < 2) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!JavaScriptUtils.isDefined(arg1)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
    } else if (!(arg0 instanceof JobWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_JOB);
    } else if (!(arg1 instanceof Number)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_ARG_MUST_BE_NUM);
    }

    NLineInputFormat.setNumLinesPerSplit(((JobWrap)arg0).getJob(), JavaScriptUtils.fromNumber(arg1).intValue());
}
 
开发者ID:apigee,项目名称:lembos,代码行数:29,代码来源:NLineInputFormatWrap.java

示例12: getMaxSplitSize

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Java wrapper for {@link FileInputFormat#getMaxSplitSize(JobContext)}.
 *
 * @param clazz the class to invoke the method of
 * @param ctx the JavaScript context
 * @param thisObj the 'this' object
 * @param args the function arguments
 *
 * @return the max split size
 */
public static Object getMaxSplitSize(final Class<?> clazz, final Context ctx, final Scriptable thisObj,
                                     final Object[] args) {
    validateClass(clazz, ctx, thisObj);

    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;

    if (args.length < 1) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!(arg0 instanceof JobWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_JOB);
    }

    try {
        return ReflectionUtils.invokeStatic(clazz, "getMaxSplitSize", new Class<?>[] {
                JobContext.class
        }, new Object[] {
                ((JobWrap)arg0).getJob()
        });
    } catch (Exception e) {
        e.printStackTrace();
        throw Utils.makeError(ctx, thisObj, e.getMessage());
    }
}
 
开发者ID:apigee,项目名称:lembos,代码行数:36,代码来源:FileInputFormatHelper.java

示例13: getCounters

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
/**
 * Wraps {@link Job#getCounters()}.
 *
 * @param ctx the JavaScript context (unused)
 * @param thisObj the 'this' object of the caller
 * @param args the arguments for the call
 * @param func the function called (unused)
 *
 * @return the counters wrapper
 */
@JSFunction
public static Object getCounters(final Context ctx, final Scriptable thisObj, final Object[] args,
                                 final Function func) {
    final JobWrap self = (JobWrap)thisObj;
    Counters counters;

    try {
        counters = self.job.getCounters();
    } catch (IOException e) {
        throw Utils.makeError(ctx, thisObj, e.getMessage());
    }

    CountersWrap countersWrap = null;

    if (counters != null) {
        countersWrap = CountersWrap.getInstance(self.runtime, counters);
    }

    return countersWrap == null ? Undefined.instance : countersWrap;
}
 
开发者ID:apigee,项目名称:lembos,代码行数:31,代码来源:JobWrap.java

示例14: js_get

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
@Override
protected Object js_get(int index)
{
    if (checkIndex(index)) {
        return Undefined.instance;
    }
    return ByteIo.readInt16(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, false);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:9,代码来源:NativeInt16Array.java

示例15: js_set

import org.mozilla.javascript.Undefined; //导入方法依赖的package包/类
@Override
protected Object js_set(int index, Object c)
{
    if (checkIndex(index)) {
        return Undefined.instance;
    }
    int val = Conversions.toInt16(c);
    ByteIo.writeInt16(arrayBuffer.buffer, (index * BYTES_PER_ELEMENT) + offset, val, false);
    return null;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:11,代码来源:NativeInt16Array.java


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