예제 #1
0
 protected Type checkUnaryBooleanOp(Type t, Token op) {
   // Checks Unary operator !
   if (t.isArrayKind()) {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument to operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a boolean argument but found "
             + t.toString()
             + "[]");
     errorCount++;
     return Type.boolValue;
   }
   if (t.isBoolType()) {
     return t;
   } else {
     System.out.println(
         "line "
             + op.getLine()
             + ": unary operator `!' expects a boolean argument "
             + "but found "
             + t.toString());
     errorCount++;
     return Type.boolValue;
   }
 } /*      End of checkUnaryBooleanOp      */
예제 #2
0
 protected Type checkUnaryNumericOp(Type t, Token op) {
   // Checks Unary operators + and -
   if (t.isArrayKind()) {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument to operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a numeric argument but found "
             + t.toString()
             + "[]");
     errorCount++;
     return Type.errorType;
   }
   if (t.isNumericType()) {
     if (t.isCharType() && op.getText().equals("-")) {
       return Type.intValue;
     } else {
       return t;
     }
   } else {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument type for unary operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a numeric argument but found "
             + t.toString());
     errorCount++;
     return Type.errorType;
   }
 } /*      End of checkUnaryNumericOp      */
예제 #3
0
  protected Type checkBinaryNumericOp(Node exp1, Node exp2, Token op) {
    // Checks Binary operators +, -, *, /, and %
    // Do not forget to handle + for pairs of strings.
    Type t1 = null; // the type attribute of exp1
    Type t2 = null; // the type attribute of exp2

    // Below are the error messages to be printed when
    // the type is wrong.  The first is for t1 and second for t2.

    System.out.println(
        "line "
            + op.getLine()
            + ": invalid argument 1 ` "
            + exp1
            + "' for arithmetic operator `"
            + op.getText()
            + "'\n"
            + "          -- expects a numeric argument but found "
            + t1.toString());

    System.out.println(
        "line "
            + op.getLine()
            + ": invalid argument 2 ` "
            + exp2
            + "' for arithmetic operator `"
            + op.getText()
            + "'\n"
            + "          -- expects a numeric argument but found "
            + t2.toString());

    return null;
  } /*      End of checkBinaryNumericOp      */
예제 #4
0
 @Override
 public String toString() {
   StringBuilder buf = new StringBuilder();
   buf.append("(");
   for (Type type : m_argumentTypes) buf.append(type.toString());
   buf.append(")");
   buf.append(m_returnType.toString());
   return buf.toString();
 }
예제 #5
0
   public static void main(String[]argv) throws Exception {
	   Method m = Goo.class.getDeclaredMethod("getStrings");
	   Type t = m.getGenericReturnType();
	   if (!t.toString().equals("java.util.List<java.lang.String>")) 
		   throw new RuntimeException("Incorrect signature. Signature is "+t);

	   m = IFace.class.getDeclaredMethod("getStrings");
	   t = m.getGenericReturnType();
	   if (!t.toString().equals("java.util.List<java.lang.String>")) 
		   throw new RuntimeException("Incorrect signature. Signature is "+t);
   }
예제 #6
0
 protected Type checkLogicalOp(Type t1, Type t2, Token op) {
   // Checks Logical operators || and &&
   if (t1.isArrayKind()) {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument 1 to operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a boolean argument but found "
             + t1.toString()
             + "[]");
     errorCount++;
     return Type.boolValue;
   }
   if (t2.isArrayKind()) {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument 2 to operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a boolean argument but found "
             + t2.toString()
             + "[]");
     errorCount++;
     return Type.boolValue;
   }
   if (!t1.isBoolType() && !t1.isErrorType()) {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument 1 to operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a boolean argument but found "
             + t1.toString());
     errorCount++;
   }
   if (!t2.isBoolType() && !t2.isErrorType()) {
     System.out.println(
         "line "
             + op.getLine()
             + ": invalid argument 2 to operator `"
             + op.getText()
             + "'\n"
             + "          -- expects a boolean argument but found "
             + t2.toString());
     errorCount++;
   }
   return Type.boolValue;
 } /*      End of checkLogicalOp      */
