public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindInt16DefMaxValue.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamInt16DefObj) {
      Short maxValue = ((ICFBamInt16DefObj) genDef).getOptionalMaxValue();
      if (maxValue == null) {
        ret = null;
      } else {
        ret = maxValue.toString();
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamInt16DefObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFFreeSwitchMssCFBindISOLanguageISOCountryId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFFreeSwitchISOLanguageObj) {
      Short iSOCountryId = ((ICFFreeSwitchISOLanguageObj) genDef).getOptionalISOCountryId();
      if (iSOCountryId == null) {
        ret = null;
      } else {
        ret = iSOCountryId.toString();
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFFreeSwitchISOLanguageObj");
    }

    return (ret);
  }
 /** Get the src code which maps to the given glyphID */
 @Override
 public char reverseMap(short glyphID) {
   Short result = glyphLookup.get(new Short(glyphID));
   if (result == null) {
     return '\000';
   }
   return (char) result.shortValue();
 }
 /**
  * Bestimmt die betrachtete Version des Konfigurationsbereichs in dem das angegebene Objekt
  * enthalten ist.
  *
  * @param object Systemobjekt zu dem die Version ermittelt werden soll.
  * @return Version des Konfigurationsbereichs des angegebenen Systemobjekts
  */
 public short getVersion(final SystemObject object) {
   final ConfigurationArea configurationArea = object.getConfigurationArea();
   Short version = _configurationAreaVersions.get(configurationArea);
   if (version != null) return version.shortValue();
   // throw new IllegalStateException("Version des Konfigurationsbereichs " +
   // object.getConfigurationArea().getPidOrNameOrId() + " nicht definiert");
   // Falls in der Map ein Konfigurationsbereich nicht enthalten ist, dann wird die aktive Version
   // des Bereichs zurückgegeben.
   return configurationArea.getActiveVersion();
 }
예제 #5
0
 public void func_20008_a(Packet106Transaction packet106transaction) {
   Short short1 =
       (Short) field_10_k.get(Integer.valueOf(playerEntity.currentCraftingInventory.windowId));
   if (short1 != null
       && packet106transaction.shortWindowId == short1.shortValue()
       && playerEntity.currentCraftingInventory.windowId == packet106transaction.windowId
       && !playerEntity.currentCraftingInventory.getCanCraft(playerEntity)) {
     playerEntity.currentCraftingInventory.setCanCraft(playerEntity, true);
   }
 }
  public void handleTransaction(Packet106Transaction par1Packet106Transaction) {
    Short short1 = (Short) field_72586_s.lookup(playerEntity.craftingInventory.windowId);

    if (short1 != null
        && par1Packet106Transaction.shortWindowId == short1.shortValue()
        && playerEntity.craftingInventory.windowId == par1Packet106Transaction.windowId
        && !playerEntity.craftingInventory.isPlayerNotUsingContainer(playerEntity)) {
      playerEntity.craftingInventory.setPlayerIsPresent(playerEntity, true);
    }
  }
예제 #7
0
  private void loadDataXM(RandomAccessFile fp) throws IOException {
    byte[] b = new byte[20];

    // WHY THE HELL AM I DOING THIS
    name = Util.readStringNoNul(fp, b, 20);
    System.out.printf("name: \"%s\"\n", name);
    fp.read(); // skip 0x1A byte

    // THIS CAN'T BE HAPPENING
    fp.read(b, 0, 20); // skip tracker name

    // OH HELL NO
    int xmver = 0xFFFF & (int) Short.reverseBytes(fp.readShort());
    System.out.printf("XM version: %04X\n", xmver);

    // WHAT IS THIS CRAP
    InhibitedFileBlock ifb = new InhibitedFileBlock(fp, Integer.reverseBytes(fp.readInt()) - 4);

    // HELP ME PLEASE
    int ordnum = 0xFFFF & (int) Short.reverseBytes(ifb.readShort());
    int respos =
        0xFFFF & (int) Short.reverseBytes(ifb.readShort()); // can't be bothered right now --GM
    int chnnum =
        0xFFFF & (int) Short.reverseBytes(ifb.readShort()); // yeah sure, allow out of range values
    if (chnnum > 64)
      throw new RuntimeException(
          String.format("%d-channel modules not supported (max 64)", chnnum));
    int patnum = 0xFFFF & (int) Short.reverseBytes(ifb.readShort());
    int insnum = 0xFFFF & (int) Short.reverseBytes(ifb.readShort());
    int xmflags = 0xFFFF & (int) Short.reverseBytes(ifb.readShort());
    int xmspeed = 0xFFFF & (int) Short.reverseBytes(ifb.readShort());
    int xmtempo = 0xFFFF & (int) Short.reverseBytes(ifb.readShort());

    // OH PLEASE, STOP IT
    if (ordnum > 255) ordnum = 255;
    if (xmtempo > 255) xmtempo = 255;
    if (xmspeed > 255) xmspeed = 255;
    this.bpm = xmtempo;
    this.spd = xmspeed;
    this.flags = FLAG_COMPATGXX | FLAG_OLDEFFECTS | FLAG_INSMODE | FLAG_STEREO | FLAG_VOL0MIX;

    if ((xmflags & 0x01) != 0) this.flags |= FLAG_LINEAR;

    // NONONONONONO
    System.out.printf("chn=%d ordnum=%d tempo=%d speed=%s\n", chnnum, ordnum, xmtempo, xmspeed);
    for (int i = 0; i < 256; i++) orderlist[i] = ifb.read();
    for (int i = ordnum; i < 256; i++) orderlist[i] = 255;

    ifb.done();

    // SAVE ME PLEEEEEAAASSSSEEEE
    for (int i = 0; i < patnum; i++)
      map_pat.put((Integer) i, new SessionPattern(this, fp, SessionPattern.FORMAT_XM, chnnum));
    for (int i = 0; i < insnum; i++)
      map_ins.put((Integer) (i + 1), new SessionInstrument(fp, SessionInstrument.FORMAT_XM, this));
  }
예제 #8
0
  /**
   * Method getShort returns the element at the given position i as an short. Zero if null.
   *
   * @param pos of type int
   * @return long
   */
  public short getShort(int pos) {
    Comparable value = get(pos);

    if (value instanceof Number) return ((Number) value).shortValue();
    else if (value == null) return 0;
    else return Short.parseShort(value.toString());
  }
예제 #9
0
 public boolean equals(Object obj) {
   if (obj instanceof Foo) {
     Foo ofoo = (Foo) obj;
     return s.equals(ofoo.s) && i.equals(ofoo.i) && l.equals(ofoo.l);
   }
   return false;
 }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFAccMssCFBindAccountChequeNumDigits.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFAccAccountObj) {
      short chequeNumDigits = ((ICFAccAccountObj) genDef).getRequiredChequeNumDigits();
      ret = Short.toString(chequeNumDigits);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFAccAccountObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindISOCountryCurrencyISOCurrencyId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamISOCountryCurrencyObj) {
      short iSOCurrencyId = ((ICFBamISOCountryCurrencyObj) genDef).getRequiredISOCurrencyId();
      ret = Short.toString(iSOCurrencyId);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFBamISOCountryCurrencyObj");
    }

    return (ret);
  }
