當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。