gpt4 book ai didi

org.mozilla.javascript.xml.XMLObject.addValues()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 14:33:40 28 4
gpt4 key购买 nike

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

XMLObject.addValues介绍

[英]Custom + operator. Should return Scriptable#NOT_FOUND if this object does not have custom addition operator for the given value, or the result of the addition operation.

The default implementation returns Scriptable#NOT_FOUNDto indicate no custom addition operation.
[中]自定义+运算符。如果此对象没有针对给定值的自定义加法运算符或加法运算的结果,则应返回Scriptable#NOT_FOUND。
默认实现返回Scriptable#NOT _found,表示没有自定义添加操作。

代码示例

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

public final Object addValues(Context cx, boolean thisIsLeft,
                 Object value)
{
  if (value instanceof XMLObject) {
    XMLObject v1, v2;
    if (thisIsLeft) {
      v1 = this;
      v2 = (XMLObject)value;
    } else {
      v1 = (XMLObject)value;
      v2 = this;
    }
    return lib.addXMLObjects(cx, v1, v2);
  }
  if (value == Undefined.instance) {
    // both "xml + undefined" and "undefined + xml" gives String(xml)
    return ScriptRuntime.toString(this);
  }
  return super.addValues(cx, thisIsLeft, value);
}

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

public final Object addValues(Context cx, boolean thisIsLeft,
  Object value) {
  if (value instanceof XMLObject) {
    XMLObject v1, v2;
    if (thisIsLeft) {
      v1 = this;
      v2 = (XMLObject)value;
    } else {
      v1 = (XMLObject)value;
      v2 = this;
    }
    return lib.addXMLObjects(cx, v1, v2);
  }
  if (value == Undefined.instance) {
    // both "xml + undefined" and "undefined + xml" gives String(xml)
    return ScriptRuntime.toString(this);
  }
  
  return super.addValues(cx, thisIsLeft, value);
}

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

@Override
public final Object addValues(Context cx, boolean thisIsLeft,
  Object value) {
  if (value instanceof XMLObject) {
    XMLObject v1, v2;
    if (thisIsLeft) {
      v1 = this;
      v2 = (XMLObject)value;
    } else {
      v1 = (XMLObject)value;
      v2 = this;
    }
    return lib.addXMLObjects(cx, v1, v2);
  }
  if (value == Undefined.instance) {
    // both "xml + undefined" and "undefined + xml" gives String(xml)
    return ScriptRuntime.toString(this);
  }
  return super.addValues(cx, thisIsLeft, value);
}

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

public static Object add(Object val1, Object val2, Context cx)
{
  if(val1 instanceof Number && val2 instanceof Number) {
    return wrapNumber(((Number)val1).doubleValue() +
             ((Number)val2).doubleValue());
  }
  if (val1 instanceof XMLObject) {
    Object test = ((XMLObject)val1).addValues(cx, true, val2);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val2 instanceof XMLObject) {
    Object test = ((XMLObject)val2).addValues(cx, false, val1);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val1 instanceof Scriptable)
    val1 = ((Scriptable) val1).getDefaultValue(null);
  if (val2 instanceof Scriptable)
    val2 = ((Scriptable) val2).getDefaultValue(null);
  if (!(val1 instanceof String) && !(val2 instanceof String))
    if ((val1 instanceof Number) && (val2 instanceof Number))
      return wrapNumber(((Number)val1).doubleValue() +
               ((Number)val2).doubleValue());
    else
      return wrapNumber(toNumber(val1) + toNumber(val2));
  return toString(val1).concat(toString(val2));
}

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

public static Object add(Object val1, Object val2, Context cx)
{
  if(val1 instanceof Number && val2 instanceof Number) {
    return wrapNumber(((Number)val1).doubleValue() +
             ((Number)val2).doubleValue());
  }
  if (val1 instanceof XMLObject) {
    Object test = ((XMLObject)val1).addValues(cx, true, val2);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val2 instanceof XMLObject) {
    Object test = ((XMLObject)val2).addValues(cx, false, val1);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val1 instanceof Scriptable)
    val1 = ((Scriptable) val1).getDefaultValue(null);
  if (val2 instanceof Scriptable)
    val2 = ((Scriptable) val2).getDefaultValue(null);
  if (!(val1 instanceof String) && !(val2 instanceof String))
    if ((val1 instanceof Number) && (val2 instanceof Number))
      return wrapNumber(((Number)val1).doubleValue() +
               ((Number)val2).doubleValue());
    else
      return wrapNumber(toNumber(val1) + toNumber(val2));
  return toString(val1).concat(toString(val2));
}

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

