예제 #1
0
 @Override
 public String toString() {
   StringBuffer sb = new StringBuffer();
   for (int i = 0, N = methods.length; i != N; ++i) {
     Method method = methods[i].method();
     sb.append(JavaMembers.javaSignature(method.getReturnType()));
     sb.append(' ');
     sb.append(method.getName());
     sb.append(JavaMembers.liveConnectSignature(methods[i].argTypes));
     sb.append('\n');
   }
   return sb.toString();
 }
예제 #2
0
  static String scriptSignature(Object[] values) {
    StringBuffer sig = new StringBuffer();
    for (int i = 0; i != values.length; ++i) {
      Object value = values[i];

      String s;
      if (value == null) {
        s = "null";
      } else if (value instanceof Boolean) {
        s = "boolean";
      } else if (value instanceof String) {
        s = "string";
      } else if (value instanceof Number) {
        s = "number";
      } else if (value instanceof Scriptable) {
        if (value instanceof Undefined) {
          s = "undefined";
        } else if (value instanceof Wrapper) {
          Object wrapped = ((Wrapper) value).unwrap();
          s = wrapped.getClass().getName();
        } else if (value instanceof Function) {
          s = "function";
        } else {
          s = "object";
        }
      } else {
        s = JavaMembers.javaSignature(value.getClass());
      }

      if (i != 0) {
        sig.append(',');
      }
      sig.append(s);
    }
    return sig.toString();
  }
 static void reportConversionError(Object value, Class<?> type) {
   // It uses String.valueOf(value), not value.toString() since
   // value can be null, bug 282447.
   throw Context.reportRuntimeError2(
       "msg.conversion.not.allowed", String.valueOf(value), JavaMembers.javaSignature(type));
 }