예제 #12
0
  public void func_20007_a(Packet102WindowClick packet102windowclick) {
    if (playerEntity.currentCraftingInventory.windowId == packet102windowclick.window_Id
        && playerEntity.currentCraftingInventory.getCanCraft(playerEntity)) {
      ItemStack itemstack =
          playerEntity.currentCraftingInventory.func_27085_a(
              packet102windowclick.inventorySlot,
              packet102windowclick.mouseClick,
              packet102windowclick.field_27039_f,
              playerEntity);
      if (ItemStack.areItemStacksEqual(packet102windowclick.itemStack, itemstack)) {
        playerEntity.playerNetServerHandler.sendPacket(
            new Packet106Transaction(
                packet102windowclick.window_Id, packet102windowclick.action, true));
        playerEntity.isChangingQuantityOnly = true;
        playerEntity.currentCraftingInventory.updateCraftingMatrix();
        playerEntity.updateHeldItem();
        playerEntity.isChangingQuantityOnly = false;
      } else {
        field_10_k.put(
            Integer.valueOf(playerEntity.currentCraftingInventory.windowId),
            Short.valueOf(packet102windowclick.action));
        playerEntity.playerNetServerHandler.sendPacket(
            new Packet106Transaction(
                packet102windowclick.window_Id, packet102windowclick.action, false));
        playerEntity.currentCraftingInventory.setCanCraft(playerEntity, false);
        ArrayList arraylist = new ArrayList();
        for (int i = 0; i < playerEntity.currentCraftingInventory.inventorySlots.size(); i++) {
          arraylist.add(
              ((Slot) playerEntity.currentCraftingInventory.inventorySlots.get(i)).getStack());
        }

        playerEntity.updateCraftingInventory(playerEntity.currentCraftingInventory, arraylist);
      }
    }
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFFreeSwitchMssCFBindISOTimezoneTZMinOffset.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFFreeSwitchISOTimezoneObj) {
      short tZMinOffset = ((ICFFreeSwitchISOTimezoneObj) genDef).getRequiredTZMinOffset();
      ret = Short.toString(tZMinOffset);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFFreeSwitchISOTimezoneObj");
    }

    return (ret);
  }