public static Object add(Object val1, Object val2, Context cx)
{
  if(val1 instanceof Number && val2 instanceof Number) {
    return wrapNumber(((Number)val1).doubleValue() +
             ((Number)val2).doubleValue());
  }
  if (val1 instanceof XMLObject) {
    Object test = ((XMLObject)val1).addValues(cx, true, val2);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val2 instanceof XMLObject) {
    Object test = ((XMLObject)val2).addValues(cx, false, val1);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val1 instanceof Scriptable)
    val1 = ((Scriptable) val1).getDefaultValue(null);
  if (val2 instanceof Scriptable)
    val2 = ((Scriptable) val2).getDefaultValue(null);
  if (!(val1 instanceof CharSequence) && !(val2 instanceof CharSequence))
    if ((val1 instanceof Number) && (val2 instanceof Number))
      return wrapNumber(((Number)val1).doubleValue() +
               ((Number)val2).doubleValue());
    else
      return wrapNumber(toNumber(val1) + toNumber(val2));
  return new ConsString(toCharSequence(val1), toCharSequence(val2));
}

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

public static Object add(Object val1, Object val2, Context cx)
{
  if(val1 instanceof Number && val2 instanceof Number) {
    return wrapNumber(((Number)val1).doubleValue() +
             ((Number)val2).doubleValue());
  }
  if (val1 instanceof XMLObject) {
    Object test = ((XMLObject)val1).addValues(cx, true, val2);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val2 instanceof XMLObject) {
    Object test = ((XMLObject)val2).addValues(cx, false, val1);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val1 instanceof Scriptable)
    val1 = ((Scriptable) val1).getDefaultValue(null);
  if (val2 instanceof Scriptable)
    val2 = ((Scriptable) val2).getDefaultValue(null);
  if (!(val1 instanceof CharSequence) && !(val2 instanceof CharSequence))
    if ((val1 instanceof Number) && (val2 instanceof Number))
      return wrapNumber(((Number)val1).doubleValue() +
               ((Number)val2).doubleValue());
    else
      return wrapNumber(toNumber(val1) + toNumber(val2));
  return new ConsString(toCharSequence(val1), toCharSequence(val2));
}

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

public static Object add(Object val1, Object val2, Context cx)
{
  if(val1 instanceof Number && val2 instanceof Number) {
    return wrapNumber(((Number)val1).doubleValue() +
             ((Number)val2).doubleValue());
  }
  if (val1 instanceof XMLObject) {
    Object test = ((XMLObject)val1).addValues(cx, true, val2);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val2 instanceof XMLObject) {
    Object test = ((XMLObject)val2).addValues(cx, false, val1);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val1 instanceof Scriptable)
    val1 = ((Scriptable) val1).getDefaultValue(null);
  if (val2 instanceof Scriptable)
    val2 = ((Scriptable) val2).getDefaultValue(null);
  if (!(val1 instanceof CharSequence) && !(val2 instanceof CharSequence))
    if ((val1 instanceof Number) && (val2 instanceof Number))
      return wrapNumber(((Number)val1).doubleValue() +
               ((Number)val2).doubleValue());
    else
      return wrapNumber(toNumber(val1) + toNumber(val2));
  return new ConsString(toCharSequence(val1), toCharSequence(val2));
}

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

public static Object add(Object val1, Object val2, Context cx)
{
  if(val1 instanceof Number && val2 instanceof Number) {
    return wrapNumber(((Number)val1).doubleValue() +
             ((Number)val2).doubleValue());
  }
  if (val1 instanceof XMLObject) {
    Object test = ((XMLObject)val1).addValues(cx, true, val2);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val2 instanceof XMLObject) {
    Object test = ((XMLObject)val2).addValues(cx, false, val1);
    if (test != Scriptable.NOT_FOUND) {
      return test;
    }
  }
  if (val1 instanceof Scriptable)
    val1 = ((Scriptable) val1).getDefaultValue(null);
  if (val2 instanceof Scriptable)
    val2 = ((Scriptable) val2).getDefaultValue(null);
  if (!(val1 instanceof CharSequence) && !(val2 instanceof CharSequence))
    if ((val1 instanceof Number) && (val2 instanceof Number))
      return wrapNumber(((Number)val1).doubleValue() +
               ((Number)val2).doubleValue());
    else
      return wrapNumber(toNumber(val1) + toNumber(val2));
  return new ConsString(toCharSequence(val1), toCharSequence(val2));
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com