예제 #7
0
파일: MultiType.java 프로젝트: masonmei/mx
  public String toString() {
    if (resolved != null) return resolved.toString();

    StringBuffer buffer = new StringBuffer("{");
    Iterator iter = interfaces.keySet().iterator();
    while (iter.hasNext()) {
      buffer.append(iter.next());
      buffer.append(", ");
    }
    buffer.setLength(buffer.length() - 2);
    if (potentialClass != null) buffer.append(", *").append(potentialClass.toString());
    buffer.append("}");
    return buffer.toString();
  }
예제 #8
0
파일: List.java 프로젝트: znerd/xins
  /**
   * Converts the specified <code>ItemList</code> to a string.
   *
   * @param value the value to convert, can be <code>null</code>.
   * @return the textual representation of the value, or <code>null</code> if and only if <code>
   *     value == null</code>.
   */
  public String toString(ItemList value) {

    // Short-circuit if the argument is null
    if (value == null) {
      return null;
    }

    // Use a buffer to create the string
    StringBuffer buffer = new StringBuffer(255);

    // Iterate over the list
    int listSize = value.getSize();
    for (int i = 0; i < listSize; i++) {
      if (i != 0) {
        buffer.append('&');
      }

      Object nextItem = value.getItem(i);
      String stringItem;
      try {
        stringItem = _itemType.toString(nextItem);
      } catch (Exception ex) {

        // Should never happens as only add() is able to add items in the list.
        throw new IllegalArgumentException("Incorrect value for type: " + nextItem);
      }
      buffer.append(URLEncoding.encode(stringItem));
    }

    return buffer.toString();
  }
예제 #9
0
  @Override
  public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    // Fetch objects
    Script script = (Script) scriptEntry.getObject("script");
    Duration duration = (Duration) scriptEntry.getObject("duration");
    Type type = (Type) scriptEntry.getObject("type");

    // Report to dB
    dB.report(
        getName(),
        aH.debugObj("Type", type.toString())
            + script.debug()
            + (type == Type.PLAYER ? aH.debugObj("Player", scriptEntry.getPlayer().getName()) : "")
            + duration.debug());

    // Perform cooldown
    if (type == Type.PLAYER)
      setCooldown(
          ((OfflinePlayer) scriptEntry.getObject("player")).getName(),
          duration.getSecondsAsInt(),
          script.getName(),
          false);
    else if (type == Type.GLOBAL)
      setCooldown(null, duration.getSecondsAsInt(), script.getName(), true);
  }
예제 #10
0
 public static String humanString(Type in, Locale locale) {
   ResourceBundle exceptionResources = ResourceBundle.getBundle("ExceptionResources", locale);
   switch (in) {
     case TOO_OLD_CLIENT:
       return exceptionResources.getString("OutdatedClient");
     case AUTHENTICATION_FAILED:
       return exceptionResources.getString("AuthenticationFailed");
     case DOWNLOAD_FILE:
       return exceptionResources.getString("DownloadError");
     case NOOUTPUTFILE:
       return exceptionResources.getString("NoRendererOutput");
     case RENDERER_CRASHED:
       return exceptionResources.getString("CrashedRenderer");
     case RENDERER_OUT_OF_VIDEO_MEMORY:
       return exceptionResources.getString("CrashedRendererVram");
     case GPU_NOT_SUPPORTED:
       return exceptionResources.getString("UnsupportedGPU");
     case RENDERER_MISSING_LIBRARIES:
       return exceptionResources.getString("MissingLibraries");
     case RENDERER_KILLED:
       return exceptionResources.getString("KilledRenderer");
     case SESSION_DISABLED:
       return exceptionResources.getString("SessionDisabled");
     case RENDERER_NOT_AVAILABLE:
       return exceptionResources.getString("NoRendererAvailable");
     case OS_NOT_SUPPORTED:
       return exceptionResources.getString("UnsupportedOS");
     case CPU_NOT_SUPPORTED:
       return exceptionResources.getString("UnsupportedCPU");
     default:
       return in.toString();
   }
 }
