Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangMap


        }
    }

    @Test
    public void map_1() throws TermParserException {
        final OtpErlangMap r = (OtpErlangMap) termParser.parse("#{}");
        Assert.assertEquals("#{}", r.toString());
    }
View Full Code Here


        Assert.assertEquals("#{}", r.toString());
    }

    @Test
    public void map_2() throws TermParserException {
        @SuppressWarnings("unused")
        final OtpErlangMap r = (OtpErlangMap) termParser.parse("#{a=>2,\"b\"=>[4]}");
    }
View Full Code Here

        final OtpErlangMap r = (OtpErlangMap) termParser.parse("#{a=>2,\"b\"=>[4]}");
    }

    @Test(expected = TermParserException.class)
    public void map_3() throws TermParserException {
        @SuppressWarnings("unused")
        final OtpErlangMap r = (OtpErlangMap) termParser.parse("#{a=>2,b}");
    }
View Full Code Here

    }

    @Test
    public void cvtMapOk_1() throws SignatureException {
        final HashMap<OtpErlangObject, OtpErlangObject> map = new HashMap<OtpErlangObject, OtpErlangObject>();
        test(map, "m", new OtpErlangMap(new OtpErlangObject[0], new OtpErlangObject[0]));
    }
View Full Code Here

    @Test
    public void cvtMapOk_2() throws SignatureException {
        final HashMap<OtpErlangObject, OtpErlangObject> map = new HashMap<OtpErlangObject, OtpErlangObject>();
        map.put(new OtpErlangAtom("foo"), new OtpErlangAtom("bar"));
        test(map, "m", new OtpErlangMap(
                new OtpErlangObject[] { new OtpErlangAtom("foo") },
                new OtpErlangObject[] { new OtpErlangAtom("bar") }));
    }
View Full Code Here

                        new OtpErlangObject[size]);
                final OtpErlangObject[] values = new OtpErlangObject[size];
                for (int i = 0; i < size; i++) {
                    values[i] = map.get(keys[i]);
                }
                return new OtpErlangMap(keys, values);
            }
            failConversion(obj, type);
        }

        if (obj instanceof OtpErlangPid) {
View Full Code Here

            final OtpErlangObject[] vv = new OtpErlangObject[k.length];
            for (int i = 0; i < k.length; i++) {
                kk[i] = java2erlang(k[i]);
                vv[i] = java2erlang(map.get(k[i]));
            }
            return new OtpErlangMap(kk, vv);
        }

        if (obj instanceof OtpErlangPid) {
            return (OtpErlangPid) obj;
        }
View Full Code Here

            final OtpErlangObject[] values = new OtpErlangObject[size / 2];
            for (int i = 0; i < size / 2; i++) {
                keys[i] = all[i * 2];
                values[i] = all[i * 2 + 1];
            }
            return new OtpErlangMap(keys, values);
        }
        stack.push(parse(tokens));
        if (tokens.get(0).kind != TokenKind.ARROW) {
            throw new TermParserException("badly constructed map");
        }
View Full Code Here

                        + CANT_CONVERT_TO + cls.getCanonicalName());
            }
            if (Map.class.isAssignableFrom(cls)) {
                if (obj instanceof OtpErlangMap) {
                    final Map<Object, Object> result = Maps.newHashMap();
                    final OtpErlangMap map = (OtpErlangMap) obj;
                    for (final OtpErlangObject key : map.keys()) {
                        final OtpErlangObject value = map.get(key);
                        result.put(erlang2java(key, key.getClass()),
                                erlang2java(value, value.getClass()));
                    }
                    return result;
                }
View Full Code Here

  runTest(new byte[] { (byte) 131, 116, 0, 0, 0, 1, 104, 1, 97, 3, 108,
    0, 0, 0, 1, 100, 0, 1, 114, 106 }, "#{{3} => [r]}", 4);

  try {
      // #{2 => [],a => 1}
      final OtpErlangMap map = new OtpErlangMap(new OtpInputStream(
      new byte[] { (byte) 131, 116, 0, 0, 0, 2, 97, 2, 106,
             100, 0, 1, 97, 97, 1 }));

      if (map.arity() != 2) {
    fail(5);
      }
      if (!new OtpErlangLong(1).equals(map.get(new OtpErlangAtom("a")))) {
    fail(6);
      }
      if (!new OtpErlangList().equals(map.get(new OtpErlangLong(2)))) {
    fail(7);
      }
      if (map.get(new OtpErlangLong(1)) != null) {
    fail(8);
      }
  } catch (final OtpErlangDecodeException e) {
      fail(99);
  }
View Full Code Here

TOP

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

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.