Package propel.core.userTypes

Examples of propel.core.userTypes.UnsignedInteger


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


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

    if (targetType.equals(UnsignedByte.class))
      return new UnsignedByte((short) (number.byteValue() & 0xFF));
    if (targetType.equals(UnsignedShort.class))
      return new UnsignedShort((int) (number.shortValue() & 0xFFFF));
    if (targetType.equals(UnsignedInteger.class))
      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)));
View Full Code Here

    if (targetType.equals(UnsignedByte.class))
      return new UnsignedByte((byte) ch);
    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))
View Full Code Here

    if (targetType.equals(UnsignedByte.class))
      return bool ? new UnsignedByte((byte) 1) : new UnsignedByte((byte) 0);
    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))
View Full Code Here

    if (targetType.equals(UnsignedByte.class))
      return new UnsignedByte(str);
    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))
View Full Code Here

  @Validate
  public static UnsignedInteger parseUInt32(@NotNull final String value, @NotNull final UnsignedInteger minValue,
                                            @NotNull final UnsignedInteger maxValue)
  {
    // parse
    UnsignedInteger result;
    try
    {
      result = new UnsignedInteger(value);
    }
    catch(Throwable e)
    {
      throw new NumberFormatException("The value '" + value + "' could not be parsed: " + e.getMessage());
    }

    // sanity check
    if (result.compareTo(minValue) < 0)
      throw new NumberFormatException("Value (" + result + ") was less than allowed minimum (" + minValue + ").");
    if (result.compareTo(maxValue) > 0)
      throw new NumberFormatException("Value (" + result + ") was more than allowed maximum (" + maxValue + ").");

    return result;
  }
View Full Code Here

    BigInteger result = BigInteger.ZERO;
    result = result.or(new BigInteger(CONSTANT.EMPTY_STRING
        + (((value[0] & 0xff) << 24) | ((value[1] & 0xff) << 16) | ((value[2] & 0xff) << 8) | (value[3] & 0xff))));

    return new UnsignedInteger(result);
  }
View Full Code Here

    BigInteger hash = BigInteger.ZERO;

    for (byte b : ba)
      hash = hash.shiftLeft(5).add(hash).add(new BigInteger(Integer.toString(0xFF & b)));

    return new UnsignedInteger(hash);
  }
View Full Code Here

    for (byte b : ba)
      hash = hash.shiftLeft(5).add(hash).add(new BigInteger(Integer.toString(0xFF & b)));

    // blanks msb
    return new UnsignedInteger(hash.and(new BigInteger("16777215")));
  }
View Full Code Here

TOP

Related Classes of propel.core.userTypes.UnsignedInteger

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.