예제 #14
0
 /**
  * Helper method used to get default value for wrappers used for primitive types (0 for Integer
  * etc)
  *
  * @since 1.6.1
  */
 public static Object defaultValue(Class<?> cls) {
   if (cls == Integer.TYPE) {
     return Integer.valueOf(0);
   }
   if (cls == Long.TYPE) {
     return Long.valueOf(0L);
   }
   if (cls == Boolean.TYPE) {
     return Boolean.FALSE;
   }
   if (cls == Double.TYPE) {
     return Double.valueOf(0.0);
   }
   if (cls == Float.TYPE) {
     return Float.valueOf(0.0f);
   }
   if (cls == Byte.TYPE) {
     return Byte.valueOf((byte) 0);
   }
   if (cls == Short.TYPE) {
     return Short.valueOf((short) 0);
   }
   if (cls == Character.TYPE) {
     return '\0';
   }
   throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
 }
예제 #15
0
  private boolean compare_Short(int operation, short shortval, Object value2) {
    if (operation == SUBSTRING) {
      return false;
    }
    short shortval2;
    try {
      shortval2 = Short.parseShort(((String) value2).trim());
    } catch (IllegalArgumentException e) {
      return false;
    }

    switch (operation) {
      case APPROX:
      case EQUAL:
        {
          return shortval == shortval2;
        }
      case GREATER:
        {
          return shortval >= shortval2;
        }
      case LESS:
        {
          return shortval <= shortval2;
        }
    }
    return false;
  }
예제 #16
0
  public static void main(String[] args) throws IOException {
    File input = new File(args[0]);
    BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(input)));
    File output = new File(input.getParentFile(), input.getName() + ".out");
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(output)));
    short numberOfCases = Short.parseShort(reader.readLine());
    for (short c = 0; c < numberOfCases; ++c) {
      TreeMap<Short, TreeSet<Short>> intranet = new TreeMap<>();
      short countOfRope = Short.parseShort(reader.readLine());
      int intersectionCount = 0;
      for (short r = 0; r < countOfRope; ++r) {
        String line = reader.readLine();
        String[] words = line.split(" ");
        short leftEndPoint = Short.parseShort(words[0]);
        short rightEndPoint = Short.parseShort(words[1]);

        for (Map.Entry<Short, TreeSet<Short>> e : intranet.entrySet()) {
          short l = e.getKey();
          TreeSet<Short> rSet = e.getValue();
          if (leftEndPoint < l) {
            Short res = rSet.lower(rightEndPoint);
            if (res != null) {
              intersectionCount += rSet.headSet(res, true).size();
            }
          } else { // leftEndPoint > l
            Short res = rSet.higher(rightEndPoint);
            if (res != null) {
              intersectionCount += rSet.tailSet(res, true).size();
            }
          }
        }
        // put
        TreeSet<Short> rights;
        if (intranet.containsKey(leftEndPoint)) {
          rights = intranet.get(leftEndPoint);
        } else {
          rights = new TreeSet<>();
          intranet.put(leftEndPoint, rights);
        }
        rights.add(rightEndPoint);
      }
      writer.println("Case #" + (c + 1) + ": " + intersectionCount);
    }
    reader.close();
    writer.close();
  }
