Beispiel #1
0
 @Override
 public String getMessage() {
   StringBuffer sbuf = new StringBuffer(100);
   if (number == ARG_DESCRIPTION) {
     sbuf.append(procname);
   } else if (number == ARG_CAST || number == ARG_VARNAME) {
     sbuf.append("Value");
   } else {
     sbuf.append("Argument ");
     if (number > 0) {
       sbuf.append('#');
       sbuf.append(number);
     }
   }
   if (argValue != null) {
     sbuf.append(" '");
     String argString = argValue.toString();
     if (argString.length() > 50) {
       sbuf.append(argString.substring(0, 47));
       sbuf.append("...");
     } else sbuf.append(argString);
     sbuf.append("'");
   }
   if (procname != null && number != ARG_DESCRIPTION) {
     sbuf.append(number == ARG_VARNAME ? " for variable '" : " to '");
     sbuf.append(procname);
     sbuf.append("'");
   }
   sbuf.append(" has wrong type");
   if (argValue != null) {
     sbuf.append(" (");
     Class wrongClass = argValue.getClass();
     Language currentLang = Language.getDefaultLanguage();
     String wrongClassname =
         currentLang == null
             ? wrongClass.getName()
             : currentLang.formatType(currentLang.getTypeFor(wrongClass));
     sbuf.append(wrongClassname);
     sbuf.append(")");
   }
   Object expectType = expectedType;
   if (expectType == null && number > 0 && proc instanceof MethodProc)
     expectType = ((MethodProc) proc).getParameterType(number - 1);
   if (expectType != null && expectType != Type.pointer_type) {
     sbuf.append(" (expected: ");
     if (expectType instanceof Type) expectType = ((Type) expectType).getName();
     else if (expectType instanceof Class) expectType = ((Class) expectType).getName();
     sbuf.append(expectType);
     sbuf.append(")");
   }
   Throwable ex = getCause();
   if (ex != null) {
     String msg = ex.getMessage();
     if (msg != null) {
       sbuf.append(" (");
       sbuf.append(msg);
       sbuf.append(')');
     }
   }
   return sbuf.toString();
 }
Beispiel #2
0
 /** The compiler insert calls to this method for applications and applets. */
 public static void registerEnvironment() {
   Language.setDefaults(instance);
 }