本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}