Esempio n. 1
0
 /** Convert a collection of ConstantSets to the format expected by GenTest.addClassLiterals. */
 public static MultiMap<Class<?>, PrimitiveOrStringOrNullDecl> toMap(
     Collection<ConstantSet> constantSets) {
   final MultiMap<Class<?>, PrimitiveOrStringOrNullDecl> map =
       new MultiMap<Class<?>, PrimitiveOrStringOrNullDecl>();
   for (ConstantSet cs : constantSets) {
     Class<?> clazz;
     try {
       clazz = Class.forName(cs.classname);
     } catch (ClassNotFoundException e) {
       throw new Error("Class " + cs.classname + " not found on the classpath.");
     }
     for (Integer x : cs.ints) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(int.class, x.intValue()));
     }
     for (Long x : cs.longs) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(long.class, x.longValue()));
     }
     for (Float x : cs.floats) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(float.class, x.floatValue()));
     }
     for (Double x : cs.doubles) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(double.class, x.doubleValue()));
     }
     for (String x : cs.strings) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(String.class, x));
     }
     for (Class<?> x : cs.classes) {
       map.add(clazz, new PrimitiveOrStringOrNullDecl(Class.class, x));
     }
   }
   return map;
 }
Esempio n. 2
0
 private CompoundInstruction createInstructionPush(Element inst) throws IllegalXMLVMException {
   String t = inst.getAttributeValue("type");
   Type type = parseTypeString(t);
   String value = inst.getAttributeValue("value");
   if (type == Type.STRING) return new PUSH(_cp, value);
   else if (type == Type.INT) return new PUSH(_cp, Integer.parseInt(value));
   else if (type == Type.FLOAT) return new PUSH(_cp, Float.parseFloat(value));
   else if (type == Type.DOUBLE) return new PUSH(_cp, Double.parseDouble(value));
   else if (type == Type.LONG) return new PUSH(_cp, Long.parseLong(value));
   else throw new IllegalXMLVMException(inst.getName() + " with bad type '" + t + "'");
 }