Ejemplo n.º 1
0
  void addRecipe(ItemStack itemstack, Object aobj[]) {
    String s = "";
    int i = 0;
    int j = 0;
    int k = 0;
    if (aobj[i] instanceof String[]) {
      String as[] = (String[]) aobj[i++];
      for (int l = 0; l < as.length; l++) {
        String s2 = as[l];
        k++;
        j = s2.length();
        s = (new StringBuilder()).append(s).append(s2).toString();
      }

    } else {
      while (aobj[i] instanceof String) {
        String s1 = (String) aobj[i++];
        k++;
        j = s1.length();
        s = (new StringBuilder()).append(s).append(s1).toString();
      }
    }
    HashMap hashmap = new HashMap();
    for (; i < aobj.length; i += 2) {
      Character character = (Character) aobj[i];
      ItemStack itemstack1 = null;
      if (aobj[i + 1] instanceof Item) {
        itemstack1 = new ItemStack((Item) aobj[i + 1]);
      } else if (aobj[i + 1] instanceof Block) {
        itemstack1 = new ItemStack((Block) aobj[i + 1], 1, -1);
      } else if (aobj[i + 1] instanceof ItemStack) {
        itemstack1 = (ItemStack) aobj[i + 1];
      }
      hashmap.put(character, itemstack1);
    }

    ItemStack aitemstack[] = new ItemStack[j * k];
    for (int i1 = 0; i1 < j * k; i1++) {
      char c = s.charAt(i1);
      if (hashmap.containsKey(Character.valueOf(c))) {
        aitemstack[i1] = ((ItemStack) hashmap.get(Character.valueOf(c))).copy();
      } else {
        aitemstack[i1] = null;
      }
    }

    recipes.add(new ShapedRecipes(j, k, aitemstack, itemstack));
  }
Ejemplo n.º 2
0
 private void readLeftParen() throws IOException {
   //      System.out.println("Read left.");
   readWhiteSpace();
   int ch = in.read();
   if (isNotLeftParen(ch))
     throw new RuntimeException(
         "Format error reading tree with character: (" + Character.valueOf((char) ch) + ")");
 }
Ejemplo n.º 3
0
  /**
   * @param fieldName 字段名
   * @param fieldValue 字段值
   * @param o 对象 @Description 根据字段名给对象的字段赋值
   */
  private static void setFieldValueByName(String fieldName, Object fieldValue, Object o)
      throws Exception {
    //        if (fieldName.equals("id") || fieldName.equals("operatorId")) {
    //            return;
    //        }
    Field field = getFieldByName(fieldName, o.getClass());
    if (field != null) {
      field.setAccessible(true);
      // 获取字段类型
      Class<?> fieldType = field.getType();

      // 根据字段类型给字段赋值
      if (String.class == fieldType) {
        field.set(o, String.valueOf(fieldValue));
      } else if (Integer.TYPE == fieldType || Integer.class == fieldType) {
        field.set(o, Integer.valueOf(fieldValue.toString()));
      } else if (Long.TYPE == fieldType || Long.class == fieldType) {
        field.set(o, Long.valueOf(fieldValue.toString()));
      } else if (Float.TYPE == fieldType || Float.class == fieldType) {
        field.set(o, Float.valueOf(fieldValue.toString()));
      } else if (Short.TYPE == fieldType || Short.class == fieldType) {
        field.set(o, Short.valueOf(fieldValue.toString()));
      } else if (Double.TYPE == fieldType || Double.class == fieldType) {
        field.set(o, Double.valueOf(fieldValue.toString()));
      } else if (Character.TYPE == fieldType) {
        if ((fieldValue != null) && (fieldValue.toString().length() > 0)) {
          field.set(o, Character.valueOf(fieldValue.toString().charAt(0)));
        }
      } else if (Date.class == fieldType) {
        String dateStr = fieldValue.toString();
        //                String[] split = dateStr.split("/");
        //                StringBuilder sb = new StringBuilder();
        //                int i = 0;
        //                for (String str : split) {
        //                    if (i == split.length - 1) {
        //                        sb.append("20" + str);
        //                        continue;
        //                    }
        //                    sb.append(str).append("/");
        //                    i++;
        //                }
        //                dateStr = sb.toString();
        SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm");
        Date parseDate = formatter.parse(dateStr);
        // Date parseDate = DateUtils.parseDate(fieldValue.toString(), new String[] { "MM/dd/yyyy
        // HH:mm:ss" });
        field.set(o, parseDate);
      } else if (BigDecimal.class == fieldType) {
        field.set(o, new BigDecimal(fieldValue.toString()));
      } else {
        field.set(o, fieldValue);
      }
    } else {
      throw new ExcelException(o.getClass().getSimpleName() + "类不存在字段名" + fieldName);
    }
  }
  static {
    UtilsChatFormatting[] var0 = values();
    int var1 = var0.length;

    for (int var2 = 0; var2 < var1; ++var2) {
      UtilsChatFormatting var3 = var0[var2];
      formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3);
      nameMapping.put(var3.getFriendlyName(), var3);
    }
  }
 /** {@inheritDoc} */
 @Override
 public boolean retainAll(Collection<?> collection) {
   boolean modified = false;
   TCharIterator iter = iterator();
   while (iter.hasNext()) {
     if (!collection.contains(Character.valueOf(iter.next()))) {
       iter.remove();
       modified = true;
     }
   }
   return modified;
 }
Ejemplo n.º 6
0
 /** {@inheritDoc} */
 @SuppressWarnings({"SuspiciousMethodCalls"})
 public boolean retainAll(Collection<?> collection) {
   boolean modified = false;
   TCharIterator iter = iterator();
   while (iter.hasNext()) {
     if (!collection.contains(Character.valueOf(iter.next()))) {
       iter.remove();
       modified = true;
     }
   }
   return modified;
 }
 @Override
 public <T> T next(InstanceType<T> instanceType, FixtureContract fixture) {
   try {
     if (instanceType.isCompatibleWith(Integer.class)) {
       return (T) Integer.valueOf(this.getNextRandom().intValue());
     } else if (instanceType.isCompatibleWith(Short.class)) {
       return (T) Short.valueOf(getNextRandom().shortValue());
     } else if (instanceType.isCompatibleWith(Long.class)) {
       return (T) getNextRandom();
     } else if (instanceType.isCompatibleWith(Byte.class)) {
       return (T) Byte.valueOf(getNextRandom().byteValue());
     } else if (instanceType.isCompatibleWith(Character.class)) {
       return (T)
           Character.valueOf(new String(new byte[] {getNextRandom().byteValue()}).charAt(0));
     }
     return (T) this.getNextRandom();
   } catch (Exception e) {
     throw new ObjectCreationException(instanceType, e);
   }
 }
