Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangInt


* @version $Rev$ $Date$
*/
public class IntTypeHelper implements TypeHelper {

  public OtpErlangObject toErlang(Object object) {
    return new OtpErlangInt((Integer) object);
  }
View Full Code Here


                return l.intValue();
            } catch (final OtpErlangRangeException e) {
            }
        }
        if (object instanceof OtpErlangInt) {
            final OtpErlangInt l = (OtpErlangInt) object;
            try {
                return l.intValue();
            } catch (final OtpErlangRangeException e) {
            }
        }
        return defaultValue;
    }
View Full Code Here

        }
        if (obj instanceof Short) {
            return new OtpErlangShort((Short) obj);
        }
        if (obj instanceof Integer) {
            return new OtpErlangInt((Integer) obj);
        }
        if (obj instanceof Long) {
            return new OtpErlangLong((Long) obj);
        }
        if (obj instanceof BigInteger) {
View Full Code Here

            final OtpErlangObject[] tuple = {new OtpErlangAtom("send_async"),
                                             new OtpErlangString(name),
                                             new OtpErlangBinary(request_info),
                                             new OtpErlangBinary(request),
                                             new OtpErlangUInt(timeout),
                                             new OtpErlangInt(priority)};
            send_async.write_any(new OtpErlangTuple(tuple));
            send(send_async);
            return (TransId) poll_request(null, false);
        }
        catch (OtpErlangRangeException e)
View Full Code Here

            final OtpErlangObject[] tuple = {new OtpErlangAtom("send_sync"),
                                             new OtpErlangString(name),
                                             new OtpErlangBinary(request_info),
                                             new OtpErlangBinary(request),
                                             new OtpErlangUInt(timeout),
                                             new OtpErlangInt(priority)};
            send_sync.write_any(new OtpErlangTuple(tuple));
            send(send_sync);
            return (Response) poll_request(null, false);
        }
        catch (OtpErlangRangeException e)
View Full Code Here

            final OtpErlangObject[] tuple = {new OtpErlangAtom("mcast_async"),
                                             new OtpErlangString(name),
                                             new OtpErlangBinary(request_info),
                                             new OtpErlangBinary(request),
                                             new OtpErlangUInt(timeout),
                                             new OtpErlangInt(priority)};
            mcast_async.write_any(new OtpErlangTuple(tuple));
            send(mcast_async);
            return (List<TransId>) poll_request(null, false);
        }
        catch (OtpErlangRangeException e)
View Full Code Here

            final OtpErlangObject[] tuple = {new OtpErlangAtom("forward_async"),
                                             new OtpErlangString(name),
                                             new OtpErlangBinary(request_info),
                                             new OtpErlangBinary(request),
                                             new OtpErlangUInt(timeout),
                                             new OtpErlangInt(priority),
                                             new OtpErlangBinary(trans_id),
                                             pid};
            forward_async.write_any(new OtpErlangTuple(tuple));
            send(forward_async);
        }
View Full Code Here

            final OtpErlangObject[] tuple = {new OtpErlangAtom("forward_sync"),
                                             new OtpErlangString(name),
                                             new OtpErlangBinary(request_info),
                                             new OtpErlangBinary(request),
                                             new OtpErlangUInt(timeout),
                                             new OtpErlangInt(priority),
                                             new OtpErlangBinary(trans_id),
                                             pid};
            forward_sync.write_any(new OtpErlangTuple(tuple));
            send(forward_sync);
        }
View Full Code Here

    String arg2 = "arg2";
    String arg3 = "arg3";
    boolean arg4 = true;

    OtpErlangObject[] smallTupleContent = new OtpErlangObject[2];
    smallTupleContent[0] = new OtpErlangInt(arg1);
    smallTupleContent[1] = new OtpErlangString(arg2);
    OtpErlangTuple smallTuple = new OtpErlangTuple(smallTupleContent);
    OtpErlangObject[] structuredTupleContent = new OtpErlangObject[3];
    structuredTupleContent[0] = smallTuple;
    structuredTupleContent[1] = new OtpErlangString(arg3);