예제 #17
0
 /**
  * Check for short
  *
  * @param input
  * @return
  */
 public static boolean isShort(String input) {
   try {
     Short.parseShort(input);
     return true;
   } catch (Exception ex) {
     return false;
   }
 }
예제 #18
0
 private BasicProcessImage getModscanProcessImage(int slaveId, Map map, DBCollection coll) {
   BasicProcessImage processImage = new BasicProcessImage(slaveId);
   processImage.setAllowInvalidAddress(true);
   processImage.setInvalidAddressValue(Short.valueOf("0"));
   // Add an image listener.
   processImage.addListener(new BasicProcessImageListener());
   return processImage;
 }
 public int compareTo(Object obj) {
   if (obj == null) {
     return (1);
   } else if (obj instanceof CFBamSchemaDefByEAccSecIdxKey) {
     CFBamSchemaDefByEAccSecIdxKey rhs = (CFBamSchemaDefByEAccSecIdxKey) obj;
     if (getOptionalEditAccessSecurityId() != null) {
       Short lhsEditAccessSecurityId = getOptionalEditAccessSecurityId();
       if (rhs.getOptionalEditAccessSecurityId() != null) {
         Short rhsEditAccessSecurityId = rhs.getOptionalEditAccessSecurityId();
         int cmp = lhsEditAccessSecurityId.compareTo(rhsEditAccessSecurityId);
         if (cmp != 0) {
           return (cmp);
         }
       } else {
         return (1);
       }
     } else {
       if (rhs.getOptionalEditAccessSecurityId() != null) {
         return (-1);
       }
     }
     return (0);
   } else if (obj instanceof CFBamSchemaDefBuff) {
     CFBamSchemaDefBuff rhs = (CFBamSchemaDefBuff) obj;
     if (getOptionalEditAccessSecurityId() != null) {
       Short lhsEditAccessSecurityId = getOptionalEditAccessSecurityId();
       if (rhs.getOptionalEditAccessSecurityId() != null) {
         Short rhsEditAccessSecurityId = rhs.getOptionalEditAccessSecurityId();
         int cmp = lhsEditAccessSecurityId.compareTo(rhsEditAccessSecurityId);
         if (cmp != 0) {
           return (cmp);
         }
       } else {
         return (1);
       }
     } else {
       if (rhs.getOptionalEditAccessSecurityId() != null) {
         return (-1);
       }
     }
     return (0);
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newUnsupportedClassException(getClass(), "compareTo", "obj", obj, null);
   }
 }
 public CFSecurityCursor openISOTimezoneCursorByOffsetIdx(
     CFSecurityAuthorization Authorization, short TZHourOffset, short TZMinOffset) {
   String sql =
       getSqlSelectISOTimezoneBuff()
           + "WHERE "
           + "itzn.TZHourOffset = "
           + Short.toString(TZHourOffset)
           + " "
           + "AND "
           + "itzn.TZMinOffset = "
           + Short.toString(TZMinOffset)
           + " "
           + "ORDER BY "
           + "itzn.ISOTimezoneId ASC";
   CFDbTestCursor cursor = new CFDbTestPgSqlCursor(Authorization, schema, sql);
   return (cursor);
 }
