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


Java Undefined类代码示例

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


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

示例1: addToList

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
void addToList(Object toAdd) {
    if (toAdd instanceof Undefined) {
        // Missing argument do nothing...
        return;
    }

    if (toAdd instanceof XMLList) {
        XMLList xmlSrc = (XMLList)toAdd;
        for (int i = 0; i < xmlSrc.length(); i++) {
            this._add((xmlSrc.item(i)).getAnnotation());
        }
    } else if (toAdd instanceof XML) {
        this._add(((XML)(toAdd)).getAnnotation());
    } else if (toAdd instanceof XmlNode) {
        this._add((XmlNode)toAdd);
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:18,代码来源:XmlNode.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: stepExecute

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
	variables.clear();

	if (isEnabled()) {
		for (RequestableVariable var : getParentSequence().getAllVariables()) {
			try {
				//evaluate(javascriptContext, scope, var.getName(), "expression", true);
				evaluated = scope.get(var.getName(), scope);
				if (evaluated != null && !(evaluated instanceof Undefined)) {
					if (evaluated instanceof NativeJavaObject) {
						evaluated = ((NativeJavaObject) evaluated).unwrap();
					}
					variables.put(var.getName(), evaluated);
				}
			} catch (Exception e) {
				evaluated = null;
				Engine.logBeans.warn(e.getMessage());
			}
		}
		return super.stepExecute(javascriptContext, scope);
	}
	return false;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:25,代码来源:InputVariablesStep.java

示例4: getParameterValue

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
@Override
public Object getParameterValue(String parameterName) throws EngineException {
	Object variableValue = null;

	int variableVisibility = getVariableVisibility(parameterName);
	
	// Scope parameter
	if (scope != null) {
		variableValue = scope.get(parameterName, scope);
		if (variableValue instanceof Undefined)
			variableValue = null;
		if (variableValue instanceof UniqueTag && ((UniqueTag) variableValue).equals(UniqueTag.NOT_FOUND)) 
			variableValue = null;
		if (variableValue != null)
			Engine.logBeans.trace("(SqlTransaction) scope value: "+ Visibility.Logs.printValue(variableVisibility,variableValue));
	}

	if (variableValue == null) {
		variableValue = super.getParameterValue(parameterName);
	}
	
	return variableValue = ((variableValue == null)? new String(""):variableValue);
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:24,代码来源:SqlTransaction.java

示例5: evaluateToInteger

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
protected Integer evaluateToInteger(Context javascriptContext, Scriptable scope, String source, String sourceName, boolean bDialog) throws EngineException {
	Integer value = getValueOfInteger(source);
	if (value == null) {
		evaluate(javascriptContext, scope, source, sourceName, true);
		if (evaluated instanceof Undefined || evaluated.equals(""))
			value = -1;
		else if (evaluated instanceof Number) {
			value = Integer.valueOf(((Number)evaluated).intValue());
		}
		else {
			try {value = Integer.valueOf(String.valueOf(evaluated), 10);}
			catch (NumberFormatException nfe) {}
		}
		if (value == null) {
			EngineException ee = new EngineException(
					"Invalid \""+sourceName+"\" value.\n" +
					"Step: \"" + getName()+ "\"");
			throw ee;
		}
	}
	return value;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:23,代码来源:Step.java

示例6: 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

示例7: 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

示例8: importVariables

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
private void importVariables(@NonNull ScriptableObject scope) throws StethoJsException {
  // Define the variables
  for (Map.Entry<String, Object> entrySet : mVariables.entrySet()) {
    String varName = entrySet.getKey();
    Object varValue = entrySet.getValue();
    try {
      Object jsValue;
      if (varValue instanceof Scriptable || varValue instanceof Undefined) {
        jsValue = varValue;
      } else {
        jsValue = Context.javaToJS(varValue, scope);
      }
      ScriptableObject.putProperty(scope, varName, jsValue);
    } catch (Exception e) {
      throw new StethoJsException(e, "Failed to setup variable: %s", varName);
    }
  }
}
 
开发者ID:facebook,项目名称:stetho,代码行数:19,代码来源:JsRuntimeReplFactoryBuilder.java

示例9: 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

示例10: getValueFromView

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
public Object getValueFromView(Object view, String[] path) {
    if(view instanceof Scriptable) {
        Scriptable o = (Scriptable)view;
        for(int i = 0; i < path.length; ++i) {
            if(o == null || (o instanceof Undefined)) { return null; }
            Object value = ScriptableObject.getProperty(o, path[i]);
            if(value instanceof Scriptable) {
                o = (Scriptable)value;
            } else {
                // Scriptable values can be any Object, allow this in last entry in path
                if(i == (path.length - 1)) {
                    return hasValue(value) ? value : null;
                }
                o = null;
            }
        }
        return hasValue(o) ? o : null;
    } else if(path.length == 0) {
        return view;    // to allow . value to work
    }
    return null;
}
 
开发者ID:haplo-org,项目名称:haplo-safe-view-templates,代码行数:23,代码来源:RhinoJavaScriptDriver.java

示例11: 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

示例12: 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 = 0;
    return this;
}
 
开发者ID:tntim96,项目名称:rhino-jscover,代码行数:21,代码来源:NativeRegExp.java

示例13: 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

示例14: findCounter

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
/**
 * Wraps {@link CounterGroup#findCounter(String)}.
 *
 * @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 counter
 */
@JSFunction
public static Object findCounter(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);
    }

    final CounterGroupWrap self = (CounterGroupWrap)thisObj;
    final Counter counter = self.counterGroup.findCounter(arg0.toString());
    CounterWrap counterWrap = null;

    if (counter != null) {
        counterWrap = CounterWrap.getInstance(self.runtime, counter);
    }

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

示例15: incrAllCounters

import org.mozilla.javascript.Undefined; //导入依赖的package包/类
/**
 * Wraps {@link Counters#incrAllCounters(Counters)}.
 *
 * @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 incrAllCounters(final Context ctx, final Scriptable thisObj, final Object[] args,
                                     final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;

    if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
    } else if (!(arg0 instanceof CountersWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_COUNTERS);
    }

    ((CountersWrap)thisObj).counters.incrAllCounters(((CountersWrap)arg0).counters);

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


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