private void printAnnotationValue(AST ast, Object value) {
   if (value == null) {
     print("nil");
   } else if (value instanceof IVariableBinding) {
     IVariableBinding var = (IVariableBinding) value;
     ITypeBinding declaringClass = var.getDeclaringClass();
     printf("[%s %s]", NameTable.getFullName(declaringClass), var.getName());
   } else if (value instanceof ITypeBinding) {
     ITypeBinding type = (ITypeBinding) value;
     printf("[[%s class] getClass]", NameTable.getFullName(type));
   } else if (value instanceof String) {
     StringLiteral node = ast.newStringLiteral();
     node.setLiteralValue((String) value);
     print(StatementGenerator.generateStringLiteral(node));
   } else if (value instanceof Number || value instanceof Character || value instanceof Boolean) {
     print(value.toString());
   } else if (value.getClass().isArray()) {
     print("[IOSObjectArray arrayWithObjects:(id[]) { ");
     Object[] array = (Object[]) value;
     for (int i = 0; i < array.length; i++) {
       if (i > 0) {
         print(", ");
       }
       printAnnotationValue(ast, array[i]);
     }
     printf(" } count:%d type:[[NSObject class] getClass]]", array.length);
   } else {
     assert false : "unknown annotation value type";
   }
 }
Esempio n. 2
0
 /**
  * Builds a new {@link StringLiteral} instance.
  *
  * @param s the string literal value
  * @return a new string literal
  */
 public StringLiteral string(String s) {
   final StringLiteral sl = ast.newStringLiteral();
   sl.setLiteralValue(s);
   return sl;
 }
Esempio n. 3
0
 public StringLiteral newStringLit(String value) {
   StringLiteral st = ast.newStringLiteral();
   st.setLiteralValue(value);
   return st;
 }
 @Override
 protected StringLiteral convertObject(String string, AST ast) {
   StringLiteral stringLiteral = ast.newStringLiteral();
   stringLiteral.setLiteralValue(string);
   return stringLiteral;
 }