예제 #11
0
 // where
 private String className(Symbol sym, boolean longform) {
   if (sym.name.len == 0 && (sym.flags() & COMPOUND) != 0) {
     StringBuffer s = new StringBuffer(supertype_field.toString());
     for (List<Type> is = interfaces_field; is.nonEmpty(); is = is.tail) {
       s.append("&");
       s.append(is.head.toString());
     }
     return s.toString();
   } else if (sym.name.len == 0) {
     String s;
     ClassType norm = (ClassType) tsym.type;
     if (norm == null) {
       s = Log.getLocalizedString("anonymous.class", (Object) null);
     } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
       s = Log.getLocalizedString("anonymous.class", norm.interfaces_field.head);
     } else {
       s = Log.getLocalizedString("anonymous.class", norm.supertype_field);
     }
     if (moreInfo) s += String.valueOf(sym.hashCode());
     return s;
   } else if (longform) {
     return sym.getQualifiedName().toString();
   } else {
     return sym.name.toString();
   }
 }
예제 #12
0
  @Override
  public String toString() {
    if (type.equals(Type.Pointer)) {
      return String.format("%s to %s", type.toString(), name);
    }

    if (type.equals(Type.List)) {
      if (ofType.equals(Type.Pointer)) {
        return String.format("List of %s to %s", ofType.toString(), name);
      }

      return String.format("List of %s", ofType.toString());
    }

    return type.toString();
  }
예제 #13
0
 public WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound) {
   BoundKind bkind;
   Type bound;
   if (extendsBound == null && superBound == null) {
     bkind = BoundKind.UNBOUND;
     bound = syms.objectType;
   } else if (superBound == null) {
     bkind = BoundKind.EXTENDS;
     bound = (Type) extendsBound;
   } else if (extendsBound == null) {
     bkind = BoundKind.SUPER;
     bound = (Type) superBound;
   } else {
     throw new IllegalArgumentException("Extends and super bounds cannot both be provided");
   }
   switch (bound.getKind()) {
     case ARRAY:
     case DECLARED:
     case ERROR:
     case TYPEVAR:
       return new Type.WildcardType(bound, bkind, syms.boundClass);
     default:
       throw new IllegalArgumentException(bound.toString());
   }
 }
예제 #14
0
 public BigDecimal getFirst() {
   if (this.type == Type.VALUE) {
     return this.value[0];
   } else {
     throw new IllegalStateException("Wrong type " + type.toString());
   }
 }
예제 #15
0
 public String export() {
   if (type == Type.CHANNEL) {
     return JacobVPU.activeJacobThread().exportCommChannel(((CommChannel) target));
   } else {
     throw new UnsupportedOperationException("Cannot export channels of type " + type.toString());
   }
 }
예제 #16
0
 protected String getTypeString(SootField soot_field) {
   Type type = soot_field.getType();
   String name = type.toString();
   char[] name_array = name.toCharArray();
   name_array[0] = Character.toUpperCase(name_array[0]);
   return new String(name_array);
 }
예제 #17
0
 public Fragment object(Type type) {
   Mail mail = new Mail();
   Bundle bundle = new Bundle();
   bundle.putString(KEY, type.toString());
   mail.setArguments(bundle);
   return mail;
 }
예제 #18
0
 /**
  * Translates a void into an object of internal type <code>type</code>. This translation is needed
  * when calling external functions that return void.
  *
  * @see org.apache.xalan.xsltc.compiler.util.Type#translateTo
  */
 public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, Type type) {
   if (type == Type.String) {
     translateTo(classGen, methodGen, (StringType) type);
   } else {
     ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, toString(), type.toString());
     classGen.getParser().reportError(Constants.FATAL, err);
   }
 }
예제 #19
0
 public boolean isLeftAssociative() {
   if (this.type == Type.OPERATOR) {
     if (this.operator == '^') return false;
     else return true;
   } else {
     throw new IllegalStateException("Wrong type " + type.toString());
   }
 }
