Package propel.core.userTypes

Examples of propel.core.userTypes.UnsignedLong


   * @throws NumberFormatException A number could not be parsed.
   */
  @Validate
  public static UnsignedLong fromBinaryToUInt64(@NotNull final String binary)
  {
    return new UnsignedLong(new BigInteger(binary, 2));
  }
View Full Code Here


   * @throws NumberFormatException A number could not be parsed.
   */
  @Validate
  public static UnsignedLong fromStringToUInt64(@NotNull final String value)
  {
    return new UnsignedLong(value);
  }
View Full Code Here

   * @throws NumberFormatException A number could not be parsed.
   */
  @Validate
  public static UnsignedLong fromHexToUInt64(@NotNull final String hex)
  {
    return new UnsignedLong(new BigInteger(hex, 16));
  }
View Full Code Here

    // convert blocks to alphanumerics
    StringBuilder sb = new StringBuilder(16);
    for (int i = offset; i < offset + length; i += 8)
    {
      byte[] ulBytes = ByteArrayUtils.subarray(ba, i, 8);
      UnsignedLong num = ByteArrayUtils.toUInt64(ulBytes);
      sb.append(toAlphanumeric(num, true));
    }

    return sb.toString();
  }
View Full Code Here

    byte[] result = new byte[alphanumeric.length() / 11 * 8];

    int j = 0;
    for (int i = 0; i < alphanumeric.length(); i += 11)
    {
      UnsignedLong num = fromAlphanumericToUInt64(alphanumeric.substring(i, i + 11));
      byte[] bytes = ByteArrayUtils.getBytes(num);
      System.arraycopy(bytes, 0, result, j, 8);
      j += 8;
    }

View Full Code Here

   */
  @Validate
  public static UnsignedLong fromAlphanumericToUInt64(@NotNull final String alphanumeric)
  {
    if (alphanumeric.equals(CONSTANT.ZERO))
      return new UnsignedLong(BigInteger.ZERO);

    UnsignedLong result = new UnsignedLong(BigInteger.ZERO);
    BigInteger sixtyTwo = new BigInteger("62");

    int len = alphanumeric.length();
    for (int i = 0; i < len; i++)
    {
      char ch = alphanumeric.charAt(i);
      if (!StringUtils.contains(CONSTANT.ALPHANUMERIC_DIGITS, ch))
        throw new NumberFormatException("The digit does not belong to the alphanumeric number structure: " + ch);

      // add and check for overflows
      int pos = len - i - 1;
      int charIndex = StringUtils.indexOf(CONSTANT.ALPHANUMERIC_DIGITS, ch);
      BigInteger added = sixtyTwo.pow(pos).multiply(new BigInteger(charIndex + ""));
      result = new UnsignedLong(result.bigIntegerValue().add(added));
    }

    return result;
  }
View Full Code Here

      return new UnsignedInteger((long) (number.intValue() & 0xFFFFFFFF));
    if (targetType.equals(UnsignedLong.class))
    {
      // perform similar operation as above to get rid of the negative values
      long ln = new BigInteger(number.toString()).longValue();
      return new UnsignedLong(new BigInteger("0" + toBinary(ln)));
    }
    if (targetType.equals(SignedByte.class))
      return new SignedByte(number.byteValue());
    if (targetType.equals(BigInteger.class))
      return new BigInteger(number.toString());
View Full Code Here

    if (targetType.equals(UnsignedShort.class))
      return new UnsignedShort(ch);
    if (targetType.equals(UnsignedInteger.class))
      return new UnsignedInteger(ch);
    if (targetType.equals(UnsignedLong.class))
      return new UnsignedLong(new Integer(ch).toString());
    if (targetType.equals(SignedByte.class))
      return new SignedByte((byte) ch);
    if (targetType.equals(BigInteger.class))
      return new BigInteger(Integer.valueOf(ch).toString());
    if (targetType.equals(propel.core.userTypes.BigInteger.class))
View Full Code Here

    if (targetType.equals(UnsignedShort.class))
      return bool ? new UnsignedShort(1) : new UnsignedShort(0);
    if (targetType.equals(UnsignedInteger.class))
      return bool ? new UnsignedInteger(1) : new UnsignedInteger(0);
    if (targetType.equals(UnsignedLong.class))
      return bool ? new UnsignedLong("1") : new UnsignedLong("0");
    if (targetType.equals(SignedByte.class))
      return bool ? new SignedByte("1") : new SignedByte("0");
    if (targetType.equals(BigInteger.class))
      return bool ? new BigInteger("1") : new BigInteger("0");
    if (targetType.equals(propel.core.userTypes.BigInteger.class))
View Full Code Here

    if (targetType.equals(UnsignedShort.class))
      return new UnsignedShort(str);
    if (targetType.equals(UnsignedInteger.class))
      return new UnsignedInteger(str);
    if (targetType.equals(UnsignedLong.class))
      return new UnsignedLong(str);
    if (targetType.equals(SignedByte.class))
      return new SignedByte(str);
    if (targetType.equals(BigInteger.class))
      return new BigInteger(str);
    if (targetType.equals(propel.core.userTypes.BigInteger.class))
View Full Code Here

TOP

Related Classes of propel.core.userTypes.UnsignedLong

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.