예제 #21
0
  public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException {
    ArrayList arraylist = null;

    for (byte byte0 = par0DataInputStream.readByte();
        byte0 != 127;
        byte0 = par0DataInputStream.readByte()) {
      if (arraylist == null) {
        arraylist = new ArrayList();
      }

      int i = (byte0 & 0xe0) >> 5;
      int j = byte0 & 0x1f;
      WatchableObject watchableobject = null;

      switch (i) {
        case 0:
          watchableobject = new WatchableObject(i, j, Byte.valueOf(par0DataInputStream.readByte()));
          break;

        case 1:
          watchableobject =
              new WatchableObject(i, j, Short.valueOf(par0DataInputStream.readShort()));
          break;

        case 2:
          watchableobject =
              new WatchableObject(i, j, Integer.valueOf(par0DataInputStream.readInt()));
          break;

        case 3:
          watchableobject =
              new WatchableObject(i, j, Float.valueOf(par0DataInputStream.readFloat()));
          break;

        case 4:
          watchableobject = new WatchableObject(i, j, Packet.readString(par0DataInputStream, 64));
          break;

        case 5:
          short word0 = par0DataInputStream.readShort();
          byte byte1 = par0DataInputStream.readByte();
          short word1 = par0DataInputStream.readShort();
          watchableobject = new WatchableObject(i, j, new ItemStack(word0, byte1, word1));
          break;

        case 6:
          int k = par0DataInputStream.readInt();
          int l = par0DataInputStream.readInt();
          int i1 = par0DataInputStream.readInt();
          watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
          break;
      }

      arraylist.add(watchableobject);
    }

    return arraylist;
  }
예제 #22
0
 private static Object decode(Class returnType, String valueStr, TypeResolver resolver) {
   if (returnType.isArray()) {
     int sIndex = valueStr.indexOf("{");
     int eIndex = valueStr.lastIndexOf("}");
     String content = valueStr.substring(sIndex + 1, eIndex).trim();
     StringTokenizer tok = new StringTokenizer(content, ",");
     Object ar =
         java.lang.reflect.Array.newInstance(returnType.getComponentType(), tok.countTokens());
     int j = 0;
     while (tok.hasMoreElements()) {
       java.lang.reflect.Array.set(
           ar, j++, decode(returnType.getComponentType(), tok.nextToken(), resolver));
     }
     return ar;
   } else if (returnType.isEnum()) {
     try {
       String value = valueStr.trim();
       if (value.indexOf('.') > 0) {
         value = valueStr.substring(valueStr.lastIndexOf(".") + 1);
       }
       return returnType.getMethod("valueOf", String.class).invoke(null, value);
     } catch (IllegalAccessException e) {
       e.printStackTrace(); // To change body of catch statement use File | Settings | File
       // Templates.
     } catch (InvocationTargetException e) {
       e.printStackTrace(); // To change body of catch statement use File | Settings | File
       // Templates.
     } catch (NoSuchMethodException e) {
       e.printStackTrace(); // To change body of catch statement use File | Settings | File
       // Templates.
     }
   } else if (String.class.equals(returnType)) {
     return unquote(valueStr);
   } else if (boolean.class.equals(returnType)) {
     return Boolean.valueOf(valueStr);
   } else if (int.class.equals(returnType)) {
     return Integer.valueOf(valueStr);
   } else if (double.class.equals(returnType)) {
     return Double.valueOf(valueStr);
   } else if (long.class.equals(returnType)) {
     return Long.valueOf(valueStr);
   } else if (float.class.equals(returnType)) {
     return Float.valueOf(valueStr);
   } else if (short.class.equals(returnType)) {
     return Short.valueOf(valueStr);
   } else if (char.class.equals(returnType)) {
     return unquote(valueStr).charAt(0);
   } else if (Class.class.equals(returnType)) {
     try {
       String cName = valueStr.trim().replace(".class", "");
       return resolver.resolveType(cName);
     } catch (ClassNotFoundException cnfe) {
       cnfe.printStackTrace();
       return Object.class;
     }
   }
   return null;
 }
예제 #23
0
 public static Number toWrapper(int i) {
   if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) {
     return Byte.valueOf((byte) i);
   } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) {
     return Short.valueOf((short) i);
   } else {
     return Integer.valueOf(i);
   }
 }
예제 #24
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);
    }
  }
예제 #25
0
 /** Convert a string to a FsPermission object. */
 private static FsPermission toFsPermission(final String s, Boolean aclBit, Boolean encBit) {
   FsPermission perm = new FsPermission(Short.parseShort(s, 8));
   final boolean aBit = (aclBit != null) ? aclBit : false;
   final boolean eBit = (encBit != null) ? encBit : false;
   if (aBit || eBit) {
     return new FsPermissionExtension(perm, aBit, eBit);
   } else {
     return perm;
   }
 }
 public String toString() {
   String ret =
       "<CFSecurityISOCountryLanguageByCountryIdx"
           + " RequiredISOCountryId="
           + "\""
           + Short.toString(getRequiredISOCountryId())
           + "\""
           + "/>";
   return (ret);
 }