예제 #20
0
 /**
  * Converts a String into the corresponding types. Valid String values that can be converted to
  * types are: "get", "set", "result", and "error".
  *
  * @param type the String value to covert.
  * @return the corresponding Type.
  */
 public static Type fromString(String type) {
   if (type == null) {
     return null;
   }
   type = type.toLowerCase();
   if (GET.toString().equals(type)) {
     return GET;
   } else if (SET.toString().equals(type)) {
     return SET;
   } else if (ERROR.toString().equals(type)) {
     return ERROR;
   } else if (RESULT.toString().equals(type)) {
     return RESULT;
   } else {
     return null;
   }
 }
예제 #21
0
파일: Reloc.java 프로젝트: NanoGame/jnode
 public String getTypeName() {
   final Type type = getRelocType();
   if (type != null) {
     return type.toString();
   } else {
     return "type-" + r_type;
   }
 }
예제 #22
0
파일: Database.java 프로젝트: TeamMCD/LWC
    /**
     * Match the given string to a database type
     *
     * @param str
     * @return
     */
    public static Type matchType(String str) {
      for (Type type : values()) {
        if (type.toString().equalsIgnoreCase(str)) {
          return type;
        }
      }

      return null;
    }
예제 #23
0
 /**
  * Convert the type into a string. The string representation approximates the code that would be
  * used to define the type.
  *
  * @param type - the type.
  * @return a string representation of the type, similar to how it was declared.
  */
 public static String toString(Type type) {
   if (type instanceof ParameterizedType) return toString((ParameterizedType) type);
   if (type instanceof WildcardType) return toString((WildcardType) type);
   if (type instanceof GenericArrayType) return toString((GenericArrayType) type);
   if (type instanceof Class) {
     final Class theClass = (Class) type;
     return (theClass.isArray() ? theClass.getName() + "[]" : theClass.getName());
   }
   return type.toString();
 }
  public String toXML() {
    StringBuilder builder = new StringBuilder("<");
    builder.append(getElementName());
    if (node != null) appendAttribute(builder, "node", node);
    appendAttribute(builder, "jid", jid);
    appendAttribute(builder, "affiliation", type.toString());

    builder.append("/>");
    return builder.toString();
  }
예제 #25
0
 @SuppressWarnings("unchecked")
 public Object toJSON() {
   JSONObject msgObj = new JSONObject();
   msgObj.put("type", type.toString());
   msgObj.put("url", url);
   msgObj.put("title", title);
   msgObj.put("mediaUrl", imageUrl);
   msgObj.put("tweeted", Utils.jsonDateFormat.format(tweeted));
   msgObj.put("place", placeId);
   return msgObj;
 }
예제 #26
0
 public Fragmentation(Type type, NodeSorter sorter, Resolution resolution) {
   super(
       "FRAGMENTATION",
       new Parameter[] {
         new StringParameter("TYPE", type.toString()),
         new StringParameter("SORTER", sorter.getKey()),
         new StringParameter("RESOLUTION", resolution.toString())
       });
   this.sorter = sorter;
   this.resolution = resolution;
 }
예제 #27
0
  @Override
  public String toString() {
    StringBuilder buffer = new StringBuilder(type.toString());

    if (offset != null) {
      buffer.append(offset.toString());
    } else if (range != null) {
      buffer.append(range.toString());
    }

    return buffer.toString();
  }
예제 #28
0
 @Override
 public void write(Writer writer, int indentationLevel) throws IOException {
   Type type = getType(value);
   Compiluration.writeIndentation(writer, indentationLevel);
   writer.append("public static final ");
   writer.append(type.toString());
   writer.append(" ");
   writer.append(name);
   writer.append(" = ");
   type.appendValue(writer, value);
   writer.append(";\n");
 }
예제 #29
0
  @Override
  void specificToGenericStringHeader(StringBuilder sb) {
    Type genRetType = getGenericReturnType();
    sb.append(
            ((genRetType instanceof Class<?>)
                ? Field.getTypeName((Class<?>) genRetType)
                : genRetType.toString()))
        .append(' ');

    sb.append(Field.getTypeName(getDeclaringClass())).append('.');
    sb.append(getName());
  }
예제 #30
0
 @Override
 public String toString() {
   if (toString == null) {
     toString =
         new StringBuilder("VM[")
             .append(type.toString())
             .append("|")
             .append(hostName)
             .append("]")
             .toString();
   }
   return toString;
 }