View Full Code Here

    final java.math.BigInteger b = l.bigIntegerValue();
    System.out.println("long: " + l + ": " + w + ": " + b.signum()
      * b.bitLength() + ": " + x + ": " + l.isLong() + ": "
      + l.isULong());
    return new OtpErlangTuple(new OtpErlangObject[] { l,
      new OtpErlangInt(w), x,
      new OtpErlangInt(l.isLong() ? 1 : 0),
      new OtpErlangInt(l.isULong() ? 1 : 0) });
      } else if (atomValue.equals("tail")
           && i instanceof OtpErlangList) {
    final OtpErlangObject o = ((OtpErlangList) i).getTail();
    if (o == null) {
        return new OtpErlangAtom("null");
    }
    return o;
      } else if (atomValue.equals("tail3")
           && i instanceof OtpErlangList) {
    final OtpErlangObject o = ((OtpErlangList) i).getNthTail(3);
    if (o == null) {
        return new OtpErlangAtom("null");
    }
    return o;
      } else if (atomValue.equals("strcat")
           && i instanceof OtpErlangList) {
    final java.lang.StringBuffer b = new java.lang.StringBuffer();
    final OtpErlangList l = (OtpErlangList) i;
    for (final OtpErlangObject j : l) {
        final OtpErlangString k = (OtpErlangString) j;
        b.append(k.stringValue());
    }
    final OtpErlangObject o = new OtpErlangString(b.toString());
    return o;
      } else if (atomValue.equals("sub3atom")
        && i instanceof OtpErlangString) {
    final OtpErlangString s = (OtpErlangString) i;
    final OtpErlangAtom o = new OtpErlangAtom(s.stringValue()
      .substring(3));
    return o;
      } else if (atomValue.equals("codepointBug")
        && i instanceof OtpErlangString) {
    final OtpErlangString s = (OtpErlangString) i;
    final String ss = s.stringValue().substring(3, 6);
        @SuppressWarnings("unused")
    final int[] cps = OtpErlangString.stringToCodePoints(ss);
    return s;
      } else if (atomValue.equals("utf8")) {
    if (i instanceof OtpErlangString) {
        final OtpErlangString s = (OtpErlangString) i;
        byte[] bytes;
        try {
      bytes = s.stringValue().getBytes("UTF-8");
        } catch (final UnsupportedEncodingException e) {
      bytes = new byte[] { 'e', 'r', 'r', 'o', 'r' };
        }
        final OtpErlangBinary b = new OtpErlangBinary(bytes);
        return b;
    }
      } else if(atomValue.equals("to_string_neg_int_list")) {
    OtpErlangString oes = null;
    if (i instanceof OtpErlangString) {
        oes = (OtpErlangString) i;
    } else if (i instanceof OtpErlangList) {
        OtpErlangList oel = (OtpErlangList) i;
        try {
      oes = new OtpErlangString(oel);
        } catch (final Exception e) {
        }
    }
    if (oes != null) {
        String s = oes.stringValue();
        int n = s.length();
        OtpErlangObject l[] = new OtpErlangObject[n];
        for (int j = 0;  j < n;  j++) {
      int c = s.charAt(j);
      l[j] = new OtpErlangInt(-c);
        }
        return new OtpErlangList(l);
    }
      } else if(atomValue.equals("to_neg_int_list")) {
    if (i instanceof OtpErlangString) {
        OtpErlangString oes = (OtpErlangString) i;
        OtpErlangList oel = new OtpErlangList(oes.stringValue());
        int n = oel.arity();
        OtpErlangObject l[] = new OtpErlangObject[n];
        for (int j = 0;  j < n;  j++) {
      OtpErlangLong c = (OtpErlangLong) oel.elementAt(j);
      l[j] = new OtpErlangInt(-c.intValue());
        }
        return new OtpErlangList(l);
    }
      } else if (atomValue.equals("hash_lookup")) {
    final boolean exists = hash_set.contains(i);
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangInt

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.