Example #1
0
 /* Creates a global-unique-identifier as hexadecimal-encoded string.
  */
 public static SchemaString createGuid() throws Exception {
   String guid = new java.rmi.server.UID().toString().replaceAll("[-:]", "");
   byte[] addr = java.net.InetAddress.getLocalHost().getAddress();
   guid +=
       Long.toHexString(addr[0])
           + Long.toHexString(addr[1])
           + Long.toHexString(addr[2])
           + Long.toHexString(addr[3]);
   for (int i = guid.length(); i < 32; i++) guid += "0";
   return new SchemaString(guid);
 }
  public static long castToLong(String s) {
    if (s == null) return 0;

    if (s.equals("INF") || s.equals("-INF") || s.equals("NaN"))
      throw new ArithmeticException("'" + s + "' is too large for long.");

    s = s.trim();
    java.lang.StringBuffer buf = new java.lang.StringBuffer();
    switch (prepareNumber(buf, s)) {
      case 1:
        return Long.parseLong(buf.toString());
      case 2:
        return new BigDecimal(buf.toString()).longValue();
      case 3:
        return (long) Double.parseDouble(buf.toString());
      default:
        throw new NumberFormatException("'" + s + "' cannot be converted to long.");
    }
  }
 public static String castToString(Long i) {
   return i.toString();
 }
 public static String castToString(long i) {
   return Long.toString(i);
 }
 public long toLong() {
   int dot = mantissa.indexOf('.');
   if (dot >= 0) return Long.parseLong(sign + mantissa.substring(0, dot));
   else return Long.parseLong(sign + mantissa);
 }
 public static double castToDouble(Long i) {
   return (double) i.longValue();
 }
 public static BigDecimal castToBigDecimal(Long i) {
   return BigDecimal.valueOf(i.longValue());
 }
 public static BigInteger castToBigInteger(Long i) {
   return BigInteger.valueOf(i.longValue());
 }
 public static long castToLong(Long i) {
   return i.longValue();
 }
 public static int castToInt(Long i) {
   return castToInt(i.longValue());
 }
 public static boolean castToBool(Long i) {
   return i.longValue() != 0;
 }