Ejemplo n.º 8
0
 @SuppressWarnings("UnnecessaryBoxing")
 private static Object box(final Object value) {
   Object newBoxedValue;
   if (value instanceof Integer) {
     newBoxedValue = Integer.valueOf(((Integer) value).intValue());
   } else if (value instanceof Byte) {
     newBoxedValue = Byte.valueOf(((Byte) value).byteValue());
   } else if (value instanceof Short) {
     newBoxedValue = Short.valueOf(((Short) value).shortValue());
   } else if (value instanceof Long) {
     newBoxedValue = Long.valueOf(((Long) value).longValue());
   } else if (value instanceof Boolean) {
     newBoxedValue = Boolean.valueOf(((Boolean) value).booleanValue());
   } else if (value instanceof Character) {
     newBoxedValue = Character.valueOf(((Character) value).charValue());
   } else {
     return new Object();
   }
   return newBoxedValue;
 }
Ejemplo n.º 9
0
 /**
  * Wraps a key
  *
  * @param k key in the underlying map
  * @return an Object representation of the key
  */
 protected Character wrapKey(char k) {
   return Character.valueOf(k);
 }
Ejemplo n.º 10
0
  public static void init() {
    try {
      /*ModLoaderMp.registerNetClientHandlerEntity(MissileBoosterEntity.class, 144);
      ModLoaderMp.registerNetClientHandlerEntity(MissileMinerBoosterEntity.class, 145);
      ModLoaderMp.registerNetClientHandlerEntity(MissilePassengerBoosterEntity.class, 146);
      ModLoaderMp.registerNetClientHandlerEntity(MissilePassengerWarheadEntity.class, 147);
      ModLoaderMp.registerNetClientHandlerEntity(MissileWarheadEntity.class, 148);
      ModLoaderMp.registerNetClientHandlerEntity(ParachuteEntity.class, 149);
      ModLoaderMp.registerNetClientHandlerEntity(RangefinderEntity.class, 150);*/

      missileModelID = ModLoader.getUniqueBlockModelID(instance, true);
      warheadModelID = ModLoader.getUniqueBlockModelID(instance, true);
      machineModelID = ModLoader.getUniqueBlockModelID(instance, true);
      optionsFile = new File(Minecraft.getMinecraftDir(), "/config/RocketScience.cfg");
      func_22024_func_21238_readOptions();

      booster = new MissileBoosterBlock(boosterID, 0).setBlockName("Missile");
      warhead =
          new MissileWarheadBlock(warheadID).setBlockName("If you have this block, it's a glitch.");
      RSmachine = new BlockRSMachine(machineID).setBlockName("RS Machine");
      RSgenerator = new BlockRSGenerator(generatorID).setBlockName("RS Generator");
      superconductor = new BlockSuperconductor(superconductorID).setBlockName("Superconductor");
      parachute = (ItemRS) new ItemRS(parachuteID, 0).setItemName("Parachute");
      passengerModule = (ItemRS) new ItemRS(passengerModuleID, 1).setItemName("Passenger Module");
      boosterModule = (ItemRS) new ItemRS(boosterModuleID, 2).setItemName("Booster Module");
      tntModule = (ItemRS) new ItemRS(tntModuleID, 3).setItemName("TNT Warhead");
      incendiaryModule =
          (ItemRS) new ItemRS(incendiaryModuleID, 4).setItemName("Incendiary Warhead");
      nuclearModule = (ItemRS) new ItemRS(nuclearModuleID, 5).setItemName("Nuclear Warhead");
      rangefinderItem =
          (ItemRS) new RangefinderItem(rangefinderItemID, 6).setItemName("Laser Rangefinder");
      parachuteArmor =
          (ItemArmorRS)
              new ItemArmorRS(
                      parachuteArmorID,
                      7,
                      EnumArmorMaterial.CLOTH,
                      ModLoader.addArmor("parachute"),
                      1,
                      1000)
                  .setItemName("Parachute Pack");
      superconductorUncompressed =
          (ItemRS) new ItemRS(superconductorUncompressedID, 8).setItemName("SuperUncompressed");
      cellDeuterium = (ItemRS) (new ItemRS(deuteriumID, 9)).setItemName("itemCellDeuterium");
      copperCoil = (ItemRS) new ItemRS(copperCoilID, 10).setItemName("CopperCoil");
      copperCoils = (ItemRS) new ItemRS(copperCoilsID, 11).setItemName("CopperCoils");
      superCoil = (ItemRS) new ItemRS(superCoilID, 12).setItemName("SuperCoil");
      superCoils = (ItemRS) new ItemRS(superCoilsID, 13).setItemName("SuperCoils");
      ohmicHeater = (ItemRS) new ItemRS(ohmicHeaterID, 14).setItemName("OhmicHeater");
      neutralHeater = (ItemRS) new ItemRS(neutralHeaterID, 15).setItemName("NeutralHeater");
      rfHeater = (ItemRS) new ItemRS(rfHeaterID, 16).setItemName("RFHeater");
      vacuum = (ItemVacuum) new ItemVacuum(vacuumID, 17).setItemName("Vacuum");
      handPump = (ItemHandPump) new ItemHandPump(handPumpID, 20).setItemName("HandPump");
      ionDrive = (ItemRS) new ItemRS(ionDriveID, 21).setItemName("IonDrive");
      passengerDepleted =
          (ItemPassengerDepleted)
              new ItemPassengerDepleted(passengerDepletedID, 22).setItemName("PassengerDepleted");
      finder = (ItemAutominerFinder) new ItemAutominerFinder(finderID, 23).setItemName("Finder");
      lithium = (ItemRS) new ItemRS(lithiumID, 24).setItemName("Lithium");
      lithiumCell = (ItemRS) new ItemRS(lithiumCellID, 25).setItemName("LithiumCell");
      lithium6Cell = (ItemRS) new ItemRS(lithium6CellID, 26).setItemName("Lithium6Cell");
      tritiumCell = (ItemRS) new ItemRS(tritiumCellID, 27).setItemName("TritiumCell");
      thermoModule = (ItemRS) new ItemRS(thermoModuleID, 5).setItemName("Thermonuclear Warhead");

      ModLoader.registerBlock(booster, MissileItem.class);
      ModLoader.registerBlock(warhead, null);
      ModLoader.registerBlock(superconductor);
      ModLoader.registerBlock(RSmachine, ItemMachineRS.class);
      ModLoader.registerBlock(RSgenerator);
      ModLoader.registerTileEntity(MissileTileEntity.class, "Missile");
      ModLoader.registerTileEntity(TileEntitySuperconductor.class, "Superconductor");
      ModLoader.registerTileEntity(TileEntityIsotope.class, "Isotopic Separator");
      ModLoader.registerTileEntity(TileEntityFusion.class, "Fusion Reactor");
      ModLoader.registerTileEntity(TileEntityAutoMiner.class, "Autominer");
      ModLoader.registerTileEntity(TileEntityDefense.class, "Missile Defense");
      ModLoader.registerTileEntity(TileEntityOffense.class, "Missile Targeting");
      ModLoader.registerTileEntity(TileEntityLaser.class, "Defense Laser");
      ModLoader.registerTileEntity(TileEntityRadar.class, "Radar");
      TileEntityIsotope.initRecipes();

      ModLoader.addName(boosterModule, "Booster Module");
      ModLoader.addName(passengerModule, "Passenger Module");
      ModLoader.addName(parachute, "Parachute");
      ModLoader.addName(booster, "Missile");
      ModLoader.addName(warhead, "If you have this block, it's a glitch.");
      ModLoader.addName(tntModule, "TNT Warhead");
      ModLoader.addName(incendiaryModule, "Incendiary Warhead");
      ModLoader.addName(nuclearModule, "Nuclear Warhead");
      ModLoader.addName(rangefinderItem, "Laser Rangefinder");
      ModLoader.addName(parachuteArmor, "Parachute Pack");
      ModLoader.addName(superconductor, "Superconductor");
      ModLoader.addName(superconductorUncompressed, "Graphene-Gold Lattice");
      ModLoader.addName(cellDeuterium, "Deuterium Cell");
      ModLoader.addName(copperCoil, "Copper Loop");
      ModLoader.addName(copperCoils, "Copper Coils");
      ModLoader.addName(superCoil, "Superconductor Loop");
      ModLoader.addName(superCoils, "Superconducting Coils");
      ModLoader.addName(ohmicHeater, "Ohmic Heating System");
      ModLoader.addName(neutralHeater, "Neutral-Beam Heating System");
      ModLoader.addName(rfHeater, "RF Cyclotron Heating System");
      ModLoader.addName(new ItemStack(booster, 1, 14), "Missile");
      ModLoader.addName(new ItemStack(booster, 1, 15), "Reusable Passenger Rocket (half charge)");
      ModLoader.addName(new ItemStack(booster, 1, 0), "Reusable Passenger Rocket");
      ModLoader.addName(new ItemStack(booster, 1, 4), "Incendiary Missile");
      ModLoader.addName(new ItemStack(booster, 1, 8), "Nuclear Missile");
      ModLoader.addName(new ItemStack(booster, 1, 12), "Passenger Rocket");
      ModLoader.addName(new ItemStack(booster, 1, 13), "Thermonuclear Missile");
      ModLoader.addName(new ItemStack(RSmachine, 1, 0), "Isotopic Separator");
      ModLoader.addName(new ItemStack(RSmachine, 1, 1), "Mobile Auto-Miner");
      ModLoader.addName(new ItemStack(RSmachine, 1, 2), "Missile Defense System");
      ModLoader.addName(new ItemStack(RSmachine, 1, 3), "Missile Targeting System");
      ModLoader.addName(new ItemStack(RSmachine, 1, 4), "Missile Defense Laser");
      ModLoader.addName(new ItemStack(RSmachine, 1, 5), "Radar");
      ModLoader.addName(new ItemStack(RSgenerator, 1, 0), "Fusion Reactor");
      ModLoader.addName(vacuum, "Wet/Dry Vac");
      ModLoader.addName(handPump, "Hand Pump");
      ModLoader.addName(ionDrive, "Ion Drive");
      ModLoader.addName(passengerDepleted, "Discharged Passenger Rocket");
      ModLoader.addName(finder, "Autominer Location Device");
      ModLoader.addName(lithium, "Lithium");
      ModLoader.addName(lithiumCell, "Lithium Cell");
      ModLoader.addName(lithium6Cell, "Lithium-6 Cell");
      ModLoader.addName(tritiumCell, "Tritium Cell");
      ModLoader.addName(thermoModule, "Thermonuclear Warhead");

      ModLoader.addRecipe(
          new ItemStack(boosterModule, 2),
          new Object[] {
            "#X#",
            "#X#",
            "#X#",
            Character.valueOf('#'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('X'),
            Ic2Items.coalfuelCell
          });
      ModLoader.addRecipe(
          new ItemStack(boosterModule, 2),
          new Object[] {
            "#X#",
            "#X#",
            "#X#",
            Character.valueOf('#'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('X'),
            Ic2Items.biofuelCell
          });
      ModLoader.addRecipe(
          new ItemStack(parachute, 1),
          new Object[] {
            "XXX",
            "O O",
            " O ",
            Character.valueOf('X'),
            Item.leather,
            Character.valueOf('O'),
            Item.silk
          });
      ModLoader.addRecipe(
          new ItemStack(parachuteArmor, 1),
          new Object[] {
            "L L",
            "LPL",
            "LLL",
            Character.valueOf('L'),
            Item.leather,
            Character.valueOf('P'),
            parachute
          });
      ModLoader.addRecipe(
          new ItemStack(passengerModule, 1),
          new Object[] {
            "P", "M", Character.valueOf('P'), parachute, Character.valueOf('M'), Item.minecartEmpty
          });
      ModLoader.addRecipe(
          new ItemStack(tntModule, 1),
          new Object[] {
            " I ",
            "ITI",
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('T'),
            Block.tnt
          });
      ModLoader.addRecipe(
          new ItemStack(incendiaryModule, 1),
          new Object[] {
            " I ",
            "ITI",
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('T'),
            Ic2Items.lavaCell
          });
      ModLoader.addRecipe(
          new ItemStack(nuclearModule, 1),
          new Object[] {
            " I ",
            "ITI",
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('T'),
            Ic2Items.nuke
          });
      ModLoader.addRecipe(
          new ItemStack(booster, 1, 12),
          new Object[] {
            "P", "M", Character.valueOf('P'), passengerModule, Character.valueOf('M'), boosterModule
          });
      ModLoader.addRecipe(
          new ItemStack(booster, 1, 8),
          new Object[] {
            "P", "M", Character.valueOf('P'), nuclearModule, Character.valueOf('M'), boosterModule
          });
      ModLoader.addRecipe(
          new ItemStack(booster, 1, 4),
          new Object[] {
            "P",
            "M",
            Character.valueOf('P'),
            incendiaryModule,
            Character.valueOf('M'),
            boosterModule
          });
      ModLoader.addRecipe(
          new ItemStack(booster, 1, 14),
          new Object[] {
            "P", "M", Character.valueOf('P'), tntModule, Character.valueOf('M'), boosterModule
          });
      ModLoader.addRecipe(
          new ItemStack(superconductorUncompressed),
          new Object[] {
            " C ",
            " D ",
            " G ",
            Character.valueOf('C'),
            Ic2Items.carbonPlate,
            Character.valueOf('D'),
            Item.redstone,
            Character.valueOf('G'),
            Item.ingotGold
          });
      ModLoader.addRecipe(
          new ItemStack(RSmachine, 1, 0),
          new Object[] {
            "ICI",
            "RER",
            "IAI",
            Character.valueOf('E'),
            Ic2Items.extractor,
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('R'),
            Item.redstone,
            Character.valueOf('A'),
            Ic2Items.advancedMachine,
            Character.valueOf('C'),
            Ic2Items.advancedCircuit
          });
      ModLoader.addRecipe(
          new ItemStack(RSgenerator, 1, 0),
          new Object[] {
            "CCC",
            "CAC",
            "CCC",
            Character.valueOf('C'),
            Ic2Items.reactorChamber,
            Character.valueOf('A'),
            Ic2Items.advancedMachine
          });
      ModLoader.addRecipe(
          new ItemStack(copperCoil, 1),
          new Object[] {"CCC", "C C", "CCC", Character.valueOf('C'), Ic2Items.copperIngot});
      ModLoader.addRecipe(
          new ItemStack(copperCoils, 1),
          new Object[] {"CCC", "C C", "CCC", Character.valueOf('C'), copperCoil});
      ModLoader.addRecipe(
          new ItemStack(superCoil, 1),
          new Object[] {"CCC", "C C", "CCC", Character.valueOf('C'), superconductor});
      ModLoader.addRecipe(
          new ItemStack(superCoils, 1),
          new Object[] {"CCC", "C C", "CCC", Character.valueOf('C'), superCoil});
      ModLoader.addRecipe(
          new ItemStack(ohmicHeater, 1),
          new Object[] {
            "WWW",
            "C W",
            "WWW",
            Character.valueOf('W'),
            Ic2Items.insulatedCopperCableItem,
            Character.valueOf('C'),
            Ic2Items.electronicCircuit
          });
      ModLoader.addRecipe(
          new ItemStack(rfHeater, 1),
          new Object[] {
            "F",
            "A",
            "M",
            Character.valueOf('M'),
            Ic2Items.machine,
            Character.valueOf('A'),
            Ic2Items.advancedCircuit,
            Character.valueOf('F'),
            Ic2Items.frequencyTransmitter
          });
      ModLoader.addRecipe(
          new ItemStack(neutralHeater, 1),
          new Object[] {
            "AMW",
            " I ",
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('M'),
            Ic2Items.machine,
            Character.valueOf('A'),
            Ic2Items.advancedCircuit,
            Character.valueOf('W'),
            Ic2Items.insulatedCopperCableItem
          });
      ModLoader.addRecipe(
          new ItemStack(rangefinderItem, 1),
          new Object[] {
            "III",
            "ICD",
            "III",
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('C'),
            Ic2Items.electronicCircuit,
            Character.valueOf('D'),
            Item.diamond
          });
      ModLoader.addRecipe(
          new ItemStack(vacuum),
          new Object[] {
            "R",
            "P",
            "B",
            Character.valueOf('R'),
            Ic2Items.rubber,
            Character.valueOf('B'),
            Ic2Items.reBattery,
            Character.valueOf('P'),
            Ic2Items.pump
          });
      ModLoader.addRecipe(
          new ItemStack(handPump),
          new Object[] {
            "RB",
            " C",
            Character.valueOf('C'),
            Ic2Items.cell,
            Character.valueOf('B'),
            Ic2Items.bronzeIngot,
            Character.valueOf('R'),
            Ic2Items.rubber
          });
      ModLoader.addRecipe(
          new ItemStack(ionDrive),
          new Object[] {
            "ACA",
            "ARA",
            "AGA",
            Character.valueOf('A'),
            Ic2Items.advancedAlloy,
            Character.valueOf('C'),
            new ItemStack(Ic2Items.energyCrystal.getItem(), 1, 26),
            Character.valueOf('R'),
            Ic2Items.advancedCircuit,
            Character.valueOf('G'),
            Block.glowStone
          });
      ModLoader.addRecipe(
          new ItemStack(ionDrive),
          new Object[] {
            "ACA",
            "ARA",
            "AGA",
            Character.valueOf('A'),
            Ic2Items.advancedAlloy,
            Character.valueOf('C'),
            new ItemStack(Ic2Items.energyCrystal.getItem(), 1, 27),
            Character.valueOf('R'),
            Ic2Items.advancedCircuit,
            Character.valueOf('G'),
            Block.glowStone
          });
      ModLoader.addRecipe(
          new ItemStack(passengerDepleted, 1, 10001),
          new Object[] {
            "P", "I", Character.valueOf('P'), passengerModule, Character.valueOf('I'), ionDrive
          });
      ModLoader.addRecipe(
          new ItemStack(RSmachine, 1, 1),
          new Object[] {
            "CTC",
            "AMA",
            "I I",
            Character.valueOf('C'),
            Ic2Items.advancedCircuit,
            Character.valueOf('T'),
            Block.chest,
            Character.valueOf('A'),
            Ic2Items.advancedMachine,
            Character.valueOf('M'),
            Ic2Items.miner,
            Character.valueOf('I'),
            ionDrive
          });
      ModLoader.addRecipe(
          new ItemStack(thermoModule),
          new Object[] {
            " T ",
            "DND",
            " T ",
            Character.valueOf('T'),
            tritiumCell,
            Character.valueOf('D'),
            cellDeuterium,
            Character.valueOf('N'),
            nuclearModule
          });
      ModLoader.addRecipe(
          new ItemStack(thermoModule),
          new Object[] {
            " D ",
            "TNT",
            " D ",
            Character.valueOf('T'),
            tritiumCell,
            Character.valueOf('D'),
            cellDeuterium,
            Character.valueOf('N'),
            nuclearModule
          });
      ModLoader.addRecipe(
          new ItemStack(booster, 1, 13),
          new Object[] {
            "P", "M", Character.valueOf('P'), thermoModule, Character.valueOf('M'), boosterModule
          });
      ModLoader.addRecipe(
          new ItemStack(RSmachine, 1, 2),
          new Object[] {
            "GAG",
            "RMR",
            "GCG",
            Character.valueOf('G'),
            Block.thinGlass,
            Character.valueOf('A'),
            Ic2Items.advancedCircuit,
            Character.valueOf('R'),
            Item.redstone,
            Character.valueOf('M'),
            Ic2Items.machine,
            Character.valueOf('C'),
            Ic2Items.electronicCircuit
          });
      ModLoader.addRecipe(
          new ItemStack(RSmachine, 1, 3),
          new Object[] {
            "GCG",
            "RMR",
            "GAG",
            Character.valueOf('G'),
            Block.thinGlass,
            Character.valueOf('A'),
            Ic2Items.advancedCircuit,
            Character.valueOf('R'),
            Item.redstone,
            Character.valueOf('M'),
            Ic2Items.machine,
            Character.valueOf('C'),
            Ic2Items.electronicCircuit
          });
      ModLoader.addRecipe(
          new ItemStack(RSmachine, 1, 4),
          new Object[] {
            " E ",
            "GCG",
            "AMA",
            Character.valueOf('E'),
            new ItemStack(Ic2Items.energyCrystal.getItem(), 1, 26),
            Character.valueOf('G'),
            Item.lightStoneDust,
            Character.valueOf('C'),
            Ic2Items.advancedCircuit,
            Character.valueOf('A'),
            Ic2Items.advancedAlloy,
            Character.valueOf('M'),
            Ic2Items.advancedMachine
          });
      ModLoader.addRecipe(
          new ItemStack(RSmachine, 1, 5),
          new Object[] {
            "IFI",
            " I ",
            " M ",
            Character.valueOf('I'),
            Ic2Items.refinedIronIngot,
            Character.valueOf('F'),
            Ic2Items.frequencyTransmitter,
            Character.valueOf('M'),
            Ic2Items.machine
          });
      ModLoader.addShapelessRecipe(
          StackUtil.copyWithSize(Ic2Items.copperIngot, 64), new Object[] {copperCoils});
      ModLoader.addShapelessRecipe(
          StackUtil.copyWithSize(Ic2Items.copperIngot, 8), new Object[] {copperCoil});
      ModLoader.addShapelessRecipe(new ItemStack(superconductor, 64), new Object[] {superCoils});
      ModLoader.addShapelessRecipe(new ItemStack(superconductor, 8), new Object[] {superCoil});
      ModLoader.addShapelessRecipe(
          new ItemStack(finder, 1),
          new Object[] {Ic2Items.frequencyTransmitter, new ItemStack(Item.dyePowder, 1, 1)});
      ModLoader.addShapelessRecipe(
          new ItemStack(lithiumCell, 1), new Object[] {Ic2Items.cell, lithium});

      ModLoader.registerEntityID(
          MissileBoosterEntity.class, "Missile", ModLoader.getUniqueEntityId());
      ModLoader.registerEntityID(
          MissileWarheadEntity.class, "Warhead", ModLoader.getUniqueEntityId());
      ModLoader.registerEntityID(
          MissilePassengerBoosterEntity.class, "Passenger Missile", ModLoader.getUniqueEntityId());
      ModLoader.registerEntityID(
          MissilePassengerWarheadEntity.class, "Passenger Warhead", ModLoader.getUniqueEntityId());
      ModLoader.registerEntityID(
          RangefinderEntity.class, "Rangefinder", ModLoader.getUniqueEntityId());
      ModLoader.registerEntityID(
          MissileMinerBoosterEntity.class, "Miner", ModLoader.getUniqueEntityId());
      ModLoader.registerEntityID(
          EntityDefenseLaser.class, "Defense Laser", ModLoader.getUniqueEntityId());

      Ic2Recipes.addCompressorRecipe(
          new ItemStack(superconductorUncompressed), new ItemStack(superconductor));
      Ic2Recipes.addExtractorRecipe(new ItemStack(Item.clay), new ItemStack(lithium));

      ModLoader.setInGameHook(instance, true, false);
    } catch (Exception exception) {
      System.out.println("Rocket Science: Failed to initialize");
      exception.printStackTrace();
    }
  }
Ejemplo n.º 11
0
 private Object createObject(
     Node node, String name, String classPackage, String type, String value, boolean setProperty) {
   Bean parentBean = null;
   if (beansStack.size() > 0) parentBean = (Bean) beansStack.peek();
   Object object = null;
   // param is either an XSD type or a bean,
   // check if it can be converted to an XSD type
   XSDatatype dt = null;
   try {
     dt = DatatypeFactory.getTypeByName(type);
   } catch (DatatypeException dte) {
     // the type is not a valid XSD data type
   }
   // convert null value to default
   if ((dt != null) && (value == null)) {
     Class objType = dt.getJavaObjectType();
     if (objType == String.class) value = "";
     else if ((objType == java.math.BigInteger.class)
         || (objType == Long.class)
         || (objType == Integer.class)
         || (objType == Short.class)
         || (objType == Byte.class)) value = "0";
     else if ((objType == java.math.BigDecimal.class)
         || (objType == Double.class)
         || (objType == Float.class)) value = "0.0";
     else if (objType == Boolean.class) value = "false";
     else if (objType == java.util.Date.class) value = DateUtils.getCurrentDate();
     else if (objType == java.util.Calendar.class) value = DateUtils.getCurrentDateTime();
   }
   //  check whether the type was converted to an XSD datatype
   if ((dt != null) && dt.isValid(value, null)) {
     // create and return an XSD Java object (e.g. String, Integer, Boolean, etc)
     object = dt.createJavaObject(value, null);
     if (object instanceof java.util.Calendar) {
       // check that the object is truly a Calendar
       // because DatatypeFactory converts xsd:date
       // types to GregorianCalendar instead of Date.
       if (type.equals("date")) {
         java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
         try {
           object = df.parse(value);
         } catch (java.text.ParseException pe) {
           object = new java.util.Date();
         }
       }
     }
   } else {
     // Create a bean object
     if (topLevelBean == null) topLevelBean = parentBean;
     object = pushBeanOnStack(classPackage, type);
     // Check fields to see if this property is the 'value' for the object
     Field[] fields = object.getClass().getDeclaredFields();
     for (int i = 0; i < fields.length; i++) {
       if (fields[i].isAnnotationPresent(ObjectXmlAsValue.class)) {
         try {
           StringBuffer fieldName = new StringBuffer(fields[i].getName());
           char c = fieldName.charAt(0);
           if (c >= 'a' && c <= 'z') {
             c += 'A' - 'a';
           }
           fieldName.setCharAt(0, c);
           fieldName.insert(0, "set");
           Method method =
               object
                   .getClass()
                   .getMethod(fieldName.toString(), new Class[] {fields[i].getType()});
           method.invoke(object, value);
           break;
         } catch (Exception e) {
           System.err.println(e.getMessage());
         }
       }
     }
     NamedNodeMap nodeAttrs = node.getAttributes();
     // iterate attributes and set field values for property attributes
     for (int i = 0; i < nodeAttrs.getLength(); i++) {
       String nodePrefix = nodeAttrs.item(i).getPrefix();
       if (nodePrefix.equals(nsPrefix)) {
         String nodeName = nodeAttrs.item(i).getLocalName();
         String nodeValue = nodeAttrs.item(i).getNodeValue();
         try {
           Field field = object.getClass().getDeclaredField(nodeName);
           if (field.isAnnotationPresent(ObjectXmlAsAttribute.class)) {
             StringBuffer fieldName = new StringBuffer(field.getName());
             char c = fieldName.charAt(0);
             if (c >= 'a' && c <= 'z') {
               c += 'A' - 'a';
             }
             fieldName.setCharAt(0, c);
             fieldName.insert(0, "set");
             Method method =
                 object.getClass().getMethod(fieldName.toString(), new Class[] {field.getType()});
             if (field.getType() == String.class) method.invoke(object, nodeValue);
             else if (field.getType() == Boolean.TYPE)
               method.invoke(object, StringUtils.strToBool(nodeValue, "true"));
             else if (field.getType() == Byte.TYPE)
               method.invoke(object, Byte.valueOf(nodeValue).byteValue());
             else if (field.getType() == Character.TYPE)
               method.invoke(object, Character.valueOf(nodeValue.charAt(0)));
             else if (field.getType() == Double.TYPE)
               method.invoke(object, Double.valueOf(nodeValue).doubleValue());
             else if (field.getType() == Float.TYPE)
               method.invoke(object, Float.valueOf(nodeValue).floatValue());
             else if (field.getType() == Integer.TYPE)
               method.invoke(object, Integer.valueOf(nodeValue).intValue());
             else if (field.getType() == Long.TYPE)
               method.invoke(object, Long.valueOf(nodeValue).longValue());
             else if (field.getType() == Short.TYPE)
               method.invoke(object, Short.valueOf(nodeValue).shortValue());
           }
         } catch (Exception e) {
           System.err.println(e.getMessage());
         }
       }
     }
   }
   if ((parentBean != null) && (setProperty)) {
     parentBean.setProperty(name, object);
   }
   return object;
 }
Ejemplo n.º 12
0
 private CraftingManager() {
   recipes = new ArrayList();
   (new RecipesTools()).addRecipes(this);
   (new RecipesWeapons()).addRecipes(this);
   (new RecipesIngots()).addRecipes(this);
   (new RecipesFood()).addRecipes(this);
   (new RecipesCrafting()).addRecipes(this);
   (new RecipesArmor()).addRecipes(this);
   (new RecipesDyes()).addRecipes(this);
   addRecipe(
       new ItemStack(Item.paper, 3), new Object[] {"###", Character.valueOf('#'), Item.reed});
   addRecipe(
       new ItemStack(Item.book, 1),
       new Object[] {"#", "#", "#", Character.valueOf('#'), Item.paper});
   addRecipe(
       new ItemStack(Block.fence, 2),
       new Object[] {"###", "###", Character.valueOf('#'), Item.stick});
   addRecipe(
       new ItemStack(Block.netherFence, 6),
       new Object[] {"###", "###", Character.valueOf('#'), Block.netherBrick});
   addRecipe(
       new ItemStack(Block.fenceGate, 1),
       new Object[] {
         "#W#", "#W#", Character.valueOf('#'), Item.stick, Character.valueOf('W'), Block.planks
       });
   addRecipe(
       new ItemStack(Block.jukebox, 1),
       new Object[] {
         "###",
         "#X#",
         "###",
         Character.valueOf('#'),
         Block.planks,
         Character.valueOf('X'),
         Item.diamond
       });
   addRecipe(
       new ItemStack(Block.music, 1),
       new Object[] {
         "###",
         "#X#",
         "###",
         Character.valueOf('#'),
         Block.planks,
         Character.valueOf('X'),
         Item.redstone
       });
   addRecipe(
       new ItemStack(Block.bookShelf, 1),
       new Object[] {
         "###",
         "XXX",
         "###",
         Character.valueOf('#'),
         Block.planks,
         Character.valueOf('X'),
         Item.book
       });
   addRecipe(
       new ItemStack(Block.blockSnow, 1),
       new Object[] {"##", "##", Character.valueOf('#'), Item.snowball});
   addRecipe(
       new ItemStack(Block.blockClay, 1),
       new Object[] {"##", "##", Character.valueOf('#'), Item.clay});
   addRecipe(
       new ItemStack(Block.brick, 1),
       new Object[] {"##", "##", Character.valueOf('#'), Item.brick});
   addRecipe(
       new ItemStack(Block.glowStone, 1),
       new Object[] {"##", "##", Character.valueOf('#'), Item.lightStoneDust});
   addRecipe(
       new ItemStack(Block.cloth, 1),
       new Object[] {"##", "##", Character.valueOf('#'), Item.silk});
   addRecipe(
       new ItemStack(Block.tnt, 1),
       new Object[] {
         "X#X",
         "#X#",
         "X#X",
         Character.valueOf('X'),
         Item.gunpowder,
         Character.valueOf('#'),
         Block.sand
       });
   addRecipe(
       new ItemStack(Block.stairSingle, 3, 3),
       new Object[] {"###", Character.valueOf('#'), Block.cobblestone});
   addRecipe(
       new ItemStack(Block.stairSingle, 3, 0),
       new Object[] {"###", Character.valueOf('#'), Block.stone});
   addRecipe(
       new ItemStack(Block.stairSingle, 3, 1),
       new Object[] {"###", Character.valueOf('#'), Block.sandStone});
   addRecipe(
       new ItemStack(Block.stairSingle, 3, 2),
       new Object[] {"###", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Block.stairSingle, 3, 4),
       new Object[] {"###", Character.valueOf('#'), Block.brick});
   addRecipe(
       new ItemStack(Block.stairSingle, 3, 5),
       new Object[] {"###", Character.valueOf('#'), Block.stoneBrick});
   addRecipe(
       new ItemStack(Block.ladder, 2),
       new Object[] {"# #", "###", "# #", Character.valueOf('#'), Item.stick});
   addRecipe(
       new ItemStack(Item.doorWood, 1),
       new Object[] {"##", "##", "##", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Block.trapdoor, 2),
       new Object[] {"###", "###", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Item.doorSteel, 1),
       new Object[] {"##", "##", "##", Character.valueOf('#'), Item.ingotIron});
   addRecipe(
       new ItemStack(Item.sign, 1),
       new Object[] {
         "###",
         "###",
         " X ",
         Character.valueOf('#'),
         Block.planks,
         Character.valueOf('X'),
         Item.stick
       });
   addRecipe(
       new ItemStack(Item.cake, 1),
       new Object[] {
         "AAA",
         "BEB",
         "CCC",
         Character.valueOf('A'),
         Item.bucketMilk,
         Character.valueOf('B'),
         Item.sugar,
         Character.valueOf('C'),
         Item.wheat,
         Character.valueOf('E'),
         Item.egg
       });
   addRecipe(new ItemStack(Item.sugar, 1), new Object[] {"#", Character.valueOf('#'), Item.reed});
   addRecipe(
       new ItemStack(Block.planks, 4), new Object[] {"#", Character.valueOf('#'), Block.wood});
   addRecipe(
       new ItemStack(Item.stick, 4),
       new Object[] {"#", "#", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Block.torchWood, 4),
       new Object[] {
         "X", "#", Character.valueOf('X'), Item.coal, Character.valueOf('#'), Item.stick
       });
   addRecipe(
       new ItemStack(Block.torchWood, 4),
       new Object[] {
         "X",
         "#",
         Character.valueOf('X'),
         new ItemStack(Item.coal, 1, 1),
         Character.valueOf('#'),
         Item.stick
       });
   addRecipe(
       new ItemStack(Item.bowlEmpty, 4),
       new Object[] {"# #", " # ", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Item.glassBottle, 3),
       new Object[] {"# #", " # ", Character.valueOf('#'), Block.glass});
   addRecipe(
       new ItemStack(Block.rail, 16),
       new Object[] {
         "X X",
         "X#X",
         "X X",
         Character.valueOf('X'),
         Item.ingotIron,
         Character.valueOf('#'),
         Item.stick
       });
   addRecipe(
       new ItemStack(Block.railPowered, 6),
       new Object[] {
         "X X",
         "X#X",
         "XRX",
         Character.valueOf('X'),
         Item.ingotGold,
         Character.valueOf('R'),
         Item.redstone,
         Character.valueOf('#'),
         Item.stick
       });
   addRecipe(
       new ItemStack(Block.railDetector, 6),
       new Object[] {
         "X X",
         "X#X",
         "XRX",
         Character.valueOf('X'),
         Item.ingotIron,
         Character.valueOf('R'),
         Item.redstone,
         Character.valueOf('#'),
         Block.pressurePlateStone
       });
   addRecipe(
       new ItemStack(Item.minecartEmpty, 1),
       new Object[] {"# #", "###", Character.valueOf('#'), Item.ingotIron});
   addRecipe(
       new ItemStack(Item.cauldron, 1),
       new Object[] {"# #", "# #", "###", Character.valueOf('#'), Item.ingotIron});
   addRecipe(
       new ItemStack(Item.brewingStand, 1),
       new Object[] {
         " B ",
         "###",
         Character.valueOf('#'),
         Block.cobblestone,
         Character.valueOf('B'),
         Item.blazeRod
       });
   addRecipe(
       new ItemStack(Block.pumpkinLantern, 1),
       new Object[] {
         "A", "B", Character.valueOf('A'), Block.pumpkin, Character.valueOf('B'), Block.torchWood
       });
   addRecipe(
       new ItemStack(Item.minecartCrate, 1),
       new Object[] {
         "A", "B", Character.valueOf('A'), Block.chest, Character.valueOf('B'), Item.minecartEmpty
       });
   addRecipe(
       new ItemStack(Item.minecartPowered, 1),
       new Object[] {
         "A",
         "B",
         Character.valueOf('A'),
         Block.stoneOvenIdle,
         Character.valueOf('B'),
         Item.minecartEmpty
       });
   addRecipe(
       new ItemStack(Item.boat, 1),
       new Object[] {"# #", "###", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Item.bucketEmpty, 1),
       new Object[] {"# #", " # ", Character.valueOf('#'), Item.ingotIron});
   addRecipe(
       new ItemStack(Item.flintAndSteel, 1),
       new Object[] {
         "A ", " B", Character.valueOf('A'), Item.ingotIron, Character.valueOf('B'), Item.flint
       });
   addRecipe(
       new ItemStack(Item.bread, 1), new Object[] {"###", Character.valueOf('#'), Item.wheat});
   addRecipe(
       new ItemStack(Block.stairCompactPlanks, 4),
       new Object[] {"#  ", "## ", "###", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Item.fishingRod, 1),
       new Object[] {
         "  #", " #X", "# X", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Item.silk
       });
   addRecipe(
       new ItemStack(Block.stairCompactCobblestone, 4),
       new Object[] {"#  ", "## ", "###", Character.valueOf('#'), Block.cobblestone});
   addRecipe(
       new ItemStack(Block.stairsBrick, 4),
       new Object[] {"#  ", "## ", "###", Character.valueOf('#'), Block.brick});
   addRecipe(
       new ItemStack(Block.stairsStoneBrickSmooth, 4),
       new Object[] {"#  ", "## ", "###", Character.valueOf('#'), Block.stoneBrick});
   addRecipe(
       new ItemStack(Block.stairsNetherBrick, 4),
       new Object[] {"#  ", "## ", "###", Character.valueOf('#'), Block.netherBrick});
   addRecipe(
       new ItemStack(Item.painting, 1),
       new Object[] {
         "###",
         "#X#",
         "###",
         Character.valueOf('#'),
         Item.stick,
         Character.valueOf('X'),
         Block.cloth
       });
   addRecipe(
       new ItemStack(Item.appleGold, 1),
       new Object[] {
         "###",
         "#X#",
         "###",
         Character.valueOf('#'),
         Block.blockGold,
         Character.valueOf('X'),
         Item.appleRed
       });
   addRecipe(
       new ItemStack(Block.lever, 1),
       new Object[] {
         "X", "#", Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Item.stick
       });
   addRecipe(
       new ItemStack(Block.torchRedstoneActive, 1),
       new Object[] {
         "X", "#", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Item.redstone
       });
   addRecipe(
       new ItemStack(Item.redstoneRepeater, 1),
       new Object[] {
         "#X#",
         "III",
         Character.valueOf('#'),
         Block.torchRedstoneActive,
         Character.valueOf('X'),
         Item.redstone,
         Character.valueOf('I'),
         Block.stone
       });
   addRecipe(
       new ItemStack(Item.pocketSundial, 1),
       new Object[] {
         " # ",
         "#X#",
         " # ",
         Character.valueOf('#'),
         Item.ingotGold,
         Character.valueOf('X'),
         Item.redstone
       });
   addRecipe(
       new ItemStack(Item.compass, 1),
       new Object[] {
         " # ",
         "#X#",
         " # ",
         Character.valueOf('#'),
         Item.ingotIron,
         Character.valueOf('X'),
         Item.redstone
       });
   addRecipe(
       new ItemStack(Item.map, 1),
       new Object[] {
         "###",
         "#X#",
         "###",
         Character.valueOf('#'),
         Item.paper,
         Character.valueOf('X'),
         Item.compass
       });
   addRecipe(
       new ItemStack(Block.button, 1),
       new Object[] {"#", "#", Character.valueOf('#'), Block.stone});
   addRecipe(
       new ItemStack(Block.pressurePlateStone, 1),
       new Object[] {"##", Character.valueOf('#'), Block.stone});
   addRecipe(
       new ItemStack(Block.pressurePlatePlanks, 1),
       new Object[] {"##", Character.valueOf('#'), Block.planks});
   addRecipe(
       new ItemStack(Block.dispenser, 1),
       new Object[] {
         "###",
         "#X#",
         "#R#",
         Character.valueOf('#'),
         Block.cobblestone,
         Character.valueOf('X'),
         Item.bow,
         Character.valueOf('R'),
         Item.redstone
       });
   addRecipe(
       new ItemStack(Block.pistonBase, 1),
       new Object[] {
         "TTT",
         "#X#",
         "#R#",
         Character.valueOf('#'),
         Block.cobblestone,
         Character.valueOf('X'),
         Item.ingotIron,
         Character.valueOf('R'),
         Item.redstone,
         Character.valueOf('T'),
         Block.planks
       });
   addRecipe(
       new ItemStack(Block.pistonStickyBase, 1),
       new Object[] {
         "S", "P", Character.valueOf('S'), Item.slimeBall, Character.valueOf('P'), Block.pistonBase
       });
   addRecipe(
       new ItemStack(Item.bed, 1),
       new Object[] {
         "###", "XXX", Character.valueOf('#'), Block.cloth, Character.valueOf('X'), Block.planks
       });
   addRecipe(
       new ItemStack(Block.enchantmentTable, 1),
       new Object[] {
         " B ",
         "D#D",
         "###",
         Character.valueOf('#'),
         Block.obsidian,
         Character.valueOf('B'),
         Item.book,
         Character.valueOf('D'),
         Item.diamond
       });
   addShapelessRecipe(
       new ItemStack(Item.eyeOfEnder, 1), new Object[] {Item.enderPearl, Item.blazePowder});
   Collections.sort(recipes, new RecipeSorter(this));
   System.out.println((new StringBuilder()).append(recipes.size()).append(" recipes").toString());
 }
Ejemplo n.º 13
0
  /**
   * Primary Constructor
   *
   * @param parmObjTypes The object instances of the classes containing command line parsing
   *     annotations. Non-null. Non-empty.
   * @param args
   * @param prefix
   */
  public JCommanderModule(Collection<Class<?>> parmObjTypes, String[] args, String prefix) {
    checkNotNull(parmObjTypes);
    checkNotNull(args);
    checkNotNull(prefix);
    checkArgument(!parmObjTypes.isEmpty());
    checkArgument(args.length != 0);

    this.parmObjTypes.addAll(parmObjTypes);
    this.args = args;
    this.prefix = prefix;

    /*
     * Populate the binding functions
     */

    bindingFxns.put(
        int.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Integer.valueOf((int) val)));
    bindingFxns.put(
        byte.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Byte.valueOf((byte) val)));
    bindingFxns.put(
        long.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Long.valueOf((long) val)));
    bindingFxns.put(
        short.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Short.valueOf((short) val)));
    bindingFxns.put(
        float.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Float.valueOf((float) val)));
    bindingFxns.put(
        double.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Double.valueOf((double) val)));
    bindingFxns.put(
        char.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Character.valueOf((char) val)));
    bindingFxns.put(
        boolean.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(Boolean.valueOf((boolean) val)));

    bindingFxns.put(
        Integer.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Integer) val));
    bindingFxns.put(
        Byte.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Byte) val));
    bindingFxns.put(
        Long.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Long) val));
    bindingFxns.put(
        Short.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Short) val));
    bindingFxns.put(
        Float.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Float) val));
    bindingFxns.put(
        Double.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Double) val));
    bindingFxns.put(
        Character.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Character) val));
    bindingFxns.put(
        Boolean.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((Boolean) val));
    bindingFxns.put(
        String.class,
        (name, val) -> bindConstant().annotatedWith(named((String) name)).to((String) val));

    bindingFxns.put(
        File.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(((File) val).getAbsolutePath()));
    bindingFxns.put(
        Path.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(((Path) val).toString()));
    bindingFxns.put(
        URL.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(((URL) val).getFile()));

    bindingFxns.put(
        LocalDate.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(((LocalDate) val).toString()));
    bindingFxns.put(
        LocalDateTime.class,
        (name, val) ->
            bindConstant()
                .annotatedWith(named((String) name))
                .to(((LocalDateTime) val).toString()));
    bindingFxns.put(
        LocalTime.class,
        (name, val) ->
            bindConstant().annotatedWith(named((String) name)).to(((LocalTime) val).toString()));

    bindingFxnsForGenerics.put(
        new TypeLiteral<List<String>>() {},
        (name, val) ->
            bind(new TypeLiteral<List<String>>() {})
                .annotatedWith(named((String) name))
                .toInstance((List<String>) val));
    bindingFxnsForGenerics.put(
        new TypeLiteral<Set<String>>() {},
        (name, val) ->
            bind(new TypeLiteral<Set<String>>() {})
                .annotatedWith(named((String) name))
                .toInstance((Set<String>) val));
  }