예제 #27
0
  public short getValueInt16(int idx, short defv) {
    Object o = getValue(idx);
    if (o == null) return defv;

    if (o instanceof String) {
      return Short.parseShort((String) o);
    }

    return ((Number) o).shortValue();
  }
예제 #28
0
  // load
  // loads the provided program into memory
  public static void load(Scanner in) {

    int i = 0;
    String code;
    while (in.hasNext()) {
      code = in.next();
      writeMemory((short) i, (byte) (0xFF & Short.valueOf(code, 16)));
      i++;
    }
  }
  public static short getAnyDataShort(String objectString, String enumValue)
      throws IllegalArgumentException {
    // Firstly, can the string be cast directly as a short?
    try {
      Short s = Short.parseShort(enumValue);
      return s;
    } catch (NumberFormatException ex) {
    }

    // If not, test the enum
    if (objectString.equalsIgnoreCase("LOG")
        || objectString.equalsIgnoreCase("LEAVES")
        || objectString.equalsIgnoreCase("SAPLING")) {
      return (short) TreeSpecies.valueOf(enumValue).getData();
    } else if (objectString.equalsIgnoreCase("WOOL")
        || objectString.equalsIgnoreCase("CREATURE_SHEEP")) {
      return (short) DyeColor.valueOf(enumValue).getData();
    } else if (objectString.equalsIgnoreCase("INK_SACK")) {
      return (short) (0xF - DyeColor.valueOf(enumValue).getData());
    } else if (objectString.equalsIgnoreCase("COAL")) {
      return (short) (CoalType.valueOf(enumValue).getData());
    } else if (objectString.equalsIgnoreCase("CROPS")) {
      return (short) (CropState.valueOf(enumValue).getData());
    } else if (objectString.equalsIgnoreCase("STEP")
        || objectString.equalsIgnoreCase("DOUBLE_STEP")) {
      if (enumValue.equalsIgnoreCase("STONE")) return 0;
      else if (enumValue.equalsIgnoreCase("SANDSTONE")) return 1;
      else if (enumValue.equalsIgnoreCase("WOOD")) return 2;
      else if (enumValue.equalsIgnoreCase("COBBLESTONE")) return 3;
      else throw new IllegalArgumentException();
    } else if (objectString.equalsIgnoreCase("CREATURE_PIG")) {
      if (enumValue.equalsIgnoreCase("UNSADDLED")) return 0;
      else if (enumValue.equalsIgnoreCase("SADDLED")) return 1;
      else throw new IllegalArgumentException();
    } else if (objectString.equalsIgnoreCase("CREATURE_CREEPER")) {
      if (enumValue.equalsIgnoreCase("UNPOWERED")) return 0;
      else if (enumValue.equalsIgnoreCase("POWERED")) return 1;
      else throw new IllegalArgumentException();
    } else if (objectString.equalsIgnoreCase("CREATURE_WOLF")) {
      if (enumValue.equalsIgnoreCase("NEUTRAL")) return 0;
      else if (enumValue.equalsIgnoreCase("TAME")) return 1;
      else if (enumValue.equalsIgnoreCase("TAMED")) return 1;
      else if (enumValue.equalsIgnoreCase("ANGRY")) return 2;
      else throw new IllegalArgumentException();
    } else if (objectString.equalsIgnoreCase("CREATURE_SLIME")) {
      if (enumValue.equalsIgnoreCase("TINY")) return 1;
      else if (enumValue.equalsIgnoreCase("SMALL")) return 2;
      else if (enumValue.equalsIgnoreCase("BIG")) return 3;
      else if (enumValue.equalsIgnoreCase("HUGE")) return 4;
      else throw new IllegalArgumentException();
    } else {
      return 0;
    }
  }
예제 #30
0
  private Short parseShort(String value) throws IllegalArgumentException {
    if (value == null || value.trim().length() == 0) {
      return null;
    }

    try {
      return Short.parseShort(value);
    } catch (NumberFormatException e) {
      throw new IllegalArgumentException("Invalid short value '" + value + "' specified");
    }
  }