Ejemplo n.º 14
0
 public final boolean isOperator(char c) {
   return _operators.containsKey(Character.valueOf(c));
 }
Ejemplo n.º 15
0
  /** Read a {@link Writable}, {@link String}, primitive type, or an array of the preceding. */
  @SuppressWarnings("unchecked")
  public static Object readObject(DataInput in, ObjectWritable objectWritable, Configuration conf)
      throws IOException {
    String className = UTF8.readString(in);
    Class<?> declaredClass = PRIMITIVE_NAMES.get(className);
    if (declaredClass == null) {
      declaredClass = loadClass(conf, className);
    }

    Object instance;

    if (declaredClass.isPrimitive()) { // primitive types

      if (declaredClass == Boolean.TYPE) { // boolean
        instance = Boolean.valueOf(in.readBoolean());
      } else if (declaredClass == Character.TYPE) { // char
        instance = Character.valueOf(in.readChar());
      } else if (declaredClass == Byte.TYPE) { // byte
        instance = Byte.valueOf(in.readByte());
      } else if (declaredClass == Short.TYPE) { // short
        instance = Short.valueOf(in.readShort());
      } else if (declaredClass == Integer.TYPE) { // int
        instance = Integer.valueOf(in.readInt());
      } else if (declaredClass == Long.TYPE) { // long
        instance = Long.valueOf(in.readLong());
      } else if (declaredClass == Float.TYPE) { // float
        instance = Float.valueOf(in.readFloat());
      } else if (declaredClass == Double.TYPE) { // double
        instance = Double.valueOf(in.readDouble());
      } else if (declaredClass == Void.TYPE) { // void
        instance = null;
      } else {
        throw new IllegalArgumentException("Not a primitive: " + declaredClass);
      }

    } else if (declaredClass.isArray()) { // array
      int length = in.readInt();
      instance = Array.newInstance(declaredClass.getComponentType(), length);
      for (int i = 0; i < length; i++) {
        Array.set(instance, i, readObject(in, conf));
      }

    } else if (declaredClass == String.class) { // String
      instance = UTF8.readString(in);
    } else if (declaredClass.isEnum()) { // enum
      instance = Enum.valueOf((Class<? extends Enum>) declaredClass, UTF8.readString(in));
    } else { // Writable
      Class instanceClass = null;
      String str = UTF8.readString(in);
      instanceClass = loadClass(conf, str);

      Writable writable = WritableFactories.newInstance(instanceClass, conf);
      writable.readFields(in);
      instance = writable;

      if (instanceClass == NullInstance.class) { // null
        declaredClass = ((NullInstance) instance).declaredClass;
        instance = null;
      }
    }

    if (objectWritable != null) { // store values
      objectWritable.declaredClass = declaredClass;
      objectWritable.instance = instance;
    }

    return instance;
  }